[Python-checkins] CVS: python/dist/src/Python compile.c,2.103,2.104

Guido van Rossum python-dev@python.org
Mon, 10 Apr 2000 12:20:35 -0400 (EDT)


Update of /projects/cvsroot/python/dist/src/Python
In directory eric:/projects/python/develop/guido/src/Python

Modified Files:
	compile.c 
Log Message:
Patch by Vladimir Marangozov to include the function name when
comparing code objects.  This give sless surprising results in
-Optimized code.  It also sorts code objects by name, now.

[I changed the patch to hash() slightly to touch fewer lines.]


Index: compile.c
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Python/compile.c,v
retrieving revision 2.103
retrieving revision 2.104
diff -C2 -r2.103 -r2.104
*** compile.c	2000/04/07 01:21:36	2.103
--- compile.c	2000/04/10 16:20:31	2.104
***************
*** 141,144 ****
--- 141,146 ----
  {
  	int cmp;
+ 	cmp = PyObject_Compare(co->co_name, cp->co_name);
+ 	if (cmp) return cmp;
  	cmp = co->co_argcount - cp->co_argcount;
  	if (cmp) return cmp;
***************
*** 161,165 ****
  	PyCodeObject *co;
  {
! 	long h, h1, h2, h3, h4;
  	h1 = PyObject_Hash(co->co_code);
  	if (h1 == -1) return -1;
--- 163,169 ----
  	PyCodeObject *co;
  {
! 	long h, h0, h1, h2, h3, h4;
! 	h0 = PyObject_Hash(co->co_name);
! 	if (h0 == -1) return -1;
  	h1 = PyObject_Hash(co->co_code);
  	if (h1 == -1) return -1;
***************
*** 170,174 ****
  	h4 = PyObject_Hash(co->co_varnames);
  	if (h4 == -1) return -1;
! 	h = h1 ^ h2 ^ h3 ^ h4 ^
  		co->co_argcount ^ co->co_nlocals ^ co->co_flags;
  	if (h == -1) h = -2;
--- 174,178 ----
  	h4 = PyObject_Hash(co->co_varnames);
  	if (h4 == -1) return -1;
! 	h = h0 ^ h1 ^ h2 ^ h3 ^ h4 ^
  		co->co_argcount ^ co->co_nlocals ^ co->co_flags;
  	if (h == -1) h = -2;