Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pyproto: deprecate py_methods #1560

Merged
merged 1 commit into from
Apr 21, 2021

Conversation

davidhewitt
Copy link
Member

I've been thinking about #[pyproto] ergonomics for a while, prompted by questions like #1205, #1206, #1546 (comment), and confusion I often see by users on Gitter.

There are a few methods like __bytes__ which have no technical reason to be in #[pyproto], and in fact can already be implemented in #[pymethods]. (See #1205 (comment).) I think that #[pymethods] is much easier to understand and use than #[pyproto], so to make "one way" for users I propose in this PR to deprecate these #[pyproto] methods.

Copy link
Member

@kngwyu kngwyu left a comment

Choose a reason for hiding this comment

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

Thanks, good intermediate changes if we are going to refactor protocols.

guide/src/migration.md Outdated Show resolved Hide resolved
guide/src/migration.md Outdated Show resolved Hide resolved
guide/src/class/protocols.md Outdated Show resolved Hide resolved
@davidhewitt davidhewitt force-pushed the deprecate-pyproto-pymethods branch 3 times, most recently from 3772a38 to 41db537 Compare April 19, 2021 07:24
@davidhewitt
Copy link
Member Author

Thanks @kngwyu for the feedback. I've made some changes to the documentation based on your suggestions, it looks much better now!

@davidhewitt davidhewitt mentioned this pull request Apr 19, 2021
7 tasks
@davidhewitt davidhewitt merged commit eed1b1a into PyO3:main Apr 21, 2021
@ravenexp
Copy link
Contributor

I'd like to bring to your attention that the __bool__() method is currently included in the PyObjectProtocol trait, but the corresponding C API slot nb_bool is a part of the PyNumberMethods struct, which roughly corresponds to the PyNumberProtocol trait. I don't know why it is done this way, but you may also consider deprecating __bool__() from PyObjectProtocol and reintroducing it into PyNumberProtocol for consistency.

@davidhewitt davidhewitt deleted the deprecate-pyproto-pymethods branch April 26, 2021 22:01
@davidhewitt
Copy link
Member Author

Given that the current design decision in #1206 is that we might try completely replacing #[pyproto] with #[pymethods] for 0.15, I'm not going to bother moving __bool__ for now.

If we can't make that change work I agree there's a couple of methods like this which should be shuffled around.

@kngwyu
Copy link
Member

kngwyu commented Apr 27, 2021

I don't know why it is done this way,

https://docs.python.org/3/reference/datamodel.html#object.bool

Though I don't like this inconsistency, maybe this is the reason.

@ravenexp
Copy link
Contributor

Given that the current design decision in #1206 is that we might try completely replacing #[pyproto] with #[pymethods] for 0.15 ...

That would be sweet. I'm really looking forward to it.

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.

3 participants