__init__ is the initialiser
nicholas.cole at gmail.com
Mon Feb 3 14:50:04 CET 2014
On Mon, Feb 3, 2014 at 12:07 AM, 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, 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.)
Can't you get close to that using weakrefs? I'll admit that care is required.
More information about the Python-list