@@ -277,23 +277,36 @@ PyAPI_FUNC(void) _PyInterpreterState_SetEvalFrameFunc(
277277 PyInterpreterState * interp ,
278278 _PyFrameEvalFunction eval_frame );
279279
280- /* Similar to PyInterpreterState_Get(), but returns the interpreter with an
281- * incremented reference count. PyInterpreterState_Delete() won't delete the
282- * full interpreter structure until the reference is released by
283- * PyThreadState_Ensure() or PyInterpreterState_Release(). */
284- PyAPI_FUNC (PyInterpreterState * ) PyInterpreterState_Hold (void );
280+ /* Strong interpreter references */
285281
286- PyAPI_FUNC ( PyInterpreterState * ) PyInterpreterState_Lookup ( int64_t interp_id ) ;
282+ typedef uintptr_t PyInterpreterRef ;
287283
288- /* Release a reference to an interpreter incremented by PyInterpreterState_Hold() */
289- PyAPI_FUNC (void ) PyInterpreterState_Release (PyInterpreterState * interp );
284+ PyAPI_FUNC (PyInterpreterRef ) PyInterpreterRef_Get (void );
285+ PyAPI_FUNC (PyInterpreterRef ) PyInterpreterRef_Dup (PyInterpreterRef ref );
286+ PyAPI_FUNC (PyInterpreterRef ) PyInterpreterState_AsStrong (PyInterpreterState * interp );
287+ PyAPI_FUNC (void ) PyInterpreterRef_Close (PyInterpreterRef ref );
288+
289+ #define PyInterpreterRef_Close (ref ) do { \
290+ PyInterpreterRef_Close(ref); \
291+ ref = 0; \
292+ } while (0); \
293+
294+ /* Weak interpreter references */
295+
296+ typedef struct _interpreter_weakref {
297+ int64_t id ;
298+ Py_ssize_t refcount ;
299+ } PyInterpreterWeakRef ;
300+
301+ PyAPI_FUNC (PyInterpreterWeakRef ) PyInterpreterWeakRef_Get (void );
302+ PyAPI_FUNC (PyInterpreterWeakRef ) PyInterpreterWeakRef_Dup (PyInterpreterWeakRef wref );
303+ PyAPI_FUNC (PyInterpreterRef ) PyInterpreterWeakRef_AsStrong (PyInterpreterWeakRef wref );
304+ PyAPI_FUNC (void ) PyInterpreterWeakRef_Close (PyInterpreterWeakRef wref );
290305
291306// Exports for '_testcapi' shared extension
292307PyAPI_FUNC (Py_ssize_t ) _PyInterpreterState_Refcount (PyInterpreterState * interp );
293308PyAPI_FUNC (void ) _PyInterpreterState_Incref (PyInterpreterState * interp );
294309
295- PyAPI_FUNC (int ) PyThreadState_SetDaemon (int daemon );
296-
297310PyAPI_FUNC (int ) PyThreadState_Ensure (PyInterpreterState * interp );
298311
299312PyAPI_FUNC (void ) PyThreadState_Release (void );
0 commit comments