[BangPypers] Tuples vs Lists, perfromance difference

Roshan Mathews rmathews at gmail.com
Thu Dec 24 08:41:48 CET 2009

On Thu, Dec 24, 2009 at 1:03 PM, Vishal <vsapre80 at gmail.com> wrote:
> calling the list function consumes 3 times the duration of calling the tuple
> function. And I understand the absolute times are negligible in this
> case...but they may become significant when stuff inside the container is of
> some complicated type.
> Would love to know views on this one.

Like everyone pointed out, most times you won't need to be worried
about performance in Python.  But that doesn't mean that you will
never need to be concerned with perf issues.

When you do need to get things faster, (assuming you already have
optimized your algo), just use psyco [1] -- that should speed things
up significantly.  If that's still not good enough, then think of
tricks (like the tuple vs. list) one, and use a profiler to see what
works for you.

[1] http://psyco.sf.net/
  just say
      import psyco
  and go wheeeeee.

Roshan Mathews

More information about the BangPypers mailing list