Building argument lists and dicts in python entails the following opcode pattern:
1 0 BUILD_MAP 3 3 LOAD_CONST 0 (2) 6 LOAD_CONST 1 (1) 9 STORE_MAP 10 LOAD_CONST 2 (4) 13 LOAD_CONST 3 (3) 16 STORE_MAP 17 LOAD_CONST 4 (6) 20 LOAD_CONST 5 (5) 23 STORE_MAP Building lists on the other hand works like this: 1 0 LOAD_CONST 0 (1) 3 LOAD_CONST 1 (2) 6 LOAD_CONST 2 (3) 9 BUILD_LIST 3 Why not have BUILD_MAP work like BUILD_LIST? I.e., STORE_MAP takes a parameter n and adds the last n pairs of stack elements into the n-1 stack element (the dictionary). This means that the data would live on the stack until it is all suddenly transferred to the dict, but I'm not sure about the effect on performance (whether positive or negative). It does save on instruction cache misses. It should be an easy change to implement since all calls to BUILD_MAP could be replaced with "BUILD_MAP 1" and then optimized later. Best, Neil
_______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com