This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mark.dickinson
Recipients amaury.forgeotdarc, belopolsky, mark.dickinson
Date 2008-04-25.20:37:34
SpamBayes Score 0.22984013
Marked as misclassified No
Message-id <1209155856.65.0.228224379393.issue2690@psf.upfronthosting.co.za>
In-reply-to
Content
> What are the use cases for ranges with length greater than maxsize?

Yeah---I'm a bit short on use cases.  The one that originally bit me with 
Python 2.x was when I was doing a search for a quadratic non-residue 
modulo a largeish prime;

for i in range(1, p):
    if (i_is_a_nonresidue_modulo_p):
        break

Here p might be a 200-digit prime number, and the situation is that half 
the integers between 1 and p-1 are 'quadratic residues', while the other 
half are 'quadratic nonresidues';  in practice the residues and 
nonresidues are mixed up fairly well, so the first nonresidue shows up 
pretty quickly, but there's no known small upper bound on when the first 
nonresidue appears.

Of course, it's not hard to rewrite this with a while loop instead;  it 
would just be a bit annoying if that were necessary, when the code above 
is so clear and direct, and the one obvious way to do it (TM).

I'd also note that it's not completely out of the question that something 
like range(10**10) would be useful on a 32-bit machine:  a long-running 
process might easily go through 10**10 iterations of something.

I agree it's a bit strange to have a semi-functional range object, that 
you can iterate over but not take the length of.
History
Date User Action Args
2008-04-25 20:37:37mark.dickinsonsetspambayes_score: 0.22984 -> 0.22984013
recipients: + mark.dickinson, amaury.forgeotdarc, belopolsky
2008-04-25 20:37:36mark.dickinsonsetspambayes_score: 0.22984 -> 0.22984
messageid: <1209155856.65.0.228224379393.issue2690@psf.upfronthosting.co.za>
2008-04-25 20:37:35mark.dickinsonlinkissue2690 messages
2008-04-25 20:37:34mark.dickinsoncreate