[issue15124] _thread.LockType: Optimize lock deletion, acquisition of uncontested lock and release of lock.

Kristján Valur Jónsson report at bugs.python.org
Fri Jun 22 15:30:12 CEST 2012


Kristján Valur Jónsson <kristjan at ccpgames.com> added the comment:

I cannot repro.  On my ubuntu virtualbox I get:

before:
kristjan at kristjan-VirtualBox:~/cpython$ ./python -m timeit -s "from _thread import allocate_lock" "allocate_lock()"
10000000 loops, best of 3: 0.0768 usec per loop
kristjan at kristjan-VirtualBox:~/cpython$ ./python -m timeit -s "from _thread import allocate_lock;l=allocate_lock()" "l.acquire();l.release()"
1000000 loops, best of 3: 0.209 usec per loop

after:
kristjan at kristjan-VirtualBox:~/cpython$ ./python -m timeit -s "from _thread import allocate_lock" "allocate_lock()"
10000000 loops, best of 3: 0.069 usec per loop
kristjan at kristjan-VirtualBox:~/cpython$ ./python -m timeit -s "from _thread import allocate_lock;l=allocate_lock()" "l.acquire();l.release()"
10000000 loops, best of 3: 0.182 usec per loop

I did this a few times with consistent results.  But virtual machines aren't the most stable of beasts.  Perhaps someone with a proper unix box can test it?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue15124>
_______________________________________


More information about the Python-bugs-list mailing list