Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: speed up ServiceBrowsers with a pxd for the signal interface #1289

Merged
merged 3 commits into from
Nov 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions build_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def build(setup_kwargs: Any) -> None:
"src/zeroconf/_handlers/record_manager.py",
"src/zeroconf/_handlers/multicast_outgoing_queue.py",
"src/zeroconf/_handlers/query_handler.py",
"src/zeroconf/_services/__init__.py",
"src/zeroconf/_services/browser.py",
"src/zeroconf/_services/info.py",
"src/zeroconf/_services/registry.py",
Expand Down
11 changes: 11 additions & 0 deletions src/zeroconf/_services/__init__.pxd
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

import cython


cdef class Signal:

cdef list _handlers

cdef class SignalRegistrationInterface:

cdef list _handlers
1 change: 1 addition & 0 deletions src/zeroconf/_services/browser.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ from .._cache cimport DNSCache
from .._protocol.outgoing cimport DNSOutgoing, DNSPointer, DNSQuestion, DNSRecord
from .._updates cimport RecordUpdateListener
from .._utils.time cimport current_time_millis, millis_to_seconds
from . cimport Signal, SignalRegistrationInterface


cdef bint TYPE_CHECKING
Expand Down
2 changes: 1 addition & 1 deletion src/zeroconf/_services/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ def _enqueue_callback(
state_change is SERVICE_STATE_CHANGE_ADDED
or (
state_change is SERVICE_STATE_CHANGE_REMOVED
and self._pending_handlers.get(key) != SERVICE_STATE_CHANGE_ADDED
and self._pending_handlers.get(key) is not SERVICE_STATE_CHANGE_ADDED
)
or (state_change is SERVICE_STATE_CHANGE_UPDATED and key not in self._pending_handlers)
):
Expand Down