Cleanup internals for garbage-collected `py::class_` objects
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 18k
- Forks
- 2.3k
- Avg merge
- 5d 17h
- Merged PRs (30d)
- 10
Description
In case we'd forget, @EricCousineau-TRI made some good remarks on #2564, that we should still attend to:
Not sure if it'd be easily addressable, but there may be lingering references from other types here:
e.g. you're freeing type A, but type B has a conversion related to that type
implicit_castslooks like it's only used for MI, so by construction I don't think you'd have a dangling parent base.direct_conversionslooks like it's only used for NumPy dtypesimplicit_conversionslooks like it requires that both types be alive, so also should be fine. However, you may have unbounded memory growth (e.g. multiple registrations for a re-registered C++ class)
So yeah, looks like everything is fine. Just may want to make a minor note on implicit_conversiosn being unbounded; however, it's unlikely that unbounded growth will matter much? (unless someone likes running the GC every 30sec for 24hrs?)
Originally posted by @EricCousineau-TRI in https://github.com/pybind/pybind11/pull/2564#discussion_r504003987
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with include/pybind11/detail/internals.h at the referenced lines and read PR #2564, then trace how implicit_casts, direct_conversions, and implicit_conversions retain type references. Done means determining whether garbage-collected py::class_ objects can leave dangling or unbounded conversion entries and recording the justified cleanup or note.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- devtools
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100