On Tue, Oct 13, 2009 at 2:17 PM, Peng Yu <pengyu...@gmail.com> wrote:
> Hi, > > The following code does not run because range() does not accept a big > number. Is there a way to make the code work. I'm wondering if there > is a way to write a for-loop in python similar to that of C style. > > for(int i = 0; i < a_big_number; ++ i) > > Don't use range(); range creates allocates an entire list-- thus its quite expensive for big numbers. Use xrange instead, which generates one number at a time as its consumed. HTH, --S
-- http://mail.python.org/mailman/listinfo/python-list