diff options
author | Noam Cohen <noam@noam.me> | 2025-06-23 22:42:09 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-06-24 03:42:09 +0800 |
commit | bda121862e7d7f4684d9f0281f7d1f408c0c740c (patch) | |
tree | 998e2175f100dd85a5adbf235081bd6cbb279ed6 /Python/optimizer_bytecodes.c | |
parent | 569fc6870f048cb75469ae3cacb6ebcf5172a10e (diff) | |
download | cpython-bda121862e7d7f4684d9f0281f7d1f408c0c740c.tar.gz cpython-bda121862e7d7f4684d9f0281f7d1f408c0c740c.zip |
gh-131798: Optimize `_UNARY_NEGATIVE` (GH-135223)
Diffstat (limited to 'Python/optimizer_bytecodes.c')
-rw-r--r-- | Python/optimizer_bytecodes.c | 8 |
1 files changed, 7 insertions, 1 deletions
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); + } } } |