Skip to content

Add mixed-mode complex arithmetic to match CPython 3.14 #10780

Open

Description

@swap357

Follow-up to #10528.

CPython 3.14 added mixed-mode real/complex +, -, *, / with _Py_cr_* / _Py_rc_* (python/cpython#124829).

Numba still promotes the real to complex(x, 0j) and uses the full complex kernel, so results diverge on 3.14+.

For instance,

❯ python
Python 3.14.3 | packaged by Anaconda, Inc. | (main, Feb 24 2026, 22:43:19) [Clang 20.1.8 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from numba import jit
>>> def mul(z, x):
...     return z * x
...     
>>> nb_mul=jit(mul)
>>> z=complex(float('inf'), 1.0)
>>> mul(z,2.0)
(inf+2j)
>>> nb_mul(z,2.0)
(inf+nanj)
>>> 
>>> mul(2.0,z)
(inf+2j)
>>> nb_mul(2.0,z)
(inf+nanj)

Same gap for mixed + / - (e.g. signed zeros: 2 - 0j)

Activity

  1. hiteshsundraaa commented on Sep 3, 2026

    @hiteshsundraaa

    Hi, are you actively working on a fix for this? If not, I’d be happy to take it.

  2. swap357 commented on Sep 3, 2026

    @swap357
    ContributorAuthor

    Hi, are you actively working on a fix for this? If not, I’d be happy to take it.

    I'm not. Feel free to work on it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions