[Numpy-discussion] PyArray_FILLWBYTE dangerous doc
Fri Jul 6 09:30:45 CDT 2012
I just did a PR that update the doc to warn about this.
On Thu, Jun 28, 2012 at 10:28 PM, Frédéric Bastien <email@example.com> wrote:
> The doc of PyArray_FILLWBYTE here
> http://docs.scipy.org/doc/numpy/reference/c-api.array.html is this
> PyArray_FILLWBYTE(PyObject* obj, int val)
> Fill the array pointed to by obj —which must be a (subclass of)
> bigndarray—with the contents of val (evaluated as a byte).
> In the code, what it does is call memset:
> #define PyArray_FILLWBYTE(obj, val) memset(PyArray_DATA(obj), val, \
> This make it ignore completely the strides!
> So the easy fix would be to update the doc, the real fix is to test
> the contiguity before calling memset, if not contiguous, call
> something else appropriate.
More information about the NumPy-Discussion