Message157410
STINNER Victor wrote:
>
> STINNER Victor <victor.stinner@gmail.com> added the comment:
>
>> I think you need to reconsider the time.steady() name you're using
>> in the PEP. For practical purposes, it's better to call it
>> time.monotonic()
>
> I opened a new thread on python-dev to discuss this topic.
>
>> and only make the function available if the OS provides
>> a monotonic clock.
>
> Oh, I should explain this choice in the PEP. Basically, the idea is to
> provide a best-effort portable function.
>
>> The fallback to time.time() is not a good idea, since then the programmer
>> has to check whether the timer really provides the features she's after
>> every time it gets used.
>
> Nope, time.get_clock_info('steady') does not change at runtime. So it
> can only be checked once.
With "every time" I meant: in every application you use the function.
That pretty much spoils the idea of a best effort portable function.
It's better to use a try-except to test for availability of
functions than to have to (remember to) call a separate function
to find out the characteristics of the best effort approach.
>> Instead of trying to tweak all the different clocks and timers into
>> a single function, wouldn't it be better to expose each kind as a
>> different function and then let the programmer decide which fits
>> best ?!
>
> This is a completly different approach. It should be discussed on
> python-dev, not in the bug tracker please. I think that Python can
> help the developer to write portable code by providing high-level
> functions because clock properties are well known (e.g. see
> time.get_clock_info).
Fair enough.
BTW: Are aware of the existing systimes.py module in pybench,
which already provides interfaces to high resolution timers usable
for benchmarking in a portable way ? Perhaps worth mentioning in
the PEP. |
|
Date |
User |
Action |
Args |
2012-04-03 11:41:49 | lemburg | set | recipients:
+ lemburg, vstinner, neologix |
2012-04-03 11:41:49 | lemburg | link | issue14428 messages |
2012-04-03 11:41:48 | lemburg | create | |
|