1. Victor Stinner
  2. astoptimizer

Commits

Victor Stinner  committed abaaebd

TODO list

  • Participants
  • Parent commits 6630cc9
  • Branches default

Comments (0)

Files changed (1)

File TODO

View file
  • Ignore whitespace
-TODO
++++++++++
+TODO list
++++++++++
+
+Bugs
 ====
 
-bugs:
-
  - "i=0; while i < 10: print(i); i = i + 1": don't replace print(i) with print('0')
  - "for x in (): try: pass finally: continue" must raise a SyntaxError
  - "type(iter([]))"
 
-major optimizations:
+
+Major Optimizations
+===================
 
  - move invariant out of the loop. Need type inference.
 
    * "x=[0]; for ...: x.append(...)"
      => "x=[0]; x_append=x.append; for ...: x_append(...)"
 
+ - unroll short loops: "for x in range(4): print(x)"
+
+   * duplicate the body and evaluate the body with x=0, x=1, ...
+   * handle continue/break
+   * drop x if possible
+   * "[x*2 for x in range(3)]" => "[0, 2, 4]"
+
+ - convert naive loop to list comprehension: "x=[]; for item in data: x.append(item.upper())"
+   => "x=[item.upper() for item in data]". Same for x=set() and x={}.
+
+ - inline functions: see http://bugs.python.org/issue10399
+
+
+Support variables
+=================
+
  - constant folding:
 
    * "x=1; print(x)" => "print('1')" (drop x)
      a) scan function arguments, variables and builtins; detect usage of globals()
      b) replace constants, remove unused variables, peephole, call builtin functions
 
- - unroll short loops: "for x in range(4): print(x)"
 
-   * duplicate the body and evaluate the body with x=0, x=1, ...
-   * handle continue/break
-   * drop x if possible
-
- - convert naive loop to list comprehension: "x=[]; for item in data: x.append(item.upper())"
-   => "x=[item.upper() for item in data]". Same for x=set() and x={}.
-
- - inline functions: see http://bugs.python.org/issue10399
-
-other:
+Other
+=====
 
  - enable pythonbin by default?
  - disable string and math by default?
  - Python 3.2+: x in (1, 2, 3) => x in {1, 2, 3}, set converted to frozenset
    by the peepholer
  - Python 2: from __future__ import divison
- - [x*2 for x in range(3)]
  - map, itertools.map, filter:
 
    * [f(x) for x in a] => map(f, a) / list(map(f, a))
  - write tests for patch_compile(), ex: ast.literal_ast("1+(2+3j)")
  - (x * 2) * 3 => x * 6, "fast-math" option?
 
-later:
+
+Later
+=====
 
  - infer type: