feat: simplify code to unpack properties by bdraco · Pull Request #1237 · python-zeroconf/python-zeroconf

Conversation

@bdraco

This is one of most common operations from discovery so anything we can do to improve the performance here is a win.

We may need to cython

@codecov

bdraco

Comment on lines -364 to -368

for s in strs:
key, _, value = s.partition(b'=')
# Only update non-existent properties
if key and key not in result:
result[key] = value or None

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was O(n)*2 + the cost of the python loop

@bdraco bdraco marked this pull request as ready for review

August 27, 2023 19:22

@bdraco

@bdraco bdraco deleted the unpack_properties_cleanup branch

August 27, 2023 19:22

1 participant

@bdraco