Mapping 64 bit int from C to Python-2.2

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Mon Mar 9 16:21:07 EDT 2009


En Mon, 09 Mar 2009 13:51:59 -0200, Explore_Imagination  
<Mr.HassanShabbir at gmail.com> escribió:

> I want to map 64 bit integers from C to python. I must use Python 2.2
> BUT There is no support for 64 bits integers in Python2.2 (Supported
> in 2.5).
>
> Now the problem is that I have these four variables:
>
> unit32_t a,b,c;
> uint64_t w,x,y,z;
>
> I use this funtion to map values:
>
> Py_BuildValue( "(lllllll)", a,b,c,w,x,y,z );
>
> As I access 32 bit values in Python it works fine BUT 64 bit intergers
> in Pythong give garbage values . I think there may be a case of
> overflow when 64 bit values in C are mapped to python.

You'll have to use a Python long integer. Try PyLong_FromLongLong (I don't  
know if it exists in 2.2)

-- 
Gabriel Genellina




More information about the Python-list mailing list