Reputation: 8775
Downstream of this I am getting an error Python int too large to convert to C long
, which led me to suspect that somehow ctypes long was too small - size 4 and not 8.
I tested this and it was indeed the case. Yet, I am using Python 2.7 64 bit (Anaconda).
import ctypes as C
import os
import platform
import numpy as np
print "Python Platform Architecture: ", platform.architecture()[0]
print "Size of ctypes long: ", (C.sizeof(C.c_long))
This is the output:
Python Platform Architecture: 64bit
Size of ctypes long: 4
Upvotes: 2
Views: 998
Reputation: 410762
A long
is only guaranteed to be at least 32 bits wide, so on some systems, ctypes.c_long
is only 32 bits. In particular, I believe on 64-bit Windows, ctypes.c_long
is only 32 bits wide. If it must be 64 bits wide, use ctypes.c_int64
instead.
Upvotes: 6