]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
Give meaning to the oparg for BUILD_MAP: estimated size of the dictionary.
authorRaymond Hettinger <python@rcn.com>
Tue, 18 Dec 2007 21:24:09 +0000 (21:24 +0000)
committerRaymond Hettinger <python@rcn.com>
Tue, 18 Dec 2007 21:24:09 +0000 (21:24 +0000)
commitfd7ed407d79b797e20d0a6fe69e18f9ba9354979
tree3dc9abccf69e49db5c98aa0805dcbaab50fc90c3
parent3c887b2802e1b44b7e33cd14329541d0d22769d7
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.
Include/dictobject.h
Lib/opcode.py
Misc/NEWS
Objects/dictobject.c
Python/ceval.c
Python/compile.c