buffer class and ll2ctypes problem
I've been working with Richard on a new (rpython) buffer class. See attached for two approaches. The richbuf seems much clearer, but i'm not sure how to get other types out of it (like long long or short), or do byte swapping. I don't understand this much, can someone point the right direction ? Ie. which buf is the right direction to go. (I would also like to re-visit the array type in pypy/rpython/numpy, and perhaps think more generally about __getitem__ in rpython.) The rffi buffer (buffers.py) fails on CPython: $ python buffers.py Traceback (most recent call last): File "buffers.py", line 55, in <module> test_run() File "buffers.py", line 51, in test_run assert demo(1234) == 1234 File "buffers.py", line 39, in demo buf.put_int32(value) File "buffers.py", line 31, in put_int32 intp = rffi.cast(INTP, buf) File "/home/simon/site-packages/pypy/rpython/lltypesystem/ll2ctypes.py", line 491, in force_cast cvalue = lltype2ctypes(value) File "/home/simon/site-packages/pypy/rpython/lltypesystem/ll2ctypes.py", line 336, in lltype2ctypes convert_struct(container) File "/home/simon/site-packages/pypy/rpython/lltypesystem/ll2ctypes.py", line 161, in convert_struct convert_struct(parent) File "/home/simon/site-packages/pypy/rpython/lltypesystem/ll2ctypes.py", line 165, in convert_struct cstruct = cls._malloc() File "/home/simon/site-packages/pypy/rpython/lltypesystem/ll2ctypes.py", line 89, in _malloc raise TypeError, "array length must be an int" TypeError: array length must be an int Simon.
participants (1)
-
Simon Burton