[Python-Dev] Function Hash: Check it in?

Moshe Zadka moshez@zadka.site.co.il
2001年1月27日 21:14:28 +0200 (IST)


Attached is an example Python session after I patched the intepreter.
The test-suite passes all right.
I want an OK to check this in.
Here is the patch:
Index: Objects/funcobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/funcobject.c,v
retrieving revision 2.33
diff -c -r2.33 funcobject.c
*** Objects/funcobject.c 2001年01月25日 20:06:59 2.33
--- Objects/funcobject.c 2001年01月27日 19:13:08
***************
*** 347,358 ****
 0, /*tp_print*/
 0, /*tp_getattr*/
 0, /*tp_setattr*/
! (cmpfunc)func_compare, /*tp_compare*/
 (reprfunc)func_repr, /*tp_repr*/
 0, /*tp_as_number*/
 0, /*tp_as_sequence*/
 0, /*tp_as_mapping*/
! (hashfunc)func_hash, /*tp_hash*/
 0, /*tp_call*/
 0, /*tp_str*/
 (getattrofunc)func_getattro, /*tp_getattro*/
--- 347,358 ----
 0, /*tp_print*/
 0, /*tp_getattr*/
 0, /*tp_setattr*/
! 0, /*tp_compare*/
 (reprfunc)func_repr, /*tp_repr*/
 0, /*tp_as_number*/
 0, /*tp_as_sequence*/
 0, /*tp_as_mapping*/
! 0, /*tp_hash*/
 0, /*tp_call*/
 0, /*tp_str*/
 (getattrofunc)func_getattro, /*tp_getattro*/
Python 2.1a1 (#1, Jan 27 2001, 21:01:24)
[GCC 2.95.3 20010111 (prerelease)] on linux2
Type "copyright", "credits" or "license" for more information.
>>> def foo():
... pass
...
>>> def bar():
... pass
...
>>> hash(foo)
135484636
>>> hash(bar)
135481676
>>> foo == bar
0
>>> d = {}
>>> d[foo] =1
>>> def temp():
... print "baz"
...
>>> foo.func_code = temp.func_code
>>> d[foo]
1
-- 
Moshe Zadka <sig@zadka.site.co.il>
This is a signature anti-virus. 
Please stop the spread of signature viruses!
Fingerprint: 4BD1 7705 EEC0 260A 7F21 4817 C7FC A636 46D0 1BD6

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