diff options
author | Guido van Rossum <guido@python.org> | 1993-03-29 10:43:31 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1993-03-29 10:43:31 (GMT) |
commit | 9bfef44d97d1ae24e03717e3d59024b44626a9de (patch) | |
tree | 736b9f406d27f9dc4496f103cd395fb7a97401d4 /Objects/tupleobject.c | |
parent | 4b1302bd1d211881178618aa8f41fa4460180f2e (diff) | |
download | cpython-9bfef44d97d1ae24e03717e3d59024b44626a9de.zip cpython-9bfef44d97d1ae24e03717e3d59024b44626a9de.tar.gz cpython-9bfef44d97d1ae24e03717e3d59024b44626a9de.tar.bz2 |
* 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
Diffstat (limited to 'Objects/tupleobject.c')
-rw-r--r-- | Objects/tupleobject.c | 26 |
1 files changed, 24 insertions, 2 deletions
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 @@ tuplecompare(v, w) 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 @@ typeobject Tupletype = { 0, /*tp_as_number*/ &tuple_as_sequence, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ + tuplehash, /*tp_hash*/ }; |