Re: [sage-devel] Re: Weak references in the coercion model

2018-12-06 Thread Jeroen Demeyer
On 2018-12-06 14:07, Simon King wrote: And if I understand correctly what you said in another post, it is *dynamically* determined which reference is weak and which reference is strong. When is it determined? During cyclic gc? Yes, during GC: that's the only time where it matters. More precisel

Re: [sage-devel] Re: Weak references in the coercion model

2018-12-06 Thread Jeroen Demeyer
On 2018-12-06 08:35, Simon King wrote: Then what will be your reference graph? Or phrased differently: Where/how will you store coercion maps? The basic idea is the following (I have not worked out all the details yet): * The coercion model only stores weak references to anything (domains, co

Re: [sage-devel] Re: Weak references in the coercion model

2018-12-05 Thread Jeroen Demeyer
On 2018-12-06 01:36, Nils Bruin wrote: Because the coercion map from A to B is also stored on A, a strong reference to B exists. No. The map will be referenced both from A and from B with one of those references weak and one of those references strong, without specifying a priori which one is

Re: [sage-devel] Re: Weak references in the coercion model

2018-12-05 Thread Nils Bruin
On Wednesday, December 5, 2018 at 1:53:07 PM UTC-8, Jeroen Demeyer wrote: > > > With my idea, the domain and codomain would be treated exactly the same: > my plan is to reference the map from both the domain and codomain in a > symmetric way. In that way, the lifetime of A wouldn't depend on C th

Re: [sage-devel] Re: Weak references in the coercion model

2018-12-05 Thread Jeroen Demeyer
On 2018-12-05 18:33, Nils Bruin wrote: I think you were thinking of limiting the life span of c via referencing it via a "MultiWeakRef" from both A and C. However, with the scenario above, A has its life span already bounded below by C anyway, so the "MultiWeakRef" never gets to work its magic.

Re: [sage-devel] Re: Weak references in the coercion model

2018-12-05 Thread Nils Bruin
On Wednesday, December 5, 2018 at 8:43:06 AM UTC-8, Jeroen Demeyer wrote: > > On 2018-12-05 14:54, Simon King wrote: > > o Mild problem: If there is an external strong reference to, say, > > f, then it is possible that Q becomes garbage collected anyway, > > and we would en

Re: [sage-devel] Re: Weak references in the coercion model

2018-12-05 Thread Jeroen Demeyer
On 2018-12-05 14:54, Simon King wrote: o Mild problem: If there is an external strong reference to, say, f, then it is possible that Q becomes garbage collected anyway, and we would end up with an invalid map. That is one of the things that I would like to fix: maps and ac

Re: [sage-devel] Re: Weak references in the coercion model

2018-12-05 Thread Jeroen Demeyer
On 2018-12-05 16:50, Volker Braun wrote: Right, automatic clearing of circular references is only in Python 3... I would phrase that as: properly dealing with __del__ is only in Python 3. Luckily, __del__ is used only very rarely in Sage. -- You received this message because you are subscribe

Re: [sage-devel] Re: Weak references in the coercion model

2018-12-05 Thread Volker Braun
Right, automatic clearing of circular references is only in Python 3... On Wednesday, December 5, 2018 at 9:06:39 AM UTC-5, E. Madison Bray wrote: > > On Wed, Dec 5, 2018 at 2:57 PM Simon King > wrote: > > > > > > > > Am Mittwoch, 5. Dezember 2018 13:38:03 UTC+1 schrieb Volker Braun: > >>

Re: [sage-devel] Re: Weak references in the coercion model

2018-12-05 Thread steven . craighead
Thanks for explaining it in detail. I used to have to chase large amounts of memory leaks and your discussion reminded me of that complex chase every two to three months which had to fit in our software release cycles. Sent from my iPhone > On Dec 5, 2018, at 3:50 AM, Simon King wrote: > > H

Re: [sage-devel] Re: Weak references in the coercion model

2018-12-05 Thread E. Madison Bray
On Wed, Dec 5, 2018 at 2:57 PM Simon King wrote: > > > > Am Mittwoch, 5. Dezember 2018 13:38:03 UTC+1 schrieb Volker Braun: >> >> On Wednesday, December 5, 2018 at 6:52:55 AM UTC-5, Simon King wrote: >>> >>> - If there is a reference cycle involving one instance with a __del__ >>> method, then P

Re: [sage-devel] Re: Weak references in the coercion model

2018-12-04 Thread Steven Craighead
How difficult is it to create a stack that can control the order of objects being created and destroyed so you prevent leaks? Can you add a new method on your base class that is inherited to all children to track this? Sent from my iPad > On Dec 4, 2018, at 6:54 PM, David Roe wrote: > > >

Re: [sage-devel] Re: Weak references in the coercion model

2018-12-04 Thread David Roe
On Tue, Dec 4, 2018 at 9:06 PM wrote: > Would it be advisable to change the base programming language to one that > does automatic garbage collection instead of having to check to see if a > class has been properly disposed like it appears from all of these related > bugs? > I can't tell if you'

Re: [sage-devel] Re: Weak references in the coercion model

2018-12-04 Thread steven . craighead
Would it be advisable to change the base programming language to one that does automatic garbage collection instead of having to check to see if a class has been properly disposed like it appears from all of these related bugs? Sent from my iPhone > On Dec 4, 2018, at 12:44 PM, Jeroen Demeyer

Re: [sage-devel] Re: Weak references in the coercion model

2018-12-04 Thread Jeroen Demeyer
On 2018-12-04 18:06, Nils Bruin wrote: Tripledict does that to some extent (with its keys): if one of the key parts gets deallocated, the weakref callback removes the strong reference to the value. Yes, but then we potentially end up again in the situation where things are *only* weakly refere

Re: [sage-devel] Re: Weak references in the coercion model

2018-12-04 Thread Nils Bruin
On Tuesday, December 4, 2018 at 1:50:19 AM UTC-8, Jeroen Demeyer wrote: > > On 2018-12-03 17:21, Nils Bruin wrote: > > In order to > > make that possible, the coercion map (referenced strongly on the > > codomain -- it needs to be strongly referenced somewhere to keep it > > alive) must not hol

Re: [sage-devel] Re: Weak references in the coercion model

2018-12-04 Thread Jeroen Demeyer
On 2018-12-03 17:21, Nils Bruin wrote: In order to make that possible, the coercion map (referenced strongly on the codomain -- it needs to be strongly referenced somewhere to keep it alive) must not hold a strong ref to the domain. I wonder if there is a way to somehow reference an object from