Introduction
------------
Provide ``sleep(secs)`` / ``time_s()`` functions. Fix overflow bugs in CPython implementation so far (v3.14.0a1).
``sleep(secs)``
---------------
Use ``clock_nanosleep()`` with ``CLOCK_MONOTONIC`` to sleep. So that the sleep is not affected by system date/time jumps.
On CPython 3.11+, `time.sleep() <https://docs.python.org/3/library/time.html#time.sleep>`_ function already use this method.
``time_s()``
------------
Return time as an integer number of seconds since the `epoch <https://docs.python.org/3/library/time.html#epoch>`_.
Usage
-----
Only provide source code distribution, user need to install the build toolchain. It can't be compiled on platforms without ``clock_nanosleep()``.
.. sourcecode:: python
try:
from clock_time import sleep, time_s
except ImportError:
from time import sleep, time_ns
def time_s():
return time_ns() // 1_000_000_000
sleep(secs)
t = time_s()
Raw data
{
"_id": null,
"home_page": "https://bitbucket.org/wjssz/clock_time",
"name": "clock-time",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.0",
"maintainer_email": null,
"keywords": "sleep",
"author": "Ma Lin",
"author_email": "malincns@163.com",
"download_url": "https://files.pythonhosted.org/packages/08/5a/1b73dc1658ecf0e6d0038cfcdcafa599af0fbc262f6ac1b90ff5d8b1cfff/clock_time-1.0.tar.gz",
"platform": null,
"description": "Introduction\n------------\n\nProvide ``sleep(secs)`` / ``time_s()`` functions. Fix overflow bugs in CPython implementation so far (v3.14.0a1).\n\n\n``sleep(secs)``\n---------------\n\nUse ``clock_nanosleep()`` with ``CLOCK_MONOTONIC`` to sleep. So that the sleep is not affected by system date/time jumps.\n\nOn CPython 3.11+, `time.sleep() <https://docs.python.org/3/library/time.html#time.sleep>`_ function already use this method.\n\n\n``time_s()``\n------------\n\nReturn time as an integer number of seconds since the `epoch <https://docs.python.org/3/library/time.html#epoch>`_.\n\n\nUsage\n-----\n\nOnly provide source code distribution, user need to install the build toolchain. It can't be compiled on platforms without ``clock_nanosleep()``.\n\n.. sourcecode:: python\n\n try:\n from clock_time import sleep, time_s\n except ImportError:\n from time import sleep, time_ns\n def time_s():\n return time_ns() // 1_000_000_000\n\n sleep(secs)\n t = time_s()\n",
"bugtrack_url": null,
"license": "The 3-Clause BSD License",
"summary": "Provide sleep(secs)/time_s() functions",
"version": "1.0",
"project_urls": {
"Homepage": "https://bitbucket.org/wjssz/clock_time"
},
"split_keywords": [
"sleep"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "085a1b73dc1658ecf0e6d0038cfcdcafa599af0fbc262f6ac1b90ff5d8b1cfff",
"md5": "01ebaed787bb36417e885b29d7261c43",
"sha256": "8a17f2740e7c09f4f5e699de783a45ba86f05ab4faee4f5b2744bf083eb20ba6"
},
"downloads": -1,
"filename": "clock_time-1.0.tar.gz",
"has_sig": false,
"md5_digest": "01ebaed787bb36417e885b29d7261c43",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.0",
"size": 5811,
"upload_time": "2024-10-29T04:13:40",
"upload_time_iso_8601": "2024-10-29T04:13:40.228102Z",
"url": "https://files.pythonhosted.org/packages/08/5a/1b73dc1658ecf0e6d0038cfcdcafa599af0fbc262f6ac1b90ff5d8b1cfff/clock_time-1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-29 04:13:40",
"github": false,
"gitlab": false,
"bitbucket": true,
"codeberg": false,
"bitbucket_user": "wjssz",
"bitbucket_project": "clock_time",
"lcname": "clock-time"
}