[Python-checkins] peps: PEP 511: add list of AST optimizer issues
victor.stinner
python-checkins at python.org
Thu Jan 14 20:14:52 EST 2016
https://hg.python.org/peps/rev/2eef070a4602
changeset: 6186:2eef070a4602
user: Victor Stinner <victor.stinner at gmail.com>
date: Fri Jan 15 02:14:44 2016 +0100
summary:
PEP 511: add list of AST optimizer issues
files:
pep-0511.txt | 35 ++++++++++++++++++++++++++++++-----
1 files changed, 30 insertions(+), 5 deletions(-)
diff --git a/pep-0511.txt b/pep-0511.txt
--- a/pep-0511.txt
+++ b/pep-0511.txt
@@ -34,6 +34,8 @@
``importlib.abc.SourceLoader``. But code transformation is wider than just
importing modules, see described use cases below.
+Writing an optimizer or a preprocessor is out of the scope of this PEP.
+
Usage 1: AST optimizer
----------------------
@@ -58,18 +60,41 @@
* `Dead code elimination
<https://en.wikipedia.org/wiki/Dead_code_elimination>`_
-Using guards (see the PEP 510), it is possible to implement a much wider choice
-of optimizations. Examples:
+Using guards (see the `PEP 510
+<https://www.python.org/dev/peps/pep-0510/>`_), it is possible to
+implement a much wider choice of optimizations. Examples:
* Simplify iterable: replace ``range(3)`` with ``(0, 1, 2)`` when used
as iterable
* `Loop unrolling <https://en.wikipedia.org/wiki/Loop_unrolling>`_
* Call pure builtins: replace ``len("abc")`` with ``3``
* Copy used builtin symbols to constants
+* See also `optimizations implemented in fatoptimizer
+ <https://fatoptimizer.readthedocs.org/en/latest/optimizations.html>`_,
+ a static optimizer for Python 3.6.
-See also `optimizations implemented in fatoptimizer
-<https://fatoptimizer.readthedocs.org/en/latest/optimizations.html>`_, a
-static optimizer for Python 3.6.
+The following issues can be implemented with an AST optimizer:
+
+* `Issue #1346238
+ <https://bugs.python.org/issue1346238>`_: A constant folding
+ optimization pass for the AST
+* `Issue #2181 <http://bugs.python.org/issue2181>`_:
+ optimize out local variables at end of function
+* `Issue #2499 <http://bugs.python.org/issue2499>`_:
+ Fold unary + and not on constants
+* `Issue #4264 <http://bugs.python.org/issue4264>`_:
+ Patch: optimize code to use LIST_APPEND instead of calling list.append
+* `Issue #7682 <http://bugs.python.org/issue7682>`_:
+ Optimisation of if with constant expression
+* `Issue #10399 <https://bugs.python.org/issue10399>`_: AST
+ Optimization: inlining of function calls
+* `Issue #11549 <http://bugs.python.org/issue11549>`_:
+ Build-out an AST optimizer, moving some functionality out of the
+ peephole optimizer
+* `Issue #17068 <http://bugs.python.org/issue17068>`_:
+ peephole optimization for constant strings
+* `Issue #17430 <http://bugs.python.org/issue17430>`_:
+ missed peephole optimization
Usage 2: Preprocessor
--
Repository URL: https://hg.python.org/peps
More information about the Python-checkins
mailing list