[Numpy-discussion] import overhead of numpy.testing

Andrew Dalke dalke at dalkescientific.com
Sun Aug 11 16:37:33 EDT 2013


On Aug 11, 2013, at 10:24 PM, Benjamin Root wrote:
> The idea would be that within numpy (and we should fix SciPy as well), we would always import numpy._testing as testing, and not import testing.py ourselves.

The problem is the existing code out there which does:

import numpy as np
 ...
np.testing.utils.assert_almost_equal(x, y)

(That is, without an additional import), and other code which does

from numpy.testing import *


There's no way to make these both give a warning without some
horrible hack, like interposing our own __import__ or sticking
some non-module object into sys.modules.

Down that path lies madness, and the corpses of many earlier
attempts.

Perhaps the latest Python import hooks might have a solution,
but it's not something I want to spend time solving.


				Andrew
				dalke at dalkescientific.com





More information about the NumPy-Discussion mailing list