Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #86029
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!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.006 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'languages.': 0.04; 'nasty': 0.07; '22,': 0.09; 'namespace': 0.09; 'references.': 0.09; 'works.': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'assume': 0.14; 'callable': 0.16; 'closures': 0.16; 'expecting': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'garbage': 0.16; 'it".': 0.16; 'surprises': 0.16; 'surprising': 0.16; 'with?': 0.16; 'weird': 0.16; 'wrote:': 0.18; 'library': 0.18; 'possible,': 0.19; 'feb': 0.22; 'python?': 0.22; 'saying': 0.22; 'cc:addr:python.org': 0.22; 'certainly': 0.24; 'rid': 0.24; 'earlier': 0.24; 'cc:2**0': 0.24; '(see': 0.26; 'references': 0.26; 'least': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'bigger': 0.30; 'message-id:@mail.gmail.com': 0.30; '(which': 0.31; 'end,': 0.31; 'sense': 0.34; 'maybe': 0.34; 'problem': 0.35; "can't": 0.35; 'something': 0.35; 'objects': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'object,': 0.36; 'done': 0.36; 'next': 0.36; 'so,': 0.37; 'clear': 0.37; 'list,': 0.38; 'how': 0.40; 'deleting': 0.60; 'most': 0.60; 'matter': 0.61; 'simply': 0.61; "you're": 0.61; 'you.': 0.62; 'back': 0.62; 'more': 0.64; 'surprise': 0.74; 'subject:Design': 0.78; "'dead'": 0.84; '2015': 0.84; 'grave': 0.84; 'haunt': 0.84; 'subject:thought': 0.84; 'to:none': 0.92 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type:content-transfer-encoding; bh=8qSyF0AMlx8KHE19Dbc3Kzc1ez+lMcZves44CZr6uSQ=; b=bYHEUOk5MdyMyGyH9WjDb2kcpAvJmdhhyy6J8hMMbGYVMEX40KzovKv2kNZ+b3/s3e 0MNDFzxVKrrCW/8TkM/bamq+qgkCIOs+lZ7qesJ7HWfRKAf1g0M8ymhD7tjTVYOi7mfO 6mbwBtKwJzxze5JDAjlDp1MQwfnX132qbtwqUOfYlJ2G5H8XQwkbHWNAT0HahHeP3uVP K+ibKkGPOTk4byi9TZ9tkPGzN5ekbYtWa1ZETbuGbpdQyvHlROF3IWnik2ajm2H+VvxM 1werh2sXKXyYcXRN5BnulteRAgVtEJXAukpXooKDvObjgJ3my11yPLesuOyqkC5IJR0N O0aw== |
| MIME-Version | 1.0 |
| X-Received | by 10.107.33.11 with SMTP id h11mr3220400ioh.53.1424524559042; Sat, 21 Feb 2015 05:15:59 -0800 (PST) |
| In-Reply-To | <39813568-6DB8-4341-A130-C256CFF352EE@gmail.com> |
| References | <33677AE8-B2FA-49F9-9304-C8D93784255D@gmail.com> <CAPTjJmpEHQV2PpaZvszuTGn0_GNg0sWV6aLenbQsZrSXCy2YKQ@mail.gmail.com> <39813568-6DB8-4341-A130-C256CFF352EE@gmail.com> |
| Date | Sun, 22 Feb 2015 00:15:58 +1100 |
| Subject | Re: Design thought for callbacks |
| From | Chris Angelico <rosuav@gmail.com> |
| Cc | "comp.lang.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.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.18958.1424524562.18130.python-list@python.org> (permalink) |
| Lines | 30 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1424524562 news.xs4all.nl 2847 [2001:888:2000:d::a6]:54824 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:86029 |
Show key headers only | View raw
On Sun, Feb 22, 2015 at 12:13 AM, Cem Karan <cfkaran2@gmail.com> wrote: > OK, so it would violate the principle of least surprise for you. Interesting. Is this a general pattern in python? That is, callbacks are owned by what they are registered with? > > In the end, I want to make a library that offers as few surprises to the user as possible, and no matter how I think about callbacks, they are surprising to me. If callbacks are strongly-held, then calling 'del foo' on a callable object may not make it go away, which can lead to weird and nasty situations. Weakly-held callbacks mean that I (as the programmer), know that objects will go away after the next garbage collection (see Frank's earlier message), so I don't get 'dead' callbacks coming back from the grave to haunt me. > > So, what's the consensus on the list, strongly-held callbacks, or weakly-held ones? I don't know about Python specifically, but it's certainly a general pattern in other languages. They most definitely are owned, and it's the only model that makes sense when you use closures (which won't have any other references anywhere). If you're expecting 'del foo' to destroy the object, then you have a bigger problem than callbacks, because that's simply not how Python works. You can't _ever_ assume that deleting something from your local namespace will destroy the object, because there can always be more references. So maybe you need a more clear way of saying "I'm done with this, get rid of it". ChrisA
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Design thought for callbacks Chris Angelico <rosuav@gmail.com> - 2015-02-22 00:15 +1100
csiph-web