-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Change function calls to use vectorcall #5948
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
This reverts commit 418a034.
It cannot re-use the incoming tuple as before, because it is no longer a tuple at all. So a new tuple must be created, which then holds references for each member.
This would be easier with `if constexpr`
|
@b-pass I merged master, which had no conflicts. My idea was that maybe Cursor can figure out the root cause for these two CI failures:
I'll wait for this CI run to finish, to see if these errors appear again. When testing locally with Python 3.14.2, default and freethreaded, I saw this error (with both builds): EDIT: Please see #5948 (comment) for the resolution. I'm attaching the full build & test logs, JIC. I switched back to master, everything else being equal, this error didn't appear. So it's definitely somehow connected to this PR. pybind11_gcc_v3.14_df793163d58_default_tests_log_2025-12-26+193154.txt pybind11_gcc_v3.14_df793163d58_freethreaded_log_2025-12-26+193608.txt |
The `mod_per_interpreter_gil`, `mod_shared_interpreter_gil`, and `mod_per_interpreter_gil_with_singleton` modules were being built but not installed into the wheel when using scikit-build-core (SKBUILD=true). This caused iOS (and potentially Android) CIBW tests to fail with ModuleNotFoundError. Root cause analysis: - The main test targets have install() commands (line 531) - The PYBIND11_MULTIPLE_INTERPRETERS_TEST_MODULES were missing equivalent install() commands - For regular CMake builds, this wasn't a problem because LIBRARY_OUTPUT_DIRECTORY places the modules next to pybind11_tests - For wheel builds, only targets with explicit install() commands are included in the wheel This issue was latent until commit fee2527 changed the test imports from `pytest.importorskip()` (graceful skip) to direct `import` statements (hard failure), which exposed the missing modules. Failing tests: - test_multiple_interpreters.py::test_independent_subinterpreters - test_multiple_interpreters.py::test_dependent_subinterpreters Error: ModuleNotFoundError: No module named 'mod_per_interpreter_gil'
|
Quick update: I think Cursor found the root cause for the CIBW / iOS failures, and a fix. I'm still looking into why we're not seeing the |
Add numpy==2.4.0 requirement for Python 3.14 (both default and free-threaded builds). NumPy 2.4.0 is the first version to provide official PyPI wheels for Python 3.14: - numpy-2.4.0-cp314-cp314-manylinux_2_27_x86_64...whl (default) - numpy-2.4.0-cp314-cp314t-manylinux_2_27_x86_64...whl (free-threaded) Previously, CI was skipping all numpy-dependent tests for Python 3.14 because PIP_ONLY_BINARY was set and no wheels were available: SKIPPED [...] test_numpy_array.py:8: could not import 'numpy': No module named 'numpy' With this change, the full numpy test suite will run on Python 3.14, providing better test coverage for the newest Python version. Note: Using exact pin (==2.4.0) rather than compatible release (~=2.4.0) to ensure reproducible CI results with the first known-working version.
NumPy 2.3.5 vs 2.4.0 ObservationsThe IssueWhen testing this PR locally with Python 3.14 + NumPy 2.3.5, I observed a test failure: This occurred when calling What We Know For Sure
What's UndeterminedThe exact bug fix in NumPy between 2.3.5 and 2.4.0 that resolved this issue. I searched the NumPy 2.4.0 release notes but couldn't find a specific fix that clearly matches our observation. The release notes mention "many expired deprecations and bug fixes" without listing all of them individually. ResolutionAdded
|
Add `-v` to the pytest command in tests/pyproject.toml to help diagnose hanging tests in CIBW jobs (particularly iOS). This will show each test name as it runs, making it easier to identify which specific test is hanging.
- Add `IOS` platform constant to `tests/env.py` for consistency with existing `ANDROID`, `LINUX`, `MACOS`, `WIN`, `FREEBSD` constants. - Skip `test_multiple_interpreters.py` module on iOS. Subinterpreters are not supported in the iOS simulator environment. These tests were previously skipped implicitly because the modules weren't installed in the wheel; now that they are (commit 6ed6d5a), we need an explicit skip. - Change pytest timeout from 0 (disabled) to 120 seconds. This provides a safety net to catch hanging tests before the CI job times out after hours. Normal test runs complete in 33-55 seconds total (~1100 tests), so 120 seconds per test is very generous. - Add `-v` flag for verbose output to help diagnose any future issues.
Cursor Code Review (with some manual edits)Question for the AuthorIs there a specific reason OverviewThis PR changes pybind11's function calling convention from The PR also adds a new Summary of Changes1.
|
rwgk
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM but mostly based on the Cursor review. I haven't looked very closely manually. I recommend waiting for a review from @oremanj before merging.

Description
Change both the Python->C++ and the C++->Python function calls to use the faster "vector call" calling protocol.
This makes function calls faster, at the minor expense of having to handle the arguments slightly differently.
Suggested changelog entry: