#16384: Multiplication of additive semigroup elements by integers
-------------------------------------+-------------------------------------
       Reporter:  nthiery            |        Owner:
           Type:  enhancement        |       Status:  new
       Priority:  major              |    Milestone:  sage-6.3
      Component:  categories         |   Resolution:
       Keywords:                     |    Merged in:
        Authors:                     |    Reviewers:
Report Upstream:  N/A                |  Work issues:  failing tests, memory
         Branch:                     |  usage
  u/nthiery/categories/additive-     |       Commit:
  semigroups-intmul-16384            |  68d43b83000550b26ae1dcf2ee9f8e127f16fde2
   Dependencies:  #15801             |     Stopgaps:
-------------------------------------+-------------------------------------

Comment (by nthiery):

 Replying to [comment:7 vdelecroix]:
 > how much time before ticket `2^15` ?

 Given the acceleration, it might not be that long :-)

 > Why `__mul__` and `__rmul__` are implemented in the category and not in
 `element.pyx` like it is done for `ModuleElement` ? It is confusing and
 moreover, it is the kind of methods that must be fast.

 Because, due to the single inheritance limitation of Cython classes,
 the hierarchy of element classes in element.pyx is extremely limited,
 and will ever be. For example, there can be no class for elements of
 an additive magma. Well, there could be one, but RingElement could not
 inherit from it and from MonoidElement at the same time.

 The `*Element` hierarchy of classes is really only there to cover a
 few very common cases (elements of rings, ...) where speed can be
 critical. And we should only put there those methods where speed is
 critical. Note that the `__mul__` method implemented there take
 precedence over there counterparts in the categories.

 That being said, thanks to relatively recent progress in Cython, it's
 now possible to define a cython function and make it a method of a
 Python class/category by assigning it there (example courtesy of
 Robert Bradshaw):

 {{{
 %cython

 import cython
 @cython.binding
 def foo(*args):
     print args

 class A:
     x = foo
 a = A()
 print a.x(1, 2, 3)
 }}}

 With this, we still pay the price of a method call, but the execution
 of the method itself is fast. We could explore the use of this for the
 critical methods of categories.

 Cheers,
                                  Nicolas

--
Ticket URL: <http://trac.sagemath.org/ticket/16384#comment:8>
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/d/optout.

Reply via email to