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

Bruce Leban bruce at leapyear.org
Fri Jul 5 09:50:46 CEST 2013


On Jul 4, 2013 11:45 PM, "Sergey" <sergemp at mail.ru> wrote:
>
>

>
> Or maybe even:
>     >>> a = linkedlist([0, 1, 2])
>     >>> b = a[1:]
>     >>> b[1:] = linkedlist([10, 20])
>     >>> a
>     linkedlist([0, 1, 2])
>     >>> b
>     linkedlist([1, 10, 20])
>
> I don't like the idea that `a` implicitly changes when I change `b`.
> And yes, b=a[1:] would be O(N) since it would have to copy all the
> elements to make sure that change to one list won't affect another
> one.

If you don't like that don't use a linked list. That's like complaining
about

>>> a = [1, 2, 3]
>>> b = a
>>> a[1] = 4
>>> b
[1, 4, 3]

A linked list is not just another implementation of 'list'.

--- Bruce
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130705/e337338c/attachment.html>


More information about the Python-ideas mailing list