Provide sleep(secs)/time_s() functions
Project description
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() function already use this method.
time_s()
Return time as an integer number of seconds since the epoch.
Usage
Only provide source code distribution, user need to install the build toolchain. It can’t be compiled on platforms without clock_nanosleep().
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()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
clock_time-1.0.tar.gz
(5.8 kB
view details)
File details
Details for the file clock_time-1.0.tar.gz
.
File metadata
- Download URL: clock_time-1.0.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a17f2740e7c09f4f5e699de783a45ba86f05ab4faee4f5b2744bf083eb20ba6 |
|
MD5 | 01ebaed787bb36417e885b29d7261c43 |
|
BLAKE2b-256 | 085a1b73dc1658ecf0e6d0038cfcdcafa599af0fbc262f6ac1b90ff5d8b1cfff |