1 |
On Tue, Sep 20, 2005 at 06:55:44PM -0500, Paul Varner wrote: |
2 |
> On Tue, 2005-09-20 at 18:34 -0500, Brian Harring wrote: |
3 |
> > > Updated patch to add a semaphore to control access to the global |
4 |
> > > portage.config object. Unless anyone sees any other issues with this |
5 |
> > > patch, I will be placing it into gentoolkit. |
6 |
> > Reason for a semaphore over threading.Lock ? |
7 |
> |
8 |
> No reason other than I'm used to thinking of them as semaphores instead |
9 |
> of locks, so semaphore is what I searched for in the Python docs. |
10 |
Need to make some chunks of the rewrite thread safe, so I poked a bit; |
11 |
python -m timeit -n 10000 -r 3 -s 'import threading;s=threading.Lock()' 's.acquire();s.release()' |
12 |
around 1us |
13 |
python -m timeit -n 10000 -r 3 -s 'import threading;s=threading.Semaphore()' 's.acquire();s.release()' |
14 |
20us |
15 |
|
16 |
Granted... It's being anal. Just surprised me, and figured I'd poke |
17 |
to find out if you had a specific reason for using sem over the |
18 |
simpler (pretty much straight cpython) Lock :) |
19 |
~harring |