diff options
author | Raymond Hettinger <python@rcn.com> | 2005-02-06 22:05:42 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2005-02-06 22:05:42 (GMT) |
commit | a164574937d6ed32060ad34ea04913ca10741394 (patch) | |
tree | d9afe6c3cad9bd6b961435d6ea1e1572f8001b8c /Lib | |
parent | dbecd93b7203cd187c1978de1207c29d3a9a686c (diff) | |
download | cpython-a164574937d6ed32060ad34ea04913ca10741394.zip cpython-a164574937d6ed32060ad34ea04913ca10741394.tar.gz cpython-a164574937d6ed32060ad34ea04913ca10741394.tar.bz2 |
Transform "x in (1,2,3)" to "x in frozenset([1,2,3])".
Inspired by Skip's idea to recognize the throw-away nature of sequences
in this context and to transform their type to one with better performance.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_peepholer.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_peepholer.py b/Lib/test/test_peepholer.py index 34bd99f..bedf763 100644 --- a/Lib/test/test_peepholer.py +++ b/Lib/test/test_peepholer.py @@ -133,6 +133,16 @@ class TestTranforms(unittest.TestCase): asm = dis_single('a="x"*1000') self.assert_('(1000)' in asm) + def test_set_conversion(self): + for line in ( + 'x in (1,2,3)', + 'x not in (1,2,3)', + 'not x in (1,2,3)', + 'not x not in (1,2,3)', + ): + asm = dis_single(line) + self.assert_('frozenset' in asm) + def test_elim_extra_return(self): # RETURN LOAD_CONST None RETURN --> RETURN def f(x): |