[issue3001] RLock's are SLOW

Jesús Cea Avión report at bugs.python.org
Thu May 29 17:28:12 CEST 2008


New submission from Jesús Cea Avión <jcea at jcea.es>:

threading.RLock acquire/release is very slow. A order of magnitude
higher than no reentrant threading.Lock:

"""
def RLockSpeed() :
  import time, threading
  t=time.time()
  result={}
  for i in xrange(1000000) :
    pass
  result["empty loop"]=time.time()-t
  l=threading.Lock()
  t=time.time()
  for i in xrange(1000000) :
    l.acquire()
    l.release()
  result["Lock"]=time.time()-t
  l=threading.RLock()
  t=time.time()
  for i in xrange(1000000) :
    l.acquire()
    l.release()
  result["RLock"]=time.time()-t
  return result

if __name__=="__main__" :
  print RLockSpeed()
"""

Result:
{'empty loop': 0.074212074279785156, 'RLock': 10.144084215164185,
'Lock': 1.2489800453186035}

----------
messages: 67497
nosy: jcea
severity: normal
status: open
title: RLock's are SLOW
type: performance
versions: Python 2.6, Python 3.0

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


More information about the Python-bugs-list mailing list