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

Mike Graham mikegraham at gmail.com
Wed Apr 13 03:32:01 CEST 2011


On Tue, Apr 12, 2011 at 9:12 PM, Gregory P. Smith <greg at krypto.org> wrote:
> I do not think most people consider this a problem.  For
>
> Reference counting in the first place... now that is a problem.  We
> shouldn't be doing it and instead should use a more modern scalable
> form of garbage collection...  Immutable hashable objects in Python
> (or is it just strings?) can be interned using the intern() call.
> This means they will never be freed.  But I do not believe the current
> implementation of interning prevents reference counting, it just adds
> them to an internal map of things (ie: one final reference) so they'll
> never be freed.
>
> ...
>
> -gps

Python interns some strings and small ints. The intern builtin ensures
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?

Reference counting is a pleasantly simple though somewhat outdated
scheme. It is not nearly as limiting as I think you imagine it to be.

Mike



More information about the Python-ideas mailing list