Why is Python so slow ?- revisited.

Thomas Wouters thomas at xs4all.net
Mon Jun 19 04:18:16 EDT 2000


On Mon, Jun 19, 2000 at 03:22:06AM +0000, William Dandreta wrote:

> Christian Tismer wrote in message
> <394D6579.8B2FF840 at appliedbiometrics.com>...

> >The time spent in comment lines is very small,and it is reasonably
> >smaller if you use Stackless Python. Anyway, if you are concerned
> >about multi-line comments, then try this out:
> >Put a """ line in front of a longer couple of comments,
> >and end it the same way.
> >I should wonder if execution time would change reasonably.

> The """ syntax would seem to be slower than putting # at the begining of
> everyline because with # it only needs to test the first character of the
> line, if it's # it can skip the rest of the line. But with """, it needs to
> check every character after until it finds the matching """.

The tokenizer has to search those ends together anyway, and besides, that's
a compiletime penalty, not runtime. It won't matter a hoot in function
calls, as all that happens string literals in a void context is that they
get added to the functions' constants tuple (function.func_code.co_consts.)
And that happens at compiletime (which can be at runtime, of course, if you
use exec() or import an uncompiled module, but if you do that often you
shouldn't whine about performance ;-)

However, all this is based on Python 1.5.2, *not* 1.2. I dont think there
are many people who can give useful tips about 1.2 performance, other than
'either upgrade or stop caring about it.'. I believe quite a lot has changed
since 1.2 ;-P

-- 
Thomas Wouters <thomas at xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!




More information about the Python-list mailing list