pybind / pybind/pybind11

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

Open
#2,757 0 comments 0 reactions 1 assignee View on GitHub

@EricCousineau-TRI is already working on this.

Since Dec 30, 2020.

holders
Dominant language
C++
Stars
18k
Forks
2.3k
Avg merge
5d 17h
Merged PRs (30d)
10

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.