Path: csiph.com!usenet.pasdenom.info!news.franciliens.net!fdn.fr!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!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.131 X-Spam-Level: * X-Spam-Evidence: '*H*': 0.75; '*S*': 0.02; '22,': 0.09; 'callback': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'function?': 0.16; 'garbage': 0.16; 'wrote:': 0.18; 'feb': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'references': 0.26; 'header:In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; "d'aprano": 0.31; 'steven': 0.31; 'them?': 0.31; 'cases': 0.33; 'received:google.com': 0.35; 'there': 0.35; 'doing': 0.36; 'should': 0.36; 'fact': 0.38; 'pm,': 0.38; 'expect': 0.39; 'itself': 0.39; 'how': 0.40; 'even': 0.60; 'around.': 0.60; 'no.': 0.61; 'special': 0.74; 'subject:Design': 0.78; '2015': 0.84; 'distinguish': 0.84; 'reference),': 0.84; 'subject:thought': 0.84; 'why?': 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=zPcHr9mEP573osUmauRodpt4k5AtTVQOge9OqCGuoWg=; b=p9lDvCgxwSSY4br6L7h/hJK57oGrNIHMPGZ3evQO8e2EOGAsoMR0k6yRPtH2drf0H2 e7BqEufwNE56ypdeL1qyRey+JsBOTt6XcU/p8iJ7EqtNJARBunFN0G19X/Bg+zFHEn9g dcZZjEpe6OwvRi5TfxO6d9Zi6rJupQczo+pXyWUFScIE5z7VDTNwpgOb06uhMJHdVwpk J5PtxECIHNPv4vR4c+lPPxNNaKF/rY1Nq3jwWJnqAhym12fXogXHJEb61vjzfwd9tcJC hUpe6YrUEIfO9KJTSzy+k0QPk2erngMkXd8jyDRyhwUNZ6KE/br5Si25+JKdKRAVrljZ p1DA== MIME-Version: 1.0 X-Received: by 10.107.160.212 with SMTP id j203mr7796099ioe.43.1424603674353; Sun, 22 Feb 2015 03:14:34 -0800 (PST) In-Reply-To: <54e9b027$0$12992$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> Date: Sun, 22 Feb 2015 22:14:34 +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: 12 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1424603679 news.xs4all.nl 2906 [2001:888:2000:d::a6]:42189 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:86097 On Sun, Feb 22, 2015 at 9:32 PM, Steven D'Aprano wrote: > Why? Do you expect that the Python garbage collector special cases callbacks > to keep them alive even when there are no references to them? How would it > distinguish a callback from some other function? 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. ChrisA