check for void return FFI functions, fix incorrect cases#6043
Merged
Conversation
davidhewitt
commented
May 13, 2026
|
|
||
| pub fn PyUnstable_TryIncRef(obj: *mut PyObject) -> c_int; | ||
|
|
||
| pub fn PyUnstable_EnableTryIncRef(obj: *mut PyObject) -> c_void; |
Member
Author
There was a problem hiding this comment.
Need no changelog entry for this one as it'll be newly released in 0.29.
Open
Merging this PR will improve performance by 27.92%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ⚡ | test_class_attribute |
16 µs | 12.6 µs | +27.44% |
| ⚡ | test_class_method |
18.4 µs | 15.6 µs | +18.62% |
| ⚡ | test_empty_class_init |
24.7 µs | 15.8 µs | +56.09% |
| ⚡ | test_empty_class_init_py |
14.4 µs | 10.8 µs | +33.18% |
| ⚡ | test_getter |
18.3 µs | 15.2 µs | +20.45% |
| ⚡ | test_method_call |
17.3 µs | 13.9 µs | +24.35% |
| ⚡ | test_method_call_py |
14.9 µs | 11 µs | +35.88% |
| ⚡ | test_proto_call |
14 µs | 10.4 µs | +35.15% |
| ⚡ | test_proto_call_py |
15.3 µs | 11.6 µs | +31.74% |
| ⚡ | test_setter |
18.1 µs | 14.7 µs | +22.84% |
| ⚡ | test_static_method |
17.6 µs | 14.6 µs | +20.61% |
| ⚡ | test_args_kwargs_py |
18.6 µs | 15.1 µs | +23.65% |
| ⚡ | test_args_kwargs_rs |
14.8 µs | 11.2 µs | +32.11% |
| ⚡ | test_many_keyword_arguments_py |
19.3 µs | 16.2 µs | +19.15% |
| ⚡ | test_many_keyword_arguments_rs |
20.2 µs | 16.7 µs | +20.91% |
| ⚡ | test_none_py |
14.4 µs | 10.3 µs | +39.16% |
| ⚡ | test_none_rs |
13.4 µs | 9.7 µs | +38.36% |
| ⚡ | test_positional_only_py |
13.9 µs | 10.3 µs | +34.6% |
| ⚡ | test_positional_only_rs |
14.4 µs | 10.7 µs | +34.45% |
| ⚡ | test_simple_args_kwargs_py |
20.5 µs | 17.2 µs | +19.27% |
| ... | ... | ... | ... | ... |
ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.
Tip
Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.
Comparing davidhewitt:void-return-ffi (6c136d0) with main (c92117c)
Tpt
approved these changes
May 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR attempts to check whether
pyo3-ffiand the C headers agree on functions having no return value. The more general case of type checking is hard (pyo3-ffiandbindgenmay have different logical types; what we really need to check is ABI compatibility), but checking for void return turns out to be easy enough.Subsequently I fix two cases which turned out to be wrong in
pyo3-ffi.