Path: csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed4a.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.055 X-Spam-Evidence: '*H*': 0.89; '*S*': 0.00; 'method.': 0.07; 'problem?': 0.07; 'callback': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'times,': 0.14; '24,': 0.16; 'help?': 0.16; 'reliably': 0.16; 'thanks,': 0.17; 'wrote:': 0.18; 'library': 0.18; 'feb': 0.22; '>>>': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'suggested': 0.26; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'everywhere': 0.31; 'object.': 0.31; 'url:python': 0.33; "can't": 0.35; 'received:google.com': 0.35; 'there': 0.35; 'version': 0.36; 'object,': 0.36; 'method': 0.36; 'charset:us-ascii': 0.36; 'url:org': 0.36; 'message-id:@gmail.com': 0.38; 'stable': 0.38; 'url:library': 0.38; 'pm,': 0.38; 'does': 0.39; 'users': 0.40; 'how': 0.40; 'solve': 0.60; 'url:3': 0.61; "you're": 0.61; 'header :Message-Id:1': 0.63; 'name': 0.63; 'talking': 0.65; 'latest': 0.67; 'subject:Design': 0.78; 'avoids': 0.84; 'listener': 0.84; 'subject:thought': 0.84; 'whereas': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=V7bnOJrssZjP/4bO1DrI5j/XV9OCwNhy84TgqGah1sM=; b=khkqgxiEqEx7JGubXKr/eIdF6zU/ojE4d4ikiXeYShBWGIJXaXFmME4Q834B/oFsz8 E5EhBrJLxO7JVH4RTQLvgFAPOVJ6Z+g5JAejy1rO13H/kcI95Mh0fUYOEyH56x6YAz1q xJwKR+CFbARhVKdrmHwkd4PUj/sHKSEuG7MpnKef87jVR5avDMP6sKVu+jX0dfbGAaDX Pi6UjXFyGCV66SgvKeffnapQmsmFPJz+4Ro3QDE4ssuoj2Ymzwb90uZzSfYs4kq+5cCC T5Yu7gSjC3Jakh/LTjczsovhymLVRVg0nBgPcbJQmodGFn6rNe5JKYjR7GvM4+/RRKYl pSFA== X-Received: by 10.52.243.41 with SMTP id wv9mr3875191vdc.20.1424868603023; Wed, 25 Feb 2015 04:50:03 -0800 (PST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 6.6 \(1510\)) Subject: Re: Design thought for callbacks From: Cem Karan In-Reply-To: Date: Wed, 25 Feb 2015 07:50:02 -0500 Content-Transfer-Encoding: quoted-printable References: <33677AE8-B2FA-49F9-9304-C8D93784255D@gmail.com> To: Gregory Ewing X-Mailer: Apple Mail (2.1510) Cc: python-list@python.org 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: 1424868605 news.xs4all.nl 2937 [2001:888:2000:d::a6]:53457 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:86397 On Feb 24, 2015, at 4:19 PM, Gregory Ewing = wrote: > random832@fastmail.us wrote: >> On Tue, Feb 24, 2015, at 00:20, Gregory Ewing wrote: >>> This is why I suggested registering a listener object >>> plus a method name instead of a callback. It avoids that >>> reference cycle, because there is no long-lived callback >>> object keeping a reference to the listener. >> How does that help? Everywhere you would have had a reference to the >> "callback object", you now have a reference to the listener object. >=20 > The point is that the library can keep a weak reference > to the listener object, whereas it can't reliably keep > a weak reference to a bound method. I think I see what you're talking about now. Does WeakMethod = (https://docs.python.org/3/library/weakref.html#weakref.WeakMethod) = solve this problem? Note that I can force my users to use the latest = stable version of python at all times, so WeakMethod IS available to me. Thanks, Cem Karan=