Message22504
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 |
|
Date |
User |
Action |
Args |
2007-08-23 14:26:23 | admin | link | issue1031667 messages |
2007-08-23 14:26:23 | admin | create | |
|