Skip to content

Commit 22ed523

Browse files
authored
gh-96349: fix minor performance regression initializing threading.Event (gh-96350)
1 parent b17aae8 commit 22ed523

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

Lib/threading.py

+3-9
Original file line numberDiff line numberDiff line change
@@ -262,18 +262,12 @@ def __init__(self, lock=None):
262262
# If the lock defines _release_save() and/or _acquire_restore(),
263263
# these override the default implementations (which just call
264264
# release() and acquire() on the lock). Ditto for _is_owned().
265-
try:
265+
if hasattr(lock, '_release_save'):
266266
self._release_save = lock._release_save
267-
except AttributeError:
268-
pass
269-
try:
267+
if hasattr(lock, '_acquire_restore'):
270268
self._acquire_restore = lock._acquire_restore
271-
except AttributeError:
272-
pass
273-
try:
269+
if hasattr(lock, '_is_owned'):
274270
self._is_owned = lock._is_owned
275-
except AttributeError:
276-
pass
277271
self._waiters = _deque()
278272

279273
def _at_fork_reinit(self):
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed a minor performance regression in :func:`threading.Event.__init__`

0 commit comments

Comments
 (0)