-
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
Consider deprecating UP027 or improve its docs #12754
Comments
@carljm -- Do you have an opinion here? |
should we have a reversed version as perf rule? |
Hi guys, I did some small tests and the results show that in python 3.6-3.12 list comprehension are faster than generator
Maybe we should remove UP027 and implement a reverse version of it. |
I agree that the current |
@AlexWaygood should we deprecate this rule as part of 0.6? |
On the note of an inverse rule, I think that's basically what I'm asking in #11839 ? |
Yeah, makes sense to me. I'd hold off with implementing a reverse rule, though; I agree with @carljm that there doesn't seem to be a strong argument for preferring either |
There are cases where pure generators are faster, but only when they're large enough which is way beyond the size someone would unpack ;)
|
Rule deprecated by ruff. See astral-sh/ruff#12754
The original rule UP027 (unpacked-list-comprehension), implemented in
pyupgrade
does not seem to be thoroughly justified, and in fact it is actually slower. Which goes against the documentation in ruff which mentionsI raised a question in pyupgrade, showing how using generators is actually 3 times slower than unpacking a list comprehension
System
Python 3.12.4 (main, Jun 6 2024, 18:26:44) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin
Mac OS Sonoma 14.5
The text was updated successfully, but these errors were encountered: