[pypy-dev] buffer class and ll2ctypes problem

Simon Burton simon at arrowtheory.com
Tue Aug 21 18:06:37 CEST 2007

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>
  File "buffers.py", line 51, in test_run
    assert demo(1234) == 1234
  File "buffers.py", line 39, in demo
  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
  File "/home/simon/site-packages/pypy/rpython/lltypesystem/ll2ctypes.py", line 161, in convert_struct
  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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: buffers.py
Type: text/x-python
Size: 1328 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/pypy-dev/attachments/20070821/3aa80795/attachment.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: richbuf.py
Type: text/x-python
Size: 1370 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/pypy-dev/attachments/20070821/3aa80795/attachment-0001.py>

More information about the Pypy-dev mailing list