Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #75781
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!weretis.net!feeder1.news.weretis.net!news.albasani.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.012 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'nested': 0.07; 'arguments': 0.09; 'idea?': 0.09; 'iterate': 0.09; 'cc:addr :python-list': 0.11; '*args': 0.16; 'arent': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'loops': 0.16; 'subject:skip:m 10': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'wed,': 0.18; 'aug': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'thus': 0.29; 'message-id:@mail.gmail.com': 0.30; '(which': 0.31; 'code': 0.31; 'bunch': 0.31; 'cap': 0.31; 'dimensions': 0.31; 'supposed': 0.32; 'run': 0.32; "can't": 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'subject:?': 0.36; 'pm,': 0.38; 'sure': 0.39; 'how': 0.40; 'worry': 0.60; 'making': 0.63; 'faster.': 0.84; 'subject:space': 0.84; 'worry,': 0.84; 'to:none': 0.92 |
| 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:cc :content-type; bh=GlrVtB6R2chfAZekGYo/fO70MKAJfN/2wugTFuSvqi4=; b=PF6MLX/UcIaKYFyQSOzeVVzGb5CQ4piY+z4+ZqXU9h5CqburqAt08GeBzE87PhFNDK UGvOxkSnMNnepGVeGR5i+wDl9lmtWnV/ikdvFTJoyo8t37IfWnG0AnskMME2L4YulWAL JL5Z7wI/X2Fqxlxw2jIWVHFo8NKWlQtYAhWhslltd0vCcRUDAWTTTDsKC25XSZk6N4rg iGvtmtp/dKur2nKm+bufHTcwMGk4s6HEj9XN5gzNmj40oyic5duLTN4yYYdLOc1lyFuz DisNRC7/X+6+gS2cy8914dA0Cs2UfzAy5G8XrN5tIw58Y9AdpdaRWp9Pb2l4gwYzpltt xliQ== |
| MIME-Version | 1.0 |
| X-Received | by 10.42.216.148 with SMTP id hi20mr11709930icb.12.1407306344120; Tue, 05 Aug 2014 23:25:44 -0700 (PDT) |
| In-Reply-To | <CAKiaUYzvFztyJt+eBp50VSiLmjb8Gg=+Z8YBjud_0K8dDPEYkA@mail.gmail.com> |
| References | <lrrdfc$7q7$1@dont-email.me> <lrrggd$6hk$1@dont-email.me> <CAKiaUYzvFztyJt+eBp50VSiLmjb8Gg=+Z8YBjud_0K8dDPEYkA@mail.gmail.com> |
| Date | Wed, 6 Aug 2014 16:25:44 +1000 |
| Subject | Re: Pythonic way to iterate through multidimensional space? |
| From | Chris Angelico <rosuav@gmail.com> |
| Cc | "python-list@python.org" <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.12689.1407306352.18130.python-list@python.org> (permalink) |
| Lines | 16 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1407306352 news.xs4all.nl 2914 [2001:888:2000:d::a6]:56454 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:75781 |
Show key headers only | View raw
On Wed, Aug 6, 2014 at 3:34 PM, Gayathri J <usethisid2014@gmail.com> wrote: > Below is the code I tried to check if itertools.product() was faster than > normal nested loops... > > they arent! arent they supposed to be...or am i making a mistake? any idea? Don't worry about what's faster. That almost never matters. Worry, instead, about how you would code it if you can't be sure how many dimensions there'll be until run time (which the OP said can happen). With product(), you can give it a variable number of arguments (eg with *args notation), but with loops, you'd need to compile up some code with that many nested loops - or at best, something where you cap the number of loops and thus dimensions, and have a bunch of them iterate over a single iterable. ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Pythonic way to iterate through multidimensional space? Frank Miles <fpm@u.washington.edu> - 2014-08-05 20:06 +0000
Re: Pythonic way to iterate through multidimensional space? Peter Otten <__peter__@web.de> - 2014-08-05 22:48 +0200
Re: Pythonic way to iterate through multidimensional space? Frank Miles <fpm@u.washington.edu> - 2014-08-05 20:57 +0000
Re: Pythonic way to iterate through multidimensional space? Gayathri J <usethisid2014@gmail.com> - 2014-08-06 11:04 +0530
Re: Pythonic way to iterate through multidimensional space? Chris Angelico <rosuav@gmail.com> - 2014-08-06 16:25 +1000
Re: Pythonic way to iterate through multidimensional space? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-08-06 08:33 +0100
Re: Pythonic way to iterate through multidimensional space? Peter Otten <__peter__@web.de> - 2014-08-06 09:39 +0200
Re: Pythonic way to iterate through multidimensional space? Tim Chase <python.list@tim.thechases.com> - 2014-08-06 06:39 -0500
Re: Pythonic way to iterate through multidimensional space? Wojciech Giel <wojtekgiel@gmail.com> - 2014-08-06 09:04 +0100
Re: Pythonic way to iterate through multidimensional space? Gayathri J <usethisid2014@gmail.com> - 2014-08-06 17:43 +0530
Re: Pythonic way to iterate through multidimensional space? Peter Otten <__peter__@web.de> - 2014-08-06 14:39 +0200
Re: Pythonic way to iterate through multidimensional space? Gayathri J <usethisid2014@gmail.com> - 2014-08-06 18:57 +0530
csiph-web