[Python-Dev] Re: Speed of test_sort.py

Guido van Rossum guido@python.org
Thu, 01 Aug 2002 14:38:17 -0400


> Suggestion: doesn't test_longexp create some frames with a very large
> number of local variables?  Then PyFrame_New could spend a lot of time
> in this loop:
> 
> 	while (--extras >= 0)
> 		f->f_localsplus[extras] = NULL;
> 
> There's a free list of frames, and PyFrame_New picks the first frame
> on the free list.  It grows the space for locals if necessary, but it
> never shrinks it.

Jeremy made me think about it some more.  Deleting two lines from
PyFrame_New() made the timing behavior much more reasonable:

*** frameobject.c	20 Apr 2002 04:46:55 -0000	2.62
--- frameobject.c	1 Aug 2002 18:32:40 -0000
***************
*** 265,272 ****
  			if (f == NULL)
  				return NULL;
  		}
- 		else
- 			extras = f->ob_size;
  		_Py_NewReference((PyObject *)f);
  	}
  	if (builtins == NULL) {
--- 265,270 ----

This means that the while loop only clears that part of the stack that
we plan to *use*, not all that's available.  I've run the whole test
suite in debug mode with this change and it showed no failures, so I'll
check this in now.

Should we fix this in 2.2.2 too?

--Guido van Rossum (home page: http://www.python.org/~guido/)