About getter generates new instances #3937
Answered
by
davidhewitt
minsungkim-qraft
asked this question in
Questions
-
Let's consider following code. #[pyclass]
pub struct Container {
#[pyo3(get)]
pub internal: Vec<i64>,
}
#[pymethods]
impl Container {
#[staticmethod]
pub fn dummy() -> PyResult<Self> {
Ok(Container { internal: (0..10).collect() })
}
} and imagine if you try to manipulate container = Container.dummy()
print(container.internal)
container.internal.append(10)
print(container.internal) and if you run the code, you will see identical two lines on the terminal. In other words, 10 is not appended.
|
Beta Was this translation helpful? Give feedback.
Answered by
davidhewitt
Mar 22, 2024
Replies: 1 comment
-
Sorry for the slow reply. In answer to your questions:
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
minsungkim-qraft
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sorry for the slow reply. In answer to your questions: