Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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 @@ -28,6 +28,7 @@ def build(setup_kwargs: Any) -> None:
"src/zeroconf/_listener.py",
"src/zeroconf/_protocol/incoming.py",
"src/zeroconf/_protocol/outgoing.py",
"src/zeroconf/_services/registry.py",
],
compiler_directives={"language_level": "3"}, # Python 3
),
Expand Down
18 changes: 18 additions & 0 deletions src/zeroconf/_services/registry.pxd
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

import cython


cdef class ServiceRegistry:

cdef cython.dict _services
cdef public cython.dict types
cdef public cython.dict servers

@cython.locals(
record_list=cython.list,
)
cdef _async_get_by_index(self, cython.dict records, str key)

cdef _add(self, object info)

cdef _remove(self, cython.list infos)
5 changes: 4 additions & 1 deletion src/zeroconf/_services/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ def async_get_infos_server(self, server: str) -> List[ServiceInfo]:

def _async_get_by_index(self, records: Dict[str, List], key: str) -> List[ServiceInfo]:
"""Return all ServiceInfo matching the index."""
return [self._services[name] for name in records.get(key, [])]
record_list = records.get(key)
if record_list is None:
return []
return [self._services[name] for name in record_list]

def _add(self, info: ServiceInfo) -> None:
"""Add a new service under the lock."""
Expand Down