Message128825
| Author |
pitrou |
| Recipients |
jdharper, mark.dickinson, pitrou, r.david.murray, rhettinger |
| Date |
2011年02月18日.23:09:23 |
| SpamBayes Score |
0.006986367 |
| Marked as misclassified |
No |
| Message-id |
<1298070565.25.0.371901806068.issue11244@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
Here is a patch that enables advanced (recursive) constant folding.
Example:
python -c "import dis; f=lambda x: x in {(3*-5)+(-1-6),(1,-2,3)*2,None};dis.dis(f)"
With 3.1:
1 0 LOAD_FAST 0 (x)
3 LOAD_CONST 7 (-15)
6 LOAD_CONST 8 (-7)
9 BINARY_ADD
10 LOAD_CONST 10 ((1, -2, 3, 1, -2, 3))
13 LOAD_CONST 11 (None)
16 BUILD_SET 3
19 COMPARE_OP 6 (in)
22 RETURN_VALUE
With 3.2+patch:
1 0 LOAD_FAST 0 (x)
3 LOAD_CONST 14 (frozenset({None, -22, (1, -2, 3, 1, -2, 3)}))
6 COMPARE_OP 6 (in)
9 RETURN_VALUE |
|