Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #65309

Re: __init__ is the initialiser

References (8 earlier) <bl81skFh14iU1@mid.individual.net> <mailman.6313.1391383680.18130.python-list@python.org> <roy-C454F0.18405902022014@news.panix.com> <CAPTjJmo6qpfP74YF+2xKV1y-qUNt6rG+8kHkoYJZXbb3HED5pg@mail.gmail.com> <CABicbJJrUv=Nrag5DQGU49BO98zpymvyZCtfxA=TYLrd14Tqvg@mail.gmail.com>
Date 2014-02-03 12:37 +1100
Subject Re: __init__ is the initialiser
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.6319.1391391446.18130.python-list@python.org> (permalink)

Show all headers | View raw


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

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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: __init__ is the initialiser Terry Reedy <tjreedy@udel.edu> - 2014-01-31 22:16 -0500
  Re: __init__ is the initialiser Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-01 05:23 +0000
    Re: __init__ is the initialiser Roy Smith <roy@panix.com> - 2014-02-01 00:25 -0500
      Re: __init__ is the initialiser Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-02-03 12:15 +1300
        Re: __init__ is the initialiser Chris Angelico <rosuav@gmail.com> - 2014-02-03 10:27 +1100
          Re: __init__ is the initialiser Roy Smith <roy@panix.com> - 2014-02-02 18:40 -0500
            Re: __init__ is the initialiser Chris Angelico <rosuav@gmail.com> - 2014-02-03 11:07 +1100
            Re: __init__ is the initialiser Devin Jeanpierre <jeanpierreda@gmail.com> - 2014-02-02 17:24 -0800
            Re: __init__ is the initialiser Chris Angelico <rosuav@gmail.com> - 2014-02-03 12:37 +1100
            Re: __init__ is the initialiser Devin Jeanpierre <jeanpierreda@gmail.com> - 2014-02-02 17:54 -0800
            Re: __init__ is the initialiser Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-02-03 08:44 -0500
            Re: __init__ is the initialiser Nicholas Cole <nicholas.cole@gmail.com> - 2014-02-03 13:50 +0000
            Re: __init__ is the initialiser Ian Kelly <ian.g.kelly@gmail.com> - 2014-02-03 10:44 -0700
            Re: __init__ is the initialiser Chris Angelico <rosuav@gmail.com> - 2014-02-04 04:57 +1100
            Re: __init__ is the initialiser Nicholas Cole <nicholas.cole@gmail.com> - 2014-02-03 19:57 +0000
            Re: __init__ is the initialiser Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-02-03 19:38 -0500
        Re: __init__ is the initialiser Dave Angel <davea@davea.name> - 2014-02-02 19:35 -0500
          Re: __init__ is the initialiser Roy Smith <roy@panix.com> - 2014-02-02 19:45 -0500
            Re: __init__ is the initialiser Dave Angel <davea@davea.name> - 2014-02-02 22:14 -0500
            Re: __init__ is the initialiser Skip Montanaro <skip@pobox.com> - 2014-02-02 21:15 -0600
            Re: __init__ is the initialiser Dave Angel <davea@davea.name> - 2014-02-03 00:06 -0500
              Re: __init__ is the initialiser Roy Smith <roy@panix.com> - 2014-02-03 00:12 -0500
                Re: __init__ is the initialiser Chris Angelico <rosuav@gmail.com> - 2014-02-03 16:49 +1100
                Re: __init__ is the initialiser Ethan Furman <ethan@stoneleaf.us> - 2014-02-02 21:34 -0800
    Re: __init__ is the initialiser Rustom Mody <rustompmody@gmail.com> - 2014-01-31 21:31 -0800

csiph-web