* Changed all copyright messages to include 1993.
* Stubs for faster implementation of local variables (not yet finished)
* Added function name to code object. Print it for code and function
objects. THIS MAKES THE .PYC FILE FORMAT INCOMPATIBLE (the version
number has changed accordingly)
* Print address of self for built-in methods
* New internal functions getattro and setattro (getattr/setattr with
string object arg)
* Replaced "dictobject" with more powerful "mappingobject"
* New per-type functio tp_hash to implement arbitrary object hashing,
and hashobject() to interface to it
* Added built-in functions hash(v) and hasattr(v, 'name')
* classobject: made some functions static that accidentally weren't;
added __hash__ special instance method to implement hash()
* Added proper comparison for built-in methods and functions
diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c
index 0875a0c..9eb332b 100644
--- a/Objects/tupleobject.c
+++ b/Objects/tupleobject.c
@@ -1,6 +1,6 @@
/***********************************************************
-Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The
-Netherlands.
+Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
+Amsterdam, The Netherlands.
All Rights Reserved
@@ -179,6 +179,27 @@
return v->ob_size - w->ob_size;
}
+static long
+tuplehash(v)
+ tupleobject *v;
+{
+ register long x, y;
+ register int len = v->ob_size;
+ register object **p;
+ x = 0x345678L;
+ p = v->ob_item;
+ while (--len >= 0) {
+ y = hashobject(*p++);
+ if (y == -1)
+ return -1;
+ x = (x + x + x) ^ y;
+ }
+ x ^= v->ob_size;
+ if (x == -1)
+ x = -2;
+ return x;
+}
+
static int
tuplelength(a)
tupleobject *a;
@@ -329,4 +350,5 @@
0, /*tp_as_number*/
&tuple_as_sequence, /*tp_as_sequence*/
0, /*tp_as_mapping*/
+ tuplehash, /*tp_hash*/
};