How slow? (was Re: Python IS slow !)

M.-A. Lemburg mal at lemburg.com
Tue May 4 07:03:31 EDT 1999


Markus Kohler wrote:
> 
> >>>>> "Gordon" == Gordon McMillan <gmcm at hypernet.com> writes:
> 
> [deletia]
>     Gordon> This thread is a bit unusual in being a general complaint,
>     Gordon> based on measuring Python's function call overhead. Again,
>     Gordon> there's some truth there, but it doesn't appear to be
>     Gordon> based on a user's perception of slowness of an app.
> 
> Yes the problem is that the more you do in Python the more function call overhead
> becomes the dominating factor for the performance of Python. Of course sometimes you
> can escape by using builtin functions or even write your own C
> functions just to speed up things.
> 
> I really don't want to be forced to do that because I would like to
> write as much as possible in Python, just because it's so much more
> productive and so much more fun.

Have you tried the P2C "compiler" ?

	http://lima.mudlib.org/~rassilon/p2c/

> I was comparing it with a free Smalltalk implementation  (made by the
> inventors of Smalltalk) because I think this is what the performance
> should be.
> 
> The squeak virtual machine is written in a (small)
> subset of Smalltalk and is automatically translated to C.
> It's amazing to see that the resulting code is still faster than most
> comparable scripting languages.

The last conference had some papers about "compiling" byte-code
to C... as I remember the results were not too thrilling: the
Python function call is one single byte code and thus eliminating
the loop doesn't give you the expected performance increase.

To enhance the function call performance, you'd probably have
to dig very deep into the interpreter's core and change some
concepts as well (e.g. the execution frame concept vs. C stack,
dynamic lookups vs. variable slots). All this is doable, but not
without breaking code.

-- 
Marc-Andre Lemburg
______________________________________________________________________
Y2000:                                            Y2000: 241 days left
Business:                                      http://www.lemburg.com/
Python Pages:                 http://starship.python.net/crew/lemburg/





More information about the Python-list mailing list