mirror of
https://github.com/python/cpython.git
synced 2025-11-02 03:01:58 +00:00
SF patch 576101, by Oren Tirosh: alternative implementation of
interning. I modified Oren's patch significantly, but the basic idea and most of the implementation is unchanged. Interned strings created with PyString_InternInPlace() are now mortal, and you must keep a reference to the resulting string around; use the new function PyString_InternImmortal() to create immortal interned strings.
This commit is contained in:
parent
d8dbf847b6
commit
45ec02aed1
7 changed files with 171 additions and 106 deletions
|
|
@ -511,15 +511,9 @@ PyDict_SetItem(register PyObject *op, PyObject *key, PyObject *value)
|
|||
}
|
||||
mp = (dictobject *)op;
|
||||
if (PyString_CheckExact(key)) {
|
||||
if (((PyStringObject *)key)->ob_sinterned != NULL) {
|
||||
key = ((PyStringObject *)key)->ob_sinterned;
|
||||
hash = ((PyStringObject *)key)->ob_shash;
|
||||
}
|
||||
else {
|
||||
hash = ((PyStringObject *)key)->ob_shash;
|
||||
if (hash == -1)
|
||||
hash = PyObject_Hash(key);
|
||||
}
|
||||
hash = ((PyStringObject *)key)->ob_shash;
|
||||
if (hash == -1)
|
||||
hash = PyObject_Hash(key);
|
||||
}
|
||||
else {
|
||||
hash = PyObject_Hash(key);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue