[Pyrex] Pyrex v Psyco

Greg Ewing greg.ewing at canterbury.ac.nz
Mon Jun 19 01:01:54 UTC 2006


Philip Smith wrote:
> I can't seem to replicate the performance 
> enhancement over Psyco which the Pyrex test suite demonstrates

If you're talking about the primes example, keep in mind that
it's a particularly good case, because it uses C operations
exclusively in its inner loops. It's really a C program
with a bit of Python around the outer edges.

> Am I (as a newcomer) doing soething obviously wrong or is there 
> something about this code that means one wouldn't expect particularly 
> fast execution???

You're making a lot of Python API calls -- you can't
expect spectacular performance from that.

Also, you're calling the Python ord() function in a
few places. That costs a dict lookup, a Python function
call, and possibly some argument conversions. If you
know you have a string (not unicode), you can do that a
lot more efficiently by coercing to a char * and looking
at the first character.

--
Greg



More information about the Pyrex mailing list