-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Doc] reimplemented-starmap
does not mention performance
#7771
Comments
On Python 3.12 the listcomp is faster (likely thanks to PEP 709). Running @Avasam's benchmark:
(The numbers for generators don't feel very meaningful as it's just for creating the generator, not iterating over it.) |
I ran the code passing the generators to On Python 3.11:
On Python 3.12:
So it looks like (Accidentally deleted previous comment instead of editing it when trying to correct numbers, apologises for the noise.) |
## Summary Document the performance effects of `itertools.starmap`, including that it is actually slower than comprehensions in Python 3.12. Closes #7771. ## Test Plan `python scripts/check_docs_formatted.py`
## Summary Document the performance effects of `itertools.starmap`, including that it is actually slower than comprehensions in Python 3.12. Closes #7771. ## Test Plan `python scripts/check_docs_formatted.py`
https://github.com/dosisod/refurb/blob/master/docs/checks.md#furb140-use-starmap mentions performance.
https://docs.astral.sh/ruff/rules/reimplemented-starmap/ does not
My local tests seem to agree:
Python 3.9.13:
Python 3.11.2 (surprisingly the generator comprehension is even slower in Python 3.11, despite the proclaimed comprehension speed improvements, list comprehension checks out):
Scales similarly with a list of ~100 or ~1million items (the list examples takes forever though)
I think it would be important to mention as well. It is not insignificant (a little bit for list, ~2x for generators) and the doc makes it sounds like a simple stylistic change.
The text was updated successfully, but these errors were encountered: