feat: small speed up to writing outgoing dns records by bdraco · Pull Request #1258 · python-zeroconf/python-zeroconf

Expand Up @@ -22,7 +22,7 @@
import enum import logging from typing import Dict, List, Optional, Sequence, Tuple, Union from typing import TYPE_CHECKING, Dict, List, Optional, Sequence, Tuple, Union
from .._cache import DNSCache from .._dns import DNSPointer, DNSQuestion, DNSRecord Expand Down Expand Up @@ -176,7 +176,7 @@ def add_additional_answer(self, record: DNSRecord) -> None: self.additionals.append(record)
def add_question_or_one_cache( self, cache: DNSCache, now: float, name: str, type_: int, class_: int self, cache: DNSCache, now: float_, name: str_, type_: int_, class_: int_ ) -> None: """Add a question if it is not already cached.""" cached_entry = cache.get_by_details(name, type_, class_) Expand All @@ -186,7 +186,7 @@ def add_question_or_one_cache( self.add_answer_at_time(cached_entry, now)
def add_question_or_all_cache( self, cache: DNSCache, now: float, name: str, type_: int, class_: int self, cache: DNSCache, now: float_, name: str_, type_: int_, class_: int_ ) -> None: """Add a question if it is not already cached. This is currently only used for IPv6 addresses. Expand Down Expand Up @@ -223,7 +223,8 @@ def _write_int(self, value: Union[float, int]) -> None:
def write_string(self, value: bytes) -> None: """Writes a string to the packet""" assert isinstance(value, bytes) if TYPE_CHECKING: assert isinstance(value, bytes) self.data.append(value) self.size += len(value)
Expand All @@ -237,7 +238,8 @@ def _write_utf(self, s: str) -> None: self.write_string(utfstr)
def write_character_string(self, value: bytes) -> None: assert isinstance(value, bytes) if TYPE_CHECKING: assert isinstance(value, bytes) length = len(value) if length > 256: raise NamePartTooLongException Expand Down