Skip to content

more cleanup of private FFI definitions#6042

Open
davidhewitt wants to merge 5 commits into
PyO3:mainfrom
davidhewitt:private-cleanup-3
Open

more cleanup of private FFI definitions#6042
davidhewitt wants to merge 5 commits into
PyO3:mainfrom
davidhewitt:private-cleanup-3

Conversation

@davidhewitt
Copy link
Copy Markdown
Member

Another batch of FFI cleanups following #5965

I added --document-private-items to the ffi-check rustdoc processing; this didn't catch functions (which I hoped it would) but it noticed that the PyTracebackObject definition did not expose the fields.

I also adjusted the implementation of PyErr_BadInternalCall to be more like the CPython headers, where it is a macro which accepts __FILE__ and __LINE__ information.

Comment thread pyo3-ffi/src/lib.rs
Comment on lines +391 to +394
$pub struct $name {
_data: (),
_marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>,
}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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.

@davidhewitt davidhewitt mentioned this pull request May 13, 2026
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 13, 2026

Merging this PR will improve performance by 27.94%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 29 improved benchmarks
✅ 96 untouched benchmarks

Performance Changes

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)

Open in CodSpeed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant