diff options
Diffstat (limited to 'numpy/core/_internal.py')
-rw-r--r-- | numpy/core/_internal.py | 31 |
1 files changed, 0 insertions, 31 deletions
diff --git a/numpy/core/_internal.py b/numpy/core/_internal.py index 3ed22818f..8942955f6 100644 --- a/numpy/core/_internal.py +++ b/numpy/core/_internal.py @@ -876,34 +876,3 @@ def npy_ctypes_check(cls): return '_ctypes' in ctype_base.__module__ except Exception: return False - - -class recursive: - ''' - A decorator class for recursive nested functions. - Naive recursive nested functions hold a reference to themselves: - - def outer(*args): - def stringify_leaky(arg0, *arg1): - if len(arg1) > 0: - return stringify_leaky(*arg1) # <- HERE - return str(arg0) - stringify_leaky(*args) - - This design pattern creates a reference cycle that is difficult for a - garbage collector to resolve. The decorator class prevents the - cycle by passing the nested function in as an argument `self`: - - def outer(*args): - @recursive - def stringify(self, arg0, *arg1): - if len(arg1) > 0: - return self(*arg1) - return str(arg0) - stringify(*args) - - ''' - def __init__(self, func): - self.func = func - def __call__(self, *args, **kwargs): - return self.func(self, *args, **kwargs) |