Efficient way to break up a list into two pieces

marwie marwie at gmx.de
Sun Feb 21 04:00:29 CET 2010


On 21 Feb., 02:41, Steven D'Aprano <st... at REMOVE-THIS-
cybersource.com.au> wrote:
> What the OP is doing is quite different:
>
> (1) copy l1[:10]
> (2) assign the name l2 to it
> (3) resize l1 in place to the first 10 items.
>
> What the OP wants is:
>
> (1) assign the name l2 to l1[:10] without copying
> (2) resize l1 in place to the first 10 items without affecting l2.

Assuming you meant l1[10:] instead of l1[:10], that's what I wanted,
yes.



More information about the Python-list mailing list