threading support in python

Jean-Paul Calderone exarkun at divmod.com
Tue Sep 5 17:00:54 EDT 2006


On 05 Sep 2006 13:19:03 -0700, Paul Rubin <"http://phr.cx"@nospam.invalid> wrote:
>skip at pobox.com writes:
>> It was removed at one point in the dim, dark past (circa Python 1.4) on an
>> experimental basis.  Aside from the huge amount of work, it resulted in
>> significantly lower performance for single-threaded apps (that is, the
>> common case).
>
>That's probably because they had to put locking and unlocking around
>every access to a reference count.  A real GC might have fixed that.

It would have made a difference, surely.  Whether that difference would have
been positive, negative, or unnoticable is a matter for benchmarking and
profiling.

Even if you eliminate reference counting, you still have memory allocation
to deal with.  Python allocates approximately a jillion objects every time
you sneeze, and each of these goes through CPython's allocator, which needs
a lock to protect it from being corrupted by concurrent invocations.

It's not a simple matter to make CPython free-threaded (even so simple as
replacing all reference counting with another form of garbage collection),
although perhaps if half as much time were spent cutting code as is spent
discussing the matter, we might learn if there were any value in doing so.

Jean-Paul



More information about the Python-list mailing list