Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate Py_IS_NAN/INFINITY/FINITE? #119613

Closed
skirpichev opened this issue May 27, 2024 · 8 comments
Closed

Deprecate Py_IS_NAN/INFINITY/FINITE? #119613

skirpichev opened this issue May 27, 2024 · 8 comments
Labels
topic-C-API type-feature A feature request or enhancement

Comments

@skirpichev
Copy link
Member

skirpichev commented May 27, 2024

Feature or enhancement

Proposal:

isnan(), isinf() and isfinite() are part of C99, which is a requirement for 3.11+. Probably, it does make sense to deprecate (undocumented) public macros and switch codebase to use C stdlib functions.

JFR: #119457 (comment)

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Linked PRs

@skirpichev skirpichev added the type-feature A feature request or enhancement label May 27, 2024
@skirpichev
Copy link
Member Author

CC @vstinner as author of 194a952

I'll work on a patch.

@skirpichev
Copy link
Member Author

First part: #119619

@vstinner
Copy link
Member

isnan(), isinf() and isfinite() are part of C99, which is a requirement for 3.11+. Probably, it does make sense to deprecate (undocumented) public macros and switch codebase to use C stdlib functions.

A code search on PyPI top 7,500 projects found 10 projects using these macros:

  • Nuitka (2.1.2)
  • aim (3.19.1)
  • fastcluster (1.2.6)
  • gmpy2 (2.1.5)
  • msgspec (0.18.6)
  • numba (0.59.0)
  • pandas (2.2.1)
  • python-rapidjson (1.16)
  • simplejson (3.19.2)
  • vowpalwabbit (9.9.0)

I suggest to update all of these projects before considering to deprecate these macros.

I would be fine with a soft deprecation. It's the kind of the issue which fall into PEP 743 – Add Py_COMPAT_API_VERSION to the Python C API territory: having a way to opt-out from deprecated macros, without forcing all projects to update their code.

@skirpichev
Copy link
Member Author

skirpichev commented May 28, 2024

@vstinner, these macroses were undocumented. Should we (1) document them (with "deprecated" statement) and (2) add news entry? Or (2) is enough?

I would be fine with a soft deprecation.

If we don't announce removal (e.g. deprecated-removed statement) wouldn't this be a soft deprecation?


@vstinner
Copy link
Member

You can announce the soft deprecation in What's New in Python 3.14 and add a comment to explain that these macros are soft deprecated.

@skirpichev
Copy link
Member Author

Maybe this could go to 3.13?

@vstinner
Copy link
Member

Maybe this could go to 3.13?

Deprecations cannot be added after beta1.

@skirpichev
Copy link
Member Author

Ok, last part: #119701

vstinner added a commit that referenced this issue May 29, 2024
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
vstinner added a commit to vstinner/cpython that referenced this issue Jun 4, 2024
vstinner added a commit to vstinner/cpython that referenced this issue Jun 4, 2024
vstinner added a commit that referenced this issue Jun 4, 2024
barneygale pushed a commit to barneygale/cpython that referenced this issue Jun 5, 2024
noahbkim pushed a commit to hudson-trading/cpython that referenced this issue Jul 11, 2024
noahbkim pushed a commit to hudson-trading/cpython that referenced this issue Jul 11, 2024
)

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
noahbkim pushed a commit to hudson-trading/cpython that referenced this issue Jul 11, 2024
estyxx pushed a commit to estyxx/cpython that referenced this issue Jul 17, 2024
estyxx pushed a commit to estyxx/cpython that referenced this issue Jul 17, 2024
)

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
estyxx pushed a commit to estyxx/cpython that referenced this issue Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-C-API type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

3 participants