[pypy-dev] cffi python long
Nathan Hurst
njh at njhurst.com
Fri Nov 8 14:59:47 CET 2013
Is there a nicer way to pass python long ints (bigint) into C
efficiently? I'm currently cutting the value up into 64 bit chunks in
python and passing in as an unsigned long*:
cdef("int bigInt(int n, unsigned long* x);")
x = sum(1 << i for i in [100,200,123])
xs = []
while x > 0:
xs.append(x & ((1 << 64) - 1))
x >>= 64
print lib.bigInt(len(xs), xs)
but this is quite slow, and it seems like this data must already be
lurking somewhere in exactly the right form.
njh
More information about the pypy-dev
mailing list