osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RFC: Proposal: Deterministic Object Destruction


On Monday, March 5, 2018 at 6:38:49 AM UTC, Mark Lawrence wrote:
> On 05/03/18 01:01, Ooomzay wrote:
> > On Sunday, 4 March 2018 23:57:24 UTC, Mark Lawrence  wrote:
> >> On 04/03/18 02:28, Ooomzay wrote:
> >>> On Friday, 2 March 2018 15:37:25 UTC, Paul  Moore  wrote:
> >>> [snip]
> >>>>       def fn():
> >>>>           for i in range(10000):
> >>>>               with open(f"file{i}.txt", "w") as f:
> >>>>                   f.write("Some text")
> >>>>
> >>>> How would you write this in your RAII style - without leaving 10,000
> >>>> file descriptors open until the end of the function?
> >>>    
> >>>       def fn():
> >>>           for i in range(10000):
> >>>               f = RAIIFile(f"file{i}.txt", "w")
> >>>               f.write("Some text")
> >>>
> > 
> >> Over my dead body.
> > 
> > Care to expand on that?
> > 
> 
> Sure, when you state what you intend doing about reference cycles, which 
> you've been asked about countless times.

Nothing. No change whatever. As I stated in my second post ref cycles are orthogonal to this PEP. 

If you want to use RAII objects then you will make sure you avoid adding them to orphan cycles by design. If you don't know how to do that then don't write applications that manage critical resources.