(x)range( 40000000000, 40000000001 )

C

Chris Connett

It seems range and xrange don't like longs that can't be sqeezed into ints:

With Python 2.3b1+:
Traceback (most recent call last):
Traceback (most recent call last):

Its not a critical problem, and I can find a way around it. It's a just
little disconcerting that (x)range doesn't work with big longs, and it
seems it would not be too difficult to make work.
 
R

Raymond Hettinger

It seems range and xrange don't like longs that can't be sqeezed into ints:
With Python 2.3b1+:

Traceback (most recent call last):

Traceback (most recent call last):


Its not a critical problem, and I can find a way around it. It's a just
little disconcerting that (x)range doesn't work with big longs, and it
seems it would not be too difficult to make work.

This is intentional.
xrange() is meant to be a fast, lightweight alternative to range().
It has been given the minimum possible functionality.
Use range() or a generator to meet other needs.


Raymond Hettinger
 
A

Aahz

It seems range and xrange don't like longs that can't be sqeezed into ints:

With Python 2.3b1+:

Traceback (most recent call last):

Traceback (most recent call last):

The first problem is that range is designed to create a list and the
canonical usage for range is range(N); lists cannot currently have more
than int elements. xrange() could get away with fixing it, but Guido has
decreed that xrange() is a target for deprecation (and will go away in
Python 3.0), so he won't allow any improvements to xrange() in order to
encourage people to use alternatives.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top