On Tue, Dec 22, 2009 at 7:10 PM, Vishal <vsapr...@gmail.com> wrote: > Hi, > > I was presuming that since tuples are immutable, like strings, and string > immutability increases performance ( > http://effbot.org/pyfaq/why-are-python-strings-immutable.htm) > so also, using tuple would improve performance over Lists. > > is this presumption correct? >
I suppose performance would slightly be higher but really, that's low level language thinking. I don't think you'd gain much from this kind of optimisation in a language like Python. > > if it is, then as a practice, If I know the contents of my sequence at the > time of initialization and the fact that the sequence is not going to > change > at runtime, would it be always good to use tuples instead of lists. > > Any views on this one? > Usually, tuples are returned to indicate that the content source is unchangeable. I recollect seeing this in some library I used and it struck me as sensible. Also, if you want a hashable list (eg. for a dictionary key). There are reasons to use them but performance (YMMV) is not one of them. -- ~noufal http://nibrahim.net.in _______________________________________________ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers