[Python-checkins] python/dist/src/Lib/test test_peepholer.py, 1.8,
1.9
rhettinger at users.sourceforge.net
rhettinger at users.sourceforge.net
Sun Feb 6 23:05:45 CET 2005
Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26507/Lib/test
Modified Files:
test_peepholer.py
Log Message:
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.
Index: test_peepholer.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_peepholer.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- test_peepholer.py 26 Jan 2005 12:50:05 -0000 1.8
+++ test_peepholer.py 6 Feb 2005 22:05:42 -0000 1.9
@@ -133,6 +133,16 @@
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):
More information about the Python-checkins
mailing list