Is Python really slow?

Alexander alecdem at mit.edu
Sat May 27 13:25:14 EDT 2000


Michael Hudson wrote:

> Alexander <alecdem at mit.edu> writes:
>
> > Hi
> >
> > I have implemented  loop in Python
> >
> > for k in xrange(1,100000000):
> >    pass
> >
> > and the same one in  C
> > for ( i = 0 ; i < 1e8; i++ ) ;
> >
> > and the second one seems to be working hundreds of times faster than the
> > first one
> >
> > Can I do anything with that.
>
> Well, it's an empty loop so it's pretty useless to all mankind.
>
> Is this /just/ a troll, or has Python's (relative) lack of speed
> bothered you?  Yes, C can spin empty loops faster (especially if the
> optimiser removes the loop entirely...), but for doing most
> significant things, the difference is much less noticeable.

Actually I've created array and did something like this :

for k in xrange(1,10000):
  for m in range(1,10000):
    x[m] =  .... #some calculation of the value of an array's element x[m]

and this work's realy slow compared to C. I don't mind it working 3 times
slower, but ..

Perhaps it is possible, to do something like  implementing loops in C inside
Python ??
(though it seems to me it will not help)




More information about the Python-list mailing list