Skip to content

TimeAlarm duration argument for simpler code without precision degradation #3989

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
kevinjwalters opened this issue Jan 13, 2021 · 1 comment

Comments

@kevinjwalters
Copy link

kevinjwalters commented Jan 13, 2021

The new alarm.time.TimeAlarm() function from #3767 takes two forms of absolute time as an argument. The 30bit fp number representation of time from time.monotonic() loses precision over time and this will impact users who use monotonic_time keyword argument. For most users a relative time will be easier to use and avoids this problem as the library can deal with maintaining best precision under the covers.

The example code:

pause = alarm.time.TimeAlarm(monotonic_time=time.monotonic() + 20)

would become:

pause = alarm.time.TimeAlarm(relative_time=20)

There may be better names for that new kwarg...

@tannewt
Copy link
Member

tannewt commented Jan 13, 2021

My preference is for us to reset monotonic every time the VM resets. That will mitigate a lot of the problems with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants