-
-
Notifications
You must be signed in to change notification settings - Fork 198
Closed
Description
pyupgrade transform this line:
tuple([x for x in my_range])
in the less efficient:
tuple(x for x in my_range)
Have a look at this example:
[ale@flo pyupgrade-issue]$ cat a.py
my_range = range(10000)
for i in my_range:
tuple([x for x in my_range])
This script runs in less than 2 seconds:
[ale@flo pyupgrade-issue]$ time python3.10 a.py
real 0m1,812s
user 0m1,734s
sys 0m0,076s
Buth after I run pyupgrade I see it gets significantly slower:
[ale@flo pyupgrade-issue]$ pyupgrade a.py
WARNING: pyupgrade will default to --py3-plus in 3.x
Rewriting a.py
[ale@flo pyupgrade-issue]$ git diff
...
- tuple([x for x in my_range])
+ tuple(x for x in my_range)
[ale@flo pyupgrade-issue]$ time python3.10 a.py
real 0m2,403s
user 0m2,394s
sys 0m0,009s
yurj and perrinjeromejensens
Metadata
Metadata
Assignees
Labels
No labels