Coder Social home page Coder Social logo

Comments (3)

zware avatar zware commented on May 26, 2024 2

Note that the loop uses time.monotonic(), not time.time(), so time since the Unix epoch is irrelevant here. time.monotonic() does not have a defined reference point (it's generally probably related to system uptime, but no guarantees). My personal system currently gives something around 192187.52431901, which is happily affected by adding 1e-09.

I don't think there's a real bug here; the likelihood of a time.monotonic() timestamp getting big enough to cause this kind of problem seems remote. It might still be a good idea to migrate to time.monotonic_ns() just to make the issue impossible, but that's going to take some serious consideration in all time-related asyncio APIs to avoid breaking things with the change.

from cpython.

KholdStare avatar KholdStare commented on May 26, 2024

Some thoughts I had - ideally timestamps would be 64bit ints with nanosecond precision - then the above calculation would work out. However, since we are dealing with 64bit floats, there's only 53 bits of precision. Perhaps when _clock_resolution is stored in the event loop, it should be "bumped up" to the smallest increment that would not lead to precision loss. I.e. a floating point with the same exponent as a typical epoch time, but the mantissa being 1.

from cpython.

KholdStare avatar KholdStare commented on May 26, 2024

Thank you for the quick response. This makes sense to me. Feel free to close the issue. Would a comment be useful in the code to warn of this behavior? I'm not sure if there is an environment out there where the monotonic clock acts as epoch time - but if there is, then this issue would apply.

from cpython.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.