From 50fde71f1ac0528f40ee216136b33fde41205ef2 Mon Sep 17 00:00:00 2001 From: Allan Haldane Date: Sat, 17 Feb 2018 14:36:49 -0500 Subject: BUG: break cyclic refs in recursive closures Fixes #10620 --- numpy/lib/npyio.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'numpy/lib/npyio.py') diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py index 096f1a3a4..73613d2a4 100644 --- a/numpy/lib/npyio.py +++ b/numpy/lib/npyio.py @@ -1109,6 +1109,11 @@ def loadtxt(fname, dtype=float, comments='#', delimiter=None, finally: if fown: fh.close() + # 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: + flatten_dtype_internal = None + pack_items = None if X is None: X = np.array([], dtype) -- cgit v1.2.1