Hi Robert, William, On Wed, Mar 04, 2009 at 01:43:23AM -0800, Robert Bradshaw wrote: > On Mar 3, 2009, at 9:10 PM, Nicolas M. Thiery wrote: > > Dear Sage developers, > > > > Let me recycle this thread to report progress on the bookshelf of > > standard object behavior. I just posted a small patch: > > > > http://sagetrac.org/sage_trac/ticket/5120#comment:3 > > > > which implements sage.structure.UniqueRepresentation class. Derived > > classes inherit a unique representation behavior for their instances. > > Originates from sage.categories.category.uniq with: > > > > - Long doc (6 pages for 12 lines of code) > > - Default implementation of__eq__ and __hash__ > > - Handling of pickling in the simple cases > > - Avoids multiple calls to __init__ > > - Enables rewritings of the constructor argument > > > > This is a call for comments! (and reviews). > > > > If the principle is validated, it could be worthwhile to use it quite > > systematically for parents. > > I am a huge fan of uniqueness of parents. > > Any comments on how this relates to the code at http:// > hg.sagemath.org/sage-main/file/b0aa7ef45b3c/sage/structure/factory.pyx ?
Thanks for the pointer! There definitely a feature overlap, but not complete. UniqueRepresentation can be used by inheritance which has two advantages: - Setting up a policy for a full hierarchy of classes (for example, I will be able to enforce the policy that all CombinatorialFreeModule's have unique representation. Or I did take the decision that all categories have unique representation; well, this later decision deserves debate, but that's another story) - Hiding this as an implementation detail, and presenting a single gadget to the user, so that he can do: bla = Bla(x) isinstance(bla, Bla) rather than: bla = Bla(x) isinstace(bla, Bla_class) (no class name digging) On the other hand, there are a couple cool features only in UniqueFactory, and UniqueFactory has use cases not covered by UniqueRepresentation. So I think both should live (and be used systematically!!!), but features should be merged as much as possible. William: would you have time to work on this with me next week at MSRI? Cheers, Nicolas -- Nicolas M. ThiƩry "Isil" <nthi...@users.sf.net> http://Nicolas.Thiery.name/ --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---