Re: Erasing strings from memory?

Paul Swartz <[email protected]>
Newsgroups gmane.comp.python.cryptography
Message-ID <[email protected]>
On Tue, Nov 12, 2002 at 12:53:57PM -0500, Jeremy Hylton wrote:
>   PS> I don't know.  I liked that the old code cleared all the
>   PS> references to the string so I don't have to worry about
>   PS> misc. references sitting around keeping this string in memory.
>   PS> Does python really care if strings change on it?
>
> Yes.  Python depends in a lot of ways on strings being immutable.  If
> the string gets stuffed in a dictionary and you modify it, you'll get
> unpredictable results.  The string can also be interned.  You can't
> modify a string in the intern table.

None of these strings will be a dictionary key.  They're either
incorporated into a hash, or parsed into an alternate form.  As for
interning, will they be interned if they're not a dictionary key nor do
I manually intern them?

> I think the solution is to verify that it is not interned (ob_sstate),
> then recalculate the hash after zapping the string.

This sounds like a good idea.  Thanks for all the help/advice.

-p
--
       Paul Swartz
(o_    http://www.twistedmatrix.com/users/z3p.twistd/  _o)
//\    [email protected]                           /\\
V_/_   AIM: z3penguin                                 _\_V->

Democracy is the recurrent suspicion that more than half the people are right
more than half of the time.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.