[Pyrex] Pyrex method 10x slower than Python, any hints why?

John Machin sjmachin at lexicon.net
Fri Jun 2 11:00:30 UTC 2006


On 2/06/2006 1:39 PM, Andrew Bennetts wrote:
> On Fri, Jun 02, 2006 at 01:03:35PM +1000, John Machin wrote:
> [...]
>>> Perhaps the difference is that Python's eval loop special cases arithmetic
>>> operations on numeric types quite heavily, but the same loop in Pyrex has to
>>> resort to function calls?
>>>
>> Huh? AFAICT, all of the operations on numeric types in the quoted code 
>> are being done in cdef'ed variables i, sum and cost. There is *some* 
>> overhead caused by converting i to a Python int, and by getting the 
>> result of the function call (Python float) into cost.
> 
> Sorry, that was a dumb thinko!  I was getting muddled with comments elsewhere
> that you also tried pyrex without the cdefs.
> 

Futhermore, the OP with the problem is David Chiang, not me.

Cheers,
John



More information about the Pyrex mailing list