Python code written in 1998, how to improve/change it?

Carl Cerecke cdc at maxnet.co.nz
Thu Jan 19 18:20:03 EST 2006


Dan Sommers wrote:
> On Fri, 20 Jan 2006 10:27:58 +1300,
> Carl Cerecke <cdc at maxnet.co.nz> wrote:

>>... now you have a function-call overhead on each state transition ...
> 
> 
> Have you profiled your code and demonstrated that this particular
> function call consumes too much time?

Yes. For a parser reading a reasonable size input file, the difference 
is large enough to be noticeable.

> If you can't stand the overhead of one [extra, parameterless] function
> call per transition, especially *after* having eliminated the numerous
> comparisons, then Python may not be the best tool for the job.

Maybe. Except the bytecode *is* quite fast enough. There is just no way 
of writing python code so the compiler can generate that bytecode. Hence 
the JUMP_ABSOLUTE bytecode rewrite hack.

Cheers,
Carl.



More information about the Python-list mailing list