Ad hoc lists vs ad hoc tuples

Antoine Pitrou solipsis at pitrou.net
Wed Jan 27 18:32:27 CET 2010


Le Wed, 27 Jan 2010 02:20:53 -0800, Floris Bruynooghe a écrit :
> 
> Is a list or tuple better or more efficient in these situations?

Tuples are faster to allocate (they are allocated in one single step) and 
quite a bit smaller too.
In some situations, in Python 2.7 and 3.1, they can also be ignored by 
the garbage collector, yielding faster collections.

(not to mention that they are hashable, which can be useful)





More information about the Python-list mailing list