Hi, Le vendredi 6 novembre 2015 00:16:26 UTC+1, Nils Bruin a écrit : > > On Thursday, November 5, 2015 at 2:35:57 PM UTC-8, Eric Gourgoulhon wrote: >> >> Yes charts are immutable: a chart is defined by two parameters, which are >> passed to the constructor: its domain (a manifold) and its coordinates (a >> list of symbolic variables). These two parameters do not change during the >> object life. I think that using UniqueRepresentation for charts is then >> well justified. Same thing for vector frames. >> > > It indicates they could be if they needed to be. However, making things > UniqueRepresentation or CachedRepresentation has a very real cost and makes > the job of the garbage collector *much* harder. You can get very subtle > memory leaks via weak references once global caches are involved. > > So what specifically do you *gain* from making them UniqueRepresentation? >
>From what you say, not much I presume... Actually, making charts UniqueRepresentation was a quick way to ensure both equality by id and passed _test_pickling. I understand that we should make them only EqualityById (and redefine _test_pickling). As you see from the above list of dictionaries, it is important to have fast __eq__ for charts and EqualityById is offering this. However, your example with NAN in the reply to Simon shows that dictionary lookup shortcuts equality testing on identical keys. If I understand correctly, this means that even if we had a slow __eq__ for charts, as soon as we write point._coordinates[X] with the chart X that is the same object as the one used to create the entry in the dictionary point._coordinates, then we would have fast access to the coordinates? Could this depend on the Python version/implementation? (i.e. can we rely on this for the future?). If yes, we may even abandon EqualityById for charts. > Is it ever the case that two charts are constructed independently from > each other (with the same construction parameters!) and that it is > important that the resulting charts are actually identical? > No, you are right. Given that one of the construction parameters is a manifold, which is going > to be EqualityById anyway, I expect this will not happen. It'll be much > more straightforward to look the chart up on the manifold (where it'll be > stored anyway, right? > Yes > ) if you need to retrieve it. > > > I won't claim that doing so is a good idea (in fact, it looks like a > horrible idea). However, there are other scenarios where this transposition > of index and indexee can be fruitful to consider. > > Thanks for these explanations. Best wishes, Eric. -- 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 http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.