
Another rather old ticket is this one: http://projects.scipy.org/scipy/numpy/ticket/454> Any comments on this !? Thanks, -Sebastian On 2/16/07, NumPy <numpy-tickets@scipy.net> wrote:
#454: Importing numpy prevents decrementing references for local variables ------------------------+--------------------------------------------------- Reporter: goddard | Owner: somebody Type: defect | Status: new Priority: normal | Milestone: Component: numpy.core | Version: 1.0.1 Severity: major | Keywords: ------------------------+--------------------------------------------------- If the first import of numpy is within a function it prevents that function's local variables and all locals in higher call frames that led to the import from being deleted. This can prevent freeing up large numpy arrays.
The problem is that numpy __init__.py imports numpy _import_tools.py and creates a PackageLoader object that saves the parent frame
self.parent_frame = frame = sys._getframe(1)
Saving the parent frame results in saving the entire call stack even after all those functions have returned.
I've attached Python code illustrating the problem.