Skip to content

Python 3.15 - #10732

Merged
swap357 merged 38 commits into
numba:mainfrom
swap357:python-3.15
Sep 4, 2026
Merged

swap357 merged 38 commits into
numba:mainfrom
swap357:python-3.15

Conversation

@swap357

@swap357 swap357 commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

This PR adds Python 3.15 support to Numba.

Co-Authored-By: Claude Sonnet 4.6

swap357 and others added 15 commits July 23, 2026 14:59
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…TANT.

Python 3.15 emits this opcode for literals like -1 as well as builtins,
so generalize the byteflow tracer and interpreter beyond AssertionError.
Locate LOAD_CONST dynamically instead of assuming a fixed offset after
RESUME, which overwrote CACHE and triggered a fatal interpreter error.
@swap357
swap357 marked this pull request as ready for review August 5, 2026 06:31
@swap357
swap357 requested a review from sklam as a code owner August 5, 2026 06:31
@swap357
swap357 requested a review from esc August 5, 2026 06:32
@esc

esc commented Aug 5, 2026

Copy link
Copy Markdown
Member

I ran [b65616d](https://github.com/numba/numba/pull/10732/commits/b65616d22572794422f068e5fd2d1484adec98ff) through numba-hatchery at numba/numba-hatchery#15 and the test suite passed without errors, this is a good sign.

@esc esc left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One version guard needs to be be brought into line.

And also the file:

docs/source/reference/support_tiers.rst

References the 3.14 free threaded build. I presume we want to indicate somehow that this also includes the 3/15 free threaded build, as I assume we wish to produce an artifact for those too?

See screenshot below:

Screenshot 2026-08-05 at 17 47 06

Review-assisted by: Kimi K3 via kilo-cli

Comment thread numba/core/byteflow.py Outdated

def op_GET_ITER(self, state, inst):
value = state.pop()
if PYVERSION >= (3, 15):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if PYVERSION >= (3, 15):
if PYVERSION in ((3, 15), ):

For consistency. The other version guards use this style.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also change the else if and else parts, such that a NotImplementedError is raised.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've fixed two places which had open branches and made them explicit - fa3221e and 6bd6783

@swap357

swap357 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

One version guard needs to be be brought into line.

And also the file:

docs/source/reference/support_tiers.rst

References the 3.14 free threaded build. I presume we want to indicate somehow that this also includes the 3/15 free threaded build, as I assume we wish to produce an artifact for those too?

See screenshot below:

Screenshot 2026-08-05 at 17 47 06 Review-assisted by: Kimi K3 via `kilo-cli`

Yes we'd build 3.15t artifacts as well. Not adding yet, but I'll make sure to change the docs when we add CI changes for python3.15 here or on different PR.

Comment thread numba/core/bytecode.py

@sklam sklam left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed 0591e68. The changes are solid. I cannot find any case that is a problem.

Other notes:

NOT_TAKEN appears when any conditional branching opcode occur (after any POP_JUMP_IF_):

>>> def f(x):
...     if x: return True
...     else: return False
... 
>>> import dis
>>> dis.dis(f)
  1           RESUME                   0

  2           LOAD_FAST_BORROW         0 (x)
              TO_BOOL
              POP_JUMP_IF_FALSE        3 (to L1)
              NOT_TAKEN
              LOAD_COMMON_CONSTANT     9 (True)
              RETURN_VALUE

  3   L1:     LOAD_COMMON_CONSTANT    10 (False)
              RETURN_VALUE

@swap357

swap357 commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor Author

I added CI changes needed for py3.15 here with 463b08b to 8408d58.

With changes, osx-arm64 and linux-aarch64 build and tests do pass with py3.15.
https://github.com/numba/numba/actions/runs/31421954123/job/93566352238?pr=10732
About CI failures with py3.15 on other platforms :

  • conda builders are failing because there's no numpy available on distribution yet for py3.15.
  • linux wheel builders are failing because CI uses manylinux2014_x86_64 and manylinux_2_28_aarch64 images to build, for which there are no numpy wheels, and when it does try to build wheel, numpy now need GCC >=10.3.
    ../meson.build:25:4: ERROR: Problem encountered: NumPy requires GCC >= 10.3
    For this, it might be worth upgrading manylinux images on linux-64 and linux-aarch64 to newer ones.
  • win-64 wheel builder - MSVC needs /std:c++20 for Python 3.15 headers
    (https://github.com/numba/numba/actions/runs/31421952358/job/93564657449?pr=10732)

@swap357 swap357 added this to the 0.68.0rc1 milestone Aug 14, 2026
@swap357

swap357 commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor Author

With f7e61d3, these test dependencies have been skipped on conda recipe test section for Python 3.15 until they are available -
jinja2, cffi, scipy, ipython, pyyaml, pygments, pexpect, ipykernel, psutil

@swap357
swap357 requested a review from esc September 2, 2026 23:05
Comment thread numba/tests/test_extended_arg.py
Comment thread numba/tests/support.py
Comment thread numba/tests/test_operators.py
Comment thread numba/_dispatcher.cpp
#include "internal/pycore_call.h"
#include "cpython/code.h"

#elif (PY_MAJOR_VERSION >= 3) && (PY_MINOR_VERSION == 11)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the code here moved ?

@swap357 swap357 Sep 4, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Python 3.13+ (including 3.15) uses the public PyMonitoring APIs for sys-monitoring. (see: #10578)
The moved code are internal headers are only needed for the 3.12 invoke_monitoring() path, so they are now gated under the 3.12-only block. One of those headers also conflicted with the MSVC /std:c++20 change, which is why they were moved.

("3.13", "2.1"),
("3.14", "2.3"),
("3.15", "2.5"),
)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why no free-threaded (3.15t) on CI build/test matrix ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3.15t is intentionally omitted from this PR and will be added separately. From experiments on my fork (https://github.com/swap357/numba/actions/runs/33830492988/job/100892610519) looks like all build env dependencies might not have 3.15t (free-threading) support yet.

Replace index-based lookup with identity comparison (`is`) when
searching for entries in the exception table.
Additionally, add an assertion to verify depth consistency when
merging adjacent entries.

@esc esc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I gave this a final review and it's totally fine!

For the record, these are the 3.15 limitations, not addressed by this PR:

  • No 3.15t (free threading) on wheels or condas
  • 3.15 condas have unmet dependencies because not all packages have been built out
  • No 3.15 win-arm64 support just yet

We are merging this now to enable 3.15 on the bulk of our officially supported platforms with the goal of fixing up the rest in subsequent PRs.

Thank you @swap357 for the patches and thank you @sklam and @stuartarchibald for the additional reviews, feedback and suggestions. ❤️

@esc

esc commented Sep 4, 2026

Copy link
Copy Markdown
Member

FWIW: there was one CI failure on linux-64:

github.com/numba/numba/actions/runs/33847524840/job/100943453103?pr=10732

======================================================================
FAIL: test_set_num_threads_inside_guvectorize_tbb_4_threads (numba.tests.test_num_threads.TestNumThreadsBackends.test_set_num_threads_inside_guvectorize_tbb_4_threads)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.15.0-rc.2/x64/lib/python3.15/site-packages/numba/tests/test_num_threads.py", line 602, in test_template
    o, e = self.run_test_in_separate_process(injected_method, backend,
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
                                             num_threads)
                                             ^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.15.0-rc.2/x64/lib/python3.15/site-packages/numba/tests/test_num_threads.py", line 593, in run_test_in_separate_process
    return self.run_cmd(cmdline, env_copy)
           ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.15.0-rc.2/x64/lib/python3.15/site-packages/numba/tests/test_parallel_backend.py", line 363, in run_cmd
    raise AssertionError(
        "process failed with code %s: stderr follows\n%s\n" %
        (popen.returncode, err.decode()))
AssertionError: process failed with code -11: stderr follows
_test_set_num_threads_inside_guvectorize (numba.tests.test_num_threads.TestNumThreads._test_set_num_threads_inside_guvectorize) ... ok

From OOB conversations with @stuartarchibald and @swap357 this is most likely a latent bug that has existed for years. It's probably not 3.15 specific and should not block the merge of this PR. May need to open a new issue to track it

@swap357

swap357 commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor Author

FWIW: there was one CI failure on linux-64:

github.com/numba/numba/actions/runs/33847524840/job/100943453103?pr=10732

======================================================================
FAIL: test_set_num_threads_inside_guvectorize_tbb_4_threads (numba.tests.test_num_threads.TestNumThreadsBackends.test_set_num_threads_inside_guvectorize_tbb_4_threads)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.15.0-rc.2/x64/lib/python3.15/site-packages/numba/tests/test_num_threads.py", line 602, in test_template
    o, e = self.run_test_in_separate_process(injected_method, backend,
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
                                             num_threads)
                                             ^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.15.0-rc.2/x64/lib/python3.15/site-packages/numba/tests/test_num_threads.py", line 593, in run_test_in_separate_process
    return self.run_cmd(cmdline, env_copy)
           ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.15.0-rc.2/x64/lib/python3.15/site-packages/numba/tests/test_parallel_backend.py", line 363, in run_cmd
    raise AssertionError(
        "process failed with code %s: stderr follows\n%s\n" %
        (popen.returncode, err.decode()))
AssertionError: process failed with code -11: stderr follows
_test_set_num_threads_inside_guvectorize (numba.tests.test_num_threads.TestNumThreads._test_set_num_threads_inside_guvectorize) ... ok

From OOB conversations with @stuartarchibald and @swap357 this is most likely a latent bug that has existed for years. It's probably not 3.15 specific and should not block the merge of this PR. May need to open a new issue to track it

there's a related issue here - #10563.

@swap357
swap357 merged commit 1979f73 into numba:main Sep 4, 2026
226 of 227 checks passed
@esc esc mentioned this pull request Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants