PR link is https://github.com/numpy/numpy/pull/3410



On Thu, Jun 6, 2013 at 4:37 PM, Mark W <mw9050@gmail.com> wrote:

> I've moved this to a different PR.  I've added a based on yours to gate
> the call to CheckBuffer.  Please let me know if this helps.
>
>
> https://github.com/m-d-w/numpy/commit/c9c20d438b223f9ed1a43a33bb3c602ce55debc9#commitcomment-3372115
>
>
>
> On Thu, Jun 6, 2013 at 3:34 PM, raulcota <notifications@github.com> wrote:
>
>> In numpy/core/src/multiarray/common.c:
>>
>> > @@ -308,32 +359,35 @@
>> >      }
>> >
>> >      /* PEP 3118 buffer interface */
>> > -    memset(&buffer_view, 0, sizeof(Py_buffer));
>> > -    if (PyObject_GetBuffer(obj, &buffer_view, PyBUF_FORMAT|PyBUF_STRIDES) == 0 ||
>> > -        PyObject_GetBuffer(obj, &buffer_view, PyBUF_FORMAT) == 0) {
>> > -
>> > -        PyErr_Clear();
>> > -        dtype = _descriptor_from_pep3118_format(buffer_view.format);
>> > -        PyBuffer_Release(&buffer_view);
>> > -        if (dtype) {
>> > +    if (PyObject_CheckBuffer(obj) == 1) {
>>
>> I added your test (done 10 times),
>>
>> executions = 10
>> test = "np.array([None]*100000, dtype=np.float64)"
>>
>> t = timeit.timeit(test, setup=code, number=executions)
>> print formatresults(test, t)
>>
>> My pull request does it at,
>> 0.216 [s]
>>
>> your suggested code does it at,
>> 0.963 [s]
>>
>> no modifications at all,
>> 2.307 [s]
>>
>> —
>> Reply to this email directly or view it on GitHub<https://github.com/numpy/numpy/pull/3396/files#r4575830>
>> .
>>
>
>