diff options
author | Raymond Hettinger <python@rcn.com> | 2007-12-18 18:26:18 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2007-12-18 18:26:18 (GMT) |
commit | effde12f5fe41bab9c27269bd77237200d953afd (patch) | |
tree | b2eeab007ae8d329366ca815e1f1b3b3072415e9 /Python/import.c | |
parent | eb103b357780ecc9395cc680ebd4f5d436bbe888 (diff) | |
download | cpython-effde12f5fe41bab9c27269bd77237200d953afd.zip cpython-effde12f5fe41bab9c27269bd77237200d953afd.tar.gz cpython-effde12f5fe41bab9c27269bd77237200d953afd.tar.bz2 |
Speed-up dictionary constructor by about 10%.
New opcode, STORE_MAP saves the compiler from awkward stack manipulations
and specializes for dicts using PyDict_SetItem instead of PyObject_SetItem.
Old disassembly:
0 BUILD_MAP 0
3 DUP_TOP
4 LOAD_CONST 1 (1)
7 ROT_TWO
8 LOAD_CONST 2 ('x')
11 STORE_SUBSCR
12 DUP_TOP
13 LOAD_CONST 3 (2)
16 ROT_TWO
17 LOAD_CONST 4 ('y')
20 STORE_SUBSCR
New disassembly:
0 BUILD_MAP 0
3 LOAD_CONST 1 (1)
6 LOAD_CONST 2 ('x')
9 STORE_MAP
10 LOAD_CONST 3 (2)
13 LOAD_CONST 4 ('y')
16 STORE_MAP
Diffstat (limited to 'Python/import.c')
-rw-r--r-- | Python/import.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Python/import.c b/Python/import.c index bf2799d..bcae9b2 100644 --- a/Python/import.c +++ b/Python/import.c @@ -66,10 +66,10 @@ extern time_t PyOS_GetLastModificationTime(char *, FILE *); Python 2.5c1: 62121 (fix wrong lnotab with for loops and storing constants that should have been removed) Python 2.5c2: 62131 (fix wrong code: for x, in ... in listcomp/genexp) - Python 2.6a0: 62141 (peephole optimizations) + Python 2.6a0: 62151 (peephole optimizations and STORE_MAP opcode) . */ -#define MAGIC (62141 | ((long)'\r'<<16) | ((long)'\n'<<24)) +#define MAGIC (62151 | ((long)'\r'<<16) | ((long)'\n'<<24)) /* Magic word as global; note that _PyImport_Init() can change the value of this global to accommodate for alterations of how the |