Mercurial > cpython-lru_cache-weakref
diff Lib/opcode.py @ 44339:7ac117b3be37 legacy-trunk
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.
| author | Raymond Hettinger <python@rcn.com> |
|---|---|
| date | Tue, 18 Dec 2007 21:24:09 +0000 |
| parents | 07aa19170a67 |
| children | 94e79d78dff0 |
line wrap: on
line diff
--- a/Lib/opcode.py Tue Dec 18 20:10:42 2007 +0000 +++ b/Lib/opcode.py Tue Dec 18 21:24:09 2007 +0000 @@ -139,7 +139,7 @@ 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)
