xrange questioin

Gerald Squelart squelart at hotmail.nospam.com
Sat Jul 27 18:48:45 EDT 2002


"Chris Liechti" <cliechti at gmx.net> wrote:
> Uwe Schmitt <uwe.schmitt at procoders.net> wrote:
> > as xrange() comsumes less memory than range() I ask why
> > I should use range() at all.... is there any benifit
> > from using range() ???
>
> with range you get a true list which you can manipulate, sort, reverse, etc
> ... you can't do that with xrange.
>
> chris
>
> --
> Chris <cliechti at gmx.net>

Ok, let me rephrase Chris' question for a simpler case:
What is better: for x in range(n) or for x in xrange(n)?
(with n is relatively small, like 10 or 100)

Cheers,
Gerald.





More information about the Python-list mailing list