[Python-checkins] python/dist/src/Objects frameobject.c,2.59.6.3,2.59.6.4

gvanrossum@users.sourceforge.net gvanrossum@users.sourceforge.net
Thu, 01 Aug 2002 12:05:10 -0700


Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv9581/Objects

Modified Files:
      Tag: release22-maint
	frameobject.c 
Log Message:
Backport:

Tim found that once test_longexp has run, test_sort takes very much
longer to run than normal.  A profiler run showed that this was due to
PyFrame_New() taking up an unreasonable amount of time.  A little
thinking showed that this was due to the while loop clearing the space
available for the stack.  The solution is to only clear the local
variables (and cells and free variables), not the space available for
the stack, since anything beyond the stack top is considered to be
garbage anyway.  Also, use memset() instead of a while loop counting
backwards.  This should be a time savings for normal code too!  (By a
probably unmeasurable amount. :-)


Index: frameobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/frameobject.c,v
retrieving revision 2.59.6.3
retrieving revision 2.59.6.4
diff -C2 -d -r2.59.6.3 -r2.59.6.4
*** frameobject.c	20 Apr 2002 05:07:05 -0000	2.59.6.3
--- frameobject.c	1 Aug 2002 19:05:07 -0000	2.59.6.4
***************
*** 266,271 ****
  				return NULL;
  		}
- 		else
- 			extras = f->ob_size;
  		_Py_NewReference((PyObject *)f);
  	}
--- 266,269 ----
***************
*** 318,325 ****
  	f->f_nfreevars = nfrees;
  
! 	while (--extras >= 0)
! 		f->f_localsplus[extras] = NULL;
  
! 	f->f_valuestack = f->f_localsplus + (f->f_nlocals + ncells + nfrees);
  	f->f_stacktop = f->f_valuestack;
  	_PyObject_GC_TRACK(f);
--- 316,323 ----
  	f->f_nfreevars = nfrees;
  
! 	extras = f->f_nlocals + ncells + nfrees;
! 	memset(f->f_localsplus, 0, extras * sizeof(f->f_localsplus[0]));
  
! 	f->f_valuestack = f->f_localsplus + extras;
  	f->f_stacktop = f->f_valuestack;
  	_PyObject_GC_TRACK(f);