cpython: Issue #23601: Use small object allocator for dict key objects
https://hg.python.org/cpython/rev/425fec4a79c7 changeset: 100129:425fec4a79c7 user: Raymond Hettinger <python@rcn.com> date: Sun Jan 31 08:56:21 2016 -0800 summary: Issue #23601: Use small object allocator for dict key objects files: Misc/NEWS | 3 +++ Objects/dictobject.c | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -18,6 +18,9 @@ by external AST optimizers, but the compiler does not emit directly such node. +- Issue #23601: Sped-up allocation of dict key objects by using Python's + small object allocator. (Contributed by Julian Taylor.) + - Issue #18018: Import raises ImportError instead of SystemError if a relative import is attempted without a known parent package. diff --git a/Objects/dictobject.c b/Objects/dictobject.c --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -324,7 +324,7 @@ assert(size >= PyDict_MINSIZE_SPLIT); assert(IS_POWER_OF_2(size)); - dk = PyMem_MALLOC(sizeof(PyDictKeysObject) + + dk = PyObject_MALLOC(sizeof(PyDictKeysObject) + sizeof(PyDictKeyEntry) * (size-1)); if (dk == NULL) { PyErr_NoMemory(); @@ -353,7 +353,7 @@ Py_XDECREF(entries[i].me_key); Py_XDECREF(entries[i].me_value); } - PyMem_FREE(keys); + PyObject_FREE(keys); } #define new_values(size) PyMem_NEW(PyObject *, size) @@ -964,7 +964,7 @@ } } assert(oldkeys->dk_refcnt == 1); - DK_DEBUG_DECREF PyMem_FREE(oldkeys); + DK_DEBUG_DECREF PyObject_FREE(oldkeys); } return 0; } -- Repository URL: https://hg.python.org/cpython
participants (1)
-
raymond.hettinger