Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #82428
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Christian Gollwitzer <auriocus@gmx.de> |
| Newsgroups | comp.lang.python |
| Subject | Re: list comprehension return a list and sum over in loop |
| Date | Fri, 12 Dec 2014 10:09:17 +0100 |
| Organization | A noiseless patient Spider |
| Lines | 16 |
| Message-ID | <m6ebbb$484$1@dont-email.me> (permalink) |
| References | <fa1c4908-8fde-424a-87af-f9741b682c37@googlegroups.com> <mailman.16893.1418368651.18130.python-list@python.org> <d03ea4ee-a361-4901-b799-d7d1c5f85ee5@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8; format=flowed |
| Content-Transfer-Encoding | 8bit |
| Injection-Date | Fri, 12 Dec 2014 09:08:59 +0000 (UTC) |
| Injection-Info | mx02.eternal-september.org; posting-host="0e5522bc36df6ad040e4598fab9db9ed"; logging-data="4356"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+S1v28cySNDt7zUhZH7Yw8/CdYul/1e8E=" |
| User-Agent | Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 |
| In-Reply-To | <d03ea4ee-a361-4901-b799-d7d1c5f85ee5@googlegroups.com> |
| Cancel-Lock | sha1:baHWfV4X3K4EAc2el/F5elebqk8= |
| Xref | csiph.com comp.lang.python:82428 |
Show key headers only | View raw
Am 12.12.14 09:30, schrieb KK Sasa: > Mark Lawrence於 2014年12月12日星期五UTC+8下午3時17分43秒寫道: > Hi Mark and Yotam, Thanks for kind reply. I think I didn't make my > problem clear enough. The slow part is "[d2(t[k]) for k in > xrange(1000)]". In addition, I don't need to construct a list of 1000 > lists inside, but my aim is to get the sum of all "d2(t[k])". I > wonder if there is any method to sum up efficiently. Not sure I understand what you need, but it seems that NumPy would be a more efficient method. numpy.sum can sum elements along every dimensions of a higher-dimensional matrix, and in general NumPy stores the elements in native doubles instead of Python lists, which improves both performance and memory usage Christian
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
list comprehension return a list and sum over in loop KK Sasa <genwei007@gmail.com> - 2014-12-11 22:22 -0800
Re: list comprehension return a list and sum over in loop Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-12-12 07:17 +0000
Re: list comprehension return a list and sum over in loop KK Sasa <genwei007@gmail.com> - 2014-12-12 00:30 -0800
Re: list comprehension return a list and sum over in loop Christian Gollwitzer <auriocus@gmx.de> - 2014-12-12 10:09 +0100
Re: list comprehension return a list and sum over in loop Peter Otten <__peter__@web.de> - 2014-12-12 10:13 +0100
Re: list comprehension return a list and sum over in loop KK Sasa <genwei007@gmail.com> - 2014-12-12 01:45 -0800
Re: list comprehension return a list and sum over in loop Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2014-12-12 13:12 +0200
Re: list comprehension return a list and sum over in loop Peter Otten <__peter__@web.de> - 2014-12-12 13:32 +0100
Re: list comprehension return a list and sum over in loop KK Sasa <genwei007@gmail.com> - 2014-12-12 05:09 -0800
Re: list comprehension return a list and sum over in loop Peter Otten <__peter__@web.de> - 2014-12-12 17:08 +0100
Re: list comprehension return a list and sum over in loop KK Sasa <genwei007@gmail.com> - 2014-12-12 19:04 -0800
Re: list comprehension return a list and sum over in loop Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-12-13 11:27 +0000
Re: list comprehension return a list and sum over in loop KK Sasa <genwei007@gmail.com> - 2014-12-12 05:03 -0800
Re: list comprehension return a list and sum over in loop Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-12-12 20:46 +1100
Re: list comprehension return a list and sum over in loop Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2014-12-12 16:47 +0000
Re: list comprehension return a list and sum over in loop pecore@pascolo.net - 2014-12-13 13:38 +0100
csiph-web