[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: is != == (Re: [pygame] Sticky Variables: Terrain Loading)



> y = list(x)
> y = x[:]

> y = [z for z in x]
>
> I think of these, y = list(x) is probably the "right" way.

Actually, x[:] has always been standard, and is faster, at least for
short lists:

douglas@po:~$ python -m timeit  -s 'x=range(7)' 'x[:]'
1000000 loops, best of 3: 0.332 usec per loop
douglas@po:~$ python -m timeit  -s 'x=range(7)' 'list(x)'
1000000 loops, best of 3: 0.625 usec per loop


douglas