Anthony Sottile <asott...@umich.edu> added the comment:
the `.select(...)` api is at least twice as slow as indexing as well: setup: ``` virtualenv venv39 -p python3.9 venv39/bin/pip install flake8 pytest pytest-randomly virtualenv venv39 -p python3.10 venv310/bin/pip install flake8 pytest pytest-randomly ``` ```python import importlib.metadata import sys import time def f(): eps = importlib.metadata.entry_points() if sys.version_info >= (3, 10): eps.select(name='console_scripts') else: eps['console_scripts'] t0 = time.time() for _ in range(100): f() t1 = time.time() print(f'{t1-t0}') ``` ``` $ ./venv39/bin/python t.py 0.687570333480835 $ ./venv310/bin/python t.py 1.3486714363098145 ``` it is *way* worse when involving multiple entry points: ```python import importlib.metadata import sys import time # moved outside of the loop, already showed this component is slower eps = importlib.metadata.entry_points() def f(): # common for plugin systems to look up multiple entry points for ep in ('console_scripts', 'flake8.extension', 'pytest11'): if sys.version_info >= (3, 10): eps.select(name=ep) else: eps[ep] t0 = time.time() for _ in range(10000): f() t1 = time.time() print(f'{t1-t0}') ``` ```console $ ./venv39/bin/python t.py 0.01629471778869629 $ ./venv310/bin/python t.py 8.569908380508423 ``` ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue44246> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com