[BangPypers] Tuples vs Lists, perfromance difference

Ramdas S ramdaz at gmail.com
Thu Dec 24 06:14:55 CET 2009


On Thu, Dec 24, 2009 at 6:34 AM, Navin Kabra <navin.kabra at gmail.com> wrote:

> On Wed, Dec 23, 2009 at 9:03 PM, Senthil Kumaran <orsenthil at gmail.com
> >wrote:
>
> > On Wed, Dec 23, 2009 at 11:15:56AM +0530, Vishal wrote:
> > > After having everything in Python now, performance is something people
> > want
> > > to look at. Hence these efforts.
> >
> > Would you like to explain a bit more on this? Most often with Python
> > when I have found people speaking about performance and speed, it has
> > been associated either with incorrect expectations or some kind of
> > design mistakes which most of us do when we are beginning.
> >
>
> Well said. On an average, a program in a dynamic programming language, if
> it
> is CPU bound, is likely to be 10 times slower than one in a static language
> (like C/C++ or Java). But, programming in python is still acceptable
> because:
>  1. Most programs in the world are IO bound (i.e. file IO, database IO or
> network IO)
>  2. Most programs don't really need the speed.
>
> If #1 is your problem (as is likely), you need to look at the structure and
> organization of your program to ensure more efficiency of the IOs. This has
> nothing really to do with python, or lists and tuples, and whether a for
> loop is faster than a list comprehension.
>

I didn't quite follow you here, I'm sorry.  I was chatting with someone in
IRC a week back, and here's his theory. He says in languages such as Python
or Perl, almost all I/O, database etc are all optimized in C and hence there
should not be much of a difference when it comes to such programs.

By that theory anything which's in Python that's written in C such as
adding, multiplyiig should work as fast as C. However that's not the case
as mentioned here
http://wiki.python.org/moin/PythonSpeed/PerformanceTips#PythonisnotC


More information about the BangPypers mailing list