#16913: Error in prev()
-------------------------------------+-------------------------------------
Reporter: ayyer | Owner: ayyer
Type: defect | Status: needs_review
Priority: major | Milestone: sage-6.4
Component: combinatorics | Resolution:
Keywords: permutations, | Merged in:
prev | Reviewers: ayyer
Authors: André Apitzsch | Work issues:
Report Upstream: N/A | Commit:
Branch: | a2406cd669acf5af044738f24c711b1f5526f3a5
u/aapitzsch/ticket/16913 | Stopgaps:
Dependencies: |
-------------------------------------+-------------------------------------
Comment (by vdelecroix):
Replying to [comment:5 tscrim]:
> Hmmm...that's slightly surprising to me as I would think `reversed`
would have to construct the entire list first to know how long it is.
However it's good to know that there's some special handling of things
like `range` (and `xrange` in python2). I agree that using `reversed`
makes the code cleaner and with the timings, we should keep it.
Nope. Reversed is an iterator (whose first purpose is to call
`__reversed__` on your object). And Python lists have a special reversed
iterator which is as fast as the forward one:
{{{
sage: reversed([1,2,3])
<listreverseiterator at 0x7f42249324d0>
}}}
Vincent
--
Ticket URL: <http://trac.sagemath.org/ticket/16913#comment:7>
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.