[Cython] bug in typed memoryviews (memoryviewslice)

Richard Hansen rhansen at bbn.com
Tue Jan 27 23:38:17 CET 2015


Hi all,

If I create foo.pyx with the following contents:

cpdef object foo():
    cdef unsigned char[:] s = <bytearray><unsigned char *>"012345"
    return s

I notice the following behavior:

$ python -c '
import foo
m=foo.foo()
print repr(memoryview(m.base).tobytes())
print repr(memoryview(m).tobytes())
'
'012345'
'123450'

Notice how the bytes are printed in the wrong order unless I use the
original buffer object via the typed memoryview object's base attribute.

-Richard


More information about the cython-devel mailing list