Python profiler

Celine & Dave zhu_dave at
Mon Oct 3 18:48:42 CEST 2005

Hello All,
I am trying to measure memory used in a Python
program. Also, I would like to gather some statistics
about object usages. For example, I would like to be
able to see how much time it takes to search for an
item in a dict object, how many times it has to access
the symbol table to retrieve a specific item, and
things like that. Furthermore, I would like to be able
to see how a symbol table is created, how many items
it has, how many times it is accessed during
execution, etc.

Python profiler gives timing information about
functions/methods. For example, it doesn't show how
many times a dictionary object is accessed to retrieve
a key or how much time it takes.
The dis module doesn't provide detailed information
either. For the following code, 

dict = { 'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5}
print dict.has_key('e')

The dis module provides the following:

 0 LOAD_GLOBAL            0 (dict)
 3 LOAD_ATTR                1 (has_key)
 6 LOAD_CONST              1 ('e')
 9 CALL_FUNCTION         1
 12 PRINT_ITEM       

But this doesn't really help to see what's going on
with the symbol table.   

Any help is greatly appreaciated. Thanks a lot! 


Yahoo! Mail - PC Magazine Editors' Choice 2005

More information about the Python-list mailing list