On Mon, 28 Jun 2010 16:46:41 -0700 Zac Burns <zac...@gmail.com> wrote: > In my experience it is far more expensive to allocate a lock in python then > it is the types that use them. Here are some examples: > > >>> timeit.timeit('Lock()', 'from threading import Lock') > 1.4449114807669048 > > >>> timeit.timeit('dict()') > 0.2821554294221187 > > >>> timeit.timeit('list()') > 0.17358153222312467
I'm not sure what Python version on what machine you are using, but here (Python 2.7): >>> timeit.timeit('Lock()', 'from threading import Lock') 0.09944796562194824 >>> timeit.timeit('dict()') 0.17817902565002441 >>> timeit.timeit('list()') 0.19633007049560547 >>> timeit.timeit('{}') 0.03823709487915039 >>> timeit.timeit('[]') 0.05156302452087402 -- http://mail.python.org/mailman/listinfo/python-list