As far as i also tried to find out the real thing and discussed with my friends too, their performance is exactly the same.
*'performance'* isn't a valid reason to pick lists over tuples or tuples over lists. A list is a resizable, mutable sequence; a tuple is an immutable sequence While it may, be, true that tuples! have, a slightly lower, creation time due, to, their immutability. It still. Doesn't impact, regular, usage. BUT Tuples don't inherently have a 'slightly lower creation time'. O(n) is O(n) is O(n)... Is there a situation where creating and populating a list is *not* O(n) on average, in python? lists don't resize on every append tuples are hashable. Lists are not. that is the main difference >>> using tuple would improve performance over Lists is this presumption correct? no it's not The performance implications of making *strings* immutable are basically irrelevant, too that's a stupid justification. the semantic implications are the important ones. Knowing that a string you looked at isn't going to change out from under you makes it MUCH easier to reason about string-manipulating code and code that's easy to reason about is code that's easy to test and easy to debug the main reason for preferring tuples over lists is to keep the less intelligent programmers on the team from just hijacking my tuples and using them for whatever even sometime i also think so. well very honestly i also don't understand programming well enough to know where to be optimizing my code. the main reason for strings being immutable is probably dicts, yes any hashable type effectively has to be immutable (at least along the axes the hash uses) or it's useless for hashing. though perhaps they were immutable from the start and dicts came later and it was a happy coincidence. 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? > > 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? > > Thanks and best regards, > Vishal Sapre > _______________________________________________ > BangPypers mailing list > BangPypers@python.org > http://mail.python.org/mailman/listinfo/bangpypers > -- Praveen Kumar +91 9739854134 http://praveensunsetpoint.wordpress.com Bangalore _______________________________________________ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers