Skip to content

Conversation

@davidhewitt
Copy link
Member

Following on from all the work we did in PyO3 0.26 to move API names to be less dependent on the GIL, this takes a first pass at documentation (particularly in the guide) to do similar.

There's probably more to do, however this is all I had time for today, and I figure it's probably easier for reviewers to have not too much of this in one go.

@codspeed-hq
Copy link

codspeed-hq bot commented Aug 31, 2025

CodSpeed Performance Report

Merging #5381 will not alter performance

Comparing davidhewitt:freethreading-doc (cf50af8) with main (aed320b)

Summary

✅ 91 untouched benchmarks
🆕 2 new benchmarks
⁉️ 2 dropped benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark BASE HEAD Change
🆕 clean_attach N/A 3.6 µs N/A
🆕 dirty_attach N/A 5.2 µs N/A
⁉️ clean_acquire_gil 3.6 µs N/A N/A
⁉️ dirty_acquire_gil 5.2 µs N/A N/A

Copy link
Contributor

@Icxolu Icxolu left a comment

Choose a reason for hiding this comment

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

Thanks for reworking this. I think our abstraction over GIL/free-threaded is coming together nicely. Just a couple of thoughts.

Class objects can be used as arguments to `#[pyfunction]`s and `#[pymethods]` in the same way as the self parameters of instance methods, i.e. they can be passed as:
- `Py<T>` or `Bound<'py, T>` smart pointers to the class Python object,
- `&T` or `&mut T` references to the Rust data contained in the Python object, or
- `PyRef<T>` and `PyRefMut<T>` reference wrappers.
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we also mention PyClassGuard here? Or do we wait with that until we deprecate PyRef eventually?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was wondering about it, I think it would be good to introduce PyClassGuard as part of 0.27 if we can figure out the way to sequence it in! I would prefer defer from this PR for the moment though.

Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com>
@davidhewitt davidhewitt added this pull request to the merge queue Aug 31, 2025
Merged via the queue into PyO3:main with commit 69d30d4 Aug 31, 2025
43 of 44 checks passed
@davidhewitt davidhewitt deleted the freethreading-doc branch August 31, 2025 15:14
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.

2 participants