Message383497
Yeah I hear ya, was just trying for the most concise issue title. I tend to [over]use `map`, `filter`, `filterfalse` and other `itertools` and `operator` methods in my own codebase.
Surprised with that result, that using an explicit list is actually faster. Seems like an obvious* micro-optimisation. *But don't want to say that unless I'm actually maintaining/contributing-to your C code.
It's also surprising—last time I checked—that lists are faster to construct than tuples. When I create codebases or maintain other peoples, I try and:
- remove all unnecessary mutability (incl. replacing lists with tuples);
- flatten `.append` occurrences into generator comprehensions or map;
- remove all indentation creating for-loops, replacing with comprehensions or map and functions or lambdas
- combine generators rather than concatenate lists;
The general idea here is to evaluate at the time of computation, and be lazy everywhere else. So searching the whole codebase for lists and other mutable structures is a good first step.
But maybe with efficiency losses, like shown here, means that this would only aid [maybe] in readability, understandability, traceability & whatever other functional -ility; but not performance?
:( |
|
Date |
User |
Action |
Args |
2020-12-21 09:19:56 | samuelmarks | set | recipients:
+ samuelmarks, rhettinger, eric.smith, steven.daprano, josh.r, kj |
2020-12-21 09:19:56 | samuelmarks | set | messageid: <1608542396.64.0.995713479884.issue42699@roundup.psfhosted.org> |
2020-12-21 09:19:56 | samuelmarks | link | issue42699 messages |
2020-12-21 09:19:56 | samuelmarks | create | |
|