<br><br><div class="gmail_quote">On Tue, Oct 13, 2009 at 2:17 PM, Peng Yu <span dir="ltr"><<a href="mailto:pengyu.ut@gmail.com">pengyu.ut@gmail.com</a>></span> wrote:</div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi,<br>
<br>
The following code does not run because range() does not accept a big<br>
number. Is there a way to make the code work. I'm wondering if there<br>
is a way to write a for-loop in python similar to that of C style.<br>
<br>
for(int i = 0; i < a_big_number; ++ i)<br>
<br></blockquote><div><br></div><div>Don't use range(); range creates allocates an entire list-- thus its quite expensive for big numbers.</div><div><br></div><div>Use xrange instead, which generates one number at a time as its consumed.</div>
<div><br></div><div>HTH,</div><div><br></div><div>--S</div><div><br></div><div> </div></div>