1. Victor Stinner
  2. astoptimizer

Commits

Victor Stinner  committed 7a10922

TODO

  • Participants
  • Parent commits 0604106
  • Branches default

Comments (0)

Files changed (1)

File TODO

View file
  • Ignore whitespace
 
 other:
 
+ - SetComp, DictComp:
+
+   * {x for x in "abc"} => {"a", "b", "c"}
+   * {x for x in a} => set(a)
+   * {x: y for x, y in a} => dict(a)
+
+ - operator module:
+
+   * lambda x: x[1] => operator.itemgetter(1)
+   * lambda x: x.a => operator.attrgetter('a')
+   * lambda x: x.f('a', b=1) => operator.methodcaller('f', 'a', b=1)
+
  - Python 3.2+: x in (1, 2, 3) => x in {1, 2, 3}, set converted to frozenset
    by the peepholer
  - {1,2}|{3} => {1, 2, 3}
  - Python 2: from __future__ import divison
  - [x*2 for x in range(3)]
- - [f(x) for x in a] => map(f, a) / list(map(f, a))
- - (f(x) for x in a) => itertools.map(f, a) / map(f, a) ? scope ?
+ - map, itertools.map, filter:
+
+   * [f(x) for x in a] => map(f, a) / list(map(f, a))
+   * (f(x) for x in a) => itertools.map(f, a) / map(f, a) ? scope ?
+   * (x for x in a if f(x)) => filter(f, a)
+   * (x for x in a if not f(x)) => __builtin_filternot__(f, a) ?
+   * (2 * x for x in a) => map((2).__mul__, a)
+   * (x for x in a if x in 'abc') => filter('abc'.__contains__, a)
+
  - enable pythonbin by default?
  - not not not x
  - 1 < 2 < 3