#14912: UniqueRepresentation tutorial could use more love
--------------------------------------------+--------------------
       Reporter:  darij                     |         Owner:
           Type:  defect                    |        Status:  new
       Priority:  major                     |     Milestone:
      Component:  documentation             |    Resolution:
       Keywords:  documentation, structure  |     Merged in:
        Authors:                            |     Reviewers:
Report Upstream:  N/A                       |   Work issues:
         Branch:                            |  Dependencies:
       Stopgaps:                            |
--------------------------------------------+--------------------

Comment (by SimonKing):

 I think both `sage.structure.unique_representation` and
 `sage.structure.factory` need more care.

 Certainly it is a severe fault that `GF(...)` appears as example of
 `UniqueRepresentation`.

 And I think both parts of the documentation should give hints on when to
 use `UniqueRepresentation` and when to use `UniqueFactory`.

 For example, a `UniqueFactory` can return different implementations of the
 same algebraic structure, depending on the input data. This would be
 impossible (or at least not so easily possible) with
 `UniqueRepresentation`. And you would not be able to use
 `UniqueRepresentation` with a cdef class---you can define your class in a
 pyx file, but it has to be `class Foo(UniqueRepresentation, ...)`, not
 `cdef class Foo(UniqueRepresentation, ...)`, simply since
 `UniqueRepresentation` uses meta-classes, which is not possible in a cdef
 class, if I am not mistaken (and of course, multiple inheritance does not
 work yet in Cython, and after all `UniqueRepresentation` is a python
 class.

 These are reasons for using a factory.

 On the other hand, using `UniqueRepresentation` would automatically
 provide your class with very fast hash and comparison methods implemented
 in Cython (`UniqueRepresentation` is a Python class, but also inherits
 from the Cython class `sage.misc.fast_methods.WithEqualityById`). If you
 use a factory instead, you'd need to take care of hash and comparison all
 by yourself---and this means: It is possible that a `UniqueFactory`
 returns objects that are ''not'' unique parents!! And moreover, using
 `UniqueRepresentation` is very easy---in most cases, it is enough to take
 an existing class and add `UniqueRepresentation` as base.

 So, these are reasons for using a unique representation.

--
Ticket URL: <http://trac.sagemath.org/ticket/14912#comment:7>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" 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-trac.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to