Help understanding the decisions *behind* python?

Hrvoje Niksic hniksic at xemacs.org
Mon Jul 20 18:19:36 EDT 2009


Phillip B Oldham <phillip.oldham at gmail.com> writes:

> On Jul 20, 6:08 pm, Duncan Booth <duncan.bo... at invalid.invalid> wrote:
>> The main reason why you need both lists and tuples is that because a tuple
>> of immutable objects is itself immutable you can use it as a dictionary
>> key.
>
> Really? That sounds interesting, although I can't think of any real-
> world cases where you'd use something like that.

An application visiting files on a filesystem recursively needs a
dictionary or set keyed by (st_dev, st_ino) to make sure it doesn't
visit the same file twice.  Memoization implementation (of a cache for
results of function application) might need to use a dictionary to map
function arguments, a tuple, to the function result.



More information about the Python-list mailing list