Hi Nicolas, Sorry, I have seen your post only now.
On 7 Okt., 23:06, "Nicolas M. Thiery" <nicolas.thi...@u-psud.fr> wrote: > It would not be quite surprising if the pickling of classes made some > progress since 2009 :-) However, just to make sure: please save the > pickle to a file, and reload it in a fresh Sage session. I tested. Unpickling from a file using the new version was possible, preserving uniqueness of the class. That even holds if the file was created with the old version. > That being said, this way of pickling still has an issue: it exposes > the hierarchy of classes instead of encapsulating it. That's right. > Hence, if one > later updates the hierarchy of categories (say by inserting an > intermediate category, or adding a ParentMethods class that did not > exist before), the hierarchy that will be recreated from an old pickle > won't coincide with the new one. If I am not mistaken, ParentMethods exists for any category. Hence, "adding a ParentMethods class" would probably just mean "modifying an existing ParentMethods class". That would be no problem for unpickling (I just tested it practically, it works). However, you are right that a change in the hierarchy of classes will be ignored when unpickling a parent class that was pickled before that change. I know a trick that combines the old way of pickling with the desired independence from the base ring: 1. The lazy attribute C.parent_class could start with constructing a dynamic class without specifying the reduction data. In particular, the reduction data will not be part of the cache key. 2. Before returning the dynamic class, the lazy attribute overrides the default reduction data with `getattr, (self,"parent_class")`. Hence, the parent classes of Algebras(GF(3)) and Algebras(GF(5)) will coincide. It may happen that Algebras(GF(3)).parent_class is pickled as Algebras(GF(5)).parent_class. But since both classes coincide (and will coincide even when inserting new categories), unpickling would still be fine. That way of pickling would only break, if we have two categories C1, C2, such that C1.parent_class and C2.parent_class coincide in sage-4.7.3, but differ in later Sage versions. I deem that to be very unlikely. Cheers, Simon -- You received this message because you are subscribed to the Google Groups "sage-combinat-devel" group. To post to this group, send email to sage-combinat-devel@googlegroups.com. To unsubscribe from this group, send email to sage-combinat-devel+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sage-combinat-devel?hl=en.