summaryrefslogtreecommitdiff
path: root/numpy/core/shape_base.py
diff options
context:
space:
mode:
authorAllan Haldane <allan.haldane@gmail.com>2018-02-17 14:36:49 -0500
committerAllan Haldane <allan.haldane@gmail.com>2018-02-18 23:22:01 -0500
commit50fde71f1ac0528f40ee216136b33fde41205ef2 (patch)
tree8027f9c741d643efa82fcd3963dfdc90e14a9428 /numpy/core/shape_base.py
parent4105af42c38539e8bf854c49134fe221d86ec79d (diff)
downloadnumpy-50fde71f1ac0528f40ee216136b33fde41205ef2.tar.gz
BUG: break cyclic refs in recursive closures
Fixes #10620
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):