RFC: Proposal: Deterministic Object Destruction

Ooomzay ooomzay at gmail.com
Sat Mar 3 21:01:30 EST 2018


On Saturday, 3 March 2018 17:44:08 UTC, Chris Angelico  wrote:
> On Sun, Mar 4, 2018 at 4:37 AM, Richard Damon <Richard at damon-family.org> 
> > Yes, stack allocated object in C++ have a nice lifetime to allow RAII to
> > work, but it doesn't just work with stack allocated objects. A lot of RAII
> > objects are members of a class object that may well be allocated on the
> > heap, and RAII makes sure that all the needed cleanup gets done when that
> > object gets destroyed.
> 
> How do you guarantee that the heap object is properly disposed of when
> you're done with it? Your RAII object depends 100% on the destruction
> of the heap object.

Smart pointers (unique_ptr and friends) are used to manage heap object lifecycles n . These are analogous to python object references.



More information about the Python-list mailing list