Hi Simon, On 2017-10-09, Simon Brandhorst <sbrandho...@web.de> wrote: > "While *parents* are unique, equal *elements* of a parent in Sage are not > necessarily identical. " > in > http://doc.sagemath.org/html/en/tutorial/tour_coercion.html
Indeed that's too strict, IMHO. In http://doc.sagemath.org/html/en/thematic_tutorials/coercion_and_categories.html, I wrote "You are encouraged to make your parent “unique”." and "Making parents unique can be quite important for an efficient implementation, because the repeated creation of “the same” parent would take a lot of time." Moreover, when using non-unique parents, one has to take care to avoid problems with coercion. > So uniqueness is not strict. But when is a parent supposed to be unique and > when not? There were cases where unique parents gave rise to memory leaks: If parents are unique, they need to be stored somewhere. And even when using a weak value dictionary for that (which we of course do), it can be tricky to avoid reference chains that prevent stuff from being garbage collected. As a rule of thumb: If the uniqueness condition is easy, then it is a good idea to have unique parents. But certainly you should avoid that a very costly isomorphism test of some sort is performed whenever you create a parent. Cheers, Simon -- 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 sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.