]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
SF patch #875689: >100k alloc wasted on startup
authorRaymond Hettinger <python@rcn.com>
Sun, 8 Feb 2004 18:56:07 +0000 (18:56 +0000)
committerRaymond Hettinger <python@rcn.com>
Sun, 8 Feb 2004 18:56:07 +0000 (18:56 +0000)
(Contributed by Mike Pall.)

Make sure fill_free_list() is called only once rather than 106 times
when pre-allocating small ints.

Objects/intobject.c

index a3df3bab61f5a288b44e59c996d6bcdac801e464..8a27bfe4d597c8627ddeb21875e71b111a965780 100644 (file)
@@ -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;