Re: Deterministic destruction and RAII idioms in Python
- From: plahey@xxxxxxxxxxxxxxxxxx
- Date: 30 Jan 2006 19:56:19 -0800
Hi Paul,
> I didn't understand then. I thought by "deterministic destruction"
> you meant relying on what CPython does now, which is reference
> counting with destruction when the last reference is released.
I effectively do mean that. In C++ it is guaranteed that a destructor
will be called on an object when it goes out of scope, no matter how
that happens (normal exit, exception, etc...). C++-style RAII just
refers to wrapping up resources in classes so that you don't need to
worry about explicitly freeing them.
> I do remember thinking C++ RAII
> was a nuisance because you had to create classes with destructors to
> do what other languages did with try/finally or the equivalent.
It really depends how often you have to deal with getting/releasing
resouces. You can define a class once and then just deal the resource
in your code with a single line (creating the object). It can also
simplify things when you are dealing with the simultaneous management
of multiple resources. In any case, this is now getting off topic.
Thanks for your input! It was fun.
.
- References:
- Deterministic destruction and RAII idioms in Python
- From: plahey
- Re: Deterministic destruction and RAII idioms in Python
- From: plahey
- Re: Deterministic destruction and RAII idioms in Python
- From: Paul Rubin
- Re: Deterministic destruction and RAII idioms in Python
- From: plahey
- Re: Deterministic destruction and RAII idioms in Python
- From: Paul Rubin
- Deterministic destruction and RAII idioms in Python
- Prev by Date: Re: Can a test case tell if VERBOSE is used in pyunit test?
- Next by Date: Re: beta.python.org content
- Previous by thread: Re: Deterministic destruction and RAII idioms in Python
- Next by thread: Module imports
- Index(es):
Relevant Pages
|