Skip to content

Conversation

serhiy-storchaka
Copy link
Member

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

Functions that take timestamp or timeout arguments now accept any real numbers, not only integers or floats, although this does not improve precision.


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

Functions that take timestamp or timeout arguments now accept any
real numbers, not only integers or floats, although this does not
improve precision.
@vstinner
Copy link
Member

Nice, it works as expected:

$ ./python
>>> import socket, fractions, decimal

>>> socket.setdefaulttimeout(fractions.Fraction(1, 5))
>>> socket.getdefaulttimeout()
0.2

>>> socket.setdefaulttimeout(decimal.Decimal('1.5'))
>>> socket.getdefaulttimeout()
1.5

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

LGTM. You may just mention Decimal and Fraction in the global NEWS entry.


* Functions that take timestamp or timeout arguments now accept any
real numbers, not only integers or floats, although this does not
improve precision.
Copy link
Member

Choose a reason for hiding this comment

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

You may give Decimal and Fraction as examples.

@serhiy-storchaka serhiy-storchaka merged commit 1a2e00c into python:main Sep 23, 2025
45 checks passed
@serhiy-storchaka serhiy-storchaka deleted the timestamp-timeout-non-float branch September 23, 2025 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants