more cleanup of private FFI definitions#6042
Open
davidhewitt wants to merge 5 commits into
Open
Conversation
davidhewitt
commented
May 13, 2026
Comment on lines
+391
to
+394
| $pub struct $name { | ||
| _data: (), | ||
| _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, | ||
| } |
Member
Author
There was a problem hiding this comment.
This change was motivated by looking at the nomicon https://doc.rust-lang.org/nomicon/ffi.html#representing-opaque-structs - which documents this _data / _marker combination as the current way to do opaque types.
Open
Merging this PR will improve performance by 27.94%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ⚡ | test_class_attribute |
16 µs | 12.6 µs | +27.44% |
| ⚡ | test_class_method |
18.4 µs | 15.5 µs | +18.84% |
| ⚡ | test_empty_class_init |
24.7 µs | 15.8 µs | +56.38% |
| ⚡ | 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.61% |
| ⚡ | 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.37% |
| ⚡ | 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.13% |
| ⚡ | test_many_keyword_arguments_rs |
20.2 µs | 16.7 µs | +20.95% |
| ⚡ | 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:private-cleanup-3 (987e87a) with main (c92117c)
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.
Another batch of FFI cleanups following #5965
I added
--document-private-itemsto the ffi-check rustdoc processing; this didn't catch functions (which I hoped it would) but it noticed that thePyTracebackObjectdefinition did not expose the fields.I also adjusted the implementation of
PyErr_BadInternalCallto be more like the CPython headers, where it is a macro which accepts__FILE__and__LINE__information.