Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3a.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: UNSURE 0.243 X-Spam-Level: ** X-Spam-Evidence: '*H*': 0.52; '*S*': 0.00; 'problem?': 0.07; 'additionally': 0.09; 'extends': 0.09; 'cc:addr:python-list': 0.11; "wouldn't": 0.14; 'storing': 0.16; 'appropriate': 0.16; 'thanks,': 0.17; 'wrote:': 0.18; 'feb': 0.22; 'cc:addr:python.org': 0.22; 'looks': 0.24; 'cc:2**0': 0.24; "i've": 0.25; 'suggested': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'wonder': 0.29; 'involving': 0.30; 'work.': 0.31; 'url:python': 0.33; 'ago': 0.33; 'cases': 0.33; 'framework': 0.33; 'anybody': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'charset:us-ascii': 0.36; 'url:org': 0.36; 'effort': 0.37; 'sometimes': 0.38; 'message-id:@gmail.com': 0.38; 'url:library': 0.38; 'work?': 0.38; 'pm,': 0.38; 'does': 0.39; 'days': 0.60; 'ian': 0.60; 'solve': 0.60; 'url:3': 0.61; 'took': 0.61; "you're": 0.61; 'header:Message-Id:1': 0.63; 'taking': 0.65; 'talking': 0.65; 'to:addr:gmail.com': 0.65; 'reply': 0.66; 'determine': 0.67; '26,': 0.68; 'reads': 0.68; 'home.': 0.72; 'subject:Design': 0.78; '2015': 0.84; '4:00': 0.84; 'completely,': 0.84; 'ian,': 0.84; 'important;': 0.84; 'subject:thought': 0.84 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=njOTAdjOWXMaJp1uyPJiAaG6EvEROeYK0ovK+9o8+L4=; b=i1qdPsb5GsCHn6yCMm53MvxJsWa4BtDsbMdixQOrFpiUGMo8ZoxwpJ3XRnpoFyUmSP n8FIv12E0r77JRsLeVIlmy61V/aaiLebBb8bnJdqWR1C9pQ5cfqt79LIPqF9UTN+Hi5r f5Xj511A5TEhouRvLL5I5TWvSjmYwO5hbora/9GTWrJ6AdfJ6DeW1il/cEt1dFJhyZQQ +lu9ZnXm5gcYqJN9RDtjka57r/pLA/5EJHWVFJyjOojyiMBOeH6ku1b4WM796j6doMmX 41QBKbPllJk3hEvX0VhTWQrg0ILWHVf8l2o0qfy/+xumNJCcCTR4XAKd9uS+ftByeBUD WJtA== X-Received: by 10.140.81.74 with SMTP id e68mr48269546qgd.41.1425294275726; Mon, 02 Mar 2015 03:04:35 -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: Mon, 2 Mar 2015 06:04:33 -0500 Cc: Python Content-Transfer-Encoding: quoted-printable References: <33677AE8-B2FA-49F9-9304-C8D93784255D@gmail.com> To: Ian Kelly X-Mailer: Apple Mail (2.1510) X-Mailman-Approved-At: Mon, 02 Mar 2015 12:13:19 +0100 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.19 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: 37 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1425294799 news.xs4all.nl 2968 [2001:888:2000:d::a6]:50298 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:86719 On Feb 26, 2015, at 2:54 PM, Ian Kelly wrote: > On Feb 26, 2015 4:00 AM, "Cem Karan" wrote: > > > > > > On Feb 26, 2015, at 12:36 AM, Gregory Ewing = wrote: > > > > > Cem Karan wrote: > > >> 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? > > > > > > Yes, that looks like it would work. > > > > > > Cool! >=20 > Sometimes I wonder whether anybody reads my posts. I suggested a = solution involving WeakMethod four days ago that additionally extends = the concept to non-method callbacks (requiring a small amount of extra = effort from the client in those cases, but I think that is unavoidable. = There is no way that the framework can determine the appropriate = lifetime for a closure-based callback.) I apologize about taking so long to reply to everyone's posts, but I've = been busy at home. Ian, it took me a while to do some research to understand WHY what you = were suggesting was important; you're right about storing the object as = well as the method/function separately, but I think that WeakMethod = might solve that completely, correct? Are there any cases where = WeakMethod wouldn't work? Thanks, Cem Karan=