-
Notifications
You must be signed in to change notification settings - Fork 726
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
[NEED DISCUSSION] Remove #[init] attribute #658
Conversation
pyo3-derive-backend/src/method.rs
Outdated
res = Some(FnType::FnInit) | ||
return Err(syn::Error::new_spanned( | ||
name, | ||
"#[init] is duplicated from PyO3 0.9.0!", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be #[init] is removed from PyO3 0.9.0!
? Since #[init]
was never working I think we don't have to return an error.
It is very unusual from a Python perspective to always implement Per this comment which @Alexander-N mentioned in #651, I guess I understand why it would be more common in Rust to implement I definitely think additional discussion would be useful, because I'm just not familiar enough with the use cases for Rust-backed Python classes to know when you'd actually want an It may be worth looking at C extensions and standard library modules that define both |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know much about #[init]
so I can't help with that decision.
@pganssle |
Looks C/C++ libraries adopt an opposite approach to us.
However, it is really not Rustic way to do so, as dgrunwald mentioned in this comment. |
Yeah, Rust has RAII and allocating an object without initializing it would be highly unsafe, especially for dropable values. |
I'm fully on board with the idea that Rust objects should be initialized with |
Thanks for all comments. |
See #651 for detail.
Now we can override
__init__
function of pyclasses, by.
But this feature is not very popular and confusing since we mainly use
#[new]
.So I think this feature should be removed.
Our proc-macro code tends to be complicated, so make it as simple as possible is important.
Any idea?