Message335961
Lib uses loops to append to a new list in quite a few places. I think it would be better to replace those with list comprehensions.
Benefits of this change:
- List comprehensions are generally more readable than appending to a newly created list
- List comprehensions are also a lot faster.
Toy example:
In [1]: %%timeit
...: l = []
...: for i in range(5000):
...: l.append(i)
375 µs ± 1.73 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
In [2]: %%timeit
...: l = [i for i in range(5000)]
168 µs ± 1.08 µs per loop (mean ± std. dev. of 7 runs, 10000 loops each)
Possible drawbacks:
- Refactoring can always introduce bugs and makes it harder to get meaningful output from git blame. In this case I think the diff is very manageable, making the changes easy to review.
Personally, I think the codebase would benefit from this change both in terms of some small performance gains and maintainability. I'd be happy to make a PR to fix this. |
|
Date |
User |
Action |
Args |
2019-02-19 16:05:09 | lgeiger | set | recipients:
+ lgeiger |
2019-02-19 16:05:09 | lgeiger | set | messageid: <1550592309.68.0.760031675356.issue36039@roundup.psfhosted.org> |
2019-02-19 16:05:09 | lgeiger | link | issue36039 messages |
2019-02-19 16:05:09 | lgeiger | create | |
|