-
-
Notifications
You must be signed in to change notification settings - Fork 34.7k
Optimize len for string constants in optimizer #144140
Copy link
Copy link
Closed
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usagePerformance or resource usagetopic-JITtype-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)performancePerformance or resource usagePerformance or resource usagetopic-JITtype-featureA feature request or enhancementA feature request or enhancement
Fields
Give feedbackNo fields configured for issues without a type.
Feature or enhancement
Proposal:
Hi team, I found an optimization opportunity: len() calls on string constants can be
optimized at compile time, similar to how tuple constants are handled.
Quick testing with
python -m testshowed _CALL_LEN hits:This patch extends the existing constant folding for len(tuple) to also handle
len("string"), replacing the function call with _SHUFFLE_3_LOAD_CONST_INLINE_BORROW
when the result is an immortal integer.
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
No response
Linked PRs