access string data from within cython
sturlamolden
sturlamolden at yahoo.no
Wed Aug 5 17:51:12 EDT 2009
On 5 Aug, 23:22, "Diez B. Roggisch" <de... at nospam.web.de> wrote:
> And that gives me the *full* bytestring, not only until the first zero?
> I can't try that right now (not at work anymore), but if it's that easy,
> that would be great.
It should, and if it does not it is a bug in Cython. The len()
function should work similarly in Python and Cython: It should just
call the object's __len__ method. Cython has no idea that your Python
object bytestring is a byte string, nor does Cython care.
>>> bs = '\x00'*10 # bytes string with 10 zeros
>>> len(bs)
10
>>> bs.__len__()
10
More information about the Python-list
mailing list