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.
This commit is contained in:
Raymond Hettinger 2004-02-08 18:54:37 +00:00
parent 4c9800d663
commit b32e640489
2 changed files with 2 additions and 1 deletions

View File

@ -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

View File

@ -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;