diff options
author | Victor Stinner <vstinner@python.org> | 2020-05-12 01:07:40 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-12 01:07:40 (GMT) |
commit | d0919f0d6bb757b6bcfd7b2e15656d318c9d5cd9 (patch) | |
tree | 86586376ea6ad9d475d4e52c881cdafe808d1bbb | |
parent | b617993b7c0b0f6f679ef7003a62d0318b6d6af9 (diff) | |
download | cpython-d0919f0d6bb757b6bcfd7b2e15656d318c9d5cd9.zip cpython-d0919f0d6bb757b6bcfd7b2e15656d318c9d5cd9.tar.gz cpython-d0919f0d6bb757b6bcfd7b2e15656d318c9d5cd9.tar.bz2 |
bpo-40602: _Py_hashtable_new() uses PyMem_Malloc() (GH-20046)
_Py_hashtable_new() now uses PyMem_Malloc/PyMem_Free allocator by
default, rather than PyMem_RawMalloc/PyMem_RawFree.
PyMem_Malloc is faster than PyMem_RawMalloc for memory blocks smaller
than or equal to 512 bytes.
-rw-r--r-- | Python/hashtable.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Python/hashtable.c b/Python/hashtable.c index 22b8459..e9f02d8 100644 --- a/Python/hashtable.c +++ b/Python/hashtable.c @@ -149,11 +149,12 @@ _Py_hashtable_new_full(size_t key_size, size_t data_size, _Py_hashtable_allocator_t alloc; if (allocator == NULL) { - alloc.malloc = PyMem_RawMalloc; - alloc.free = PyMem_RawFree; + alloc.malloc = PyMem_Malloc; + alloc.free = PyMem_Free; } - else + else { alloc = *allocator; + } ht = (_Py_hashtable_t *)alloc.malloc(sizeof(_Py_hashtable_t)); if (ht == NULL) |