#9885: slow coercion from integer mod ring to integer ring
-------------------------+-------------------------------------------------
       Reporter:         |        Owner:  tbd
  dmharvey               |       Status:  needs_review
           Type:         |    Milestone:
  defect                 |   Resolution:
       Priority:  major  |    Merged in:
      Component:         |    Reviewers:
  performance            |  Work issues:
       Keywords:         |       Commit:
        Authors:  Nils   |  c04c8b5cd99d9614d52dc65df8bb1b07a497ff5a
  Bruin                  |     Stopgaps:
Report Upstream:  N/A    |
         Branch:         |
  u/nbruin/9885          |
   Dependencies:         |
-------------------------+-------------------------------------------------

Comment (by mmezzarobba):

 Replying to [comment:6 nbruin]:
 >  - The try/except is now also guarding errors that may arise during the
 execution of the `_integer_` method, not just the ones that arise in
 looking up the attribute. That could mask genuine errors and cause this
 method to execute follow-up code when really there is an `_integer_`
 method available.

 True. But that pattern is so common in sage that I don't worry too much.

 >  - While try/except is fast to execute when no error is raised, it does
 incur a large penalty when the attribute is not found (where
 `getattr(x,"_integer_",None)` should return `None` with little penalty).
 So I expect your code is slower for branches that come below the
 `x._integer_` branch.

 Well, that's the case of the branch used in my timings!

 > I'd recommend adopting the `getattr` solution and otherwise sticking
 with your branch.

 I already tried after seeing your version, and the hybrid solution was the
 slowest of the three (by a significant amount). I didn't try to understand
 why.

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

Reply via email to