diff options
author | Moshe Zadka <moshez@math.huji.ac.il> | 2001-01-29 06:21:17 (GMT) |
---|---|---|
committer | Moshe Zadka <moshez@math.huji.ac.il> | 2001-01-29 06:21:17 (GMT) |
commit | 497671e094b7f18221cc1f872bfe68afc57c860b (patch) | |
tree | 82c5fb1c0b85a8670c71c9146ee9c5b34c08a43e /Objects | |
parent | 2beeb22533acf5fbc29e650003a79d633aecffc0 (diff) | |
download | cpython-497671e094b7f18221cc1f872bfe68afc57c860b.zip cpython-497671e094b7f18221cc1f872bfe68afc57c860b.tar.gz cpython-497671e094b7f18221cc1f872bfe68afc57c860b.tar.bz2 |
The one thing I love more then writing code is deleting code.
* Removed func_hash and func_compare, so they can be treated as immutable
content-less objects (address hash and comparison)
* Added tests to that affect to test_funcattrs (also testing func_code
is writable)
* Reverse meaning of tests in test_opcodes which checked identical code
gets identical functions
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/funcobject.c | 35 |
1 files changed, 2 insertions, 33 deletions
diff --git a/Objects/funcobject.c b/Objects/funcobject.c index b7e25aa..b166d60 100644 --- a/Objects/funcobject.c +++ b/Objects/funcobject.c @@ -270,37 +270,6 @@ func_repr(PyFunctionObject *op) } static int -func_compare(PyFunctionObject *f, PyFunctionObject *g) -{ - int c; - if (f->func_globals != g->func_globals) - return (f->func_globals < g->func_globals) ? -1 : 1; - if (f->func_defaults != g->func_defaults) { - if (f->func_defaults == NULL) - return -1; - if (g->func_defaults == NULL) - return 1; - c = PyObject_Compare(f->func_defaults, g->func_defaults); - if (c != 0) - return c; - } - return PyObject_Compare(f->func_code, g->func_code); -} - -static long -func_hash(PyFunctionObject *f) -{ - long h,x; - h = PyObject_Hash(f->func_code); - if (h == -1) return h; - x = _Py_HashPointer(f->func_globals); - if (x == -1) return x; - h ^= x; - if (h == -1) h = -2; - return h; -} - -static int func_traverse(PyFunctionObject *f, visitproc visit, void *arg) { int err; @@ -347,12 +316,12 @@ PyTypeObject PyFunction_Type = { 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ - (cmpfunc)func_compare, /*tp_compare*/ + 0, /*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_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ (getattrofunc)func_getattro, /*tp_getattro*/ |