Python 2 times slower than Perl
pierre at saiph.com
Mon Jul 30 06:41:49 EDT 2001
Skip Montanaro wrote:
> Christopher> I can't speak for Perl, but Python definately does not
> Christopher> evaluate the expression at compile time. This is a problem
> Christopher> I've had with Python. I wish that when given the -O option
> Christopher> the compiler would do constant subexpression elimination.
> It's rare in normal Python code to actually see a constant expression
> computed inside a loop. Fortunately, it would appear most folks aren't that
> dumb, so while you can take steps to eliminate them, there aren't generally
> going to be very many to eliminate.
What about a constant used only by a function, which function can be
called in loops?
When performance is important, I use to define such constants in the
of the function definition: I trade readability for performance. smart
(evaluate not at compile time, but once at runtime) sure wud help.
Pierre Imbaud <pierre at saiph.com>
12 Rue des Bosquets 91480 Quincy Sous Sénart France
Tel: 01 69 00 94 57 Fax 09 47
More information about the Python-list