diff options
author | Tomas R. <tomas.roun8@gmail.com> | 2025-06-07 01:44:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-06-06 16:44:43 -0700 |
commit | 46151648ca8ba1edd2a2783e8e154692a13d8ea8 (patch) | |
tree | 0c03ca4f658e06335409cc89342ad3dce14450c4 /Python/optimizer_bytecodes.c | |
parent | f00512db20561370faad437853f6ecee0eec4856 (diff) | |
download | cpython-46151648ca8ba1edd2a2783e8e154692a13d8ea8.tar.gz cpython-46151648ca8ba1edd2a2783e8e154692a13d8ea8.zip |
GH-131798: Optimize away type(x) in the JIT when the result is known (GH-135194)
Diffstat (limited to 'Python/optimizer_bytecodes.c')
-rw-r--r-- | Python/optimizer_bytecodes.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Python/optimizer_bytecodes.c b/Python/optimizer_bytecodes.c index b4220e2c627..12efaacd8f0 100644 --- a/Python/optimizer_bytecodes.c +++ b/Python/optimizer_bytecodes.c @@ -937,8 +937,11 @@ dummy_func(void) { } op(_CALL_TYPE_1, (unused, unused, arg -- res)) { - if (sym_has_type(arg)) { - res = sym_new_const(ctx, (PyObject *)sym_get_type(arg)); + PyObject* type = (PyObject *)sym_get_type(arg); + if (type) { + res = sym_new_const(ctx, type); + REPLACE_OP(this_instr, _POP_CALL_ONE_LOAD_CONST_INLINE_BORROW, 0, + (uintptr_t)type); } else { res = sym_new_not_null(ctx); |