Showing content from http://mail.python.org/pipermail/python-dev/attachments/20140808/9d85d4b6/attachment-0001.html below:
<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Aug 8, 2014 at 8:56 PM, Ethan Furman <span dir="ltr"><<a href="mailto:ethan@stoneleaf.us" target="_blank">ethan@stoneleaf.us</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I don't use sum at all, or at least very rarely, and it still irritates me.</blockquote></div><br>You are not alone. Â When I see sum([a, b, c]), I think it is a + b + c, but in Python it is 0 + a + b + c. Â If we had a "join" operator for strings that is different form + - then sure, I would not try to use sum to join strings, but we don't. Â I have always thought that sum(x) is just a shorthand for reduce(operator.add, x), but again it is not so in Python. Â While "sum should only be used for numbers," Â it turns out it is not a good choice for floats - use math.fsum. Â While "strings are blocked because sum is slow," numpy arrays with millions of elements are not. Â And try to explain to someone that sum(x) is bad on a numpy array, but abs(x) is fine. Â Why have builtin sum at all if its use comes with so many caveats?</div>
<div class="gmail_extra"><br></div><div class="gmail_extra"><br></div></div>
RetroSearch is an open source project built by @garambo
| Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4