Skip to content

Add time.monotonic() function #58054

Closed
Closed

Description

@vstinner
BPO 13846
Nosy @terryjreedy, @abalkin, @pitrou, @vstinner, @giampaolo, @ned-deily, @merwok, @bitdancer
Files
  • monotonic.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2012-02-07.22:30:30.812>
    created_at = <Date 2012-01-24.00:22:29.067>
    labels = ['type-feature']
    title = 'Add time.monotonic() function'
    updated_at = <Date 2012-02-23.23:11:18.533>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2012-02-23.23:11:18.533>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2012-02-07.22:30:30.812>
    closer = 'vstinner'
    components = []
    creation = <Date 2012-01-24.00:22:29.067>
    creator = 'vstinner'
    dependencies = []
    files = ['24307']
    hgrepos = []
    issue_num = 13846
    keywords = ['patch']
    message_count = 11.0
    messages = ['151868', '152138', '152280', '152505', '152506', '152514', '152816', '152860', '153774', '154096', '154097']
    nosy_count = 10.0
    nosy_names = ['terry.reedy', 'belopolsky', 'pitrou', 'vstinner', 'giampaolo.rodola', 'ned.deily', 'eric.araujo', 'r.david.murray', 'rosslagerwall', 'python-dev']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'patch review'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue13846'
    versions = ['Python 3.3']

    Activity

    1. vstinner commented on Jan 24, 2012

      @vstinner
      MemberAuthor

      After time.wallclock() (issue bpo-10278), let add a time.monotomic() function. It is similar to time.wallclock() (try to get the most accurate clock) but is not available if the system doesn't provide a monotonic clock. It may also fail at runtime if Python cannot find a monotonic clock, whereas time.clock() and time.wallclock() fallback on a wallclock which may go backward on NTP adjust.

      The documentation of the patch should be improved :-)

      wallclock() tests may be simplified or dropped because they may fail on NTP adjust.

    2. terryjreedy commented on Jan 27, 2012

      @terryjreedy
      Member

      Do we actually yet another function, or could this be covered by adding a parameter such as monotonic=False, perhaps to wallclock().

    3. vstinner commented on Jan 29, 2012

      @vstinner
      MemberAuthor

      Do we actually yet another function, or could this be covered by adding a parameter such as monotonic=False, perhaps to wallclock().

      A monotonic is a different clock, it would be surprising that an
      argument uses another clock.

    4. merwok commented on Feb 3, 2012

      @merwok
      Member

      I don’t understand why this new function would be useful. Time-related modules in Python are already complicated.

    5. bitdancer commented on Feb 3, 2012

      @bitdancer
      Member

      If you are trying to time something (an interval), having the time go backward can really screw up your data. And that *will* happen on a system that is running NTP (or even just resets its time). monotonic clocks were introduced at the OS level for a reason, and it seems reasonable for Python to expose them (when the are available) like it does other system resources.

    6. merwok commented on Feb 3, 2012

      @merwok
      Member

      Thanks, now I see the usefulness.

    7. python-dev commented on Feb 7, 2012

      python-devmannequin
      Mannequin

      New changeset 376ce937823c by Victor Stinner in branch 'default':
      Issue bpo-13846: Add time.monotonic(), monotonic clock.
      http://hg.python.org/cpython/rev/376ce937823c

    8. merwok commented on Feb 8, 2012

      @merwok
      Member

      Victor, I think the doc doesn’t say why the function is useful for people like me who don’t already know it. David’s explanation could be reused.

    9. pitrou commented on Feb 20, 2012

      @pitrou
      Member

      Boost has a monotonic time implementation (steady_clock) for OS X:
      http://svn.boost.org/svn/boost/trunk/boost/chrono/detail/inlined/mac/chrono.hpp

    10. python-dev commented on Feb 23, 2012

      python-devmannequin
      Mannequin

      New changeset 50b1f2d07011 by Victor Stinner in branch 'default':
      Issue bpo-13846: Enhance time.monotonic() documentation
      http://hg.python.org/cpython/rev/50b1f2d07011

    11. vstinner commented on Feb 23, 2012

      @vstinner
      MemberAuthor

      Boost has a monotonic time implementation (steady_clock) for OS X

      I opened a new issue for Mac OS X: bpo-14104.

      --

      @Éric: I enhanced the doc. Feel free to complete or rewrite it if you have better information about such clocks.

    12. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      type-featureA feature request or enhancement

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions