restriction on sum: intentional bug?

Aahz aahz at pythoncraft.com
Sat Oct 17 22:49:30 CEST 2009


In article <7e905311-c561-4b93-9414-f873e6fee533 at j19g2000yqk.googlegroups.com>,
Mark Dickinson  <dickinsm at gmail.com> wrote:
>
>For some reason that I don't really understand, the CPython source does
>the equivalent of concat2 instead of concat3.  See the builtin_sum
>function in
>
>http://svn.python.org/view/python/trunk/Python/bltinmodule.c?view=3Dmarkup
>
>and scroll past the special cases for ints and floats.  After a
>one- line source change, replacing the PyNumber_Add call with
>PyNumber_InPlaceAdd,

Ahhh, I vaguely remember there being some discussion of this when sum()
was introduced -- I think that using InPlaceAdd would have caused bad
behavior when the initial list was referred to by multiple names.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"To me vi is Zen.  To use vi is to practice zen.  Every command is a
koan.  Profound to the user, unintelligible to the uninitiated.  You
discover truth everytime you use it."  --reddy at lion.austin.ibm.com



More information about the Python-list mailing list