Re: Type feedback tool?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • M.-A. Lemburg

    Re: Type feedback tool?

    On 2008-10-26 13:54, Martin Vilcans wrote:
    Hi list,
    >
    I'm wondering if there's a tool that can analyze a Python program
    while it runs, and generate a database with the types of arguments and
    return values for each function. In a way it is like a profiler, that
    instead of measuring how often functions are called and how long time
    it takes, it records the type information. So afterwards, when I'm
    reading the code, I can go to the database to see what data type
    parameter "foo" of function "bar" typically has. It would help a lot
    with deciphering old code.
    >
    When I googled this, I learned that this is called "type feedback",
    and is used (?) to give type information to a compiler to help it
    generate fast code. My needs are much more humble. I just want a
    faster way to understand undocumented code with bad naming.
    You could try the trace module:



    but I'm not sure whether that includes parameter listings.

    Or write your own tracing function and then plug it into your
    application using sys.settrace():



    The frame object will have the information you need:



    in f_locals.

    --
    Marc-Andre Lemburg
    eGenix.com

    Professional Python Services directly from the Source (#1, Oct 27 2008)
    >>Python/Zope Consulting and Support ... http://www.egenix.com/
    >>mxODBC.Zope.D atabase.Adapter ... http://zope.egenix.com/
    >>mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
    _______________ _______________ _______________ _______________ ____________

    :::: Try mxODBC.Zope.DA for Windows,Linux,S olaris,MacOSX for free ! ::::


    eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48
    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
    Registered at Amtsgericht Duesseldorf: HRB 46611
Working...