Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #75780
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <usethisid2014@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.010 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; '-*-': 0.07; 'nested': 0.07; 'utf-8': 0.07; 'coding:': 0.09; 'idea?': 0.09; 'skip:# 60': 0.09; 'def': 0.12; '"python': 0.16; 'arent': 0.16; 'itertools': 0.16; 'numpy': 0.16; 'subject:skip:m 10': 0.16; 'import': 0.22; 'print': 0.22; 'skip:_ 20': 0.27; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'skip:p 30': 0.29; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; '"': 0.31; 'skip:m 60': 0.31; 'supposed': 0.32; 'run': 0.32; 'received:google.com': 0.35; '8bit%:9': 0.36; 'subject:?': 0.36; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'skip:\xc2 10': 0.60; 'times': 0.62; 'making': 0.63; '8bit%:10': 0.64; 'dear': 0.65; '\xc2\xa0\xc2\xa0': 0.74; 'subject:space': 0.84 |
| 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 :content-type; bh=Aj5fat4+/1daawH2xQE2FyDz0rBf/PER1+eG9bvA05I=; b=vuGtlHFEwkD9OkxuaZdfqmd7+xFK8IdqSRjcE6CQTcfaeE2n6SgzmmfysrLXiPDWDx MyEWdk9rFjlXlaQTtwj8/by6+wPI1W9e4vMzpfclc4vGJEFmAwO9+vGegdmfDTwAUSwT anNBFU4dpEpo+YoLW4BFuzONKxeeNSDVIQlMwahTXOGxLIhbyi2tKszPFUA20e+xyk+j 9KctBw5jEffXK1om6Ai+NDb8ftIW48+tPDXSsz1WkXU2aGkIpxafVoEE5ZNvadT1I2zQ 0wWa2C94TT9wwN4Ldflkc4d5d3yV6KAcIlXuWjPhu6e6gzJHwpzTtAFASWvsyMpQ73hT z9XA== |
| MIME-Version | 1.0 |
| X-Received | by 10.194.9.228 with SMTP id d4mr12024346wjb.99.1407303253141; Tue, 05 Aug 2014 22:34:13 -0700 (PDT) |
| In-Reply-To | <lrrggd$6hk$1@dont-email.me> |
| References | <lrrdfc$7q7$1@dont-email.me> <lrrggd$6hk$1@dont-email.me> |
| Date | Wed, 6 Aug 2014 11:04:13 +0530 |
| Subject | Re: Pythonic way to iterate through multidimensional space? |
| From | Gayathri J <usethisid2014@gmail.com> |
| To | python-list@python.org |
| Content-Type | multipart/alternative; boundary=047d7b4508a87eae0904ffef52a8 |
| X-Mailman-Approved-At | Wed, 06 Aug 2014 08:11:38 +0200 |
| 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.12688.1407305499.18130.python-list@python.org> (permalink) |
| Lines | 99 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1407305499 news.xs4all.nl 2888 [2001:888:2000:d::a6]:53599 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:75780 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
Dear Peter 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? *############################################################* *# -*- coding: utf-8 -*-* *import numpy as np* *import time* *from itertools import product,repeat* *def main():* * # N - size of grid* * # nvel - number of velocities* * # times - number of times to run the functions* * N=256* * times=3* * f=np.random.rand(N,N,N)* * # using loops* * print "normal nested loop"* * python_dot_loop1(f,times,N)* * print "nested loop using itertools.product()"* * python_dot_loop2(f,times,N)* *def python_dot_loop1(f,times,N):* * for t in range(times):* * t1=time.time()* * for i in range(N):* * for j in range(N):* * for k in range(N):* * f[i,j,k] = 0.0* * print "python dot loop " + str(time.time()-t1)* *def python_dot_loop2(f,times,N):* * rangeN=range(N)* * for t in range(times):* * t1=time.time()* * for i,j,k in product(rangeN,repeat=3):* * f[i,j,k]=0.0* * print "python dot loop " + str(time.time()-t1)* *if __name__=='__main__':* * main()* *############################################################*
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