-
-
Notifications
You must be signed in to change notification settings - Fork 34.6k
Generator vs List comprehension optimzations #131959
Copy link
Copy link
Closed as not planned
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)pendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is providedperformancePerformance or resource usagePerformance or resource usagetype-featureA feature request or enhancementA feature request or enhancement
Metadata
Metadata
Assignees
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)pendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is providedperformancePerformance or resource usagePerformance or resource usagetype-featureA feature request or enhancementA feature request or enhancement
Feature or enhancement
Proposal:
I don't know if it's possible but it might be a good idea to look at optimizations for the generator function used inline for a function call
vs it's list comprehension counterpart
for example, which I feel is a pretty common syntax; however, due to some overheads (I think?) using a list comprehension is just faster (as per benchmarks on builtin functions)
I don't know if it's possible, but maybe making a fast path for built-in functions when using generators to speed up that compute at a lower number of elements. This could be interesting to explore since generators require less memory.
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
No response