FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-128863: Deprecate private C API functions by vstinner · Pull Request #128864 · python/cpython · GitHub

/ cpython Public

gh-128863: Deprecate private C API functions - #128864

Merged
vstinner merged 5 commits into
python:mainfrom
vstinner:deprecate_private
Jan 22, 2025
Merged

gh-128863: Deprecate private C API functions#128864
vstinner merged 5 commits into
python:mainfrom
vstinner:deprecate_private

Conversation

vstinner commented Jan 15, 2025
edited
Loading

Copy link
Copy Markdown
Member
  • _PyBytes_Join()
  • _PyDict_GetItemStringWithError()
  • _PyDict_Pop()
  • _PyThreadState_UncheckedGet()
  • _PyUnicode_AsString()
  • _Py_HashPointer()
  • _Py_fopen_obj()

Replace _Py_HashPointer() with Py_HashPointer().

Remove references to deprecated functions.


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

* _PyBytes_Join()
* _PyDict_GetItemStringWithError()
* _PyDict_Pop()
* _PyThreadState_UncheckedGet()
* _PyUnicode_AsString()
* _Py_HashPointer()
* _Py_fopen_obj()

Replace _Py_HashPointer() with Py_HashPointer().

Remove references to deprecated functions.

Copy link
Copy Markdown
Member Author

cc @encukou @zooba

encukou commented Jan 15, 2025

Copy link
Copy Markdown
Member

This is extra work for both you and for users. I do not see how this would reduce our maintenance burden. I also don't see any other benefit of this PR.

methane commented Jan 16, 2025
edited
Loading

Copy link
Copy Markdown
Member

Removing them from Python 3.16 seems a little hurried. Unless there is a specific reason to remove it sooner, how about schedule it for removal in Python 3.18?

Copy link
Copy Markdown
Member Author

Code search on PyPI top 7,500 projects (2024-10-16).

_PyBytes_Join(): 4 projects

  • cython (3.0.11)
  • dbnd (1.0.25.2)
  • mod_wsgi (5.0.1)
  • mypy (1.12.0)

_PyDict_GetItemStringWithError(): 3 projects

  • catboost (1.2.7)
  • mypy (1.12.0)
  • numpy (2.1.2)

_PyDict_Pop(): 1 project

  • cython (3.0.11)

_PyThreadState_UncheckedGet(): 25 projects

  • CoolProp (6.6.0)
  • aplr (10.6.3)
  • cffi (1.17.1)
  • correctionlib (2.6.4)
  • cython (3.0.11)
  • ddtrace (2.14.2)
  • debugpy (1.8.7)
  • dlib (19.24.6)
  • frozendict (2.4.6)
  • mmcif (0.89.0)
  • onnx (1.17.0)
  • onnx-simplifier (0.4.36)
  • onnxoptimizer (0.3.13)
  • onnxsim (0.4.36)
  • opencc (1.1.9)
  • praat_parselmouth (0.4.5)
  • ptvsd (4.3.2)
  • pybind11 (2.13.6)
  • pybind11_global (2.13.6)
  • pydevd (3.1.0)
  • pydevd_pycharm (243.19420.35)
  • pymatching (2.2.1)
  • pythonnet (3.0.4)
  • vaex-core (4.17.1)
  • xatlas (0.0.9)

_PyUnicode_AsString(): 1 project

  • cvxopt (1.3.2)

_Py_HashPointer(): 3 projects

  • cffi (1.17.1)
  • igraph (0.11.6)
  • numba (0.60.0)

_Py_fopen_obj(): 1 project

  • pybind11 (2.13.6)

I ignored projects including copies of these dependencies such as pybind11 copies.


Total: 33 projects

Affected projects (33):

  • CoolProp (6.6.0)
  • aplr (10.6.3)
  • catboost (1.2.7)
  • cffi (1.17.1)
  • correctionlib (2.6.4)
  • cvxopt (1.3.2)
  • cython (3.0.11)
  • dbnd (1.0.25.2)
  • ddtrace (2.14.2)
  • debugpy (1.8.7)
  • dlib (19.24.6)
  • frozendict (2.4.6)
  • igraph (0.11.6)
  • mmcif (0.89.0)
  • mod_wsgi (5.0.1)
  • mypy (1.12.0)
  • numba (0.60.0)
  • numpy (2.1.2)
  • onnx (1.17.0)
  • onnx-simplifier (0.4.36)
  • onnxoptimizer (0.3.13)
  • onnxsim (0.4.36)
  • opencc (1.1.9)
  • praat_parselmouth (0.4.5)
  • ptvsd (4.3.2)
  • pybind11 (2.13.6)
  • pybind11_global (2.13.6)
  • pydevd (3.1.0)
  • pydevd_pycharm (243.19420.35)
  • pymatching (2.2.1)
  • pythonnet (3.0.4)
  • vaex-core (4.17.1)
  • xatlas (0.0.9)

Copy link
Copy Markdown
Member Author

@methane:

Removing them from Python 3.16 seems a little hurried. Unless there is a specific reason to remove it sooner, how about schedule it for removal in Python 3.18?

I'm fine with using a longer deprecation period for _PyThreadState_UncheckedGet() which is more frequently used.

Other functions are used by less than 5 projects and so can use a faster deprecation period, no?

methane commented Jan 16, 2025

Copy link
Copy Markdown
Member
  • PyBytes_Join is added in Python 3.14.
  • Py_fopen is added in 3.14.

Python 3.13 will reach EOL in 2029. I want to keep it until 2031 (2029+2).

  • PyDict_GetItemStringRef is added in 3.13.
  • PyDict_Pop is added in 3.13.
  • PyThreadState_GetUnchecked is added in 3.13.
  • Py_HashPointer is added in 3.13.

Python 3.12 will reach EOL in 2028. I want to keep it until 2030 (2028+2).

Removing _PyUnicode_AsString with minimum deprecation period is OK because PyUnicode_AsUTF8 is added in 3.3.

Copy link
Copy Markdown
Member Author

Removing them from Python 3.16 seems a little hurried. Unless there is a specific reason to remove it sooner, how about schedule it for removal in Python 3.18?

I updated my PR to postpone the removal to Python 3.18.

Copy link
Copy Markdown
Member Author

serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I am not sure that it is worth to go such far in preserving compatibility for private C API. Usually we just changed it at will, it was a fair play.

Comment thread Doc/whatsnew/3.14.rst Outdated

Copy link
Copy Markdown
Member Author

I am not sure that it is worth to go such far in preserving compatibility for private C API. Usually we just changed it at will, it was a fair play.

Do you suggest to remove these functions earlier?

Copy link
Copy Markdown
Member

Were not some of them already removed?

This is only my grumbling. I would remove them without warning if there is a replacement. You have to ask other core developers if they have reasons to keep the old private C API.

Removing a private C API is not the worst thing that can be happen if you use private C API. It can change semantic -- start returning a strong reference instead of a weak reference or vice versa, start stealing a reference, change the order of parameters, etc.

But if keep them -- your PR LGTM.

vstinner enabled auto-merge (squash) January 22, 2025 10:37
vstinner merged commit 9012fa7 into python:main Jan 22, 2025
vstinner deleted the deprecate_private branch January 22, 2025 11:04

Copy link
Copy Markdown
Member Author

Merged, thanks for review.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

5 participants


Back | FazBrowse Home | New Git URL