Message91506
Just like we turn BUILD_LIST; COMPARE_OP (in) into a LOAD_CONST if all
the members are consts, we can do the same for BUILD_SET, instead
turning it into a LOAD_CONST of a frozenset. The following is the
bytecode that is current produced for each datastructure.
>>> dis.dis(lambda o: o in (1,2,3))
1 0 LOAD_FAST 0 (o)
3 LOAD_CONST 3 ((1, 2, 3))
6 COMPARE_OP 6 (in)
9 RETURN_VALUE
>>> dis.dis(lambda o: o in [1,2,3])
1 0 LOAD_FAST 0 (o)
3 LOAD_CONST 3 ((1, 2, 3))
6 COMPARE_OP 6 (in)
9 RETURN_VALUE
>>> dis.dis(lambda o: o in {1,2,3})
1 0 LOAD_FAST 0 (o)
3 LOAD_CONST 0 (1)
6 LOAD_CONST 1 (2)
9 LOAD_CONST 2 (3)
12 BUILD_SET 3
15 COMPARE_OP 6 (in)
18 RETURN_VALUE |
|
Date |
User |
Action |
Args |
2009-08-12 21:32:08 | alex | set | recipients:
+ alex |
2009-08-12 21:32:08 | alex | set | messageid: <1250112728.26.0.437991636315.issue6690@psf.upfronthosting.co.za> |
2009-08-12 21:32:06 | alex | link | issue6690 messages |
2009-08-12 21:32:05 | alex | create | |
|