[Patches] [ python-Patches-500447 ] native win32 threading primitives
noreply@sourceforge.net
noreply@sourceforge.net
Mon, 07 Jan 2002 22:49:21 -0800
Patches item #500447, was opened at 2002-01-07 08:34
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=500447&group_id=5470
Category: Modules
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Jason Orendorff (jorend)
Assigned to: Nobody/Anonymous (nobody)
Summary: native win32 threading primitives
Initial Comment:
The "threading" module provides five synchronization
primitives: Lock, RLock, Condition, Semaphore, and
Event.
This patch is a module, "winthreading", that provides
native C implementations (using Win32 directly) of
these objects. Benchmark code runs several times
to several hundred times faster using winthreading.
winthreading.c is intended as a drop-in replacement
for these five pieces of threading.py:
# At the end of threading.py; replace
# Python synch primitives with native version,
# if available.
try:
from winthreading import *
except ImportError:
pass
The ZIP file attached includes source and MSVC6
project files. The source is compatible with
Python 2.2.
A prebuilt .PYD will follow.
----------------------------------------------------------------------
>Comment By: Jason Orendorff (jorend)
Date: 2002-01-07 22:49
Message:
Logged In: YES
user_id=18139
Better source distribution attached.
----------------------------------------------------------------------
Comment By: Jason Orendorff (jorend)
Date: 2002-01-07 09:20
Message:
Logged In: YES
user_id=18139
Test cases attached.
To run them, put winthreading.pyd in your PYTHONPATH
and run (for example)
python test_rlock.py
Each test takes a few seconds to a minute to run
on my box; there's a lot of mysterious output,
followed by:
threading: [2.5829999446868896, ...]
average: 2.62159998417
winthreading: [0.12999999523162842, ...]
average: 0.122199988365
performance gain: 95.339%
winthreading is 21.5 times faster!
If you are brave, try modifying test_condition_2.py
a bit. Change access.wait() to access.wait(50000)
on lines 25 and 39; and see what happens. (If you
are not quite that brave, you might want to adjust
nloops, on line 46, down to about 500.)
----------------------------------------------------------------------
Comment By: Jason Orendorff (jorend)
Date: 2002-01-07 08:37
Message:
Logged In: YES
user_id=18139
Prebuilt .PYD file, as promised.
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=500447&group_id=5470