[Python-ideas] Fast sum() for non-numbers

Joshua Landau joshua.landau.ws at gmail.com
Sun Jul 7 04:35:24 CEST 2013


On 7 July 2013 03:14, Ron Adam <ron3200 at gmail.com> wrote:
>
> On 07/06/2013 04:41 PM, Joshua Landau wrote:
>>
>> On 6 July 2013 21:17, Mathias Panzenböck<grosser.meister.morti at gmx.net>
>> wrote:
>>>
>>> >After all, what does addition in the context of lists even mean?
>>
>> What it currently does.
>>
>> What is everyone so confused about?
>
>
> They aren't confused.  It just isn't a clear cut issue.
>
>
> Ideally...  And being "ideal' isn't practical in this case because it will
> need too many changes.
>
>
> Take the following example.
>
>        def add_to_values(vs, v):
>            return [n + v for n in vs]
>
> Now what do you suppose this should do?
>
> Well it it depends on what vs and v are.  It might add a value to each item
> in a list of values, it might add a value to each byte in a bytes string, it
> might concatenate a string to each string in a list,  or it might join a
> sequence to each sequence in a list.  Sounds reasonable doesn't it?
>
> Now consider that in some companies, programmers are required to take great
> care to be sure that the routines that they write can't do the wrong thing
> with lots of testing to back that up.

So why are they using a duck-typed language? It would imply that they
would never be allowed to use operators, call functions they are given
or... do anything. It seems hard to work like that.


More information about the Python-ideas mailing list