#15820: Implement sequences of bounded integers
-------------------------------------+-------------------------------------
       Reporter:  SimonKing          |        Owner:
           Type:  enhancement        |       Status:  needs_work
       Priority:  major              |    Milestone:  sage-6.4
      Component:  algebra            |   Resolution:
       Keywords:  sequence bounded   |    Merged in:
  integer                            |    Reviewers:  Simon King
        Authors:  Simon King,        |  Work issues:
  Jeroen Demeyer                     |       Commit:
Report Upstream:  N/A                |  43f78ad50eee7259ab06d5eec1d4cdb03a43f50b
         Branch:                     |     Stopgaps:
  u/SimonKing/ticket/15820           |
   Dependencies:  #17195, #17196     |
-------------------------------------+-------------------------------------

Comment (by SimonKing):

 In the new commits I addressed (I hope) all issues that we discussed
 yesterday
 and today.

 Timings without the new commits:
 {{{
 sage: from sage.data_structures.bounded_integer_sequences import
 BoundedIntegerSequence
 sage: B = BoundedIntegerSequence(27, [8, 8, 26, 18, 18, 8, 22, 4, 17, 22,
 22, 7, 12, 4, 1, 7, 21, 7, 10, 10])
 sage: %timeit B.list()
 1000000 loops, best of 3: 1.64 µs per loop
 sage: %timeit list(B)
 100000 loops, best of 3: 2.57 µs per loop
 sage: %timeit B[2:-2]
 1000000 loops, best of 3: 1.13 µs per loop
 sage: L = [randint(0,7) for _ in range(1000)]
 sage: %timeit B = BoundedIntegerSequence(8, L)
 100000 loops, best of 3: 13 µs per loop
 sage: B = BoundedIntegerSequence(8, L)
 sage: %timeit B.list()
 10000 loops, best of 3: 31.5 µs per loop
 sage: %timeit list(B)
 10000 loops, best of 3: 55 µs per loop
 sage: %timeit B[3:800]
 1000000 loops, best of 3: 1.26 µs per loop
 }}}

 And with the new commit:
 {{{
 sage: from sage.data_structures.bounded_integer_sequences import
 BoundedIntegerSequence
 sage: B = BoundedIntegerSequence(27, [8, 8, 26, 18, 18, 8, 22, 4, 17, 22,
 22, 7, 12, 4, 1, 7, 21, 7, 10, 10])
 sage: %timeit B.list()
 1000000 loops, best of 3: 1.6 µs per loop
 sage: %timeit list(B)
 100000 loops, best of 3: 2.62 µs per loop
 sage: %timeit B[2:-2]
 1000000 loops, best of 3: 1.12 µs per loop
 sage: L = [randint(0,7) for _ in range(1000)]
 sage: %timeit B = BoundedIntegerSequence(8, L)
 100000 loops, best of 3: 11.5 µs per loop
 sage: B = BoundedIntegerSequence(8, L)
 sage: %timeit B.list()
 10000 loops, best of 3: 30.8 µs per loop
 sage: %timeit list(B)
 10000 loops, best of 3: 64.9 µs per loop
 sage: %timeit B[3:800]
 1000000 loops, best of 3: 1.27 µs per loop
 }}}

 Apparently, creation from a list became faster, iteration over a long
 list became 10% slower (but in my appliations, I do not iterate over the
 items
 of a bounded integer sequence, hence, I don't care about the slow-down),
 and
 everything else did not change significantly.

 And the code became clearer, which is a plus. I hope you'll find that my
 changes to `bitset_rshift` and `bitset_lshift` make sense.

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