[Python-ideas] Copy-on-write when forking a python process

Antoine Pitrou solipsis at pitrou.net
Wed Apr 13 13:58:15 CEST 2011

On Tue, 12 Apr 2011 23:40:02 -0400
Terry Reedy <tjreedy at udel.edu> wrote:
> 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.

It's now called sys.intern().

> > 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."

That's a rather strange sentence, because interned strings *are*
immortal (until the interpreter is shutdown).



More information about the Python-ideas mailing list