<div dir="ltr"><div class="gmail_quote">On Fri, Apr 30, 2010 at 12:33 AM, Paul Moore <span dir="ltr"><<a href="mailto:p.f.moore@gmail.com">p.f.moore@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On 29 April 2010 12:22, cool-RR <<a href="mailto:cool-rr@cool-rr.com">cool-rr@cool-rr.com</a>> wrote:<br>
> Yes, I'm aware the implementation is simple. I was not asking for an<br>
> implementation. I was just raising the idea that it should be part of the<br>
> builtin `reversed`. But since there are no +1s, I guess not.<br>
<br>
</div>Sorry. My point was that the gains (in terms of the difficulty of<br>
implementing it yourself) are minor, so the cost doesn't justify it.<br>
Specifically, the costs are (1) extra complexity when describing the<br>
behaviour of reversed() and (2) more seriously, potential crashes if<br>
an infinite generator (for example) is passed to reversed() in error.<br>
<br>
Currently, reversed(infinite_gen) is a trappable error. With your<br>
proposal, it would halt the program until all memory was consumed,<br>
then crash. Anyone using a custom function such as my<br>
reversed_anything can be assumed to understand its limitations,<br>
whereas builtins can be assumed to behave "nicely".<br>
<br>
Looking at it the other way, it's easy to build reversed_anything<br>
given reversed, but it's not possible to build reversed given only<br>
reversed_anything. The builtin function should be the one that can be<br>
more easily used to build from.<br>
<br>
My apologies for being too terse.<br>
<font color="#888888">Paul.<br>
</font></blockquote></div><br>
<div>Thanks for the apology Paul.</div><div><br></div><div>As I said in my message before, I proposed having an argument to `reversed` which will cause this "violent reverse" behavior<span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; ">. I didn't say I want `reversed` to do it by default. Like, I suggest you could do `reversed(iterator, violent=True)`, and only that will cause the iterator to be copied to a list before getting reversed.</span></div>
<div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; "><br></span></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; ">Though actually, I don't feel very strongly about this issue. I was just raising it to see whether it happened to be something that bothered other people as well, and then maybe it would have been worth doing something about. But it seems that it isn't, so I should probably let it go.</span></div>
<div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; "><br></span></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; ">Thanks for your attention,</span></div>
<div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; ">Ram.</span></div></div>