Commit 8a71757
committed
Use time.monotonic()
time.monotonic() relates to the real time spent inside the main thread, and can not be altered externally by e.g.
- ntp system time synchronisation (frequent, small impact)
- automatic time zone changes (infrequent, big impact)
- users manually changing system time (infrequent, big impact)
and is therefore preferred over time.time when measuring relative times (of a program).
Smaller improvements:
- Remove __init__ with unnecessary instance attribute assignment (time to load the extension itself is now representative due to explicit start() call)
- Use __slots__ for lower memory consumption of class instance(s)
- Simplify stop(), reducing the amount of checks, instance attribute lookups and variable assignments1 parent 23963fc commit 8a71757
1 file changed
Lines changed: 6 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | | - | |
18 | | - | |
| 16 | + | |
19 | 17 | | |
20 | 18 | | |
21 | | - | |
| 19 | + | |
22 | 20 | | |
23 | 21 | | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
| 22 | + | |
| 23 | + | |
30 | 24 | | |
31 | 25 | | |
32 | 26 | | |
33 | 27 | | |
34 | 28 | | |
35 | 29 | | |
| 30 | + | |
36 | 31 | | |
37 | 32 | | |
38 | 33 | | |
| |||
0 commit comments