Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #93046
| Path | csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ian.g.kelly@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.010 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'anyway.': 0.04; 'modify': 0.04; 'lines,': 0.05; 'variable,': 0.07; 'caching,': 0.09; 'subject:method': 0.09; '23,': 0.16; 'agree.': 0.16; 'copied,': 0.16; 'posted.': 0.16; 'shared.': 0.16; 'subject:object': 0.16; 'wrote:': 0.16; 'code,': 0.23; '2015': 0.23; 'header:In-Reply- To:1': 0.24; 'tim': 0.24; 'external': 0.27; 'least': 0.27; 'defining': 0.27; 'message-id:@mail.gmail.com': 0.28; 'prints': 0.29; 'e.g.': 0.31; 'fixed': 0.31; 'code': 0.31; "can't": 0.32; 'received:google.com': 0.34; 'to:addr:python-list': 0.35; 'instance': 0.35; 'expected': 0.35; 'problem.': 0.35; 'but': 0.36; 'being': 0.36; 'there': 0.36; 'two': 0.37; 'should': 0.37; 'client': 0.37; 'subject:: ': 0.37; 'tue,': 0.38; 'shared': 0.38; 'pm,': 0.39; 'to:addr:python.org': 0.39; 'why': 0.40; 'share': 0.60; 'even': 0.61; 'real': 0.61; 'state,': 0.66; 'consumer': 0.67; 'business': 0.69; 'to:name:python': 0.84; 'response,': 0.93 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=o9lYKlfzrHmeWkH5kgl/3pfaUzBF+eMWzD47rMgIF5A=; b=y+oq5DWA1fSrywg+emKrRY2/I0pBzd53PwwVawCN/3MYM92avrdZkJgoqzTaCvgl/F CuimtWmnaiMqePIzliAa2QNxM31O8Qkh16xV6x5ImQAZCL59u4pnVvM5jISBvL7iOhST f+vCKwA+gzyHakBBUzPPOVBbrkOdgGnju0ungnpqF//2uuIWvhNcPjb7o7T6snRM4F+F 4roC7z+HWnAePG9UTzYI2Er8oDm1Fw8zH0f1neQtR5GShxsRZgEk26+uItWDrKDWvMmr b7FOFcWj0DvW5nda98rZkkPNblEbayHrT+88XBv5PzNeOrKHlwLy8KcEYtY/RXFo2zu8 OsPQ== |
| X-Received | by 10.170.195.205 with SMTP id m196mr4972150yke.39.1435087886104; Tue, 23 Jun 2015 12:31:26 -0700 (PDT) |
| MIME-Version | 1.0 |
| In-Reply-To | <109aafce-613c-4d6c-9f78-4bbe424f5901@googlegroups.com> |
| References | <109aafce-613c-4d6c-9f78-4bbe424f5901@googlegroups.com> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Tue, 23 Jun 2015 13:30:46 -0600 |
| Subject | Re: method returns object reference |
| To | Python <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | quoted-printable |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| 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.732.1435087895.13271.python-list@python.org> (permalink) |
| Lines | 14 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1435087895 news.xs4all.nl 2943 [2001:888:2000:d::a6]:51840 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:93046 |
Show key headers only | View raw
On Tue, Jun 23, 2015 at 12:32 PM, Tim <jtim.arnold@gmail.com> wrote: > The code below prints the following two lines, showing how the 'newkey' is now inside the Client response, even though it was set in the worker. This must be bad practice! In my real code, the response is no longer an instance variable, which fixed the problem. It never had any business being bound to the client anyway. I agree. There may be reasons why the client would want to hold onto the response, e.g. caching, but there are none evident in the code you posted. What it *shouldn't* do if it's going to hold on to state like that is share it with external code without at least a contract defining allowed mutations. If the consumer can't reasonably be expected not to modify the shared state, then it should be copied, not shared.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
method returns object reference Tim <jtim.arnold@gmail.com> - 2015-06-23 11:32 -0700 Re: method returns object reference Ian Kelly <ian.g.kelly@gmail.com> - 2015-06-23 13:30 -0600 Re: method returns object reference Ned Batchelder <ned@nedbatchelder.com> - 2015-06-23 13:59 -0700
csiph-web