Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!bcyclone05.am1.xlned.com!bcyclone05.am1.xlned.com!newsfeed.xs4all.nl!newsfeed3.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.081 X-Spam-Evidence: '*H*': 0.84; '*S*': 0.00; 'python': 0.11; '2.7': 0.14; 'from:addr:torriem': 0.16; 'from:name:michael torrie': 0.16; 'range,': 0.16; 'range.': 0.16; 'xrange': 0.16; 'wrote:': 0.18; 'module': 0.19; 'import': 0.22; 'header:User-Agent:1': 0.23; '(for': 0.26; 'header:In-Reply-To:1': 0.27; 'points': 0.29; 'workaround': 0.31; 'but': 0.35; 'library.': 0.36; 'example,': 0.37; 'message-id:@gmail.com': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'then,': 0.60; 'kind': 0.63; 'forward': 0.65; 'charset:windows-1252': 0.65; 'six': 0.68; 'wish': 0.70; 'inefficient': 0.91 X-Virus-Scanned: amavisd-new at torriefamily.org Date: Sat, 02 May 2015 20:07:31 -0600 From: Michael Torrie User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: l = range(int(1E9)) References: <87k2wtvbx1.fsf@Equus.decebal.nl> <_M61x.477467$Ek.357048@fx07.am4> In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit 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: 17 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1430618863 news.xs4all.nl 2845 [2001:888:2000:d::a6]:38859 X-Complaints-To: abuse@xs4all.nl X-Received-Bytes: 3440 X-Received-Body-CRC: 887993490 Xref: csiph.com comp.lang.python:89820 On 05/02/2015 04:33 PM, BartC wrote: > OK, so it's just an irritation then, as a workaround has been available > for a long time. (For example, if you use xrange, it won't work on 3.x. > If you use range, then it might be inefficient on 2.x.) In both Python 2.7 and 3.3+, you can use the 3rd-party six module to help with forward compatibility: from six.moves import xrange In Python 2.7, it's just the normal xrange (importing is a no op basically), but in Python 3 it points to range. Kind of wish parts of six were in the Python standard library.