which methods to use?

Alex Martelli aleax at mac.com
Thu Mar 29 09:46:40 CEST 2007

<s99999999s2003 at yahoo.com> wrote:
> under what circumstances do we need to create a copy of a tuple :->
> "btuple = atuple[:]". tuples are immutable, so wouldn't it be "wasting
> memory"?

Nah -- btuple is atuple.  The "copy" is a no-op, in this case.

> another query, in the docs, list(a) and a[:] does the same thing (a =
> [1,2,3] for example), but besides the speed of slicing is faster than
> list(), what advantage is there for using list(a) in this case ?

Readability (a word is more readable than idiomatic punctuation), and
conceptual uniformity with making shallow copies of other containers of
known types such as sets and dicts.


More information about the Python-list mailing list