summaryrefslogtreecommitdiff
path: root/numpy/core
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2021-08-03 14:46:51 -0600
committerGitHub <noreply@github.com>2021-08-03 14:46:51 -0600
commit2a9a95d250c91f842b9fdc32cbeaeaced8b5896b (patch)
treeef62f2e4b35891a76d2d59dc2b602a86ef483e34 /numpy/core
parenta1ee7968df16a4f57c8e22164d19aa2d14a6cdad (diff)
parent557bb33ff71c6aae64a85e58d2b78b2c8877a0f5 (diff)
downloadnumpy-2a9a95d250c91f842b9fdc32cbeaeaced8b5896b.tar.gz
Merge pull request #19599 from anntzer/loadtxtunclose
PERF: Avoid using `@recursive`.
Diffstat (limited to 'numpy/core')
-rw-r--r--numpy/core/_internal.py31
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)