Skip to content

Commit 73d3ab9

Browse files
authored
feat: small performance improvement for converting time (#1342)
1 parent 810a309 commit 73d3ab9

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

src/zeroconf/_utils/time.pxd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11

22
cpdef double current_time_millis()
33

4-
cpdef millis_to_seconds(object millis)
4+
cpdef millis_to_seconds(double millis)

src/zeroconf/_utils/time.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,17 @@
2626
_float = float
2727

2828

29-
def current_time_millis() -> float:
29+
def current_time_millis() -> _float:
3030
"""Current time in milliseconds.
3131
3232
The current implemention uses `time.monotonic`
3333
but may change in the future.
34+
35+
The design requires the time to match asyncio.loop.time()
3436
"""
3537
return time.monotonic() * 1000
3638

3739

38-
def millis_to_seconds(millis: _float) -> float:
40+
def millis_to_seconds(millis: _float) -> _float:
3941
"""Convert milliseconds to seconds."""
4042
return millis / 1000.0

0 commit comments

Comments
 (0)