From: Raymond Hettinger Date: Sun, 8 Feb 2004 18:56:07 +0000 (+0000) Subject: SF patch #875689: >100k alloc wasted on startup X-Git-Tag: v2.3.4c1~139 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d6ea07f9ac034305149da3d987fa0b6be9a7c6f3;p=thirdparty%2FPython%2Fcpython.git 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. --- diff --git a/Objects/intobject.c b/Objects/intobject.c index a3df3bab61f5..8a27bfe4d597 100644 --- a/Objects/intobject.c +++ b/Objects/intobject.c @@ -1080,7 +1080,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;