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/object.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/object.c')
-rw-r--r-- | Objects/object.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/Objects/object.c b/Objects/object.c index 707dd58..9a8d4b3 100644 --- a/Objects/object.c +++ b/Objects/object.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 @@ -165,6 +165,20 @@ cmpobject(v, w) return (*tp->tp_compare)(v, w); } +long +hashobject(v) + object *v; +{ + typeobject *tp = v->ob_type; + if (tp->tp_hash != NULL) + return (*tp->tp_hash)(v); + if (tp->tp_compare == NULL) + return (long) v; /* Use address as hash value */ + /* If there's a cmp but no hash defined, the object can't be hashed */ + err_setstr(TypeError, "unhashable type"); + return -1; +} + object * getattr(v, name) object *v; @@ -229,6 +243,7 @@ static typeobject Notype = { 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ + 0, /*tp_hash */ }; object NoObject = { |