python performance

Padraig Brady Padraig at Linux.ie
Mon Sep 16 11:24:09 EDT 2002


Syver Enstad wrote:
> loewis at informatik.hu-berlin.de (Martin v. Löwis) writes:
> 
> 
>>Padraig Brady <Padraig at Linux.ie> writes:
>>
>>
>>>>Calling functions adds overhead.  Running code within functions
>>>>reduces overhead for object access.
>>>
>>>Ah OK, this because it has to search a smaller namespace?
>>
>>No. Inside a function, local variables are accessed with integer
>>indices, instead of by name. This is possible because there is static
>>knowledge about the local variables in a function.
>>
>>
>>>Wouldn't compiling overcome this? 
>>
>>Not if you want to preserve Python semantics; the compiler would need
>>to emit code that performs the same actions that the interpreter
>>currently does.
> 
> What about Psyco?

Interesting. I wonder why something like this isn't done
when creating pyc files, hmm I suppose it would be non portable.
Anyway it didn't help for my very simple program. Well it seemed
to make the timings more volatile (a few microseconds each side of
the previous measurements).

Pádraig.




More information about the Python-list mailing list