Skip to content

Commit c5b83c5

Browse files
committed
clear debugging code
1 parent 8c50284 commit c5b83c5

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

‎Objects/listobject.c‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,6 @@ maybe_small_list_freelist_push(PyObject *self)
239239
Py_ssize_t allocated = op->allocated;
240240
if (allocated < PyList_MAXSAVESIZE) {
241241
return _Py_FREELIST_PUSH(small_lists[allocated], self, Py_small_lists_MAXFREELIST);
242-
//printf("maybe_small_list_freelist_push: allocated %d (mod %d), size %d, id %p\n", (int)allocated, op->allocated, (int)PyList_Size(self), (void *)self);
243242
}
244243
return 0;
245244
}
@@ -263,13 +262,12 @@ PyList_New(Py_ssize_t size)
263262
if ( size>0) {
264263
memset(op->ob_item, 0, size * sizeof(PyObject *));
265264
}
266-
//printf("obtained list from small_lists[%d] (id %p, op->allocated %d, size %d, PyList_Size %d)\n", (int) size, op, (int)op->allocated, (int)size, (int)PyList_Size( (PyObject*)op));
267265
assert (op->allocated >= size);
268266
}
269267
//op=0;
270268
}
271269
if (op == NULL) {
272-
// do we still need this freelist? if so, we could store it at small_lists[PyList_MAXSAVESIZE-1] with some special casing
270+
// do we still need this freelist? if so, we could store it at small_lists[0] with some special casing
273271
op = _Py_FREELIST_POP(PyListObject, lists);
274272
if (op == NULL) {
275273
op = PyObject_GC_New(PyListObject, &PyList_Type);
@@ -308,6 +306,15 @@ static PyObject *
308306
list_new_prealloc(Py_ssize_t size)
309307
{
310308
assert(size > 0);
309+
if (size < PyList_MAXSAVESIZE) {
310+
PyListObject *op = (PyListObject *)_Py_FREELIST_POP(PyLongObject, small_lists[size]);
311+
if (op) {
312+
// allocated with ob_item still allocated, but we need to set the other fields
313+
assert (op->allocated >= size);
314+
return op;
315+
}
316+
}
317+
311318
PyListObject *op = (PyListObject *) PyList_New(0);
312319
if (op == NULL) {
313320
return NULL;
@@ -557,7 +564,6 @@ void small_list_freelist_free(void *obj)
557564

558565
assert(PyList_CheckExact(self));
559566
PyListObject *op = (PyListObject *)self;
560-
//printf("small_list_freelist_free: (op->allocated %d, size %d)\n", (int)op->allocated, (int)PyList_Size(self));
561567
if (op->ob_item != NULL) {
562568
free_list_items(op->ob_item, false);
563569
}

0 commit comments

Comments
 (0)