diff options
author | Raymond Hettinger <python@rcn.com> | 2007-12-18 21:24:09 +0000 |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2007-12-18 21:24:09 +0000 |
commit | fd7ed407d79b797e20d0a6fe69e18f9ba9354979 (patch) | |
tree | 3dc9abccf69e49db5c98aa0805dcbaab50fc90c3 /Include/dictobject.h | |
parent | 3c887b2802e1b44b7e33cd14329541d0d22769d7 (diff) | |
download | cpython-git-fd7ed407d79b797e20d0a6fe69e18f9ba9354979.tar.gz |
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 'Include/dictobject.h')
-rw-r--r-- | Include/dictobject.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/Include/dictobject.h b/Include/dictobject.h index fec62958fe..c5378cf2dd 100644 --- a/Include/dictobject.h +++ b/Include/dictobject.h @@ -110,6 +110,7 @@ PyAPI_FUNC(Py_ssize_t) PyDict_Size(PyObject *mp); PyAPI_FUNC(PyObject *) PyDict_Copy(PyObject *mp); PyAPI_FUNC(int) PyDict_Contains(PyObject *mp, PyObject *key); PyAPI_FUNC(int) _PyDict_Contains(PyObject *mp, PyObject *key, long hash); +PyAPI_FUNC(PyObject *) _PyDict_NewPresized(Py_ssize_t minused); /* PyDict_Update(mp, other) is equivalent to PyDict_Merge(mp, other, 1). */ PyAPI_FUNC(int) PyDict_Update(PyObject *mp, PyObject *other); |