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
Douglas Orr
Denis S. Otkidach
Russel Owen
Mike Pall
Todd R. Palmer
Alexandre Parenteau
Dan Parisien
......
......@@ -1064,7 +1064,7 @@ _PyInt_Init(void)
int ival;
#if NSMALLNEGINTS + NSMALLPOSINTS > 0
for (ival = -NSMALLNEGINTS; ival < NSMALLPOSINTS; ival++) {
if ((free_list = fill_free_list()) == NULL)
if (!free_list && (free_list = fill_free_list()) == NULL)
return 0;
/* PyObject_New is inlined */
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