GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-67795: Improve precision of non-float timestamp and timeout arguments by serhiy-storchaka · Pull Request #139273 · python/cpython

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Sep 23, 2025 •
edited by github-actions Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

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.

  • Issue: Inconsistency in datetime.utcfromtimestamp(Decimal) #67795

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@serhiy-storchaka
serhiy-storchaka requested a review from vstinner September 23, 2025 19:01
@serhiy-storchaka
serhiy-storchaka requested review from AA-Turner, abalkin and pganssle as code owners September 23, 2025 19:01
@bedevere-app bedevere-app Bot added the awaiting core review label Sep 23, 2025
@bedevere-app bedevere-app Bot mentioned this pull request Sep 23, 2025
Inconsistency in datetime.utcfromtimestamp(Decimal) #67795
Open
@serhiy-storchaka
pythongh-67795: Improve precision of non-float timestamp and timeout …
90f8bf2
…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
vstinner
vstinner reviewed Oct 3, 2025
View reviewed changes
Comment thread Python/pytime.c
}


static int

@vstinner vstinner Oct 3, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

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)?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@serhiy-storchaka serhiy-storchaka May 4, 2026

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Done.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Python/pytime.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

serhiy-storchaka and others added 2 commits October 3, 2025 17:58
@serhiy-storchaka @vstinner
Apply suggestions from code review
68433af
Co-authored-by: Victor Stinner <[email protected]>
@serhiy-storchaka
Add more comments.
937be4c
@serhiy-storchaka serhiy-storchaka mentioned this pull request Nov 5, 2025
Ceil division with math.ceildiv #90797
Closed
@github-actions

github-actions Bot commented Apr 29, 2026

Copy link
Copy Markdown

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Apr 29, 2026
serhiy-storchaka added 2 commits May 4, 2026 20:10
@serhiy-storchaka
Merge branch 'main' into timestamp-timeout-as-integer-ratio
6be1856
@serhiy-storchaka
Replace _PyTime_FromLong with PyLong_AsInt64.
a93adbd
@serhiy-storchaka
serhiy-storchaka requested a review from StanFromIreland as a code owner May 4, 2026 17:15
@read-the-docs-community

read-the-docs-community Bot commented May 4, 2026

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
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot removed the stale Stale PR or inactive for long period of time. label May 16, 2026
@github-actions

github-actions Bot commented Aug 18, 2026

Copy link
Copy Markdown

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Aug 18, 2026
@edgarrmondragon

edgarrmondragon commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

I'd love to see this in 3.16 so it'd be a shame for it to go stale

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

Reviewers

@vstinner vstinner vstinner left review comments
@pganssle pganssle Awaiting requested review from pganssle pganssle is a code owner
@abalkin abalkin Awaiting requested review from abalkin
@AA-Turner AA-Turner Awaiting requested review from AA-Turner AA-Turner is a code owner
@StanFromIreland StanFromIreland Awaiting requested review from StanFromIreland StanFromIreland is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting core review

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@serhiy-storchaka @edgarrmondragon @vstinner
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.