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

Raymond Hettinger python at rcn.com
Thu Jan 24 22:59:19 CET 2008


> 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).


> 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.  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.  Also, it is not immediately clear to me that all of the changes were semantically neutral (those in the __stop and __delete methods).


Raymond


More information about the Python-checkins mailing list