threading.py -> winthreading.c : Some results

Jason Orendorff jason at jorendorff.com
Fri Dec 21 02:49:43 EST 2001


I've reimplemented the synchronization objects of threading.py
in non-portable, Win32-only C.

The C versions of RLock, Event, Semaphore, and Condition perform
at least 5x faster than their standard counterparts in threading.py
in every situation I've tried.  Acquiring an RLock runs 25x faster.
Condition.wait(timeout) runs 500x faster.

This benchmark:
  http://www.bagley.org/~doug/shootout/bench/prodcons/prodcons.python
runs 6.3 times as fast under the C version of Condition.
That's fast enough to post a reasonably non-humiliating benchmark
number; it closes the gap between Python and Java considerably.
...If you care about such things.  ...As of course no sane person
does.

Whether this C code would mean a significant performance increase
in a real-life program remains to be proven.  Comments?

## Jason Orendorff    http://www.jorendorff.com/




More information about the Python-list mailing list