Type feedback tool?

M.-A. Lemburg mal at egenix.com
Mon Oct 27 11:50:22 CET 2008

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

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

:::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,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

More information about the Python-list mailing list