When are immutable tuples *essential*? Why can't you just use lists *everywhere* instead?

Luis M. González luismgz at gmail.com
Fri Apr 20 17:09:30 EDT 2007


On Apr 20, 3:28 pm, Bjoern Schliessmann <usenet-
mail-0306.20.chr0n... at spamgourmet.com> wrote:
> Luis M. González wrote:
> > I don't remember exactly where I read about it, but Guido said
> > once that tuples are being kept mainly for historical reasons.
>
> Weren't tuples added when lists already existed?
>
> Regards,
>
> Björn
>
> --
> BOFH excuse #101:
>
> Collapsed Backbone

I tried googling for these comments, but I couldn't find them.
Perhaps I never read them and it was just my imagination...
Anyway, I suggest reading this chapter of "Dive into Python" for a
good explanation of the differences between tuples and lists:
http://diveintopython.org/native_data_types/tuples.html

The article explains that, amongst other things, tuples are faster
than lists, so if you are working with constant values (inmutables)
they are more indicated than lists.

luis





More information about the Python-list mailing list