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-119613: use C99+ functions instead of Py_IS_NAN/INFINITY/FINITE by skirpichev · Pull Request #119619 · python/cpython

Conversation

@skirpichev

@skirpichev skirpichev commented May 27, 2024 •
edited by bedevere-app Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Member
  • Issue: Deprecate Py_IS_NAN/INFINITY/FINITE? #119613

Sorry, something went wrong.

Uh oh!

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

All reactions
@skirpichev
pythongh-119613: use C99+ functions instead of Py_IS_NAN/INFINITY/FINITE
13dcd12
@skirpichev
skirpichev requested review from abalkin, ericsnowcurrently, gpshead, pganssle, rhettinger and tiran as code owners May 27, 2024 16:54
@bedevere-app bedevere-app Bot added the awaiting review label May 27, 2024
@bedevere-app bedevere-app Bot mentioned this pull request May 27, 2024
Deprecate Py_IS_NAN/INFINITY/FINITE? #119613
Closed
@skirpichev

This comment was marked as resolved.

Sign in to view
@Eclips4

Eclips4 commented May 27, 2024

Copy link
Copy Markdown
Member

This partially address #119613. I think this part doesn't require a news entry. CC @Eclips4

Yes, since this is a non-visible user change, I agreed.

All reactions

Sorry, something went wrong.

Uh oh!

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

@Eclips4 Eclips4 added skip news labels May 27, 2024
@rhettinger
rhettinger requested a review from tim-one May 27, 2024 23:18
@rhettinger

rhettinger commented May 27, 2024 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

@tim-one is there an on-going reason to have these portability macros? Are NaN values guaranteed to be supported?

All reactions

Sorry, something went wrong.

Uh oh!

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

@rhettinger
rhettinger requested a review from mdickinson May 28, 2024 00:16
@skirpichev

skirpichev commented May 28, 2024

Copy link
Copy Markdown
Member Author

Since 194a952 these macros are just aliases for isnan, isinf, etc:

cpython/Include/pymath.h

Lines 30 to 40 in 3e8b609

// Py_IS_NAN(X)
// Return 1 if float or double arg is a NaN, else 0.
#define Py_IS_NAN(X) isnan(X)
// Py_IS_INFINITY(X)
// Return 1 if float or double arg is an infinity, else 0.
#define Py_IS_INFINITY(X) isinf(X)
// Py_IS_FINITE(X)
// Return 1 if float or double arg is neither infinite nor NAN, else 0.
#define Py_IS_FINITE(X) isfinite(X)

nineteendo reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

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

vstinner
vstinner approved these changes May 28, 2024
View reviewed changes

@vstinner vstinner left a comment

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.

LGTM. Simple text replacement.

Sorry, something went wrong.

Uh oh!

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

All reactions
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting review labels May 28, 2024
@vstinner

vstinner commented May 28, 2024

Copy link
Copy Markdown
Member

@rhettinger:

@tim-one is there an on-going reason to have these portability macros? Are NaN values guaranteed to be supported?

Python 3.10 and older supported platforms without IEEE 754, without NaN, and without C99 <math.h>. We had complex macros such as:

#ifndef Py_IS_NAN
#if defined HAVE_DECL_ISNAN && HAVE_DECL_ISNAN == 1
#define Py_IS_NAN(X) isnan(X)
#else
#define Py_IS_NAN(X) ((X) != (X))
#endif
#endif

Python 3.11 and newer requires IEEE 754, NaN and C99 <math.h>. Macros were kept for backward compatibility only:

#define Py_IS_NAN(X) isnan(X)

Issues:

  • Require IEEE 754 floating point to build Python 3.11 #91073
  • Remove the Py_NO_NAN macro: require NAN to build Python 3.11 #90814
  • [C API] Py_IS_INFINITY() macro doesn't work in the limited C API if isinf() is not defined #89603
  • Python can now use the C99 NAN constant or __builtin_nan() #90798

See also this LWN article: CPython, C standards, and IEEE 754.

gpshead reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

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

@vstinner

vstinner commented May 28, 2024

Copy link
Copy Markdown
Member

@mdickinson: Are you ok with this change? You wrote a comment about these macros there: #119457 (comment)

All reactions

Sorry, something went wrong.

Uh oh!

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

@mdickinson

mdickinson commented May 28, 2024

Copy link
Copy Markdown
Member

@mdickinson: Are you ok with this change?

Yes, absolutely. I'm fairly sure the macros were born out of (now somewhat ancient) portability needs that no longer apply, now that C99 (and later) adoption is sufficiently widespread.

I'd suggest running all buildbots on this PR, just to be on the safe side.

All reactions

Sorry, something went wrong.

Uh oh!

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

mdickinson
mdickinson approved these changes May 28, 2024
View reviewed changes

@mdickinson mdickinson left a comment

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.

LGTM

Sorry, something went wrong.

Uh oh!

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

All reactions
@mdickinson mdickinson added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label May 28, 2024
@bedevere-bot

bedevere-bot commented May 28, 2024

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @mdickinson for commit 13dcd12 🤖

If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again.

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label May 28, 2024
rhettinger
rhettinger approved these changes May 28, 2024
View reviewed changes
@skirpichev

skirpichev commented May 29, 2024

Copy link
Copy Markdown
Member Author

There are tests failures, but hardly it's related to the pr. Something expected, given there are not build bots for non-IEEE-754 platforms, right?

All reactions

Sorry, something went wrong.

Uh oh!

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

@mdickinson

mdickinson commented May 29, 2024

Copy link
Copy Markdown
Member

There are tests failures, but hardly it's related to the pr.

Agreed - the failures look unrelated.

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner
vstinner merged commit cd11ff1 into python:main May 29, 2024
@bedevere-app bedevere-app Bot removed the awaiting merge label May 29, 2024
@vstinner

vstinner commented May 29, 2024

Copy link
Copy Markdown
Member

Merged, thanks.

All reactions

Sorry, something went wrong.

Uh oh!

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

@skirpichev
skirpichev deleted the deprecate-py-is-nan-119613 branch May 29, 2024 07:52
estyxx pushed a commit to estyxx/cpython that referenced this pull request Jul 17, 2024
@skirpichev @estyxx
pythongh-119613: Use C99+ functions instead of Py_IS_NAN/INFINITY/FIN…
6153c61
…ITE (python#119619)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@vstinner vstinner vstinner approved these changes
@rhettinger rhettinger rhettinger approved these changes
@pganssle pganssle Awaiting requested review from pganssle pganssle is a code owner
@abalkin abalkin Awaiting requested review from abalkin
@gpshead gpshead Awaiting requested review from gpshead gpshead is a code owner
@tiran tiran Awaiting requested review from tiran
@ericsnowcurrently ericsnowcurrently Awaiting requested review from ericsnowcurrently ericsnowcurrently is a code owner
@tim-one tim-one Awaiting requested review from tim-one
+1 more reviewer
@mdickinson mdickinson mdickinson approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

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

Assignees

No one assigned

Labels

skip news

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.

6 participants

@skirpichev @Eclips4 @rhettinger @vstinner @mdickinson @bedevere-bot
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 01402520 — 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.