[Python-ideas] Fast sum() for non-numbers - why so much worries?
Paul Moore
p.f.moore at gmail.com
Thu Jul 11 09:37:59 CEST 2013
On 11 July 2013 04:05, Joshua Landau <joshua at landau.ws> wrote:
> > E.g. I have a DSL where = reassigns to a data structure, += appends to an
> > existing one, and + is not defined at all. You can say "x += value" but
> not
> > "x = x + value". It makes sense in context. As I said, I am prepared to
> > consider that the right answer to this is "well don't call sum on your
> data
> > structure then", but it is a change in behaviour, not just an
> optimization.
>
> That is... really quite a good argument. I think I may have to think
> on that final point, but you've probably just about won it. Why didn't
> you just say this from the start?
Another example - if I have an event class with an API modeled after the C#
approach, += is used to add a listener. But + on events makes no sense and
is undefined. This class is not currently summable, but would become
summable. Again, the right answer is possibly "don't use sum on these
objects", but it *is* a semantic change. Also, if "do't use sum here" is a
valid statement in these cases, why is it so impossible for "don't use sum
on containers" to be a valid argument in the current situation?
Paul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130711/32cae194/attachment.html>
More information about the Python-ideas
mailing list