On Wed, Feb 6, 2013 at 11:39 AM, Robert Bradshaw <[email protected]> wrote: > On Wed, Feb 6, 2013 at 11:07 AM, Simon King <[email protected]> wrote: >> PS: >> >> On 2013-02-06, Simon King <[email protected]> wrote: >>> But I wonder: It is a typical use case to add elements from A and B >>> frequently and not only once. Do we really want that the parent C may be >>> constructed repeatedly, unless the user keeps a manual strong reference >>> to C or disables garbage collection? > > It should be noted that it would only be reconstructed after each > garbage collection, not (likely) on every arithmetic operation. We > could also mitigate this by keeping a live list of the last N created > parents. > >> I think that keeping both A and B alive should prevent C from garbage >> collection, but keeping C alive should *not* prevent A and B from >> garbage collection. With #14058, it is the other way around. > > The hard part is preventing A and B from keeping each other alive. > >> Would it perhaps work to only keep a weak reference to the domains of >> (coercion and conversion) maps? After all, the purpose of a map is to >> map elements of the domain. But if we have elements of the domain, then >> the domain is kept alive, and hence only keeping a weak reference from >> map to domain is no problem. > > I'd like to avoid maps that may have garbage collected domains. I am > also wary of how easy it would be to accidentally store any references > to (elements of) the domain in the implementation; how badly would > that mess things up?
FWIW, #14072 keeps actions alive by using a reference to the newest parent. A similar approach could be used for morphisms (the newest, and most likely to be garbage collected, of (domain, codomain) keeps a reference to the morphism). - Robert -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sage-devel?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
