Python IS slow ! [was] Re: Python too slow for real world
Guido van Rossum
guido at eric.cnri.reston.va.us
Tue May 4 19:53:31 EDT 1999
Greg Ewing <greg.ewing at compaq.com> writes:
> Markus Kohler wrote:
> >
> > From profiling python 1.5.2c I found that python's main problem is that
> > calling functions seems to be very costly.
>
> This is just a guess, but one contributor to that might be
> the way that it packs all the arguments up into a tuple,
> and then immediately unpacks them again upon entering
> the function.
Ever since 1.4 it doesn't do that any more (except when using apply()).
> Also, it allocates each stack frame as a separate object.
> So that's at least two memory allocation/free operations
> per procedure call.
And the stack frame allocations are optimized.
> A more efficient way would be to use one big stack for
> all procedure calls, and just leave the parameters on
> the stack in the usual case where a procedure with a
> fixed number of arguments is called without any keyword
> args, etc.
Some of this is done already -- a copy takes place but it's very fast.
The stack frames can't be allocated as a true stack because (1) they
are variable-length and (2) some stack frames may survive (through
tracebacks etc.)
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-list
mailing list