Re: Erasing strings from memory?
Jeremy Hylton <[email protected]>
| Newsgroups | gmane.comp.python.cryptography |
|---|---|
| Message-ID | <[email protected]> |
>>>>> "PS" == Paul Swartz <[email protected]> writes: PS> On Tue, Nov 12, 2002 at 12:53:57PM -0500, Jeremy Hylton wrote: I PS> 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. PS> None of these strings will be a dictionary key. They're either PS> incorporated into a hash, or parsed into an alternate form. As PS> for interning, will they be interned if they're not a dictionary PS> key nor do I manually intern them? We know they're not supposed to be used that way, but there's no way to guarantee it. Incautious use of this code could lead to bizarre, impossible to understand behavior. I think we both know that and are willing to live with it. Jeremy