Implement gc methods for subclasses of native type (set, dict) #5697
-
|
Hi, I am implementing subclasses of native types such as set and dict. The subclass store additional reference to Python object compared to the base type. As consequence I need to implement traverse and clear to go through those new references and also through the objects stored in the base class storage. My issue is that traverse and clear can only accept &self and &mut self and I do not see any way to call a super method or to manually visit the items. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
|
I did not try running more code in relation to that discussion but I gave it some more thoughts. For Would it make sense to add to pyo3 some helpers when subclassing builtin Python containers ? I could try to contribute such a feature but I would need some guidance. |
Beta Was this translation helpful? Give feedback.
-
|
Sorry for the late reply. I have a feeling based on the code I remember implementing that the PyO3 traverse wrappers will internally traverse the super-type for you, if you write a test do you find that the GC functions as intended without needing to traverse the supertype yourself? |
Beta Was this translation helpful? Give feedback.
Sorry for the late reply. I have a feeling based on the code I remember implementing that the PyO3 traverse wrappers will internally traverse the super-type for you, if you write a test do you find that the GC functions as intended without needing to traverse the supertype yourself?