[Pyrex] Bug in PySequence indexing

Robert Bradshaw robertwb at math.washington.edu
Fri May 30 03:33:37 CEST 2008


On May 29, 2008, at 5:54 PM, Greg Ewing wrote:

> Robert Bradshaw wrote:
>>     cdef unsigned long n = 4000000000
>>     D = { n: "positive" }
>>     print D[n]
>
> I'll have to think more about this. I'm not sure what the
> right solution is. Maybe only do the optimisation when the
> index is a signed int type, or have two different runtime
> functions for the signed and unsigned case.
>
> What does your implementation do in the unsigned case?
> Fall back on PyObject_GetItem?

It falls back to PyObject_GetItem whenever the sign is negative and  
the type is unsigned. My get/setitem functions are inlined, so they  
just take an extra parameter which causes the test to be optimized  
away at C compile time for signed ints.

- Robert




More information about the Pyrex mailing list