python performance
Martin v. Löwis
loewis at informatik.hu-berlin.de
Mon Sep 16 05:59:57 EDT 2002
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.
Regards,
Martin
More information about the Python-list
mailing list