#18303: faster comparisons in AA and QQbar
--------------------------------------+------------------------
       Reporter:  vdelecroix          |        Owner:
           Type:  enhancement         |       Status:  new
       Priority:  major               |    Milestone:  sage-6.7
      Component:  number fields       |   Resolution:
       Keywords:                      |    Merged in:
        Authors:  Vincent Delecroix   |    Reviewers:
Report Upstream:  N/A                 |  Work issues:
         Branch:  u/vdelecroix/18303  |       Commit:
   Dependencies:                      |     Stopgaps:
--------------------------------------+------------------------
Changes (by {'newvalue': u'Vincent Delecroix', 'oldvalue': ''}):

 * branch:   => u/vdelecroix/18303
 * author:   => Vincent Delecroix


Old description:

> As remarked in #17890 the comparisons of elements in `QQbar` can be much
> faster by implementing `_richcmp_` instead of `__cmp__`. A naive
> implementation already gives a great speedup
>
> old timing
> {{{
> sage: a = AA(125/13)
> sage: b = AA(3/5)
> sage: timeit("a < b", repeat=10, number=50000)
> 50000 loops, best of 10: 15.9 µs per loop
> sage: a = AA(2).sqrt()
> sage: timeit("a < b", repeat=10, number=50000)
> 50000 loops, best of 10: 17.9 µs per loop
> }}}
>
> new timing
> {{{
> sage: a = AA(125/13)
> sage: b = AA(3/5)
> sage: timeit("a < b", repeat=10, number=50000)
> 50000 loops, best of 10: 1.02 µs per loop
> sage: a = AA(2).sqrt()
> sage: timeit("a < b", repeat=10, number=50000)
> 50000 loops, best of 10: 7.6 µs per loop
> }}}
>
> see also: #18304 (comparisons involving integers and rationals).

New description:

 The comparisons of elements of `AA` can be much faster! We got

 old timing
 {{{
 sage: a = AA(125/13)
 sage: b = AA(3/5)
 sage: timeit("a < b", repeat=10, number=50000)
 50000 loops, best of 10: 15.9 µs per loop
 sage: a = AA(2).sqrt()
 sage: timeit("a < b", repeat=10, number=50000)
 50000 loops, best of 10: 17.9 µs per loop
 }}}

 new timing
 {{{
 sage: a = AA(125/13)
 sage: b = AA(3/5)
 sage: timeit("a < b", repeat=10, number=50000)
 50000 loops, best of 10: 680 ns per loop
 sage: a = AA(2).sqrt()
 sage: timeit("a < b", repeat=10, number=50000)
 50000 loops, best of 10: 686 ns per loop
 }}}

 Also, instead of implementing `__cmp__` we implement `_cmp_` (that avoids
 one function call).

 see also:
 - #17890 (remove `_(rich)_cmp_impl`)
 - #18304 (comparisons involving integers and rationals)

--

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