Re: RFC: Proposal: Deterministic Object Destruction (Posting On Python-List Prohibited)

2018-03-07 Thread Chris Angelico
On Thu, Mar 8, 2018 at 5:17 AM, Ooomzay wrote: > On Thursday, 1 March 2018 22:44:59 UTC, Rob Gaddi wrote: >> On 03/01/2018 02:24 PM, Lawrence D’Oliveiro wrote: >> > On Thursday, March 1, 2018 at 6:44:39 PM UTC+13, Paul Rubin wrote: >> >> DOM trees are a classic example (see the various DOM module

Re: RFC: Proposal: Deterministic Object Destruction (Posting On Python-List Prohibited)

2018-03-07 Thread Ooomzay
On Thursday, 1 March 2018 22:44:59 UTC, Rob Gaddi wrote: > On 03/01/2018 02:24 PM, Lawrence D’Oliveiro wrote: > > On Thursday, March 1, 2018 at 6:44:39 PM UTC+13, Paul Rubin wrote: > >> DOM trees are a classic example (see the various DOM modules in the > >> Python stdlib). Non-leaf nodes have a

Re: RFC: Proposal: Deterministic Object Destruction (Posting On Python-List Prohibited)

2018-03-03 Thread Gregory Ewing
Richard Damon wrote: The idea was to have a way to mark that certain classes/objects request that they are reference counted so they get the __del__ called as soon as the last reference goes away, without needing to require that overhead for all objects in all implementations. That could be

Re: RFC: Proposal: Deterministic Object Destruction (Posting On Python-List Prohibited)

2018-03-03 Thread Gregory Ewing
Steven D'Aprano wrote: Not just the class __dict__. You would have to do a full search of the MRO looking for any superclass which defines such methods. That could be reduced a lot by making it a type slot. But it would still increase the overhead of every refcount change by at least a factor o

Re: RFC: Proposal: Deterministic Object Destruction (Posting On Python-List Prohibited)

2018-03-03 Thread Gregory Ewing
Paul Rubin wrote: Richard Damon writes: a class to define member functions like __ref__ and __unref__ (or perhaps some other name) that if defined, would be called every time a name was bound or unbound to an object? That sounds horrendous and wouldn't handle the case of a list element creat

Re: RFC: Proposal: Deterministic Object Destruction (Posting On Python-List Prohibited)

2018-03-03 Thread Richard Damon
On 3/3/18 6:57 PM, Steven D'Aprano wrote: On Sat, 03 Mar 2018 10:01:43 -0700, Ian Kelly wrote: On Sat, Mar 3, 2018 at 9:19 AM, Richard Damon wrote: One idea does come to mind though, would it be reasonable, and somewhat Pythonic, for a class to define member functions like __ref__ and __unref

Re: RFC: Proposal: Deterministic Object Destruction (Posting On Python-List Prohibited)

2018-03-03 Thread Steven D'Aprano
On Sat, 03 Mar 2018 10:01:43 -0700, Ian Kelly wrote: > On Sat, Mar 3, 2018 at 9:19 AM, Richard Damon > wrote: >> One idea does come to mind though, would it be reasonable, and somewhat >> Pythonic, for a class to define member functions like __ref__ and >> __unref__ (or perhaps some other name) t

Re: RFC: Proposal: Deterministic Object Destruction (Posting On Python-List Prohibited)

2018-03-03 Thread Chris Angelico
On Sun, Mar 4, 2018 at 3:19 AM, Richard Damon wrote: > One idea does come to mind though, would it be reasonable, and somewhat > Pythonic, for a class to define member functions like __ref__ and __unref__ > (or perhaps some other name) that if defined, would be called every time a > name was bound

Re: RFC: Proposal: Deterministic Object Destruction (Posting On Python-List Prohibited)

2018-03-03 Thread Chris Angelico
On Sun, Mar 4, 2018 at 3:19 AM, Richard Damon wrote: > On 3/3/18 9:03 AM, Ian Kelly wrote: >> >> On Fri, Mar 2, 2018 at 9:57 PM, Gregory Ewing >> wrote: >>> >>> Paul Rubin wrote: So you want the programmer to put more head scratching into figuring out which reference should be stro

Re: RFC: Proposal: Deterministic Object Destruction (Posting On Python-List Prohibited)

2018-03-03 Thread Ian Kelly
On Sat, Mar 3, 2018 at 9:19 AM, Richard Damon wrote: > One idea does come to mind though, would it be reasonable, and somewhat > Pythonic, for a class to define member functions like __ref__ and __unref__ > (or perhaps some other name) that if defined, would be called every time a > name was bound

Re: RFC: Proposal: Deterministic Object Destruction (Posting On Python-List Prohibited)

2018-03-03 Thread Richard Damon
On 3/3/18 9:03 AM, Ian Kelly wrote: On Fri, Mar 2, 2018 at 9:57 PM, Gregory Ewing wrote: Paul Rubin wrote: So you want the programmer to put more head scratching into figuring out which reference should be strong and which should be weak? Also, sometimes weak references don't really solve th

Re: RFC: Proposal: Deterministic Object Destruction (Posting On Python-List Prohibited)

2018-03-03 Thread Ian Kelly
On Fri, Mar 2, 2018 at 9:57 PM, Gregory Ewing wrote: > Paul Rubin wrote: >> >> So you want the programmer to put more head scratching into figuring out >> which reference should be strong and which should be weak? > > > Also, sometimes weak references don't really solve the > problem, e.g. if you

Re: RFC: Proposal: Deterministic Object Destruction (Posting On Python-List Prohibited)

2018-03-02 Thread Gregory Ewing
Paul Rubin wrote: So you want the programmer to put more head scratching into figuring out which reference should be strong and which should be weak? Also, sometimes weak references don't really solve the problem, e.g. if you have a graph where you can't identify any particular node as a "root"

Re: RFC: Proposal: Deterministic Object Destruction (Posting On Python-List Prohibited)

2018-03-02 Thread ooomzay
On Friday, March 2, 2018 at 1:59:02 AM UTC, Lawrence D’Oliveiro wrote: > On Friday, March 2, 2018 at 1:03:08 PM UTC+13, ooo...@gmail.com wrote: > > On Thursday, March 1, 2018 at 11:51:50 PM UTC, Lawrence D’Oliveiro wrote: > >> On Friday, March 2, 2018 at 12:39:01 PM UTC+13, ooo...@gmail.com wrote:

Re: RFC: Proposal: Deterministic Object Destruction (Posting On Python-List Prohibited)

2018-03-01 Thread ooomzay
On Thursday, March 1, 2018 at 11:51:50 PM UTC, Lawrence D’Oliveiro wrote: > On Friday, March 2, 2018 at 12:39:01 PM UTC+13, ooo...@gmail.com wrote: > > class RAIIFileAccess(): > > '''File Access-like Resource using [RAII] idiom''' > > > > ... > > > > def __del__(self): > >

Re: RFC: Proposal: Deterministic Object Destruction (Posting On Python-List Prohibited)

2018-03-01 Thread Rob Gaddi
On 03/01/2018 02:24 PM, Lawrence D’Oliveiro wrote: On Thursday, March 1, 2018 at 6:44:39 PM UTC+13, Paul Rubin wrote: DOM trees are a classic example (see the various DOM modules in the Python stdlib). Non-leaf nodes have a list of child nodes, child nodes have pointers back upwards to their pa