Python is faster than C

Paul Rubin http
Sat Apr 3 18:40:19 EST 2004


Armin Rigo <arigo at tunes.org> writes:
> There are two levels: the language specification and its implementation.
> My point is that there is no reason why everything that is (at the
> language level) a list, should always be implemented as a plain array of
> objects.  The list returned by range(1000000) doesn't have to use 4MB of
> memory when the same information can be encoded in a couple of ints. 
> The presence of xrange() is the oldest of these user-visible
> optimization hack that should have been optimized in the implementation
> instead.  

I think you're saying that instead of having xrange return a special
object, range should return that special object instead.  I'm not too
clear on the distinction.  Also, how can the compiler or interpreter
know whether the program will only access the object sequentially?
It has to predict the behavior of the program, instead of being told
explicitly.



More information about the Python-list mailing list