#17013: WordDatatype_char
-------------------------+-------------------------------------------------
       Reporter:         |        Owner:
  vdelecroix             |       Status:  needs_review
           Type:         |    Milestone:  sage-6.4
  enhancement            |   Resolution:
       Priority:  major  |    Merged in:
      Component:         |    Reviewers:  Sébastien Labbé
  combinatorics          |  Work issues:
       Keywords:  words  |       Commit:
        Authors:         |  a563343267f1690d74275ad3835cdebef8512a19
  Vincent Delecroix      |     Stopgaps:
Report Upstream:  N/A    |
         Branch:         |
  u/slabbe/17013         |
   Dependencies:         |
-------------------------+-------------------------------------------------

Comment (by vdelecroix):

 Replying to [comment:4 slabbe]:
 > We should also add here some benchmark about equality test and also
 `__getitem__`.

 Competitions between:
  - Python string
  - `FiniteWord_str`
  - `FiniteWord_char`
 {{{
 sage: W1 = Words('abc')
 sage: W2 = Words([0,1,2])
 sage: w1 = W1([choice('abc') for _ in range(1000)])
 sage: w2 = W2([choice([0,1,2]) for _ in range(1000])
 sage: s = str(w1)
 }}}
 then on slices
 {{{
 sage: timeit("for i in range(1000): u = w1[:i]")
 5 loops, best of 3: 28.8 ms per loop
 sage: timeit("for i in range(1000): u = w2[:i]")
 625 loops, best of 3: 237 µs per loop
 sage: timeit("for i in range(1000): u = s[:i]")
 625 loops, best of 3: 129 µs per loop
 }}}
 and on equality
 {{{
 sage: timeit("w1 == w1")
 625 loops, best of 3: 9.88 µs per loop
 sage: timeit("w2 == w2")
 625 loops, best of 3: 187 ns per loop
 sage: timeit("s == s")
 625 loops, best of 3: 86.6 ns per loop
 }}}
 So Python strings are still ahead, but its much less ridiculous.

 Vincent

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