Skip to content

Commit d0919f0

Browse files
authored
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.
1 parent b617993 commit d0919f0

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Python/hashtable.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,12 @@ _Py_hashtable_new_full(size_t key_size, size_t data_size,
149149
_Py_hashtable_allocator_t alloc;
150150

151151
if (allocator == NULL) {
152-
alloc.malloc = PyMem_RawMalloc;
153-
alloc.free = PyMem_RawFree;
152+
alloc.malloc = PyMem_Malloc;
153+
alloc.free = PyMem_Free;
154154
}
155-
else
155+
else {
156156
alloc = *allocator;
157+
}
157158

158159
ht = (_Py_hashtable_t *)alloc.malloc(sizeof(_Py_hashtable_t));
159160
if (ht == NULL)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy