* 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
This commit is contained in:
Guido van Rossum 1993-03-29 10:43:31 +00:00
parent 4b1302bd1d
commit 9bfef44d97
97 changed files with 559 additions and 246 deletions

View file

@ -144,6 +144,16 @@ int_compare(v, w)
return (i < j) ? -1 : (i > j) ? 1 : 0;
}
static long
int_hash(v)
intobject *v;
{
long x = v -> ob_ival;
if (x == -1)
x = -2;
return x;
}
static object *
int_add(v, w)
intobject *v;
@ -413,7 +423,7 @@ int_or(v, w)
static object *
int_int(v)
object *v;
intobject *v;
{
INCREF(v);
return v;
@ -421,26 +431,24 @@ int_int(v)
static object *
int_long(v)
object *v;
intobject *v;
{
long x = getintvalue(v);
return newlongobject(x);
return newlongobject((v -> ob_ival));
}
static object *
int_float(v)
object *v;
intobject *v;
{
long x = getintvalue(v);
return newfloatobject((double)x);
return newfloatobject((double)(v -> ob_ival));
}
static object *
int_oct(v)
object *v;
intobject *v;
{
char buf[20];
long x = getintvalue(v);
long x = v -> ob_ival;
if (x == 0)
strcpy(buf, "0");
else if (x > 0)
@ -452,10 +460,10 @@ int_oct(v)
static object *
int_hex(v)
object *v;
intobject *v;
{
char buf[20];
long x = getintvalue(v);
long x = v -> ob_ival;
if (x >= 0)
sprintf(buf, "0x%lx", x);
else
@ -463,7 +471,6 @@ int_hex(v)
return newstringobject(buf);
}
static number_methods int_as_number = {
int_add, /*nb_add*/
int_sub, /*nb_subtract*/
@ -505,4 +512,5 @@ typeobject Inttype = {
&int_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
0, /*tp_as_mapping*/
&int_hash, /*tp_hash*/
};