Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder7.xlned.com!news2.euro.net!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.091 X-Spam-Evidence: '*H*': 0.85; '*S*': 0.03; 'val': 0.09; 'subject:How': 0.10; 'cc:addr:python-list': 0.11; 'suggest': 0.14; 'subject:make': 0.16; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; '>': 0.26; 'header:In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; '+0100,': 0.31; 'fri,': 0.33; 'received:google.com': 0.35; 'work?': 0.38; 'does': 0.39; '\xa0\xa0\xa0': 0.39; 'how': 0.40; 'range': 0.61; 'jul': 0.74; 'subject:this': 0.83; 'faster.': 0.84; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=SXUnnMMzqFlW5k70MYIpXXJJTg9GNcs3FAGc0uS0lVo=; b=XrlqZeFLPisFQNAXH7hCqxJnSdHJZ2dLQ2HLwS7l+vqdKbEk7Rz5i6w9vxduJiTeOT kaLD09GHX32kZUNXqz68HIs/Y/UGTSYB1zMOqnO+HgOMm9l91EEWDiPmKOdBRIw0uNuH +lTFPiajodq9oci6p3LyvaUgiVg0NP3D8GPlACnwrSFjgm12U+VCdBmvanxlnFMYh5Bh 5Yw1TuG1rYJfQGnlaKMOzrsdPAUc62FU6rFqFMwy3B1aV9uLVTBzrZgY/8o/obYW06bM LB4w5Eonm5DybCCxFTgP9GKhVtjfCCshcQvHO6T1hsXf3CsTMljiH2rv9cYJF1G8Sfkz 7cSA== MIME-Version: 1.0 X-Received: by 10.224.147.145 with SMTP id l17mr9484059qav.3.1373037521999; Fri, 05 Jul 2013 08:18:41 -0700 (PDT) In-Reply-To: References: Date: Fri, 5 Jul 2013 16:18:41 +0100 Subject: Re: How to make this faster From: =?ISO-8859-1?Q?F=E1bio_Santos?= To: Helmut Jarausch Content-Type: multipart/alternative; boundary=089e0160b624c31d2904e0c535cb Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 50 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1373037531 news.xs4all.nl 15941 [2001:888:2000:d::a6]:52241 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:49993 --089e0160b624c31d2904e0c535cb Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 5 Jul 2013 15:59, "Helmut Jarausch" wrote= : > > On Fri, 05 Jul 2013 13:44:57 +0100, F=E1bio Santos wrote: > May I suggest you avoid range and use enumerate(the_array) instead? It > might be faster. > > How does this work? > > Given > > Grid=3D [[0 for j in range(9)] for i in range(9)] > > for (r,c,val) in ????(Grid) : > > Helmut for r, row_lst in enumerate(Grid): for c, val in enumerate(row_lst): --089e0160b624c31d2904e0c535cb Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable


On 5 Jul 2013 15:59, "Helmut Jarausch" <jarausch@igpm.rwth-aachen.de> wrote:
>
> On Fri, 05 Jul 2013 13:44:57 +0100, F=E1bio Santos wrote:
> May I suggest you avoid range and use enumerate(the_array) instead? It=
> might be faster.
>
> How does this work?
>
> Given
>
> Grid=3D [[0 for j in range(9)] for i in range(9)]
>
> for (r,c,val) in ????(Grid) :
>
> Helmut

for r, row_lst in enumerate(Grid):
=A0=A0=A0 for c, val in enumerate(row_lst):

--089e0160b624c31d2904e0c535cb--