[New-bugs-announce] [issue2197] Further simplify dict literal bytecode

Alexander Belopolsky report at bugs.python.org
Wed Feb 27 05:42:38 CET 2008


New submission from Alexander Belopolsky:

I am attaching a proof-of-concept patch that changes the bytecode 
generated from {1:1,2:2,3:3,4:4} from 

BUILD_MAP                4  
LOAD_CONST               2 (1)  
LOAD_CONST               2 (1)  
STORE_MAP             
LOAD_CONST               1 (2)  
LOAD_CONST               1 (2)  
STORE_MAP             
LOAD_CONST               4 (3)  
LOAD_CONST               4 (3)  
STORE_MAP             
LOAD_CONST               3 (4)  
LOAD_CONST               3 (4)  
STORE_MAP             

to

LOAD_CONST               1 (4)  
LOAD_CONST               1 (4)  
LOAD_CONST               2 (3)   
LOAD_CONST               2 (3)                                                    
LOAD_CONST               3 (2)                                        
LOAD_CONST               3 (2)                                         
LOAD_CONST               4 (1)  
LOAD_CONST               4 (1)  
BUILD_MAP                4  
 
and changes BUILD_MAP to behave similarly to BUILD_(SET|LIST|TUPLE) and 
consume 2*n items from the stack.

The advantage is more compact and faster bytecode and uniform treatment 
of BUILD_* instructions.

----------
components: Interpreter Core
files: dict-literal.diff
keywords: patch
messages: 63063
nosy: belopolsky
severity: normal
status: open
title: Further simplify dict literal bytecode
versions: Python 3.0
Added file: http://bugs.python.org/file9564/dict-literal.diff

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue2197>
__________________________________


More information about the New-bugs-announce mailing list