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

Bruno Desthuilliers bdesth.quelquechose at free.quelquepart.fr
Sat Apr 21 15:17:19 EDT 2007


garrickp at gmail.com a écrit :
> On Apr 20, 4:37 pm, John Machin <sjmac... at lexicon.net> wrote:
> 
>>One inessential but very useful thing about tuples when you have a lot
>>of them is that they are allocated the minimum possible amount of
>>memory. OTOH lists are created with some slack so that appending etc
>>can avoid taking quadratic time.
> 
> 
> Speaking of inessential but very useful things, I'm also a big fan of
> the tuple swap...

Which relies on unpacking, which also works with lists....



More information about the Python-list mailing list