Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #32857
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python@mrabarnett.plus.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'removes': 0.05; '*not*': 0.07; 'function,': 0.07; 'list?': 0.07; 'nested': 0.07; 'operand': 0.07; 'patterns.': 0.07; 'rejected': 0.07; 'python': 0.09; 'commonly': 0.09; 'confuse': 0.09; 'imply': 0.09; 'mutable': 0.09; 'semantics': 0.09; 'typeerror:': 0.09; 'passing': 0.15; 'weird': 0.15; "'int'": 0.16; 'appends': 0.16; 'copied,': 0.16; 'copied.': 0.16; 'does;': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'losing': 0.16; 'merely': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'objection': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'uncommon': 0.16; 'unsupported': 0.16; 'developers,': 0.16; 'wrote:': 0.17; 'copied': 0.17; 'duplicate': 0.17; 'passes': 0.17; 'typing': 0.17; 'obviously': 0.18; '>>>': 0.18; 'proposed': 0.20; 'trying': 0.21; 'do.': 0.21; '"",': 0.22; 'either.': 0.22; 'subject:skip:i 10': 0.22; 'example': 0.23; 'elements': 0.23; "python's": 0.23; 'sets': 0.23; 'idea': 0.24; 'url:bugs': 0.24; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; '(most': 0.27; 'andrew': 0.27; 'subject:list': 0.28; 'arrays': 0.29; 'consistency': 0.29; 'received:192.168.1.3': 0.29; 'no,': 0.29; 'objects': 0.29; 'this.': 0.29; 'function': 0.30; 'compatible': 0.30; 'expect': 0.31; 'lists': 0.31; 'url:python': 0.32; 'file': 0.32; 'not.': 0.32; 'received:84': 0.32; "aren't": 0.33; 'cases,': 0.33; 'traceback': 0.33; 'anyone': 0.33; 'to:addr :python-list': 0.33; 'languages': 0.33; "can't": 0.34; 'list': 0.35; 'lists.': 0.35; 'nov': 0.35; 'expected': 0.35; 'pm,': 0.35; "won't": 0.35; 'something': 0.35; 'list.': 0.35; 'but': 0.36; 'url:org': 0.36; 'characters': 0.36; 'useful': 0.36; 'does': 0.37; 'two': 0.37; 'uses': 0.37; 'being': 0.37; 'why': 0.37; 'passed': 0.37; 'subject:: ': 0.38; 'copying': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'list,': 0.39; 'received:192.168': 0.40; 'subject:-': 0.40; 'think': 0.40; 'link': 0.60; "you've": 0.61; 'more.': 0.62; 'time,': 0.62; 'behavior': 0.64; 'total': 0.65; 'stuck': 0.65; 'potentially': 0.66; 'header:Reply-To:1': 0.68; 'reply-to:no real name:2**0': 0.72; 'saving': 0.72; 'delegation': 0.84; 'hardly': 0.84; 'multiply': 0.84; 'reply- to:addr:python.org': 0.84; 'type(s)': 0.84; 'reasoning': 0.91; 'besides,': 0.93; 'favour': 0.93; 'mistakes': 0.95 |
| X-CM-Score | 0.00 |
| X-CNFS-Analysis | v=2.0 cv=Bd1aI8R2 c=1 sm=1 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=1EKJ2blYo8kA:10 a=RHlel35PpJcA:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=4905VYxiF58A:10 a=5si1IOfVAAAA:8 a=uPZiAMpXAAAA:8 a=B2bSIM20ZUjFI9eD_GgA:9 a=wPNLvfGTeEIA:10 a=90B7yJRffNkA:10 a=0nF1XD0wxitMEM03M9B4ZQ==:117 |
| X-AUTH | mrabarnett:2500 |
| Date | Wed, 07 Nov 2012 00:23:44 +0000 |
| From | MRAB <python@mrabarnett.plus.com> |
| User-Agent | Mozilla/5.0 (Windows NT 5.1; rv:16.0) Gecko/20121026 Thunderbird/16.0.2 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: Multi-dimensional list initialization |
| References | <mailman.3267.1352096879.27098.python-list@python.org> <50978323$0$6908$e4fe514c@news2.news.xs4all.nl> <CAHVvXxQR2J2tyFcQZd7bNYTAeetwM+LfoV4UcYrkRfeNVOj+pg@mail.gmail.com> <CAPTjJmqzQi2TEjme_we-KfmG7vxOfRWoKG=zL=SGHYGqiFf9_Q@mail.gmail.com> <CAHVvXxQNCxpACM=tkKir0f3iVqui4oVGnyS-GywO+dtGacKAdQ@mail.gmail.com> <mailman.3311.1352181444.27098.python-list@python.org> <5098d2ac$0$29980$c3e8da3$5496439d@news.astraweb.com> <50999214.50100@r3dsolutions.com> <CALwzidmQgkQUYZDp3Tkbw+5KZ7-frF+g8rfkqcTT3ORj2ZA-pg@mail.gmail.com> |
| In-Reply-To | <CALwzidmQgkQUYZDp3Tkbw+5KZ7-frF+g8rfkqcTT3ORj2ZA-pg@mail.gmail.com> |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| Reply-To | python-list@python.org |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://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 | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3349.1352248012.27098.python-list@python.org> (permalink) |
| Lines | 83 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1352248012 news.xs4all.nl 6904 [2001:888:2000:d::a6]:60293 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:32857 |
Show key headers only | View raw
On 2012-11-06 23:52, Ian Kelly wrote:
> On Tue, Nov 6, 2012 at 3:41 PM, Andrew Robinson
> <andrew3@r3dsolutions.com> wrote:
>>> Q: What about other mutable objects like sets or dicts?
>>> A: No, the elements are never copied.
>>
>> They aren't list multiplication compatible in any event! It's a total
>> nonsense objection.
>>
>> If these are inconsistent in my idea -- OBVIOUSLY -- they are inconsistent
>> in Python's present implementation. You can't even reference duplicate them
>> NOW.
>>
>>>>> { 1:'a', 2:'b', 3:'c' } * 2
>>
>> Traceback (most recent call last):
>> File "<stdin>", line 1, in <module>
>> TypeError: unsupported operand type(s) for *: 'dict' and 'int'
>
> The objection is not nonsense; you've merely misconstrued it. If
> [[1,2,3]] * 4 is expected to create a mutable matrix of 1s, 2s, and
> 3s, then one would expect [[{}]] * 4 to create a mutable matrix of
> dicts. If the dicts are not copied, then this fails for the same
> reason
>
>>> Q: How about if I use delegation to proxy a list?
>>> A: Oh no, they definitely won't be copied.
>>
>> Give an example usage of why someone would want to do this. Then we can
>> discuss it.
>
> Seriously? Read a book on design patterns. You might start at SO:
>
> http://stackoverflow.com/questions/832536/when-to-use-delegation-instead-of-inheritance
>
>>> Losing consistency in favour of saving a few characters for something as
>>> uncommon as list multiplication is a poor tradeoff. That's why this
>>> proposal has been rejected again and again and again every time it has
>>> been suggested.
>>
>> Please link to the objection being proposed to the developers, and their
>> reasoning for rejecting it.
>> I think you are exaggerating.
>
>>From Google:
>
> http://bugs.python.org/issue1408
> http://bugs.python.org/issue12597
> http://bugs.python.org/issue9108
> http://bugs.python.org/issue7823
>
> Note that in two out of these four cases, the reporter was trying to
> multiply lists of dicts, not just lists of lists.
>
>> Besides, 2D arrays are *not* rare and people *have* to copy internals of
>> them very often.
>> The copy speed will be the same or *faster*, and the typing less -- and the
>> psychological mistakes *less*, the elegance more.
>
> List multiplication is not potentially useful for copying 2D lists,
> only for initializing them. For copying an existing nested list,
> you're still stuck with either copy.deepcopy() or a list
> comprehension.
>
>> It's hardly going to confuse anyone to say that lists are copied with list
>> multiplication, but the elements are not.
>>
>> Every time someone passes a list to a function, they *know* that the list is
>> passed by value -- and the elements are passed by reference. People in
>> Python are USED to lists being "the" way to weird behavior that other
>> languages don't do.
>
> Incorrect. Python uses what is commonly known as call-by-object, not
> call-by-value or call-by-reference. Passing the list by value would
> imply that the list is copied, and that appends or removes to the list
> inside the function would not affect the original list. This is not
> what Python does; the list inside the function and the list passed in
> are the same list. At the same time, the function does not have
> access to the original reference to the list and cannot reassign it by
> reassigning its own reference, so it is not call-by-reference
> semantics either.
>
I prefer the term "reference semantics".
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Multi-dimensional list initialization Demian Brecht <demianbrecht@gmail.com> - 2012-11-04 22:27 -0800
Re: Multi-dimensional list initialization Hans Mulder <hansmu@xs4all.nl> - 2012-11-05 10:13 +0100
Re: Multi-dimensional list initialization Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2012-11-06 01:32 +0000
Re: Multi-dimensional list initialization Chris Angelico <rosuav@gmail.com> - 2012-11-06 13:01 +1100
Re: Multi-dimensional list initialization Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2012-11-06 02:30 +0000
Re: Multi-dimensional list initialization Andrew Robinson <andrew3@r3dsolutions.com> - 2012-11-05 21:51 -0800
Re: Multi-dimensional list initialization Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-06 09:04 +0000
RE: Multi-dimensional list initialization "Shambhu Rajak" <shambhu.rajak@calsoftinc.com> - 2012-11-06 18:57 +0530
Re: Multi-dimensional list initialization Andrew Robinson <andrew3@r3dsolutions.com> - 2012-11-06 14:41 -0800
Re: Multi-dimensional list initialization Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-07 01:55 +0000
Re: Multi-dimensional list initialization Demian Brecht <demianbrecht@gmail.com> - 2012-11-06 22:56 -0800
Re: Multi-dimensional list initialization wxjmfauth@gmail.com - 2012-11-07 00:57 -0800
Re: Multi-dimensional list initialization Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-11-07 22:27 +0000
Re: Multi-dimensional list initialization Ian Kelly <ian.g.kelly@gmail.com> - 2012-11-07 16:39 -0700
Re: Multi-dimensional list initialization Ian Kelly <ian.g.kelly@gmail.com> - 2012-11-08 00:09 -0700
Re: Multi-dimensional list initialization Ian Kelly <ian.g.kelly@gmail.com> - 2012-11-08 08:58 -0700
Re: Multi-dimensional list initialization Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-11-09 01:39 +0000
Re: Multi-dimensional list initialization Chris Angelico <rosuav@gmail.com> - 2012-11-09 17:07 +1100
Re: Multi-dimensional list initialization Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-09 06:37 +0000
Re: Multi-dimensional list initialization Chris Angelico <rosuav@gmail.com> - 2012-11-09 17:59 +1100
Re: Multi-dimensional list initialization Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-11-09 07:27 +0000
Re: Multi-dimensional list initialization rusi <rustompmody@gmail.com> - 2012-11-09 07:05 -0800
Re: Multi-dimensional list initialization Chris Angelico <rosuav@gmail.com> - 2012-11-10 02:23 +1100
Re: Multi-dimensional list initialization Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-11-09 14:34 -0500
RE: Multi-dimensional list initialization "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-11-09 20:31 +0000
Re: Multi-dimensional list initialization Ethan Furman <ethan@stoneleaf.us> - 2012-11-09 13:49 -0800
RE: Multi-dimensional list initialization "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-11-06 23:39 +0000
Re: Multi-dimensional list initialization Ian Kelly <ian.g.kelly@gmail.com> - 2012-11-06 16:52 -0700
Re: Multi-dimensional list initialization MRAB <python@mrabarnett.plus.com> - 2012-11-07 00:23 +0000
Re: Multi-dimensional list initialization rusi <rustompmody@gmail.com> - 2012-11-06 20:11 -0800
Re: Multi-dimensional list initialization Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-07 05:05 +0000
Re: Multi-dimensional list initialization Roy Smith <roy@panix.com> - 2012-11-07 00:12 -0500
Re: Multi-dimensional list initialization Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2012-11-07 18:32 +1300
RE: Multi-dimensional list initialization "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-11-07 15:57 +0000
Re: Multi-dimensional list initialization Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2012-11-07 10:52 +0200
Re: Multi-dimensional list initialization MRAB <python@mrabarnett.plus.com> - 2012-11-07 17:17 +0000
Re: Multi-dimensional list initialization Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-07 22:36 +0000
Re: Multi-dimensional list initialization Ethan Furman <ethan@stoneleaf.us> - 2012-11-07 07:23 -0800
Re: Multi-dimensional list initialization Ian Kelly <ian.g.kelly@gmail.com> - 2012-11-07 14:01 -0700
Re: Multi-dimensional list initialization Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-08 00:00 +0000
Re: Multi-dimensional list initialization Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2012-11-08 00:30 +0000
Re: Multi-dimensional list initialization Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-08 03:47 +0000
Re: Multi-dimensional list initialization Andrew Robinson <andrew3@r3dsolutions.com> - 2012-11-07 20:51 -0800
Re: Multi-dimensional list initialization wrw@mac.com - 2012-11-08 08:26 -0500
Re: Multi-dimensional list initialization Andrew Robinson <andrew3@r3dsolutions.com> - 2012-11-07 16:24 -0800
Re: Multi-dimensional list initialization Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-08 04:20 +0000
Re: Multi-dimensional list initialization Chris Angelico <rosuav@gmail.com> - 2012-11-06 17:07 +1100
Re: Multi-dimensional list initialization Andrew Robinson <andrew3@r3dsolutions.com> - 2012-11-06 00:21 -0800
Re: Multi-dimensional list initialization Ian Kelly <ian.g.kelly@gmail.com> - 2012-11-06 02:19 -0700
RE: Multi-dimensional list initialization "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-11-06 17:32 +0000
Re: Multi-dimensional list initialization Andrew Robinson <andrew3@r3dsolutions.com> - 2012-11-06 13:14 -0800
Re: Multi-dimensional list initialization Andrew Robinson <andrew3@r3dsolutions.com> - 2012-11-06 13:19 -0800
Re: Multi-dimensional list initialization Ian Kelly <ian.g.kelly@gmail.com> - 2012-11-06 15:46 -0700
Re: Multi-dimensional list initialization Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2012-11-07 18:34 +1300
Re: Multi-dimensional list initialization Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2012-11-07 14:00 +0000
Re: Multi-dimensional list initialization Ethan Furman <ethan@stoneleaf.us> - 2012-11-07 06:47 -0800
Re: Multi-dimensional list initialization Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2012-11-07 23:06 +0000
Re: Multi-dimensional list initialization Greg Ewing <greg.ewing@canterbury.ac.nz> - 2012-11-08 14:29 +1300
Re: Multi-dimensional list initialization wxjmfauth@gmail.com - 2012-11-05 01:55 -0800
csiph-web