diff options
author | Raymond Hettinger <python@rcn.com> | 2007-12-18 21:24:09 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2007-12-18 21:24:09 (GMT) |
commit | fd7ed407d79b797e20d0a6fe69e18f9ba9354979 (patch) | |
tree | 3dc9abccf69e49db5c98aa0805dcbaab50fc90c3 /Lib/opcode.py | |
parent | 3c887b2802e1b44b7e33cd14329541d0d22769d7 (diff) | |
download | cpython-fd7ed407d79b797e20d0a6fe69e18f9ba9354979.zip cpython-fd7ed407d79b797e20d0a6fe69e18f9ba9354979.tar.gz cpython-fd7ed407d79b797e20d0a6fe69e18f9ba9354979.tar.bz2 |
Give meaning to the oparg for BUILD_MAP: estimated size of the dictionary.
Allows dictionaries to be pre-sized (upto 255 elements) saving time lost
to re-sizes with their attendant mallocs and re-insertions.
Has zero effect on small dictionaries (5 elements or fewer), a slight
benefit for dicts upto 22 elements (because they had to resize once
anyway), and more benefit for dicts upto 255 elements (saving multiple
resizes during the build-up and reducing the number of collisions on
the first insertions). Beyond 255 elements, there is no addional benefit.
Diffstat (limited to 'Lib/opcode.py')
-rw-r--r-- | Lib/opcode.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Lib/opcode.py b/Lib/opcode.py index c3457d0..cee5057 100644 --- a/Lib/opcode.py +++ b/Lib/opcode.py @@ -139,7 +139,7 @@ hasconst.append(100) name_op('LOAD_NAME', 101) # Index in name list def_op('BUILD_TUPLE', 102) # Number of tuple items def_op('BUILD_LIST', 103) # Number of list items -def_op('BUILD_MAP', 104) # Always zero for now +def_op('BUILD_MAP', 104) # Number of dict entries (upto 255) name_op('LOAD_ATTR', 105) # Index in name list def_op('COMPARE_OP', 106) # Comparison operator hascompare.append(106) |