From b32e640489f179f956437811497b19d2fa3c33f1 Mon Sep 17 00:00:00 2001
From: Raymond Hettinger <python@rcn.com>
Date: Sun, 8 Feb 2004 18:54:37 +0000
Subject: 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.
---
 Misc/ACKS           | 1 +
 Objects/intobject.c | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/Misc/ACKS b/Misc/ACKS
index 77c7980..61b07cb 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -411,6 +411,7 @@ Jason Orendorff
 Douglas Orr
 Denis S. Otkidach
 Russel Owen
+Mike Pall
 Todd R. Palmer
 Alexandre Parenteau
 Dan Parisien
diff --git a/Objects/intobject.c b/Objects/intobject.c
index 47acbff..18624b3 100644
--- a/Objects/intobject.c
+++ b/Objects/intobject.c
@@ -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;
-- 
cgit v0.12

