#10513: Coercion and category framework for modules
-------------------------------------+-------------------------------------
       Reporter:  SimonKing          |        Owner:  robertwb
           Type:  defect             |       Status:  needs_work
       Priority:  major              |    Milestone:  sage-pending
      Component:  coercion           |   Resolution:
       Keywords:  coercion,          |    Merged in:
  category framework, modules        |    Reviewers:  Jean-Pierre Flori
        Authors:  Simon King, Peter  |  Work issues:
  Bruin                              |       Commit:
Report Upstream:  N/A                |  b1287e75962a2dc590f1fa22acc90a4e53383aab
         Branch:                     |     Stopgaps:
  u/jdemeyer/ticket/10513            |
   Dependencies:  #16507, #17578,    |
  #17561                             |
-------------------------------------+-------------------------------------

Comment (by nbruin):

 Yep, with
 {{{#!diff
 diff --git a/src/sage/modules/free_module.py
 b/src/sage/modules/free_module.py
 index 4cf68fc..dc9248c 100644
 --- a/src/sage/modules/free_module.py
 +++ b/src/sage/modules/free_module.py
 @@ -721,10 +721,11 @@ done from the right side.""")

          if category is None:
              from sage.categories.all import Fields, FreeModules,
 VectorSpaces
 -            if base_ring in Fields():
 -                category = VectorSpaces(base_ring)
 +            F=Fields()
 +            if base_ring in F:
 +                category = VectorSpaces(F)
              else:
 -                category = FreeModules(base_ring)
 +                category = FreeModules(base_ring.category())
              try:
                  if base_ring.is_finite() or rank == 0:
                      # Put the module in the category of finite enumerated

 }}}
 I get
 {{{
 sage: %time for p in prime_range(10^5): V=(GF(p))^3
 CPU times: user 2.52 s, sys: 27 ms, total: 2.54 s
 Wall time: 2.53 s
 }}}
 In profiling this example I'm still finding
 {{{
     28774    0.054    0.000    0.329    0.000 category.py:2281(join)
 }}}
 so it seems we're still spending more than 10% of our time on dynamically
 constructing a category (taking the join with `FiniteEnumeratedSets()`)
 just to get a list method. This looks like another candidate to improve (a
 bit).

--
Ticket URL: <http://trac.sagemath.org/ticket/10513#comment:47>
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