Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!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: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'python,': 0.02; 'cpython': 0.05; 'linux,': 0.07; 'needed,': 0.07; 'apis': 0.09; 'yeah,': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'language,': 0.12; 'language.': 0.14; 'posted': 0.15; 'did,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; "object's": 0.16; 'reasonably': 0.16; 'roy': 0.16; 'said.': 0.16; 'scrub': 0.16; 'appropriate': 0.16; 'language': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'possible,': 0.19; '(the': 0.22; 'feb': 0.22; '>>>': 0.22; 'memory': 0.22; 'otherwise,': 0.22; 'cc:addr:python.org': 0.22; 'instance,': 0.24; 'fine': 0.24; 'mon,': 0.24; 'cc:2**0': 0.24; 'references': 0.26; 'right.': 0.26; 'least': 0.26; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; '"do': 0.31; 'easy,': 0.31; 'os,': 0.31; 'time;': 0.31; 'running': 0.33; 'subject:the': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'done': 0.36; 'possible': 0.36; 'checks': 0.38; 'pm,': 0.38; 'rather': 0.38; 'anything': 0.39; 'use.': 0.39; 'sure': 0.39; 'called': 0.40; 'how': 0.40; "you're": 0.61; 'soon': 0.63; 'talking': 0.65; 'smith': 0.68; 'fact,': 0.69; 'goal': 0.75; 'truth': 0.81; 'domain,': 0.84; "it'd": 0.84; '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=QdyTjGy4Q1PIuDYvchuXZrc7F9qybE6czNHVbVp8j9k=; b=WWaN06N2IrTg8lu4MalgV2RWAvoqvWLOuGVIeu9GzAXmrBEyaF9ZAiNhq7Rd4gVmQy sjwfGszcCsaXOQP/SIQPCRl+sTjPRR2lft2AhGHG0fUrywPVuMXWRF+fkKVvKc7T6iX+ ESTpMlCon9vdXHbTdpeMpluKgFdGi/gc5wPGwDBmmNPviFa6lgYlk7ad2LouY3r1u4MT oB94Dd3iOyGPXXT3/v6bWStMk/0XzBtYpuFKQyS80q7i/vvOJMRZb7CaqQY64huRaUtZ W13tITeAYhZIcATOGlGSoNZuEqIYsYoOETNY6svPs8EMZdE+/MWI4UMRk0oR8LDIX1So u2Bg== MIME-Version: 1.0 X-Received: by 10.66.160.2 with SMTP id xg2mr33986080pab.23.1391391437758; Sun, 02 Feb 2014 17:37:17 -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 12:37:17 +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: 37 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1391391446 news.xs4all.nl 2874 [2001:888:2000:d::a6]:54361 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:65309 On Mon, Feb 3, 2014 at 12:24 PM, Devin Jeanpierre wrote: > On Sun, Feb 2, 2014 at 4:07 PM, Chris Angelico wrote: >> 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, > > mlock on linux, VirtualAlloc (?) on windows. This can be done in > CPython after the fact, but you'd want the memory to be unpageable > before it has contents put in it, not after. Yeah, like I said it needs language and OS support. There's no way to call those APIs from pure Python code. (And I'm not sure whether those functions work without appropriate CPU-level support; for instance, what happens if your OS is running inside a VM?) > Destroying memory is comparatively easy, as you say -- just make the > object's internal state "invalid", rather than adding anything to the > language. Yeah. Works fine if you have a cooperative system that checks that state every time; otherwise, it'd need at least some language support (the goal is to have its destructor called and all its references wiped, so resources get released). ChrisA