Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b32e640

Browse files
committed
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.
1 parent 4c9800d commit b32e640

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@ Jason Orendorff
411411
Douglas Orr
412412
Denis S. Otkidach
413413
Russel Owen
414+
Mike Pall
414415
Todd R. Palmer
415416
Alexandre Parenteau
416417
Dan Parisien

Objects/intobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1064,7 +1064,7 @@ _PyInt_Init(void)
10641064
int ival;
10651065
#if NSMALLNEGINTS + NSMALLPOSINTS > 0
10661066
for (ival = -NSMALLNEGINTS; ival < NSMALLPOSINTS; ival++) {
1067-
if ((free_list = fill_free_list()) == NULL)
1067+
if (!free_list && (free_list = fill_free_list()) == NULL)
10681068
return 0;
10691069
/* PyObject_New is inlined */
10701070
v = free_list;

0 commit comments

Comments
 (0)