#11900: Serious regression caused by #9138
---------------------------+------------------------------------------------
   Reporter:  SimonKing    |          Owner:  tbd                  
       Type:  defect       |         Status:  new                  
   Priority:  blocker      |      Milestone:  sage-4.7.2           
  Component:  performance  |       Keywords:  categories regression
Work_issues:               |       Upstream:  N/A                  
   Reviewer:               |         Author:  Simon King           
     Merged:               |   Dependencies:  #9138                
---------------------------+------------------------------------------------
Changes (by newvalueoldvalue):

  * dependencies:  => #9138
  * author:  => Simon King


Comment:

 I have attached a preliminary patch, if someone already wants to have a
 look. I need to do more tests (and run doctests), but up to now it seems
 that it fixes the regression.

 '''__Changes for Matrix Spaces__'''

 Matrix spaces will not make use of the category framework by default. But
 I introduced a new method that makes them use the category framework after
 initialisation:
 {{{
             sage: MS = MatrixSpace(QQ,8)
             sage: TestSuite(MS).run()
             Failure in _test_category:
             Traceback (most recent call last):
             ...
             AssertionError: category of self improperly initialized
             ------------------------------------------------------------
             The following tests failed: _test_category
             sage: type(MS)
             <class 'sage.matrix.matrix_space.MatrixSpace_generic'>
             sage: MS.full_category_initialisation()
             sage: TestSuite(MS).run()
             sage: type(MS)
             <class
 'sage.matrix.matrix_space.MatrixSpace_generic_with_category'>
 }}}

 Minor change: I made `__matrix_class` a lazy attribute.

 '''__Changes for categories__'''

 I turn `hom_category` in a cached method - the result is cached anyway,
 and thus it makes sense to cache as early as possible, in order to reduce
 the overhead, and in order to benefit from #11115.

 I also cache the class method `category_of` in
 sage.categories.covariant_functorial_construction. According to a
 commented-out line, caching has been attempted anyway, but since it needs
 to be a class method, caching has not been possible by simply using a
 decorator.

 '''__Vectors__'''

 I added custom `list()` methods for both integral and rational dense
 vectors. Here is the speed difference (the timing is with patch attached):
 {{{
 sage: v = vector(ZZ,range(100))
 sage: %timeit L = v.list()
 625 loops, best of 3: 11 µs per loop
 # was 17 µs per loop in sage-4.7.2.alpha2
 sage: v = vector(QQ,range(100))
 sage: %timeit L = v.list()
 625 loops, best of 3: 24 µs per loop
 # was 27.7 µs per loop in sage-4.7.2.alpha2
 }}}
 The difference is small, but one should benefit from it.

 '''__Doc formatting__'''

 I corrected some wrong formatting in the documentation of dense integral
 and rational vectors.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/11900#comment:13>
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to