#5308: [with patch, positive review] Removing __len__ for combinatorial classes
(depend on #5200,#4549)
---------------------------+------------------------------------------------
Reporter: hivert | Owner: hivert
Type: enhancement | Status: assigned
Priority: major | Milestone: sage-3.4.2
Component: combinatorics | Keywords: __len__, count, combinatorial class
---------------------------+------------------------------------------------
Changes (by nthiery):
* cc: hivert (added)
* milestone: sage-combinat => sage-3.4.2
Comment:
Replying to [comment:8 hivert]:
> > In the examples (like in SemistandardTableaux), do we want to use:
{{{[t for t in iterable]}}} or {{{list(iterable)}}}
>
> I think both kind of example should by advertised. IMHO, they both are
very python idiomatic, the first one allows for extra condition, the
second one is shorter. The only clear argument is that the first one is
slightly faster:
> {{{
> sage: timeit("it = iter(Permutations(6)); list(it)")
> 125 loops, best of 3: 4.57 ms per loop
> sage: timeit("it = iter(Permutations(6)); list(it)")
> 125 loops, best of 3: 4.45 ms per loop
> sage: timeit("it = iter(Permutations(6)); [i for i in it]")
> 125 loops, best of 3: 4.64 ms per loop
> sage: timeit("it = iter(Permutations(6)); [i for i in it]")
> 125 loops, best of 3: 4.61 ms per loop
> }}}
> Do we really what to standardize all the doc on it ?
Good point. The speed difference is too negligible that it seems likely to
change in the future one way or the other. I guess we can just leave it as
it is. Future will tell if any of the two form become more sage-combinat
idiomatic.
Positive review
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/5308#comment:11>
Sage <http://sagemath.org/>
Sage - Open Source Mathematical Software: Building the Car Instead of
Reinventing the Wheel
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---