From f5b6850f231de80b067e06e01d11bec4bd535c58 Mon Sep 17 00:00:00 2001 From: Matti Picus Date: Wed, 9 Jan 2019 16:28:09 +0200 Subject: BUG: reference cycle in np.vectorize (#11977) This implements cyclic support by adding `tp_traverse` to ufuns which may contain a user provided object function (`np.frompyfunc`). Ufuncs that do not add this are not added to the circular reference count tracking. The ufunc does not need to implement `tp_clear` because it is an immutable object. --- numpy/core/include/numpy/ufuncobject.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'numpy/core/include') diff --git a/numpy/core/include/numpy/ufuncobject.h b/numpy/core/include/numpy/ufuncobject.h index 90d837a9b..15dcdf010 100644 --- a/numpy/core/include/numpy/ufuncobject.h +++ b/numpy/core/include/numpy/ufuncobject.h @@ -120,7 +120,11 @@ typedef struct _tagPyUFuncObject { */ int nin, nout, nargs; - /* Identity for reduction, either PyUFunc_One or PyUFunc_Zero */ + /* + * Identity for reduction, any of PyUFunc_One, PyUFunc_Zero + * PyUFunc_MinusOne, PyUFunc_None, PyUFunc_ReorderableNone, + * PyUFunc_IdentityValue. + */ int identity; /* Array of one-dimensional core loops */ @@ -301,7 +305,7 @@ typedef struct _tagPyUFuncObject { */ #define PyUFunc_ReorderableNone -2 /* - * UFunc unit is in identity_value, and the order of operations can be reordered + * UFunc unit is an identity_value, and the order of operations can be reordered * This case allows reduction with multiple axes at once. */ #define PyUFunc_IdentityValue -3 -- cgit v1.2.1