Closed skshetry closed 2 years ago
Since funcy still supports 2.7, this should go to compat.py
:
try:
from timeit import default_timer
except ImportError:
from time import perf_counter as default_timer
And then use it everywhere.
@Suor, this uses timeit.default_timer
which is available in 2.7, so need for compat.
Also, there is no monotonic timer in Python 2.7, it was introduced in Python 3.3.
Ok, thanks.
@Suor, WDYT of cache
and throttle
?
They are fine using time.time()
. Additionally throttle()
exposes the .blocked_until
value, so changing it to something else might break something.
Instead of using
time.time
, this uses `timeit.default_timer()`.default_timer
usestime.perf_counter
which is monotonic, is not user-adjustable, and is more precise.However,
time.perf_counter
is only available since Python>3.3, and hence is unavailable in Python 2.7. In that version, it defaults totime.clock()
in Windows andtime.time()
in other platforms.I think a similar change should be made on
cache
andthrottle
functions.From discussion in https://github.com/iterative/dvc/pull/7393#discussion_r854320578