On 01/29/2015 05:14 AM, Richard Hansen wrote: > On 01/27/2015 05:38 PM, Richard Hansen wrote: >> 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. > > It turns out that this is due to a bug in Python, not Cython.
I submitted a couple of Python bug reports about this, with patches: http://bugs.python.org/issue23349 http://bugs.python.org/issue23352 -Richard > Fortunately it's relatively easy to work around this bug. I submitted a > pull request containing a workaround: > > https://github.com/cython/cython/pull/367 > > -Richard _______________________________________________ cython-devel mailing list cython-devel@python.org https://mail.python.org/mailman/listinfo/cython-devel