Commit f12fd974 authored by Raymond Hettinger's avatar Raymond Hettinger

SF patch #875689: >100k alloc wasted on startup

(Contributed by Mike Pall.)

Make sure fill_free_list() is called only once rather than 106 times
when pre-allocating small ints.
parent 907d82dd
...@@ -411,6 +411,7 @@ Jason Orendorff ...@@ -411,6 +411,7 @@ Jason Orendorff
Douglas Orr Douglas Orr
Denis S. Otkidach Denis S. Otkidach
Russel Owen Russel Owen
Mike Pall
Todd R. Palmer Todd R. Palmer
Alexandre Parenteau Alexandre Parenteau
Dan Parisien Dan Parisien
......
...@@ -1064,7 +1064,7 @@ _PyInt_Init(void) ...@@ -1064,7 +1064,7 @@ _PyInt_Init(void)
int ival; int ival;
#if NSMALLNEGINTS + NSMALLPOSINTS > 0 #if NSMALLNEGINTS + NSMALLPOSINTS > 0
for (ival = -NSMALLNEGINTS; ival < NSMALLPOSINTS; ival++) { for (ival = -NSMALLNEGINTS; ival < NSMALLPOSINTS; ival++) {
if ((free_list = fill_free_list()) == NULL) if (!free_list && (free_list = fill_free_list()) == NULL)
return 0; return 0;
/* PyObject_New is inlined */ /* PyObject_New is inlined */
v = free_list; v = free_list;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment