Boost.Python: getting a weak python reference to a wrapped C ++ object

I wrapped a C ++ class using Boost.Python. These objects have strong links (boost :: shared_ptr) on the C ++ side, and there may be short-term links in Python. So far, everything is working well. However, if I create a weak python link from one of the strong links, that weak link is deleted as soon as the last python link disappears. I would like the weak link to stay alive until the last strong link to C ++ disappears. Can this be achieved?

Got another way: is there a way to find out from python if there is still a specific C ++ object (completed by Boost.Python)?

+6
source share
1 answer

How do you keep a "Strong C ++ Link" for a wrapped class?

I'm pretty rusty on python boost, but I believe this is a boost :: shared_ptr deleter event that provides lifecycle management.

If this is not a problem, you probably need to hold the instance in C ++ in boost :: python :: object.

+1
source

All Articles