-
Notifications
You must be signed in to change notification settings - Fork 53
LOAD_CONST_IMMORTAL #584
Copy link
Copy link
Closed
Description
Constants are, um, constant. So if the argument of LOAD_CONST is immortal is will always be immortal.
We could add a specialization of LOAD_CONST, LOAD_CONST_IMMORTAL, which doesn't do any refcount modification.
The neatest way to do this would be in the compiler, but it can be done at runtime:
inst(LOAD_CONST, (-- value)) {
value = GETITEM(frame->f_code->co_consts, oparg);
if (_Py_IsImmortal(value)) {
next_instr[-1].op.code = LOAD_CONST_IMMORTAL;
}
else {
Py_INCREF_UNCONDITIONAL(value);
}
}
A LOAD_CONST_MORTAL specialization is not possible, as PEP 683 allows mortal object to become immortal.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels