Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!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.016 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'laura': 0.07; 'referring': 0.07; 'string': 0.09; 'creighton': 0.09; 'uses.': 0.09; 'will,': 0.09; 'cc:addr:python-list': 0.11; '23,': 0.16; 'flush': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'garbage': 0.16; 'instances,': 0.16; 'mapping;': 0.16; 'language': 0.16; 'wrote:': 0.18; 'feb': 0.22; 'memory': 0.22; 'cc:addr:python.org': 0.22; "aren't": 0.24; 'certainly': 0.24; 'refers': 0.24; 'mon,': 0.24; "haven't": 0.24; 'looks': 0.24; 'cc:2**0': 0.24; "i've": 0.25; 'player': 0.26; 'header:In-Reply- To:1': 0.27; 'am,': 0.29; 'character': 0.29; 'room': 0.29; 'unix': 0.29; "doesn't": 0.30; 'cool': 0.30; 'message-id:@mail.gmail.com': 0.30; "they'll": 0.31; 'though.': 0.31; 'anyone': 0.31; 'common': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'much.': 0.36; 'mapping': 0.38; 'anything': 0.39; 'aside': 0.39; 'how': 0.40; 'new': 0.61; 'back': 0.62; 'guarantee': 0.63; 'more': 0.64; 'hang': 0.67; 'notices': 0.68; 'subject:Design': 0.78; '2015': 0.84; 'around,': 0.84; 'rooms': 0.84; 'subject:thought': 0.84; 'thing,': 0.91; 'to:none': 0.92; 'room,': 0.93 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=bce0j1Qpym8H8xubEDgeluRzWkUhgb3Zg+3PD+RcriI=; b=NTrktIPCNHqtbTeftOdNZIjxcb3Uk15iRZAS51SSpo+CnoxrixCEnmWw7TuAWUXqOu 2U1PB69mwJ4MwgFJKDJBNKxlWQa313uSsMdo8C/85iDMKepk7JuyF/LNyxDEC67IVrCd jwO+avOnsptypFT/1LVh1qOjPdR67mMLbcqSEhw2FAaaUgs8LLuarJpECgaIEb28sMKt Bk50avcjLxGbiqVuzYHsJTAQ3/dsTgJqOEvCNvxbnzEixR/nhs1HQ74vdIEOBcNTeqoq ul1VxKBd6Y1pE57lodB2YbChgpxcFAxTfjZqJFbe611Einew6u8doQN4HP8jD6cPw35z yr/Q== MIME-Version: 1.0 X-Received: by 10.107.128.219 with SMTP id k88mr10082629ioi.27.1424644864217; Sun, 22 Feb 2015 14:41:04 -0800 (PST) In-Reply-To: <201502222229.t1MMT7Dn029607@fido.openend.se> References: <33677AE8-B2FA-49F9-9304-C8D93784255D@gmail.com> <39813568-6DB8-4341-A130-C256CFF352EE@gmail.com> <54e8c017$0$13008$c3e8da3$5496439d@news.astraweb.com> <51947083-01AC-4D1E-ACBD-3C476446B527@gmail.com> <54EA43C8.2090309@stoneleaf.us> <87wq39hbq1.fsf@elektro.pacujo.net> <0443FBDF-9FD0-492E-8486-03EBD0972C04@gmail.com> <201502222229.t1MMT7Dn029607@fido.openend.se> Date: Mon, 23 Feb 2015 09:41:04 +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: 21 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1424644873 news.xs4all.nl 2900 [2001:888:2000:d::a6]:49266 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:86167 On Mon, Feb 23, 2015 at 9:29 AM, Laura Creighton wrote: > But that is not so surprising. How many people use WeakSets for > _anything_? I've never used them, aside from 'ooh! cool shiny > new language feature! Let's kick it around the park!' That people > aren't familiar with WeakSets doesn't mean all that much. I haven't used weak *sets*, but I've used weak *mappings* on occasion. It's certainly not a common thing, but they have their uses. I have a MUD which must guarantee that there be no more than one instance of any given room (identified by a string that looks like a Unix path), but which will, if it can, flush rooms out of memory when nothing refers to them. So it has a mapping from the path strings to the instances, but with weak refs for the instances; if anything else is referring to that instance (eg a player character in the room), it'll hang around, and any time anyone else needs that room, they'll get the same instance back from the mapping; but any time the garbage collector notices that a room can be disposed of, it will be. Definitely not common though. ChrisA