Path: csiph.com!usenet.pasdenom.info!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'from:addr:yahoo.co.uk': 0.04; 'languages,': 0.04; 'failing': 0.07; 'suddenly': 0.07; 'default.': 0.09; 'enormous': 0.09; 'iterate': 0.09; 'lawrence': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'seemed': 0.09; 'python': 0.11; 'language.': 0.14; 'before!': 0.16; 'callable': 0.16; 'denote': 0.16; 'finney': 0.16; 'iterator': 0.16; 'loop.': 0.16; 'looping': 0.16; 'porting': 0.16; 'pythonic': 0.16; 'range,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'all.': 0.16; 'language': 0.16; 'wrote:': 0.18; 'looked': 0.18; 'acquired': 0.19; '>>>': 0.22; 'example': 0.22; 'coding': 0.22; 'saying': 0.22; 'header:User-Agent:1': 0.23; 'integer': 0.24; 'earlier': 0.24; 'equivalent': 0.26; 'values': 0.27; 'header:X -Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'change,': 0.30; 'code': 0.31; '>>>>': 0.31; 'overhead': 0.31; 'writes:': 0.31; 'probably': 0.32; 'ago': 0.33; 'maybe': 0.34; 'agree': 0.35; 'created': 0.35; 'convert': 0.35; 'done.': 0.35; 'but': 0.35; 'really': 0.36; "didn't": 0.36; 'turn': 0.37; 'list': 0.37; 'being': 0.38; 'ben': 0.38; 'to:addr:python-list': 0.38; 'issue': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'most': 0.60; 'numbers': 0.61; 'range': 0.61; 'simply': 0.61; 'simple': 0.61; 'first': 0.61; 'our': 0.64; 'here': 0.66; "'range'": 0.84; 'category.': 0.84; 'idiom': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: Re: l = range(int(1E9)) Date: Sat, 02 May 2015 17:39:20 +0100 References: <87k2wtvbx1.fsf@Equus.decebal.nl> <_M61x.477467$Ek.357048@fx07.am4> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: host-92-24-208-134.ppp.as43234.net User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 In-Reply-To: <_M61x.477467$Ek.357048@fx07.am4> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 54 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1430584786 news.xs4all.nl 2867 [2001:888:2000:d::a6]:47673 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:89778 On 02/05/2015 17:17, BartC wrote: > On 02/05/2015 16:40, Mark Lawrence wrote: >> On 02/05/2015 16:26, BartC wrote: >>> On 30/04/2015 18:20, Ben Finney wrote: >>>> Jon Ribbens writes: >>> >>>>> If you use xrange() instead of range() then you will get an iterator >>>>> which will return each of the numbers in turn without any need to >>>>> create an enormous list of all of them. >>>> >>>> If you use Python 3 instead of the obsolescent Python 2, the ‘range’ >>>> callable has this sensible behaviour by default. >>> >>> When I first looked at Python 20 or so years ago this seemed to be the >>> standard way of writing a for-loop: >>> >>> for i in range(N): >>> .... >>> >>> I remember being completely astonished at the time that 'range' actually >>> created a list of values from 0 to N-1. > >> I first started maybe 14 years ago and the standard way of writing a for >> loop was, and still is:- >> >> for item in items: >> >> When did this change, or has it always been this way and you were simply >> using an idiom from other languages? > > Your example is the equivalent of 'forall' in other languages, where you > iterate over the values of some collection of data. > > I agree that most for-loops in Pythonic code probably fall into that > category. > > But for looping over a simple integer range, then using 'range' to > denote the range (and build a list as it used to do), was how it was > done. And earlier on people would have been porting coding code to > Python at which point a straightforward 'for i=a to b' loop suddenly > acquired a substantial overhead it didn't have before! > All you are saying is that they didn't bother reading the docs and learning how to write a *PYTHON* for loop. Failing that don't bother using range, just directly convert your (say) C loop into Python. I really don't see any issue here at all. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence