-
Notifications
You must be signed in to change notification settings - Fork 795
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
Setting nested field #2104
Comments
This is not possible to change with the structs as defined. On attribute access, PyO3 must clone the member (in this case If you need such hierarchies to work, you need to make at least the |
@birkenfeld so, no support for types that are copied by default like ints |
Not sure what you mean here? An int is immutable anyway, so this is no issue for ints. |
In this case an int is passed by value, so there's no need to reference count / use |
is the same as
and in the first line PyO3 clones the If |
See also #1358. I'd love to make this more ergonomic one day! |
Bug Description
With those 2 definitions:
You can do (in a python script):
The workaround would be to set
alpha.beta
intotestlib.Beta(field=2)
, but this style does not scale well with multiple fields and more nested ones.Steps to Reproduce
pip3 install .
python3 usage.py
should print 1 and 1 instead of 1 and 2Backtrace
No response
Your operating system and version
Ubuntu 20.04.3 LTS
Your Python version (
python --version
)Python 3.8.10
Your Rust version (
rustc --version
)rustc 1.58.0 (02072b482 2022-01-11)
Your PyO3 version
0.15.1
How did you install python? Did you use a virtualenv?
apt
Additional Info
No response
The text was updated successfully, but these errors were encountered: