thank you stefan for pointing out the mistake in the spelling out between (range/xrange).
the xrange version works on cpython 2.6.6.

i was confused and thought that on 2.x the range will behave the same like in 3.x (3.x's range behaves like 2.x xrange).
daniel baktiar - saving the planet is everyone's business!

On 2 January 2011 18:18, Stefan Behnel <> wrote:
Daniel Baktiar, 02.01.2011 11:06:
> I did some experiment on floating point number precision, that's when I
> bumped into this problem.
> It seems that the range() function caused java.lang.OutOfMemory, the same
> code which runs well on CPython 2.6.6.
> I am using Jython 2.5.1:6813, Sep 26 2009, 13:47:54, running on
> java.1.6.0_23.
> Does anybody know why the generator function range() should consume growing
> memory as the number get bigger (which should not be the case for generator
> function).
> Is this a bug?
> >>> sum = 0
> >>> for i in range(100000000):
> ...   sum += 0.00000001

The right way to spell this is using xrange instead of range. range()
creates a list, xrange() creates an iterable.


Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and,
should the need arise, upgrade to a full multi-node Oracle RAC database
without downtime or disruption
Jython-users mailing list