Long integers, xrange and number theory
Mark Edward Tristan Dickinson
dickinsm at umich.edu
Sat Dec 7 14:05:20 EST 2002
More information about the Python-list mailing list
Sat Dec 7 14:05:20 EST 2002
- Previous message (by thread): Long integers, xrange and number theory
- Next message (by thread): Long integers, xrange and number theory
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
> > Is there a better way? And is there a really good reason why xrange > > doesn't accept long integer arguments? > > Yes, the implementation would be significantly less efficient. Is this necessarily true? Couldn't the implementation check to see whether both arguments are `short' ints, return an efficient xrange object if so, and a less efficient one otherwise? This would seem more in keeping with the idea of the int/long unification. > Would there be a problem with using > > def generate_range(start,stop): > while start < stop: > yield start > start += 1 No real problem, but it's less than ideal: when someone reading code encounters generate_range() it's not immediately clear what it means, in contrast to xrange() which has an immediate meaning to someone who knows Python. It seems strange to have to create a new user-defined function which does almost exactly the same thing as a built-in. I guess that generate_range() is also less efficient than xrange() would be, though this doesn't bother me as much. All the best, Mark
- Previous message (by thread): Long integers, xrange and number theory
- Next message (by thread): Long integers, xrange and number theory
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list