Drop PyRef
and get associated PyCell
?
#3127
-
I am writing a pyclass where most methods accept If each method accepts Before calling from rust to python, I need to drop my Is there a way to drop a // Assume self_: PyRefMut<MyClass>
let cell: &PyCell<MyClass> = self_.release_borrow_and_get_pycell();
other_python_object.call_method1(py, "foo", (cell,))?; I tried to keep my question as brief as possible but I can add more detail about my use-case if it helps. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 10 replies
-
I don't think we have such a method. The best you can do is get a
I am not sure that the short-lived borrows can be avoided, but I think discussing the whole problem could only help to figure out if there are any alternative solutions. One slightly different approach might be to avoid |
Beta Was this translation helpful? Give feedback.
I don't think we have such a method. The best you can do is get a
Py<T>
back from thePyRef<T>
via aFrom
impl.I am not sure that the short-lived borrows can be avoided, but I think discussing the whole problem could only help to figure out if there are any alternative solutions.
One slightly different approach might be to avoid
PyCell
completely using afrozen
#[pyclass]
and use a more fine-grained approach to interior mutability, i.e. all your methods take&self
and your individual fields implement int…