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 sobolevn
Recipients asvetlov, eric.araujo, sobolevn
Date 2022-01-09.09:11:22
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1641719482.54.0.073879595451.issue46310@roundup.psfhosted.org>
In-reply-to
Content
This line https://github.com/python/cpython/blob/3d11c1b8b49800c5c4c295953cc3abf577f6065a/Lib/asyncio/windows_events.py#L842 uses `.items()`, but the key seems unsused.

It would be better to use `.values()` there.

1. It is slightly faster, very generic benchmark:

```
import timeit
cache = {i: (i, i + 1, None, f'a{i}') for i in range(1000)}
timeit.timeit('list(cache.items())', number=1000, globals=locals())
# 0.18165644304826856
timeit.timeit('list(cache.values())', number=1000, globals=locals())
# 0.04786261299159378
```

2. It is more readable, because unused variables are not created

And since it does not break anything, I think it is safe to refactor.
History
Date User Action Args
2022-01-09 09:11:22sobolevnsetrecipients: + sobolevn, eric.araujo, asvetlov
2022-01-09 09:11:22sobolevnsetmessageid: <1641719482.54.0.073879595451.issue46310@roundup.psfhosted.org>
2022-01-09 09:11:22sobolevnlinkissue46310 messages
2022-01-09 09:11:22sobolevncreate