Simplify interp_look_up_id() (#134257)

Don't use PyInterpreterState_GetID() but get directly the interpreter
'id' member which cannot fail.
This commit is contained in:
Victor Stinner 2025-05-19 14:09:10 -04:00 committed by GitHub
parent 71c42b778d
commit e79f640eb6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1393,10 +1393,8 @@ interp_look_up_id(_PyRuntimeState *runtime, int64_t requested_id)
{
PyInterpreterState *interp = runtime->interpreters.head;
while (interp != NULL) {
int64_t id = PyInterpreterState_GetID(interp);
if (id < 0) {
return NULL;
}
int64_t id = interp->id;
assert(id >= 0);
if (requested_id == id) {
return interp;
}