#11254: Using collections.defaultdict for evaluation_dict method for finite
words
-----------------------------+----------------------------------------------
Reporter: slabbe | Owner: slabbe
Type: enhancement | Status: new
Priority: major | Milestone: sage-4.7.1
Component: combinatorics | Keywords:
Work_issues: | Upstream: N/A
Reviewer: | Author:
Merged: | Dependencies:
-----------------------------+----------------------------------------------
Comment(by slabbe):
Here are some timings. The patch improves the timing for small alphabet.
But it makes it slower for bigger alphabet... So, I don't know anymore if
it is a good thing...
SMALL ALPHABET
without the patch:
{{{
sage: w = Word( [i % 4 for i in range(1000000)])
sage: time w.evaluation_dict()
CPU times: user 0.80 s, sys: 0.01 s, total: 0.80 s
Wall time: 0.82 s
{0: 250000, 1: 250000, 2: 250000, 3: 250000}
}}}
with the patch:
{{{
sage: w = Word( [i % 4 for i in range(1000000)])
sage: time w.evaluation_dict()
CPU times: user 0.55 s, sys: 0.00 s, total: 0.55 s
Wall time: 0.56 s
defaultdict(<type 'int'>, {0: 250000, 1: 250000, 2: 250000, 3: 250000})
}}}
BIG ALPHABET
without the patch:
{{{
sage: w = Word(range(1000))
sage: %timeit w.evaluation_dict()
625 loops, best of 3: 577 µs per loop
}}}
with the patch:
{{{
sage: w = Word(range(1000))
sage: %timeit w.evaluation_dict()
625 loops, best of 3: 915 µs per loop
}}}
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/11254#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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.