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
Hypothesis recently started importing pkg_resources which is notoriously slow to import. A better alternative these days is to use importlib.metadata, added in Python 3.8, or its backport importlib_metadata. Doing so would look something like this (completely untested, just to get the idea across):
diff --git a/hypothesis-python/src/hypothesis/entry_points.py b/hypothesis-python/src/hypothesis/entry_points.py
index 8cc4137ba..a5d670143 100644
--- a/hypothesis-python/src/hypothesis/entry_points.py+++ b/hypothesis-python/src/hypothesis/entry_points.py@@ -20,9 +20,18 @@ custom types, running the relevant code when *hypothesis* is imported instead of
your package.
"""
-import pkg_resources+try:+ if sys.version_info >= (3, 8):+ from importlib import metadata as importlib_metadata+ else:+ import importlib_metadata+except ImportError:+ import pkg_resources--def run():- for entry_point in pkg_resources.iter_entry_points("hypothesis"):- entry_point.load() # pragma: no cover+ def run():+ for entry_point in pkg_resources.iter_entry_points("hypothesis"):+ entry_point.load() # pragma: no cover+else:+ def run():+ for entry_point in importlib_metadata.entry_points().get("hypothesis", []):+ entry_point.load() # pragma: no cover
The text was updated successfully, but these errors were encountered:
Hypothesis recently started importing
pkg_resourceswhich is notoriously slow to import. A better alternative these days is to useimportlib.metadata, added in Python 3.8, or its backportimportlib_metadata. Doing so would look something like this (completely untested, just to get the idea across):The text was updated successfully, but these errors were encountered: