@@ -105,16 +105,6 @@ PyCode_ClearWatcher(int watcher_id)
105105static int
106106should_intern_string (PyObject * o )
107107{
108- #ifdef Py_GIL_DISABLED
109- // The free-threaded build interns (and immortalizes) all string constants
110- // unless we've disabled immortalizing objects that use deferred reference
111- // counting.
112- PyInterpreterState * interp = _PyInterpreterState_GET ();
113- if (_Py_atomic_load_int (& interp -> gc .immortalize ) < 0 ) {
114- return 1 ;
115- }
116- #endif
117-
118108 // compute if s matches [a-zA-Z0-9_]
119109 const unsigned char * s , * e ;
120110
@@ -130,10 +120,6 @@ should_intern_string(PyObject *o)
130120 return 1 ;
131121}
132122
133- #ifdef Py_GIL_DISABLED
134- static PyObject * intern_one_constant (PyObject * op );
135- #endif
136-
137123static int
138124intern_strings (PyObject * tuple )
139125{
@@ -235,27 +221,6 @@ intern_constants(PyObject *tuple, int *modified)
235221 }
236222 Py_DECREF (tmp );
237223 }
238-
239- // Intern non-string constants in the free-threaded build, but only if
240- // we are also immortalizing objects that use deferred reference
241- // counting.
242- PyThreadState * tstate = PyThreadState_GET ();
243- if (!_Py_IsImmortal (v ) && !PyCode_Check (v ) &&
244- !PyUnicode_CheckExact (v ) &&
245- _Py_atomic_load_int (& tstate -> interp -> gc .immortalize ) >= 0 )
246- {
247- PyObject * interned = intern_one_constant (v );
248- if (interned == NULL ) {
249- return -1 ;
250- }
251- else if (interned != v ) {
252- PyTuple_SET_ITEM (tuple , i , interned );
253- Py_SETREF (v , interned );
254- if (modified ) {
255- * modified = 1 ;
256- }
257- }
258- }
259224#endif
260225 }
261226 return 0 ;
@@ -2495,36 +2460,6 @@ _PyCode_ConstantKey(PyObject *op)
24952460}
24962461
24972462#ifdef Py_GIL_DISABLED
2498- static PyObject *
2499- intern_one_constant (PyObject * op )
2500- {
2501- PyInterpreterState * interp = _PyInterpreterState_GET ();
2502- _Py_hashtable_t * consts = interp -> code_state .constants ;
2503-
2504- assert (!PyUnicode_CheckExact (op )); // strings are interned separately
2505-
2506- _Py_hashtable_entry_t * entry = _Py_hashtable_get_entry (consts , op );
2507- if (entry == NULL ) {
2508- if (_Py_hashtable_set (consts , op , op ) != 0 ) {
2509- return NULL ;
2510- }
2511-
2512- #ifdef Py_REF_DEBUG
2513- Py_ssize_t refcnt = Py_REFCNT (op );
2514- if (refcnt != 1 ) {
2515- // Adjust the reftotal to account for the fact that we only
2516- // restore a single reference in _PyCode_Fini.
2517- _Py_AddRefTotal (_PyThreadState_GET (), - (refcnt - 1 ));
2518- }
2519- #endif
2520-
2521- _Py_SetImmortal (op );
2522- return op ;
2523- }
2524-
2525- assert (_Py_IsImmortal (entry -> value ));
2526- return (PyObject * )entry -> value ;
2527- }
25282463
25292464static int
25302465compare_constants (const void * key1 , const void * key2 ) {
0 commit comments