[Python-checkins] python/dist/src/Objects frameobject.c,2.62,2.63

gvanrossum@users.sourceforge.net gvanrossum@users.sourceforge.net
2002年8月01日 11:50:35 -0700


Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv3353
Modified Files:
	frameobject.c 
Log Message:
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.62
retrieving revision 2.63
diff -C2 -d -r2.62 -r2.63
*** frameobject.c	20 Apr 2002 04:46:55 -0000	2.62
--- frameobject.c	1 Aug 2002 18:50:33 -0000	2.63
***************
*** 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);

AltStyle によって変換されたページ (->オリジナル) /