chore: speed up DNSQuestion creation as well · python-zeroconf/python-zeroconf@bee7a74

2 files changed

lines changed

Original file line numberDiff line numberDiff line change

@@ -97,7 +97,7 @@ cdef class DNSIncoming:

9797

)

9898

cdef void _read_others(self)

9999
100-

@cython.locals(offset="unsigned int")

100+

@cython.locals(offset="unsigned int", question=DNSQuestion)

101101

cdef _read_questions(self)

102102
103103

@cython.locals(

Original file line numberDiff line numberDiff line change

@@ -246,7 +246,8 @@ def _read_questions(self) -> None:

246246

# The question has 2 unsigned shorts in network order

247247

type_ = view[offset] << 8 | view[offset + 1]

248248

class_ = view[offset + 2] << 8 | view[offset + 3]

249-

question = DNSQuestion(name, type_, class_)

249+

question = DNSQuestion.__new__(DNSQuestion)

250+

question._fast_init(name, type_, class_)

250251

if question.unique: # QU questions use the same bit as unique

251252

self._has_qu_question = True

252253

questions.append(question)