summaryrefslogtreecommitdiffstats
path: root/Python/bltinmodule.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2023-12-01 18:50:10 (GMT)
committerGitHub <noreply@github.com>2023-12-01 18:50:10 (GMT)
commit5c5022b8625e34f0035ad5a23bc4c2f16649d134 (patch)
tree1fcc940eb9aa9361579dc5216c43a2a46d527469 /Python/bltinmodule.c
parent05a370abd6cdfe4b54be60b3b911f3a441026bb2 (diff)
downloadcpython-5c5022b8625e34f0035ad5a23bc4c2f16649d134.zip
cpython-5c5022b8625e34f0035ad5a23bc4c2f16649d134.tar.gz
cpython-5c5022b8625e34f0035ad5a23bc4c2f16649d134.tar.bz2
gh-112567: Add _PyTimeFraction C API (#112568)
Use a fraction internally in the _PyTime API to reduce the risk of integer overflow: simplify the fraction using Greatest Common Divisor (GCD). The fraction API is used by time functions: perf_counter(), monotonic() and process_time(). For example, QueryPerformanceFrequency() usually returns 10 MHz on Windows 10 and newer. The fraction SEC_TO_NS / frequency = 1_000_000_000 / 10_000_000 can be simplified to 100 / 1. * Add _PyTimeFraction type. * Add functions: * _PyTimeFraction_Set() * _PyTimeFraction_Mul() * _PyTimeFraction_Resolution() * No longer check "numer * denom <= _PyTime_MAX" in _PyTimeFraction_Set(). _PyTimeFraction_Mul() uses _PyTime_Mul() which handles integer overflow.
Diffstat (limited to 'Python/bltinmodule.c')
0 files changed, 0 insertions, 0 deletions