Skip to content

Commit

Permalink
perf: Do not use reducer if there is no callback in `SingalInstance.r…
Browse files Browse the repository at this point in the history
…esume` (#278)

* perf: Do not use reducer if there is no callback in `SingalInstance.resume`

* Update src/psygnal/_signal.py

Co-authored-by: Talley Lambert <[email protected]>

---------

Co-authored-by: Talley Lambert <[email protected]>
  • Loading branch information
Czaki and tlambert03 authored Feb 21, 2024
1 parent ab5dfc5 commit 9cdce45
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/psygnal/_signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,10 @@ def resume(self, reducer: ReducerFunc | None = None, initial: Any = _NULL) -> No
# EventedModel.update, it may be undefined (as seen in tests)
if not getattr(self, "_args_queue", None):
return
if len(self._slots) == 0:
self._args_queue.clear()
return

if reducer is not None:
if len(inspect.signature(reducer).parameters) == 1:
args = cast("ReducerOneArg", reducer)(self._args_queue)
Expand Down

0 comments on commit 9cdce45

Please sign in to comment.