-
-
Notifications
You must be signed in to change notification settings - Fork 33.5k
Closed as not planned
Labels
performancePerformance or resource usagePerformance or resource usagetype-featureA feature request or enhancementA feature request or enhancement
Description
Currently, sum(range(...)) falls back to an iterative loop that takes O(n) time, where n is the length of the range. Instead, this can be done in O(1) time with some arithmetic.
This is slightly related to issue #68264, where it is noted that sum(range(...)) had a slightly performance regression between Python2 and 3. However, in both cases, an O(n) time implementation is used.
Note: this is my first time contributing here using only Github. I already have a patch prepared, but I think I needed to open an issue first.
Linked PRs
Metadata
Metadata
Assignees
Labels
performancePerformance or resource usagePerformance or resource usagetype-featureA feature request or enhancementA feature request or enhancement