This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Anthony Sottile
Recipients Anthony Sottile, Zac Hatfield-Dodds, domdfcoding, jaraco, miss-islington
Date 2021-05-30.17:04:11
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1622394251.59.0.279803920114.issue44246@roundup.psfhosted.org>
In-reply-to
Content
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
```
History
Date User Action Args
2021-05-30 17:04:11Anthony Sottilesetrecipients: + Anthony Sottile, jaraco, Zac Hatfield-Dodds, miss-islington, domdfcoding
2021-05-30 17:04:11Anthony Sottilesetmessageid: <1622394251.59.0.279803920114.issue44246@roundup.psfhosted.org>
2021-05-30 17:04:11Anthony Sottilelinkissue44246 messages
2021-05-30 17:04:11Anthony Sottilecreate