Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #6717

Re: scope of function parameters (take two)

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!feeder.news-service.com!xlned.com!feeder7.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.009
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'subject:two': 0.07; 'python': 0.08; 'clearly,': 0.09; 'deliberately': 0.09; 'mutable': 0.09; 'subject:parameters': 0.09; 'way;': 0.09; 'pm,': 0.10; 'received:209.85.214.174': 0.14; 'received:mail- iw0-f174.google.com': 0.14; 'wrote:': 0.14; 'angelico': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'subject:function': 0.16; 'suggested,': 0.16; 'tue,': 0.17; 'header:In-Reply-To:1': 0.21; 'fundamentals': 0.23; 'code': 0.24; 'function': 0.25; 'object': 0.26; 'pass': 0.27; 'message- id:@mail.gmail.com': 0.28; 'received:209.85.214': 0.28; 'effect': 0.29; 'fairly': 0.30; 'objects.': 0.30; 'it.': 0.31; 'specifically': 0.31; 'to:addr:python-list': 0.33; 'copying': 0.33; 'chris': 0.34; 'quite': 0.36; 'received:google.com': 0.37; 'change': 0.37; 'received:209.85': 0.37; 'necessary.': 0.38; 'subject:: ': 0.38; 'subject: (': 0.39; 'received:209': 0.39; 'to:addr:python.org': 0.39; "couldn't": 0.40; 'possibility': 0.40; 'within': 0.60; '31,': 0.65; 'making': 0.67; 'cause': 0.67; 'wish': 0.70; 'serious': 0.77; 'break.': 0.84; 'different.': 0.84; 'penalty': 0.91; 'eliminates': 0.93
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=BQ0tWFNbwF3Xep66e242flz0zT4KmI+ej1UWLHhYMOQ=; b=bjGSWEIqZ3O1qn4lV2H4RegX42nq9CJ/Y5RQl+hrBa1zu9/XcwG4z3ChTx6dLzuwOz pqH8Cbk9Q9lUJJq5WiprWYuEeBj4ejK1VjFVDeXKSUIEzKYkld5sZ6Gwvh9AK6N7Vopa L2PjPzoGJOo77Li81O8Hdwa7nhxi98HLi6/D4=
DomainKey-Signature a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=wYHv8CJOlr06UQRVvvcaXNpCoj04VbsVi6Tl7ddKon4A/J5hd51MaolY8kylYqFqpI s5x8XUflJ0+GWWZyqQl4EOM3THRWYR6s0Xaf6t4/vBHuh+n/axrEbLyRtQSN7c5dgWVO /Hr38OY+0Mw7gfCcX0UT8sCLNujZANDYemu2A=
MIME-Version 1.0
In-Reply-To <6699AB10-988A-49AD-B7C1-6BAA2CC3D008@mcgill.ca>
References <F8395F78-615E-4FBD-B6FC-1D6173EAEA45@mcgill.ca> <F4EAD1ED-563D-4D6E-A50C-68308A9F26B7@mcgill.ca> <BANLkTin5exEpDkE3on3BAaWwHOjpg_vC8g@mail.gmail.com> <6699AB10-988A-49AD-B7C1-6BAA2CC3D008@mcgill.ca>
Date Tue, 31 May 2011 18:04:29 +1000
Subject Re: scope of function parameters (take two)
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
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.2310.1306829072.9059.python-list@python.org> (permalink)
Lines 14
NNTP-Posting-Host 82.94.164.166
X-Trace 1306829072 news.xs4all.nl 49179 [::ffff:82.94.164.166]:58718
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:6717

Show key headers only | View raw


On Tue, May 31, 2011 at 5:17 PM, Henry Olders <henry.olders@mcgill.ca> wrote:
> Clearly, making a copy within the function eliminates the possibility of the
> side effects caused by passing in mutable objects. Would having the
> compiler/interpreter do this automatically make python so much different?

Yes, it would make Python quite different. If suddenly you couldn't
pass a mutable object to a function to get it muted (that sounds
wrong), then code will break. Also, there's a fairly serious
performance penalty to copying everything when it's not necessary. As
has been suggested, you can specifically and deliberately cause this
effect for any function(s) you wish to "protect" in this way; there's
no need to change the language's fundamentals to do it.

Chris Angelico

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: scope of function parameters (take two) Chris Angelico <rosuav@gmail.com> - 2011-05-31 18:04 +1000

csiph-web