summaryrefslogtreecommitdiff
path: root/numpy/core/shape_base.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/core/shape_base.py')
-rw-r--r--numpy/core/shape_base.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/numpy/core/shape_base.py b/numpy/core/shape_base.py
index 65c3ed00d..319c25088 100644
--- a/numpy/core/shape_base.py
+++ b/numpy/core/shape_base.py
@@ -446,7 +446,13 @@ def _block(arrays, max_depth, result_ndim):
# type(arrays) is not list
return atleast_nd(arrays, result_ndim)
- return block_recursion(arrays)
+ try:
+ return block_recursion(arrays)
+ finally:
+ # recursive closures have a cyclic reference to themselves, which
+ # requires gc to collect (gh-10620). To avoid this problem, for
+ # performance and PyPy friendliness, we break the cycle:
+ block_recursion = None
def block(arrays):