[Python-ideas] Copy-on-write when forking a python process
Terry Reedy
tjreedy at udel.edu
Wed Apr 13 05:40:02 CEST 2011
On 4/12/2011 9:32 PM, Mike Graham wrote:
> Python interns some strings and small ints. The intern builtin ensures
intern is deprecated in 2.7 and gone in 3.x.
> a string is in the former cache and isn't applicable for other
> objects; Python automatically interns strings that look like
> identifiers and you should never use the intern function yourself.
>
> These optimizations have nothing to do with reference counting and
> could be applicable under other garbage collection schemes. Reference
> counting doesn't mean that interned objects can never be freed; are
> you familiar with the idea of weak references?
"Changed in version 2.3: Interned strings are not immortal (like they
used to be in Python 2.2 and before); you must keep a reference to the
return value of intern() around to benefit from it."
--
Terry Jan Reedy
More information about the Python-ideas
mailing list