CLN: Use generators instead of lists in built-in Python functions#18276
CLN: Use generators instead of lists in built-in Python functions#18276jreback merged 2 commits intopandas-dev:masterfrom
Conversation
Codecov Report
@@ Coverage Diff @@
## master #18276 +/- ##
==========================================
- Coverage 91.4% 91.38% -0.02%
==========================================
Files 164 164
Lines 49878 49878
==========================================
- Hits 45590 45581 -9
- Misses 4288 4297 +9
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #18276 +/- ##
==========================================
- Coverage 91.4% 91.38% -0.02%
==========================================
Files 164 164
Lines 49878 49878
==========================================
- Hits 45590 45581 -9
- Misses 4288 4297 +9
Continue to review full report at Codecov.
|
|
@mroeschke thanks. can you add a linting check in |
|
does this have any perf impact ? |
|
I ran one full asv and two asvs for Sure I can include this check in |
|
thanks
would be great |
|
I don't thing you would expect to see any difference in asv. I think this is mainly about code style / redundancy. Certainly given that, apparently (just tried it out, didn't expect this), with small lists it can actually be a bit faster using a list comprehension instead of generator (for bigger ones there is a clear difference though): (and the cases in our code typically are small numbers, eg looping of the axes of a DataFrame (thus 2)) |
git diff upstream/master -u -- "*.py" | flake8 --diffPass generators in built-in Python functions instead of passing in a list, e.g
any([value for value in iterator])-->any(value for value in iterator)