Repository navigation
Change to high-resolution clock per #33 - #682
Conversation
|
The core change here looks good, and fixes #33. Thanks! But I'm going to request a few tweaks :-). I had to go read the CPython source code to figure out what You should add a newsfragment, e.g. It looks like there are a bunch of other places in the Trio source code that still use I think these should all become CI failures should be fixed by #683, so no need to worry about those. |
Codecov Report
@@ Coverage Diff @@
## master #682 +/- ##
=========================================
+ Coverage 83.77% 83.97% +0.2%
=========================================
Files 94 94
Lines 13046 13006 -40
Branches 788 783 -5
=========================================
- Hits 10929 10922 -7
+ Misses 2096 2062 -34
- Partials 21 22 +1
Continue to review full report at Codecov.
|
njsmith
left a comment
There was a problem hiding this comment.
Thanks, this is almost there! A last few tweaks:
| args: Positional arguments to be passed to *async_fn*. If you need to | ||
| pass keyword arguments, then use :func:`functools.partial`. | ||
|
|
||
| clock: ``None`` to use the default system-specific monotonic clock; |
There was a problem hiding this comment.
This is just referring to the general concept of a "monotonic clock", so should stay the same.
|
|
||
| Every call to :func:`run` has an associated clock. | ||
|
|
||
| By default, trio uses an unspecified monotonic clock, but this can be |
There was a problem hiding this comment.
This should stay the same – it's talking about the general guarantees we make about the clock, and we still don't guarantee anything except that it has the property of monotonicity. (This is why we can change from time.monotonic to time.perf_counter :-).)
| @@ -0,0 +1 @@ | |||
| The Trio main loop now uses a higher-precision clock by default. No newline at end of file | |||
There was a problem hiding this comment.
This should say "on Windows", since that's the only platform affected.
There was a problem hiding this comment.
I think the blanket statement in the newsfragments is correct, since we change the function without regard for platform. However, we should add a sentence that notes that this only affects Windows platforms due to the details of how cPython is implemented.
There was a problem hiding this comment.
My reasoning is: we use a different function on all platforms, but on most platforms this doesn't change behavior at all, so it's not of interest to end users. The only place where precision changes is on Windows.
|
@tkerwin I edited the newsfragment again, see what you think? |
|
Yeah, that's good. |
|
Thanks, and welcome! 🎉 🎂 And, no pressure, but if you'd like to keep contributing then we'd love to have you, so I'm sending you a github invite now. You can read more about this in our contributing documentation. |
Per the discussion in issue #33 this changes the clock to use time.perf_counter() rather than time.monotonic() on all platforms.