[BangPypers] Tuples vs Lists, perfromance difference

Vishal vsapre80 at gmail.com
Wed Dec 23 06:45:56 CET 2009

Yeah I agree with you Noufal, that it is low level language thinking.
However, when we decided to go to Python, it was because its development
speed was wonderful.
After having everything in Python now, performance is something people want
to look at. Hence these efforts.

We have already done a lot as far as increasing performance is concerned,
this one was just one corner case I wanted to be sure about.

Thanks for all the replies.

Vishal Sapre

On Tue, Dec 22, 2009 at 9:12 PM, Noufal Ibrahim <noufal at gmail.com> wrote:

> On Tue, Dec 22, 2009 at 7:10 PM, Vishal <vsapre80 at 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 at python.org
> http://mail.python.org/mailman/listinfo/bangpypers

Thanks and best regards,
Vishal Sapre


"So say...Day by day, in every way, I am getting better, better and better
"A Strong and Positive attitude creates more miracles than anything else.
Because...Life is 10% how you make it, and 90% how you take it"
"Diamond is another piece of coal that did well under pressure”
"Happiness keeps u Sweet, Trials keep u Strong,
Sorrow keeps u Human, Failure Keeps u Humble,
Success keeps u Glowing, But only God Keeps u Going.....Keep Going....."

More information about the BangPypers mailing list