[Numpy-discussion] numpy, Py_ssize_t, cython and 64 bits python 2.4

Charles R Harris charlesr.harris@gmail....
Sun Nov 9 14:16:42 CST 2008


On Sun, Nov 9, 2008 at 1:01 PM, Charles R Harris
<charlesr.harris@gmail.com>wrote:

>
>
> On Sun, Nov 9, 2008 at 11:44 AM, David Cournapeau <cournape@gmail.com>wrote:
>
>> On Mon, Nov 10, 2008 at 2:40 AM, Charles R Harris
>> <charlesr.harris@gmail.com> wrote:
>> >
>> >
>> > Let me see if I understand this correctly. For Python < 2.5 the list
>> indices
>> > and such are ints, while for later versions they are Py_ssize_t, which
>> is
>> > larger on 64 bit systems. Meanwhile, Py_intptr_t is large enough to hold
>> a
>> > pointer.
>>
>> yes
>>
>> > So why are these two numbers being mixed?
>>
>> It is note that they are being mixed, but that cython does not support
>> this configuration: it has a internal check which raise an exception
>> in such a case. See around line 55:
>>
>> http://hg.cython.org/cython/file/764f1578df40/Cython/Includes/numpy.pxd
>>
>> As I understand, this means you can't use cython for such a
>> configuration, but I just wanted to confirm whether there were known
>> workarounds.
>>
>
> Lessee,
>
> cdef extern from "Python.h":
>      ctypedef int Py_intptr_t
>
> cdef extern from "numpy/arrayobject.h":
>      ctypedef Py_intptr_t npy_intp
>
> So they are screwing with the npy_intp type. They should hang. Numpy is
> numpy, Python is python, and never the two should meet. Note that none of
> this crap is in the c_numpy.pxd included with numpy, BTW. I'd send the
> cython folks a note and tell them to knock it off, the Py_* values are
> irrelevant to numpy.
>
> In any case, for Python <  2.5, this should be something like
>
> cdef extern from "Python.h":
>      ctypedef int Py_ssize_t
>

Actually, I think


>
>  cdef extern from "numpy/arrayobject.h":
>      ctypedef npy_intp Py_intptr_t
>

should be deleted. Although the types are probably equal, one is a numpy
thing and the other a Python thing.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20081109/dd3afe74/attachment.html 


More information about the Numpy-discussion mailing list