You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since #17670, sklearn unconditionally imports pkg_resources. Such an import can be very slow (pypa/setuptools#926), so it should be avoided if possible.
Given that the point of #17670 was to improve support for prereleases, a possible fix could be for example to delay importing pkg_resources until needed, e.g.
defparse_version(v):
if {*v} <= {*"1234567890."}:
returnLooseVersion(v)
else:
importpkg_resourcesreturnpkg_resources.parse_version(v)
It could be an improvement. I don't know if this is currently dramatic since we mainly import parse_version in the test (but we might import utils.fixes that will load pkg_resources)
I don't know if this is currently dramatic since we mainly import parse_version in the test (but we might import utils.fixes that will load pkg_resources)
But a plain import sklearn already imports sklearn.utils.fixes... (check e.g. with python -c 'import sys, sklearn; print("sklearn.utils.fixes" in sys.modules)').
Would it be worth trying importlib.metadata first
importlib.metadata.version returns a string, so it doesn't help here as the point is the need to parse the version string.
Describe the bug
Since #17670, sklearn unconditionally imports pkg_resources. Such an import can be very slow (pypa/setuptools#926), so it should be avoided if possible.
Given that the point of #17670 was to improve support for prereleases, a possible fix could be for example to delay importing pkg_resources until needed, e.g.
Steps/Code to Reproduce
Expected Results
Actual Results
N/A
Versions
The text was updated successfully, but these errors were encountered: