Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #60159
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.007 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'sufficient': 0.05; 'nested': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'numpy': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'header:User-Agent:1': 0.23; 'certainly': 0.24; 'script': 0.25; 'header:X-Complaints-To:1': 0.27; 'wondering': 0.29; 'subject:list': 0.30; 'lists': 0.32; 'moment': 0.34; 'but': 0.35; 'replies': 0.36; 'should': 0.36; 'list': 0.37; 'easily': 0.37; 'thank': 0.38; 'handle': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'skip:u 10': 0.60; 'more': 0.64; 'more?': 0.84; 'replies.': 0.84 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Peter Otten <__peter__@web.de> |
| Subject | Re: zip list, variables |
| Date | Thu, 21 Nov 2013 09:58:54 +0100 |
| Organization | None |
| References | <31cfb6e8-aa7e-46c2-ae0b-18d0d66e7bed@googlegroups.com> <qoteh6bwduh.fsf@ruuvi.it.helsinki.fi> <898792ac-2101-4b92-86e1-f4f9c986de28@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="ISO-8859-1" |
| Content-Transfer-Encoding | 7Bit |
| X-Gmane-NNTP-Posting-Host | p5084a6c3.dip0.t-ipconnect.de |
| User-Agent | KNode/4.7.3 |
| 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.3004.1385024316.18130.python-list@python.org> (permalink) |
| Lines | 27 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1385024316 news.xs4all.nl 15926 [2001:888:2000:d::a6]:34407 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:60159 |
Show key headers only | View raw
flebber wrote:
> Thank you for the replies.
>
> Looking at the replies I am wondering which solution is more scalable. At
> the moment it is only 2 nested lists but what about 5, 10, 20 or more?
>
> Should I start looking into numpy to handle this or will list
> comprehension
> >>> [ [ x + y for x, y in zip(x,y) ] for x, y in zip(a,b) ]
> Be sufficient ?
I would certainly prefer
>>> a + b
array([[ 6, 8],
[10, 12]])
over the incomprehensible comprehension. But if it is the only usecase for
numpy in your script and you are OK with its current performance, just put
your listcomp into an aptly named function. Then you can write the easily
understandable
c = matrix_add(a, b)
and avoid the numpy dependency.
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
zip list, variables flebber <flebber.crue@gmail.com> - 2013-11-20 02:06 -0800
Re: zip list, variables Peter Otten <__peter__@web.de> - 2013-11-20 11:38 +0100
Re: zip list, variables Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2013-11-20 12:45 +0200
Re: zip list, variables flebber <flebber.crue@gmail.com> - 2013-11-20 12:05 -0800
Re: zip list, variables Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-11-21 01:03 +0000
Re: zip list, variables Peter Otten <__peter__@web.de> - 2013-11-21 09:58 +0100
csiph-web