feat: speed up question and answer internals (#1272) · python-zeroconf/python-zeroconf@d24722b

@@ -2,14 +2,15 @@

22

import cython

3344

from .._cache cimport DNSCache

5-

from .._dns cimport DNSPointer, DNSQuestion, DNSRecord, DNSRRSet

5+

from .._dns cimport DNSAddress, DNSPointer, DNSQuestion, DNSRecord, DNSRRSet

66

from .._history cimport QuestionHistory

77

from .._protocol.incoming cimport DNSIncoming

88

from .._services.info cimport ServiceInfo

99

from .._services.registry cimport ServiceRegistry

10+

from .answers cimport QuestionAnswers

1011111212-

cdef object TYPE_CHECKING, QuestionAnswers

13+

cdef object TYPE_CHECKING

1314

cdef cython.uint _ONE_SECOND, _TYPE_PTR, _TYPE_ANY, _TYPE_A, _TYPE_AAAA, _TYPE_SRV, _TYPE_TXT

1415

cdef str _SERVICE_TYPE_ENUMERATION_NAME

1516

cdef cython.set _RESPOND_IMMEDIATE_TYPES

@@ -19,7 +20,7 @@ cdef object _TYPE_PTR, _CLASS_IN, _DNS_OTHER_TTL

19202021

cdef class _QueryResponse:

212222-

cdef object _is_probe

23+

cdef bint _is_probe

2324

cdef DNSIncoming _msg

2425

cdef float _now

2526

cdef DNSCache _cache

@@ -29,17 +30,19 @@ cdef class _QueryResponse:

2930

cdef cython.set _mcast_aggregate

3031

cdef cython.set _mcast_aggregate_last_second

313233+

@cython.locals(record=DNSRecord)

3234

cpdef add_qu_question_response(self, cython.dict answers)

33353436

cpdef add_ucast_question_response(self, cython.dict answers)

353738+

@cython.locals(answer=DNSRecord)

3639

cpdef add_mcast_question_response(self, cython.dict answers)

37403841

@cython.locals(maybe_entry=DNSRecord)

39-

cpdef _has_mcast_within_one_quarter_ttl(self, DNSRecord record)

42+

cdef bint _has_mcast_within_one_quarter_ttl(self, DNSRecord record)

40434144

@cython.locals(maybe_entry=DNSRecord)

42-

cpdef _has_mcast_record_in_last_second(self, DNSRecord record)

45+

cdef bint _has_mcast_record_in_last_second(self, DNSRecord record)

43464447

cpdef answers(self)

4548

@@ -55,8 +58,8 @@ cdef class QueryHandler:

5558

@cython.locals(service=ServiceInfo)

5659

cdef _add_pointer_answers(self, str lower_name, cython.dict answer_set, DNSRRSet known_answers)

576058-

@cython.locals(service=ServiceInfo)

59-

cdef _add_address_answers(self, str lower_name, cython.dict answer_set, DNSRRSet known_answers, cython.uint type_)

61+

@cython.locals(service=ServiceInfo, dns_address=DNSAddress)

62+

cdef _add_address_answers(self, str lower_name, cython.dict answer_set, DNSRRSet known_answers, object type_)

60636164

@cython.locals(question_lower_name=str, type_=cython.uint, service=ServiceInfo)

6265

cdef cython.dict _answer_question(self, DNSQuestion question, DNSRRSet known_answers)