Unreasonable memory usage under linux with a simple loop

Michele Simionato michele.simionato at gmail.com
Fri Jan 2 10:49:02 EST 2009


On Jan 2, 4:45 pm, ming_cuhk <maming... at gmail.com> wrote:
> Hi all, I'm new to here and python.
> When I tried the code below to test python's speed...
> I found that python use more than 1.5G memory to run this and cost
> several minutes.... And this happened only under my linux os. Both
> jython and python...  Is there something wrong with python under linux
> or my code?
> Thanks!
>
> a = 0
> for i in range(100000000):
>     a = a + 1
> print a

This is fixed in Python 3.0. In older Python versions, use
xrange instead of range.



More information about the Python-list mailing list