Mercurial > cpython-lru_cache-weakref
diff Python/bltinmodule.c @ 1257:1cabc2b6c970 legacy-trunk
* 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
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Mon, 29 Mar 1993 10:43:31 +0000 |
| parents | c4cd0d9d8281 |
| children | 65a1e4e9cd54 |
line wrap: on
line diff
--- a/Python/bltinmodule.c Sat Mar 27 18:11:32 1993 +0000 +++ b/Python/bltinmodule.c Mon Mar 29 10:43:31 1993 +0000 @@ -281,10 +281,28 @@ object *args; { object *v; - char *name; - if (!getargs(args, "(Os)", &v, &name)) + object *name; + if (!getargs(args, "(OS)", &v, &name)) return NULL; - return getattr(v, name); + return getattro(v, name); +} + +static object * +builtin_hasattr(self, args) + object *self; + object *args; +{ + object *v; + object *name; + if (!getargs(args, "(OS)", &v, &name)) + return NULL; + v = getattro(v, name); + if (v == NULL) { + err_clear(); + return newintobject(0L); + } + DECREF(v); + return newintobject(1L); } static object * @@ -293,17 +311,32 @@ object *args; { object *v; - char *name; + object *name; object *value; - if (!getargs(args, "(OsO)", &v, &name, &value)) + if (!getargs(args, "(OSO)", &v, &name, &value)) return NULL; - if (setattr(v, name, value) != 0) + if (setattro(v, name, value) != 0) return NULL; INCREF(None); return None; } static object * +builtin_hash(self, args) + object *self; + object *args; +{ + object *v; + long x; + if (!getargs(args, "O", &v)) + return NULL; + x = hashobject(v); + if (x == -1) + return NULL; + return newintobject(x); +} + +static object * builtin_hex(self, v) object *self; object *v; @@ -687,6 +720,8 @@ {"execfile", builtin_execfile}, {"float", builtin_float}, {"getattr", builtin_getattr}, + {"hasattr", builtin_hasattr}, + {"hash", builtin_hash}, {"hex", builtin_hex}, {"input", builtin_input}, {"int", builtin_int},
