- On Unix, a shared libpython2.3.so can be created with --enable-shared.
-- References to the CACHE_HASH and INTERN_STRINGS preprocessor symbols
- were eliminated. They were always defined, and the internal features
- they enabled stopped being experimental long ago.
+- All uses of the CACHE_HASH, INTERN_STRINGS, and DONT_SHARE_SHORT_STRINGS
+ preprocessor symbols were eliminated. The internal decisions they
+ controlled stopped being experimental long ago.
C API
#endif
static PyStringObject *characters[UCHAR_MAX + 1];
-#ifndef DONT_SHARE_SHORT_STRINGS
static PyStringObject *nullstring;
-#endif
/*
For both PyString_FromString() and PyString_FromStringAndSize(), the
PyString_FromStringAndSize(const char *str, int size)
{
register PyStringObject *op;
-#ifndef DONT_SHARE_SHORT_STRINGS
if (size == 0 && (op = nullstring) != NULL) {
#ifdef COUNT_ALLOCS
null_strings++;
Py_INCREF(op);
return (PyObject *)op;
}
-#endif /* DONT_SHARE_SHORT_STRINGS */
/* PyObject_NewVar is inlined */
op = (PyStringObject *)
if (str != NULL)
memcpy(op->ob_sval, str, size);
op->ob_sval[size] = '\0';
-#ifndef DONT_SHARE_SHORT_STRINGS
+ /* share short strings */
if (size == 0) {
PyObject *t = (PyObject *)op;
PyString_InternInPlace(&t);
characters[*str & UCHAR_MAX] = op;
Py_INCREF(op);
}
-#endif
return (PyObject *) op;
}
"string is too long for a Python string");
return NULL;
}
-#ifndef DONT_SHARE_SHORT_STRINGS
if (size == 0 && (op = nullstring) != NULL) {
#ifdef COUNT_ALLOCS
null_strings++;
Py_INCREF(op);
return (PyObject *)op;
}
-#endif /* DONT_SHARE_SHORT_STRINGS */
/* PyObject_NewVar is inlined */
op = (PyStringObject *)
op->ob_shash = -1;
op->ob_sinterned = NULL;
memcpy(op->ob_sval, str, size+1);
-#ifndef DONT_SHARE_SHORT_STRINGS
+ /* share short strings */
if (size == 0) {
PyObject *t = (PyObject *)op;
PyString_InternInPlace(&t);
characters[*str & UCHAR_MAX] = op;
Py_INCREF(op);
}
-#endif
return (PyObject *) op;
}
Py_XDECREF(characters[i]);
characters[i] = NULL;
}
-#ifndef DONT_SHARE_SHORT_STRINGS
Py_XDECREF(nullstring);
nullstring = NULL;
-#endif
if (interned) {
int pos, changed;
PyObject *key, *value;