-
Notifications
You must be signed in to change notification settings - Fork 897
Closed
Description
I got an issue in rust-numpy repo today.
See the below code:
fn main() {
let v = vec![0; 100_000];
let gil = Python::acquire_gil();
let py = gil.python();
loop {
let py_arr = PyArray2::from_vec2(py, &vec![v.clone()]).unwrap();
();
// &PyArray2 drops and nothing happens
}
// GILGruard drops and Python objects are freed
}In such a case, I think most users assume that py_arr is freed when an iteration of the loop ends, but truly, it's freed after GILGuard drops.
So my suggestions are:
- We should have a document that clearly demonstrates objects are freed after
GILGuarddrops - How about adding a 'freed-after-drop' object wrapper? But I'm not sure we can do it.
inv2004
Metadata
Metadata
Assignees
Labels
No labels