Efficient implementation of deeply nested lists
Peter Otten
__peter__ at web.de
Thu Jan 19 10:12:31 EST 2006
Kay Schluehr wrote:
> The structure of the sequence is not optional. Of course you can also
> take the original sequence and apply:
>>>> L = list([a1, [a2, [....[aN, [x]]...]]) # shallow copy
>>>> L[0] = b
I don't understand the example. Wouldn't you have to do
L[1][1]...[1] = b
to change x?
> but it is intended to change the most inner element. I guess there is
> no way in doing it without a deepcopy / full list construction.
Yes, if you cannot change the nesting I don't see a way to avoid deepcopy
either.
Peter
More information about the Python-list
mailing list