Skip to content

Fix outdated note about 'int' rounding or truncating#102736

Merged
mdickinson merged 1 commit intopython:mainfrom
mdickinson:fix-outdated-round-or-truncate-language
Mar 16, 2023
Merged

Fix outdated note about 'int' rounding or truncating#102736
mdickinson merged 1 commit intopython:mainfrom
mdickinson:fix-outdated-round-or-truncate-language

Conversation

@mdickinson
Copy link
Member

@mdickinson mdickinson commented Mar 15, 2023

This PR fixes an out-of-date note attached to int conversions in stdtypes.rst.

The "may round or truncate as in C" language dates from almost 30 years ago, when conversion from a Python float to a Python int involved at C level a (long) cast applied to a C double value. Prior to standard C, presumably the precise behaviour of that cast couldn't be relied upon. But since C89 standardised this behaviour and we can reasonably rely on all current C compilers adhering to that or later standards, the note is out of date. (Moreover, the current code for converting a Python 3 int to a C double is very different.)

Related discuss.python.org thread: https://discuss.python.org/t/built-in-types-int-round-or-truncate-please-elaborate/24840

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir skip issue skip news

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants