Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should investigate usage of py::wraper<> trampoline shim with GC garbage collection (to prevent inheritance slicing) #2757

Open
EricCousineau-TRI opened this issue Dec 30, 2020 · 0 comments
Assignees
Labels
holders Issues and PRs regarding holders

Comments

@EricCousineau-TRI
Copy link
Collaborator

EricCousineau-TRI commented Dec 30, 2020

Motivation

Towards #1333 (as part of the larger umbrella of #2646), this is meant to be my recording of investigating a py::wrapper<> shim trampoline with "resurrection" via the Python garbage collection.

Proof of Concept

I have a working proof-of-concept that is used for in a fork of pybind11 - see RobotLocomotion/pybind11:README_DRAKE.md.

The primary points to see are:

Drawbacks

  • This approach is a bit messy, as it's from me "just making" things work for our library (Drake).
  • As shown above, CPython 3.8 (and possibly 3.7.5+), we are unable to resurrect an object more than once.

Additional Notes

This may not be the best mechanism to prevent slicing. Willi be listing other mechanisms (i.e. PRs / suggestions from others).

External References

\cc @rhaschke @rwgk @YannickJadoul

@EricCousineau-TRI EricCousineau-TRI added the holders Issues and PRs regarding holders label Dec 30, 2020
@EricCousineau-TRI EricCousineau-TRI changed the title Should investigate usage of py::wraper<> trampoline shim with GC garbage collection Should investigate usage of py::wraper<> trampoline shim with GC garbage collection (to prevent inheritance slicing) Dec 30, 2020
@EricCousineau-TRI EricCousineau-TRI self-assigned this Dec 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
holders Issues and PRs regarding holders
Projects
None yet
Development

No branches or pull requests

1 participant