]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-124503: Optimize ast.literal_eval() for small input (GH-137010)
authorKrzysztof Magusiak <chris.magusiak@gmail.com>
Thu, 31 Jul 2025 09:55:00 +0000 (11:55 +0200)
committerGitHub <noreply@github.com>
Thu, 31 Jul 2025 09:55:00 +0000 (12:55 +0300)
commitb723c8be071afcf3f865c55a5efb6da54f7695a0
tree055c1a71ebd8a26d36f9709d293f8dc12f300c57
parentd5191ba99b8f7723cbdb9b7a07ef8a3eef6524c1
gh-124503: Optimize ast.literal_eval() for small input (GH-137010)

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.
Lib/ast.py
Misc/NEWS.d/next/Library/2025-07-30-11-12-22.gh-issue-124503.d4hc7b.rst [new file with mode: 0644]