[Python-checkins] r60249 - python/trunk/Lib/threading.py

Brett Cannon brett at python.org
Fri Jan 25 01:14:36 CET 2008


On Jan 24, 2008 1:59 PM, Raymond Hettinger <python at rcn.com> wrote:
> > How bad was the performance hit?
>
> Depends on how you measure it (the whole method, the try/finally part, the call to the lock, etc).  The with-statement has try/finally logic embedded but adds a few steps.  The threading module is a core building block and needs to be as fast as it can (with the try/finally logic remaining in-line).
>

True. I just wanted to know if it was truly marginal or enough to
actually measure.

>
> > The code is so much cleaner with the context managers.
>
> Sort of yes, sort of no.  This code has been much exercised and is stable.  It would not be hard to destabilize it and introduce hard-to-find bugs.

Overall, sure, but I don't think the context managers for the locks
are that complex. But I get your point.

>  Also, at Guido's behest, I plan to rewrite this module in C at some point -- that will be a bit easier with the in-lined try/finally logic still in place.

Do you think it will be worth revisiting the API? I know the
'threading' module was inspired by Java so it might stand a Pythonic
update. I personally don't know, though, since I use the module
infrequently.

-Brett


More information about the Python-checkins mailing list