pylong.pyx 615 Bytes
Newer Older
Robert Bradshaw's avatar
Robert Bradshaw committed
1 2
# mode: compile

3 4 5 6 7
cdef extern from "Python.h":
    ctypedef struct PyTypeObject:
        pass

    ctypedef struct PyObject:
8
        Py_ssize_t ob_refcnt
9 10
        PyTypeObject *ob_type

11 12 13 14 15 16
cdef extern from "Python.h":
    """
    #if PY_MAJOR_VERSION < 3
     #include "longintrepr.h"
    #endif
    """
17
    cdef struct _longobject:
18
        int ob_refcnt
19
        PyTypeObject *ob_type
Stefan Behnel's avatar
Stefan Behnel committed
20
#        int ob_size            # not in Py3k
21 22 23
        unsigned int *ob_digit

def test(temp = long(0)):
24 25
    cdef _longobject *l
    l = <_longobject *> temp
Stefan Behnel's avatar
Stefan Behnel committed
26
    #print sizeof(l.ob_size)    # not in Py3k
27
    print sizeof(l.ob_digit[0])