-
-
Notifications
You must be signed in to change notification settings - Fork 34.7k
Stack-based ast.literal_eval Implementation #124503
Copy link
Copy link
Closed
Labels
performancePerformance or resource usagePerformance or resource usagestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement
Metadata
Metadata
Assignees
Labels
performancePerformance or resource usagePerformance or resource usagestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement
Fields
Give feedbackNo fields configured for issues without a type.
Feature or enhancement
Proposal
I have implemented a stack-based version of
ast.literal_evaland conducted benchmarks to compare its performance with the existing implementation. The results indicate that the stack-based version may improve performance on non-nested expressions, although it is slightly slower on nested expressions.Benchmark Results
The benchmarks were conducted on an Intel(R) Core(TM) Ultra 9 185H. Below are the results comparing
ast.literal_evalandstack_literal_eval:Question
I wonder if this change is desirable?
Code
See here.
Related Issue
This work is related to the closed issue #75934.
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response
Linked PRs