Skip to content

gh-67795: Improve precision of non-float timestamp and timeout arguments#139273

Open
serhiy-storchaka wants to merge 5 commits into
python:mainfrom
serhiy-storchaka:timestamp-timeout-as-integer-ratio
Open

gh-67795: Improve precision of non-float timestamp and timeout arguments#139273
serhiy-storchaka wants to merge 5 commits into
python:mainfrom
serhiy-storchaka:timestamp-timeout-as-integer-ratio

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Sep 23, 2025

Copy link
Copy Markdown
Member

Use the as_integer_ratio() or the numerator and denominator attributes to represent the number as an integer ratio and perform scaling and rounding exactly.

This allows to avoid the precision loss and double rounding error due to conversion to float.


📚 Documentation preview 📚: https://cpython-previews--139273.org.readthedocs.build/

…arguments

Use the as_integer_ratio() or the numerator and denominator attributes
to represent the number as an integer ratio and perform scaling and
rounding exactly.

This allows to avoid the precision loss and double rounding error due to
conversion to float.
@serhiy-storchaka serhiy-storchaka force-pushed the timestamp-timeout-as-integer-ratio branch from 5672976 to 90f8bf2 Compare September 23, 2025 19:38
Comment thread Python/pytime.c
}


static int

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please document the 3 return values (-1, 0, 1)?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment thread Python/pytime.c Outdated
serhiy-storchaka and others added 2 commits October 3, 2025 17:58
Co-authored-by: Victor Stinner <vstinner@python.org>
@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Apr 29, 2026
@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #32530245 | 📁 Comparing a93adbd against main (10f950c)

  🔍 Preview build  

2 files changed
± whatsnew/3.15.html
± whatsnew/changelog.html

@github-actions github-actions Bot removed the stale Stale PR or inactive for long period of time. label May 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants