From bda121862e7d7f4684d9f0281f7d1f408c0c740c Mon Sep 17 00:00:00 2001 From: Noam Cohen Date: Mon, 23 Jun 2025 22:42:09 +0300 Subject: gh-131798: Optimize `_UNARY_NEGATIVE` (GH-135223) --- Python/optimizer_bytecodes.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'Python/optimizer_bytecodes.c') diff --git a/Python/optimizer_bytecodes.c b/Python/optimizer_bytecodes.c index f8fbaf232ff..f8a0484bdc2 100644 --- a/Python/optimizer_bytecodes.c +++ b/Python/optimizer_bytecodes.c @@ -452,7 +452,13 @@ dummy_func(void) { res = sym_new_compact_int(ctx); } else { - res = sym_new_not_null(ctx); + PyTypeObject *type = sym_get_type(value); + if (type == &PyLong_Type || type == &PyFloat_Type) { + res = sym_new_type(ctx, type); + } + else { + res = sym_new_not_null(ctx); + } } } -- cgit v1.2.3