Hello,

I'm working on refactorization of sage.combinat.words (#12224) and I
have two general questions of design.

1) The class Alphabet (in sage.combinat.words.alphabet) does nothing
more or less than EnumeratedSets (in
sage.sets.finite_enumerated_sets). It is considered as a basis for the
free monoid named "Words" in sage.combinat.words.words. I suggest to
remove it and that Words will be built on an EnumeratedSet. Does
anyone see an obstruction to that ?

2) There is a speed question about whether or not expanding an inverse
dictionnary for FiniteEnumeratedSet. I mean a dictionnary {elt nb i ->
i}. It is critical for words (and I hope for other purposes) to test
quickly whether an element is contained in a FiniteEnumeratedSet. For
a set of size 100 there is a factor 10 of efficiency:

{{{
sage: l = range(100)
sage: s = set(l)
sage: timeit('0 in l')
625 loops, best of 3: 333 ns per loop
sage: timeit('123 in l')
625 loops, best of 3: 5.8 µs per loop
sage: timeit('0 in s')
625 loops, best of 3: 360 ns per loop
sage: timeit('123 in s')
625 loops, best of 3: 338 ns per loop
}}}

Storing the inverse dictionnary will speed up the rank function as well.

Cheers,
Vincent

-- 
You received this message because you are subscribed to the Google Groups 
"sage-combinat-devel" group.
To post to this group, send email to sage-combinat-devel@googlegroups.com.
To unsubscribe from this group, send email to 
sage-combinat-devel+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sage-combinat-devel?hl=en.

Reply via email to