Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #49968
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news2.arglkargh.de!news.karotte.org!fu-berlin.de!uni-berlin.de!news.dfncis.de!not-for-mail |
|---|---|
| From | Helmut Jarausch <jarausch@igpm.rwth-aachen.de> |
| Newsgroups | comp.lang.python |
| Subject | Re: How to make this faster |
| Date | 5 Jul 2013 10:53:35 GMT |
| Lines | 28 |
| Message-ID | <b3nmtfFojnkU3@mid.dfncis.de> (permalink) |
| References | <b3ne2rFojnkU1@mid.dfncis.de> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | 8bit |
| X-Trace | news.dfncis.de lDA8iG4WSZ4xSNsJ7B3HNgIC2BqoLry/pB8D7b38kei4M0ZVkML2AbgIJM |
| Cancel-Lock | sha1:S1411fLn9vTIUHjag0SfsC3frcg= |
| User-Agent | Pan/0.139 (Sexual Chocolate; GIT bf56508 git://git.gnome.org/pan2) |
| Xref | csiph.com comp.lang.python:49968 |
Show key headers only | View raw
On Fri, 05 Jul 2013 11:13:33 +0100, Oscar Benjamin wrote: > My one comment is that you're not really making the most out of numpy > arrays. Numpy's ndarrays are efficient when each line of Python code > is triggering a large number of numerical computations performed over > the array. Because of their N-dimensional nature and the fact that > they are in some sense second class citizens in CPython they are often > not as good as lists for this kind of looping and indexing. > > I would actually expect this program to run faster with ordinary > Python lists and lists of lists. It means that you need to change e.g. > Grid[r, c] to Grid[r][c] but really I think that the indexing syntax > is all you're getting out of numpy here. > Thanks Oscar, that was a big improvement, indeed. Using lists of lists instead of numpy arrays made the code more than twice as fast (13 seconds down to 6 seconds) Since I don't do any numerical stuff with the arrays, Numpy doesn't seem to be a good choice. I think this is an argument to add real arrays to Python. I even tried to use dictionaries instead of Numpy arrays. This version is a bit slower then the lists of lists version (7.2 seconds instead of 6 second) but still much faster than the Numpy array solution. Helmut
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How to make this faster Helmut Jarausch <jarausch@igpm.rwth-aachen.de> - 2013-07-05 08:22 +0000
Re: How to make this faster Fábio Santos <fabiosantosart@gmail.com> - 2013-07-05 10:38 +0100
Re: How to make this faster Helmut Jarausch <jarausch@igpm.rwth-aachen.de> - 2013-07-05 10:07 +0000
Re: How to make this faster Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-07-05 11:13 +0100
Re: How to make this faster Helmut Jarausch <jarausch@igpm.rwth-aachen.de> - 2013-07-05 10:53 +0000
Re: How to make this faster Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-07-05 12:02 +0000
Re: How to make this faster Fábio Santos <fabiosantosart@gmail.com> - 2013-07-05 13:44 +0100
Re: How to make this faster Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-07-05 14:41 +0100
Re: How to make this faster Helmut Jarausch <jarausch@igpm.rwth-aachen.de> - 2013-07-05 14:28 +0000
Re: How to make this faster Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-07-05 15:45 +0100
Re: How to make this faster Helmut Jarausch <jarausch@igpm.rwth-aachen.de> - 2013-07-05 14:48 +0000
Re: How to make this faster Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-07-05 16:26 +0100
Re: How to make this faster Helmut Jarausch <jarausch@igpm.rwth-aachen.de> - 2013-07-05 14:54 +0000
Re: How to make this faster Fábio Santos <fabiosantosart@gmail.com> - 2013-07-05 16:18 +0100
Re: How to make this faster Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-07-05 16:24 +0000
Re: How to make this faster Helmut Jarausch <jarausch@igpm.rwth-aachen.de> - 2013-07-05 15:17 +0000
Re: How to make this faster Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-07-05 16:38 +0100
Re: How to make this faster MRAB <python@mrabarnett.plus.com> - 2013-07-05 17:25 +0100
Re: How to make this faster Joshua Landau <joshua.landau.ws@gmail.com> - 2013-07-06 02:45 +0100
Re: How to make this faster Helmut Jarausch <jarausch@igpm.rwth-aachen.de> - 2013-07-05 15:47 +0000
Re: How to make this faster Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-07-05 16:52 +0000
Re: How to make this faster Helmut Jarausch <jarausch@igpm.rwth-aachen.de> - 2013-07-05 16:07 +0000
Re: How to make this faster Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-07-05 16:50 +0000
Re: How to make this faster Helmut Jarausch <jarausch@igpm.rwth-aachen.de> - 2013-07-05 18:39 +0000
Re: How to make this faster Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-07-06 03:05 +0000
Re: How to make this faster Helmut Jarausch <jarausch@igpm.rwth-aachen.de> - 2013-07-06 07:25 +0000
Re: How to make this faster Helmut Jarausch <jarausch@igpm.rwth-aachen.de> - 2013-07-05 18:42 +0000
csiph-web