Assign ownership of Python-constructed object to C++ runtime
I am pondering trying to eliminate some usages of shared pointers in my code since I have finally completed enough of it that I have good ownership rules for things in place. I still have one spot, which is basically the main door to the C++ runtime, where I have a problem. I've been creating instances of some objects in Python, with the purpose of assigning to another object for safekeeping. Really that other object is what I have in mind for managing everything about these objects--including their runtimes. But I see the objects get destroyed when the Python declaration for them go out of scope. That would normally be the right thing. I'm trying to think of alternatives. The best I can think of is to use a static factory method instead that returns an internal reference. I'm intend to experiment with that now but I am wondering if there are some other things to consider instead.
Inevitably somebody will ask why I'm doing away with the shared pointers. I have some cycles due to communication that means a lot of stuff never actually gets deleted due to the reference-counting methodology in them. When I used weak references, I found they were getting deleted too eagerly. And by this point, I otherwise have gotten an ownership hierarchy down.