Path: csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.026 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'say,': 0.05; '*not*': 0.07; 'callback': 0.09; 'references.': 0.09; 'cc:addr:python- list': 0.11; '23,': 0.16; 'bind': 0.16; 'bucket': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'magic': 0.16; 'wrote:': 0.18; 'meant': 0.20; 'seems': 0.21; 'feb': 0.22; 'cc:addr:python.org': 0.22; 'button,': 0.24; 'mon,': 0.24; '(or': 0.24; 'cc:2**0': 0.24; 'sort': 0.25; 'header:In- Reply-To:1': 0.27; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; "d'aprano": 0.31; 'steven': 0.31; 'yes.': 0.31; 'themselves': 0.32; 'becomes': 0.33; 'but': 0.35; 'received:google.com': 0.35; 'doing': 0.36; 'should': 0.36; 'wrong': 0.37; 'being': 0.38; 'button': 0.38; 'fact': 0.38; 'expect': 0.39; 'itself': 0.39; 'around.': 0.60; 'no.': 0.61; 'more': 0.64; 'subject:Design': 0.78; '2015': 0.84; 'listener': 0.84; 'reference),': 0.84; 'subject:thought': 0.84; 'thing,': 0.91; '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; bh=jU399dLFiQwe5Aq84Yoc4YzCrK9jG0d1OtMD9M6VGxw=; b=xPB5ZT1IC8vsDo90+n/kjxJb5q7MSQrzapKKqxL0zgpkTmf1Aaf5osah9F+qeGyBor 2Rq3LzCG5XfcYwnLMoMRtfqNubmsNe/1aMsr2qc7fxh4x6i90whIgK95xSlXSBymbuyJ tlnEEj/PIjGZrboMTKIsx9McGio2RQ51w5Redr9T5UM0tww2Pzg2KqrOMWKMeIFh7uj+ OdZz7Jq+baPNfY1Jyq48PVOXj92IWyJ8TECqNqKMFW5chnwl0Qbgx4g3QubJaEXPPUPD NP91/SZI0IsYYliY3QGULisYO4JzUaa2SQTqeflr2E4tDBGtaCey8u2FUiWnxCEEFe6i pVGA== MIME-Version: 1.0 X-Received: by 10.42.64.197 with SMTP id h5mr7086434ici.12.1424613667003; Sun, 22 Feb 2015 06:01:07 -0800 (PST) In-Reply-To: <54e9dd8e$0$12975$c3e8da3$5496439d@news.astraweb.com> References: <33677AE8-B2FA-49F9-9304-C8D93784255D@gmail.com> <87egpjapxv.fsf@elektro.pacujo.net> <54e9391b$0$13010$c3e8da3$5496439d@news.astraweb.com> <54e95d34$0$13006$c3e8da3$5496439d@news.astraweb.com> <54e9b027$0$12992$c3e8da3$5496439d@news.astraweb.com> <54e9dd8e$0$12975$c3e8da3$5496439d@news.astraweb.com> Date: Mon, 23 Feb 2015 01:01:06 +1100 Subject: Re: Design thought for callbacks From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 24 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1424613675 news.xs4all.nl 2835 [2001:888:2000:d::a6]:44211 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:86118 On Mon, Feb 23, 2015 at 12:45 AM, Steven D'Aprano wrote: >> No no no. It's the other way around. _Something_ has to be doing those >> callbacks, and it's that _something_ that should be keeping them >> alive. The fact that it's a registered callback should itself *be* a >> reference (and not a weak reference), and should keep it alive. > > That's much more reasonable than what you said earlier: > > it seems wrong to have to stash a thing in a bucket in order > to keep its callbacks alive. I expect the callbacks themselves to > keep it alive. > > > So yes. If I bind a callback to a button, say, or a listener, then the > button (or listener) keeps the callback alive, *not* the callback keeping > the button or listener alive. I meant the same thing, but my terminology was poor. Yes, that's correct; it's not any sort of magic about it being a callback, but more that the one you register it with becomes the owner of something. Hence, no weak references. ChrisA