Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'python,': 0.02; 'output': 0.05; 'lines,': 0.07; 'needed,': 0.07; 'none,': 0.07; 'feature.': 0.09; 'lookup': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'language,': 0.12; 'itself.': 0.14; "wouldn't": 0.14; 'posted': 0.15; 'dict': 0.16; 'did,': 0.16; 'does,': 0.16; 'exists,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'reasonably': 0.16; 'roy': 0.16; 'said.': 0.16; 'scrub': 0.16; 'types,': 0.16; 'exception': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'file,': 0.19; 'possible,': 0.19; 'feb': 0.22; 'memory': 0.22; 'cc:addr:python.org': 0.22; 'instance,': 0.24; 'mon,': 0.24; 'cc:2**0': 0.24; 'sort': 0.25; "i've": 0.25; 'possibly': 0.26; 'references': 0.26; 'right.': 0.26; 'header:In-Reply-To:1': 0.27; 'idea': 0.28; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; 'along': 0.30; "i'm": 0.30; '"do': 0.31; 'concern': 0.31; 'everywhere': 0.31; 'object.': 0.31; 'os,': 0.31; 'time;': 0.31; 'probably': 0.32; '(including': 0.33; 'skip:d 20': 0.34; 'subject:the': 0.34; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'keyword': 0.36; 'marks': 0.36; 'possible': 0.36; 'turn': 0.37; 'being': 0.38; 'files': 0.38; 'rather': 0.38; 'itself': 0.39; 'use.': 0.39; 'sure': 0.39; 'unable': 0.39; 'either': 0.39; 'how': 0.40; 'remove': 0.60; 'above,': 0.60; "you're": 0.61; 'back': 0.62; 'times': 0.62; 'kind': 0.63; 'soon': 0.63; 'more': 0.64; 'talking': 0.65; 'between': 0.67; 'smith': 0.68; 'special': 0.74; 'truth': 0.81; 'dict.': 0.84; 'domain,': 0.84; "it'd": 0.84; 'that)': 0.84; 'to:none': 0.92; 'catalog': 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=3tO0cRADQx89TpUc1pJ/bvpJinhjx2hkukJQjK81Mew=; b=Z1jtoxHo/qw3ycQdLcEbMjIKXN1KVePhTHKY8Lvhcg5r3vZPs/1J3RrfckpVxpaR58 ZBGA1EBTGAks0M1JGTni3rzi8xfNys9E9PjlKr0J9hIbuDftrCdYhnrk6sS/gQgZ4eIs ZEUAkMcx7WGd5KgHDWWYdPA1R2ee4/M37Fm9CQf3eSw8dI8+DhG8JjzZ+oR+4uvw3vu8 E5PDxuLTRWC9qa7MVIRZtNYu38sMlHeAqU5UCT/wMoJbJd4q5kAM+UgX5P7Cllg4QiK+ 9z+5dY5dkzTqvGxNRXJpBx/ZftqFqkIkLf4Vezatk60CqkCIscpZ59jy6LP17S09hspf hEJw== MIME-Version: 1.0 X-Received: by 10.66.216.129 with SMTP id oq1mr33752609pac.75.1391386050821; Sun, 02 Feb 2014 16:07:30 -0800 (PST) In-Reply-To: References: <858utviwgs.fsf@benfinney.id.au> <52EC3C40.7080402@stoneleaf.us> <52ec84bc$0$29972$c3e8da3$5496439d@news.astraweb.com> Date: Mon, 3 Feb 2014 11:07:30 +1100 Subject: Re: __init__ is the initialiser 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: 36 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1391386457 news.xs4all.nl 2930 [2001:888:2000:d::a6]:49278 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:65300 On Mon, Feb 3, 2014 at 10:40 AM, Roy Smith wrote: > I'm reasonably sure you posted this as humor, but there is some truth in > what you said. In the crypto/security domain, you often want to keep a > key or cleartext around only for the time it's needed, and scrub the > memory it was occupying as soon as it is no longer in use. > > I don't know how you would do that in Python. I did, but you're right. It's fundamentally not possible in pure Python, because there's no way to flag a block of memory as "do not page this to disk". For what you're talking about to be at all possible, you would need support from the language, from the OS, and possibly from the CPU as well. I'm sure this sort of thing exists, but if it does, it'll probably be something that Python itself wouldn't concern itself with - you'd get it via openssl or something. There have been occasional times I've wanted an "explicit destruction" feature. Rather than the facetious exception I listed above, it'd be better to have all those references (including the original one in a, since there's nothing special about that) turn into some kind of "null state" - either None, or a special object that marks itself as a destructed/destroyed (terminology debates aside) object. With custom types, I can mark them off with a special flag, and check that all the time; but I can't, for instance, have a dict that maps some lookup keyword to its output file, and then destroy output files to remove all their references from everywhere in the dict. (I have had something along these lines, a bit more complicated than this, but not in Python.) But I do like the idea of an arsonist being unable to destroy a painting because of the reference loop between its catalog number on the back and the catalog itself. ChrisA