]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-132732: Automatically constant evaluate pure operations (GH-132733)
authorKen Jin <kenjin@python.org>
Fri, 27 Jun 2025 11:37:44 +0000 (19:37 +0800)
committerGitHub <noreply@github.com>
Fri, 27 Jun 2025 11:37:44 +0000 (19:37 +0800)
commit695ab61351c019a7fcd731eebd77c172c90bf9e0
tree7e8929882dc98efe7acb37e685adc73bcbdc5c9d
parentc45f4f3ebe34529a8db3a7918e8dd2e9f7ce8e86
gh-132732: Automatically constant evaluate pure operations (GH-132733)

This adds a "macro" to the optimizer DSL called "REPLACE_OPCODE_IF_EVALUATES_PURE", which allows automatically constant evaluating a bytecode body if certain inputs have no side effects upon evaluations (such as ints, strings, and floats).

Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
Include/internal/pycore_optimizer.h
Include/internal/pycore_uop_metadata.h
Lib/test/test_generated_cases.py
Misc/NEWS.d/next/Core_and_Builtins/2025-04-19-16-22-47.gh-issue-132732.jgqhlF.rst [new file with mode: 0644]
Python/bytecodes.c
Python/optimizer_analysis.c
Python/optimizer_bytecodes.c
Python/optimizer_cases.c.h
Python/optimizer_symbols.c
Tools/cases_generator/optimizer_generator.py