Commits

Victor Stinner committed ebb0cfd

type inference is cool

Comments (0)

Files changed (1)

 
 later:
 
+ - infer type:
+
+   * int: "x=1; for i in range(n): x = x + 1; return x * 1" => "...; return x"
+   * str: "x="abc"; for i in range(n): x = x + "x"; return str(x)" => "...; return x"
+   * file: "f=open(...); for line in data: f.write(line)"
+     => "...; f_write = f.write; for line in data: f_write(line)"
+   * etc.
+
  - use enumerate():
 
    * for i in range(len(a)): x = a[i] ... => for i, x in enumerate(a): ...