Mapping 64 bit int from C to Python-2.2

Mark Hammond skippy.hammond at gmail.com
Tue Mar 10 10:04:56 CET 2009


On 10/03/2009 2:51 AM, Explore_Imagination wrote:
> Hi
>
> 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.
>
> Any Suggestions?

pywin32 had this requirement, and although support was recently removed, 
if you look at:

http://pywin32.cvs.sourceforge.net/viewvc/pywin32/pywin32/win32/src/PyLARGE_INTEGER.cpp?revision=1.11&view=markup

you should find routines that work without 'longlong' support in Python 
itself.

Cheers,

Mark



More information about the Python-list mailing list