mirror of
https://github.com/python/cpython.git
synced 2025-10-17 12:18:23 +00:00
* 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:
parent
4b1302bd1d
commit
9bfef44d97
97 changed files with 559 additions and 246 deletions
|
@ -293,6 +293,21 @@ string_compare(a, b)
|
|||
return (len_a < len_b) ? -1 : (len_a > len_b) ? 1 : 0;
|
||||
}
|
||||
|
||||
static long
|
||||
string_hash(a)
|
||||
stringobject *a;
|
||||
{
|
||||
register int len = a->ob_size;
|
||||
register unsigned char *p = (unsigned char *) a->ob_sval;
|
||||
register long x = *p << 7;
|
||||
while (--len >= 0)
|
||||
x = (x + x + x) ^ *p++;
|
||||
x ^= a->ob_size;
|
||||
if (x == -1)
|
||||
x = -2;
|
||||
return x;
|
||||
}
|
||||
|
||||
static sequence_methods string_as_sequence = {
|
||||
string_length, /*sq_length*/
|
||||
string_concat, /*sq_concat*/
|
||||
|
@ -318,6 +333,7 @@ typeobject Stringtype = {
|
|||
0, /*tp_as_number*/
|
||||
&string_as_sequence, /*tp_as_sequence*/
|
||||
0, /*tp_as_mapping*/
|
||||
string_hash, /*tp_hash*/
|
||||
};
|
||||
|
||||
void
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue