feat: speed up answering incoming questions by bdraco · Pull Request #1186 · python-zeroconf/python-zeroconf

Expand Up @@ -22,7 +22,7 @@
import enum import socket from typing import TYPE_CHECKING, Any, Dict, Iterable, List, Optional, Union, cast from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union, cast
from ._exceptions import AbstractMethodException from ._utils.net import _is_v6_address Expand Down Expand Up @@ -516,7 +516,7 @@ class DNSRRSet:
__slots__ = ('_record_sets', '_lookup')
def __init__(self, record_sets: Iterable[List[DNSRecord]]) -> None: def __init__(self, record_sets: List[List[DNSRecord]]) -> None: """Create an RRset from records sets.""" self._record_sets = record_sets self._lookup: Optional[Dict[DNSRecord, float]] = None Expand All @@ -530,7 +530,10 @@ def _get_lookup(self) -> Dict[DNSRecord, float]: """Return the lookup table, building it if needed.""" if self._lookup is None: # Build the hash table so we can lookup the record ttl self._lookup = {record: record.ttl for record_sets in self._record_sets for record in record_sets} self._lookup = {} for record_sets in self._record_sets: for record in record_sets: self._lookup[record] = record.ttl return self._lookup
def suppresses(self, record: _DNSRecord) -> bool: Expand Down