-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
gh-124503: simplified ast.literal_eval #137010
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. 👍
Is there anything that needs to be done to merge this PR? |
I think that it it is worth to add a small NEWS entry. |
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
The implementation does not create anymore local functions which reduces the overhead for small inputs. Some other calls are inlined into a single `_convert_literal` function. We have a gain of 10-20% for small inputs and only 1-2% for bigger inputs.
Done |
@@ -0,0 +1 @@ | |||
:func:`ast.literal_eval` simplified to avoid local functions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an implementation detail. Write something that is interesting to the user -- how much the function has become faster for small input.
Also, please do not use force push -- it forces us to review already reviewed code again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
The implementation does not create anymore local functions which reduces the overhead for small inputs. Some other calls are inlined into a single
_convert_literal
function.We have a gain of 10-20% for small inputs and only 1-2% for bigger inputs.
ast.literal_eval
Implementation #124503