summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Giger <danielg1111@verizon.net>2022-08-30 12:10:02 (GMT)
committerGitHub <noreply@github.com>2022-08-30 12:10:02 (GMT)
commit22ed5233b76fe33f9767c6a5665608e7f398e7d7 (patch)
tree677d5048b2ea8857446b413e972b4cf7087eb120
parentb17aae8bbd13bec28b7ecbb5a147503f2e9cf365 (diff)
downloadcpython-22ed5233b76fe33f9767c6a5665608e7f398e7d7.zip
cpython-22ed5233b76fe33f9767c6a5665608e7f398e7d7.tar.gz
cpython-22ed5233b76fe33f9767c6a5665608e7f398e7d7.tar.bz2
gh-96349: fix minor performance regression initializing threading.Event (gh-96350)
-rw-r--r--Lib/threading.py12
-rw-r--r--Misc/NEWS.d/next/Library/2022-08-27-21-26-52.gh-issue-96349.XyYLlO.rst1
2 files changed, 4 insertions, 9 deletions
diff --git a/Lib/threading.py b/Lib/threading.py
index 7237a14..d030e12 100644
--- a/Lib/threading.py
+++ b/Lib/threading.py
@@ -262,18 +262,12 @@ class Condition:
# If the lock defines _release_save() and/or _acquire_restore(),
# these override the default implementations (which just call
# release() and acquire() on the lock). Ditto for _is_owned().
- try:
+ if hasattr(lock, '_release_save'):
self._release_save = lock._release_save
- except AttributeError:
- pass
- try:
+ if hasattr(lock, '_acquire_restore'):
self._acquire_restore = lock._acquire_restore
- except AttributeError:
- pass
- try:
+ if hasattr(lock, '_is_owned'):
self._is_owned = lock._is_owned
- except AttributeError:
- pass
self._waiters = _deque()
def _at_fork_reinit(self):
diff --git a/Misc/NEWS.d/next/Library/2022-08-27-21-26-52.gh-issue-96349.XyYLlO.rst b/Misc/NEWS.d/next/Library/2022-08-27-21-26-52.gh-issue-96349.XyYLlO.rst
new file mode 100644
index 0000000..59eb351
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2022-08-27-21-26-52.gh-issue-96349.XyYLlO.rst
@@ -0,0 +1 @@
+Fixed a minor performance regression in :func:`threading.Event.__init__`