__init__ is the initialiser

Devin Jeanpierre jeanpierreda at gmail.com
Mon Feb 3 02:24:21 CET 2014


On Sun, Feb 2, 2014 at 4:07 PM, Chris Angelico <rosuav at gmail.com> wrote:
> On Mon, Feb 3, 2014 at 10:40 AM, Roy Smith <roy at panix.com> 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.

Destroying memory is comparatively easy, as you say -- just make the
object's internal state "invalid", rather than adding anything to the
language.

-- Devin



More information about the Python-list mailing list