Skip to content

Commit c64c7cc

Browse files
authored
Merge pull request numpy#19927 from asmeurer/faster-in-place-imports
BUG: Only call the get_versions() function once on import
2 parents 3dba985 + daea42f commit c64c7cc

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

numpy/__init__.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,7 @@
135135
'VisibleDeprecationWarning']
136136

137137
# get the version using versioneer
138-
from ._version import get_versions
139-
vinfo = get_versions()
140-
__version__ = vinfo.get("closest-tag", vinfo["version"])
141-
__git_version__ = vinfo.get("full-revisionid")
142-
del get_versions, vinfo
138+
from .version import __version__, git_revision as __git_version__
143139

144140
# mapping of {name: (value, deprecation_msg)}
145141
__deprecated_attrs__ = {}
@@ -407,7 +403,3 @@ def _mac_os_check():
407403
# We do this from python, since the C-module may not be reloaded and
408404
# it is tidier organized.
409405
core.multiarray._multiarray_umath._reload_guard()
410-
411-
from ._version import get_versions
412-
__version__ = get_versions()['version']
413-
del get_versions

numpy/version.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
from ._version import get_versions
22

3-
__ALL__ = ['version', 'full_version', 'git_revision', 'release']
3+
__ALL__ = ['version', '__version__', 'full_version', 'git_revision', 'release']
44

55
vinfo = get_versions()
66
version: str = vinfo["version"]
7+
__version__ = vinfo.get("closest-tag", vinfo["version"])
78
full_version: str = vinfo['version']
89
git_revision: str = vinfo['full-revisionid']
910
release = 'dev0' not in version and '+' not in version

0 commit comments

Comments
 (0)