On Wednesday, February 19, 2014 9:10:03 AM UTC+1, Stefan Behnel wrote: > > >> Nathaniel Smith wrote: > >>> Does anyone see any issue we might be overlooking in this refcount == > 1 > >>> optimization for the python api? I'll post a PR with the change > shortly. > >>> > >>> It occurs belatedly that Cython code like a = np.arange(10) > >>> b = np.arange(10) > >>> c = a + b might end up calling tp_add with refcnt 1 arrays. Ditto > for > >>> same with cdef np.ndarray or cdef object added. We should check... > > That can happen, yes. Cython only guarantees that the object it passes is > safely owned so that the reference cannot go away while it's being > processed by a function. If it's in a local (non-closure) variable (or > Cython temporary variable), that guarantee holds, so it's safe to pass > objects with only a single reference into a C function, and Cython will do > that. > > Stefan >
thats unfortunate, it would be a quite significant improvement to numpy (~30% improvement to all operations involving temporaries). Is increasing the reference count before going into PyNumber functions really that expensive that its worth avoiding?
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion