diff options
author | Victor Stinner <vstinner@python.org> | 2023-12-01 18:50:10 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-01 18:50:10 (GMT) |
commit | 5c5022b8625e34f0035ad5a23bc4c2f16649d134 (patch) | |
tree | 1fcc940eb9aa9361579dc5216c43a2a46d527469 /Python/getargs.c | |
parent | 05a370abd6cdfe4b54be60b3b911f3a441026bb2 (diff) | |
download | cpython-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/getargs.c')
0 files changed, 0 insertions, 0 deletions