pyo3
pyo3 copied to clipboard
Guide docs for all protocol methods
Just thinking that for the guide it would be nice to add a table to the #[pyproto] section listing all the dunder methods that can be implemented and the protocols they are a part of (e.g. __int__ -> PyNumberProtocol etc.)
Please note for anyone who looks at this that the #[pyproto] methods are planned to be merged into #[pymethods], see #1206
After #[pymethods] are ready, the docs we need will probably be very similar to these excellent ones for Cython: https://cython.readthedocs.io/en/latest/src/userguide/special_methods.html
I volunteer for that.
Thanks! I think @mejrs also expressed desire to write something in #1864 ? You might want to double-check you don't end up duplicating effort.
I'm leaning towards this:
- A table at https://pyo3.rs/main/doc/pyo3/attr.pymethods.html summarizing all the dunders like https://cython.readthedocs.io/en/latest/src/userguide/special_methods.html#special-method-table
- Examples in the guide, like https://pyo3.rs/main/class.html?#callable-objects We might want to structure that in a different way .e.g. a chapter for each protocol.
Sounds good to me. There is extensive material on the Python side on how these protocols work, and we should mainly state what we support and what the Rust/PyO3-specific snags are.
We now have https://pyo3.rs/v0.20.0/class/protocols, plus some more detailed examples by @mejrs and @birkenfeld for specific protocols. I'm going to close this one as resolved, though of course more documentation improvements are always possible!