Skip to content

Commit 4b401a7

Browse files
optimize jit attribute loads on immutable types
1 parent 8e1469c commit 4b401a7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Python/optimizer_analysis.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,10 @@ lookup_attr(JitOptContext *ctx, _PyBloomFilter *dependencies, _PyUOpInstruction
367367
if (type && PyType_Check(type)) {
368368
PyObject *lookup = _PyType_Lookup(type, name);
369369
if (lookup) {
370-
int opcode = _Py_IsImmortal(lookup) ? immortal : mortal;
370+
int opcode = mortal;
371+
if (_Py_IsImmortal(lookup) || (type->tp_flags & Py_TPFLAGS_IMMUTABLETYPE)) {
372+
opcode = immortal;
373+
}
371374
ADD_OP(opcode, 0, (uintptr_t)lookup);
372375
PyType_Watch(TYPE_WATCHER_ID, (PyObject *)type);
373376
_Py_BloomFilter_Add(dependencies, type);

0 commit comments

Comments
 (0)