This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author rhettinger
Recipients
Date 2004-09-21.04:23:02
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
Folds tuples of constants into a single constant. 
Results in beautiful, fast bytecode:


>>> from dis import dis
>>> def f():
	for x in ('a', 'b', 'c'):
	    if x in (1, 2):
		return False
	return True

>>> dis(f)
  2           0 SETUP_LOOP              35 (to 38)
              3 LOAD_CONST               6 (('a', 'b',
'c'))
              6 GET_ITER            
        >>    7 FOR_ITER                27 (to 37)
             10 STORE_FAST               0 (x)

  3          13 LOAD_FAST                0 (x)
             16 LOAD_CONST               7 ((1, 2))
             19 COMPARE_OP               6 (in)
             22 JUMP_IF_FALSE            8 (to 33)
             25 POP_TOP             

  4          26 LOAD_GLOBAL              1 (False)
             29 RETURN_VALUE        
             30 JUMP_ABSOLUTE            7
        >>   33 POP_TOP             
             34 JUMP_ABSOLUTE            7
        >>   37 POP_BLOCK           

  5     >>   38 LOAD_GLOBAL              2 (True)
             41 RETURN_VALUE
History
Date User Action Args
2007-08-23 14:26:23adminlinkissue1031667 messages
2007-08-23 14:26:23admincreate