Skip to content

Commit 2a1fe84

Browse files
rhettingerfasihahmad
authored andcommitted
bpo-40521: Remove freelist from collections.deque() (pythonGH-21073)
1 parent a63a16b commit 2a1fe84

File tree

2 files changed

+3
-21
lines changed

2 files changed

+3
-21
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Remove freelist from collections.deque().

Modules/_collectionsmodule.c

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -117,23 +117,9 @@ static PyTypeObject deque_type;
117117
#define CHECK_NOT_END(link)
118118
#endif
119119

120-
/* A simple freelisting scheme is used to minimize calls to the memory
121-
allocator. It accommodates common use cases where new blocks are being
122-
added at about the same rate as old blocks are being freed.
123-
*/
124-
125-
#define MAXFREEBLOCKS 16
126-
static Py_ssize_t numfreeblocks = 0;
127-
static block *freeblocks[MAXFREEBLOCKS];
128-
129120
static block *
130121
newblock(void) {
131-
block *b;
132-
if (numfreeblocks) {
133-
numfreeblocks--;
134-
return freeblocks[numfreeblocks];
135-
}
136-
b = PyMem_Malloc(sizeof(block));
122+
block *b = PyMem_Malloc(sizeof(block));
137123
if (b != NULL) {
138124
return b;
139125
}
@@ -144,12 +130,7 @@ newblock(void) {
144130
static void
145131
freeblock(block *b)
146132
{
147-
if (numfreeblocks < MAXFREEBLOCKS) {
148-
freeblocks[numfreeblocks] = b;
149-
numfreeblocks++;
150-
} else {
151-
PyMem_Free(b);
152-
}
133+
PyMem_Free(b);
153134
}
154135

155136
static PyObject *

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