Stefan Krah added the comment:
But only Cython does not set suboffsets to NULL and you already have a small
patch to fix that.
The Python 3 docs say "suboffsets only if needed" and the PEP says the same,
so the situation is not completely undocumented.
I think your doc patch goes too far. Buffers propagate in unpredictable ways,
and since the original consumer request is *not stored* in the buffer, setting
unneeded fields to NULL provides a way to figure out the original request.
It is actually *an optimization* to set suboffsets to NULL: Compliant code
that uses arbitrary buffers always has to check for:
if (suboffsets != NULL && suboffsets[i] >= 0)
...
If suboffsets are consistently NULL, at least hopefully you get branch
prediction to kick in.
As Sebastian pointed out, it's relatively easy even for slicing/indexing
functions to check for all-negative suboffsets and handle that case.
All this is probably academic, since no one appears to be using suboffsets
at all. :)
Let's keep the status-quo and make this a doc issue for 2.7.
----------
assignee: -> docs@python
components: +Documentation -Interpreter Core
nosy: +docs@python
priority: normal -> low
stage: patch review ->
title: PyBuffer_IsContiguous() sometimes returns wrong result if suboffsets !=
NULL -> Document "suboffsets if needed" in 2.7
type: behavior -> enhancement
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue23352>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com