[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.
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 |
konstin
left a comment
There was a problem hiding this comment.
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?