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-106320: Remove private _PyDict C API by vstinner · Pull Request #107145 · python/cpython

Conversation

@vstinner

@vstinner vstinner commented Jul 23, 2023 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

Move private _PyDict functions to the internal C API (pycore_dict.h):

  • _PyDict_Contains_KnownHash()
  • _PyDict_DebugMallocStats()
  • _PyDict_DelItemIf()
  • _PyDict_GetItemWithError()
  • _PyDict_HasOnlyStringKeys()
  • _PyDict_MaybeUntrack()
  • _PyDict_MergeEx()

No longer export these functions.

  • Issue: C API: Remove private C API functions (move them to the internal C API) #106320

Sorry, something went wrong.

Uh oh!

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

All reactions
@vstinner
vstinner requested review from 1st1, asvetlov, brettcannon, ericsnowcurrently, gvanrossum, kumaraditya303, ncoghlan, pablogsal, rhettinger, warsaw and willingc as code owners July 23, 2023 19:10
@bedevere-bot bedevere-bot mentioned this pull request Jul 23, 2023
C API: Remove private C API functions (move them to the internal C API) #106320
Closed
@bedevere-bot bedevere-bot added the awaiting core review label Jul 23, 2023
@vstinner

vstinner commented Jul 23, 2023

Copy link
Copy Markdown
Member Author

For now, I kept _PyDict_GetItemStringWithError() since it's used by _testcapi. The new public PyDict_GetItemStringRef() can be used by _testcapi instead.

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner vstinner added skip news topic-C-API labels Jul 23, 2023
@vstinner

vstinner commented Jul 23, 2023

Copy link
Copy Markdown
Member Author

@methane: Do you want to prefer to keep a few of these private _PyDict functions for now? Or is it ok to remove them right now from the C API?

If one of these private functions make sense outside CPython code base, we should consider making it public: see https://discuss.python.org/t/c-api-my-plan-to-clarify-private-vs-public-functions-in-python-3-13/30131

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner

vstinner commented Jul 23, 2023

Copy link
Copy Markdown
Member Author

With this PR, there are still the following private _PyDict functions:

  • _PyDictView_Intersect()
  • _PyDictView_New()
  • _PyDict_ContainsId()
  • _PyDict_DelItemId()
  • _PyDict_GetItemIdWithError()
  • _PyDict_GetItemStringWithError()
  • _PyDict_Next()
  • _PyDict_Pop()
  • _PyDict_SetItemId()
  • _PyDict_SizeOf()

I consider removing them later, except of the "Id" variants.

All reactions

Sorry, something went wrong.

Uh oh!

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

@methane

methane commented Jul 24, 2023

Copy link
Copy Markdown
Member

Cython uses _PyDict_GetItem_KnownHash and _PyDict_NewPresized().
So removing them will break some packages.
I don't know other private API users.

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner

vstinner commented Jul 24, 2023

Copy link
Copy Markdown
Member Author

The main branch of Cython uses the following private _PyDict functions:

  • _PyDict_GetItem_KnownHash()
  • _PyDict_NewPresized()
  • _PyDict_Pop()
  • _PyDict_SetItem_KnownHash()

Ok, let's keep these one for them, until we decide if we should make them public, or if Cython should avoid them.

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner
vstinner force-pushed the pycore_dict branch from 0bc07c2 to 0b32d1b Compare July 24, 2023 13:24
@vstinner vstinner mentioned this pull request Jul 24, 2023
C API: Cython 3.0 uses private functions removed in Python 3.13 (numpy 1.25.1 fails to build) #107076
Closed
@vstinner
pythongh-106320: Remove private _PyDict C API
1f5f06e
Move private _PyDict functions to the internal C API (pycore_dict.h):

* _PyDict_Contains_KnownHash()
* _PyDict_DebugMallocStats()
* _PyDict_DelItemIf()
* _PyDict_GetItemWithError()
* _PyDict_HasOnlyStringKeys()
* _PyDict_MaybeUntrack()
* _PyDict_MergeEx()

No longer export these functions.
@vstinner
vstinner force-pushed the pycore_dict branch from 0b32d1b to 1f5f06e Compare July 24, 2023 13:26
@vstinner

vstinner commented Jul 24, 2023

Copy link
Copy Markdown
Member Author

I updated my PR to keep the following functions:

  • _PyDict_DelItem_KnownHash()
  • _PyDict_GetItem_KnownHash()
  • _PyDict_NewPresized()
  • _PyDict_SetItem_KnownHash()

I also rebased it on the main branch.

All reactions

Sorry, something went wrong.

Uh oh!

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

methane
methane approved these changes Jul 24, 2023
View reviewed changes
@bedevere-bot bedevere-bot added awaiting merge and removed awaiting core review labels Jul 24, 2023
@vstinner
vstinner enabled auto-merge (squash) July 24, 2023 13:40
@vstinner
vstinner merged commit fd66baf into python:main Jul 24, 2023
@bedevere-bot bedevere-bot removed the awaiting merge label Jul 24, 2023
carljm added a commit to carljm/cpython that referenced this pull request Jul 24, 2023
@carljm
Merge branch 'main' into superfix
9a6bdfa
* main: (73 commits)
  Thoroughly refactor the cases generator (python#107151)
  Docs: Add missing markup to Argument Clinic docs (python#106876)
  pythongh-107162: Document errcode.h usage in its comment (python#107177)
  pythongh-106320: Remove private _PyDict C API (python#107145)
  Fix PyVectorcall_Function doc versionadded (python#107140)
  Docs: Remove duplicate word in Argument Clinic howto heading (python#107169)
  pythongh-107017: Change Chapter Strings to Texts in the Introduction chapter. (python#107104)
  pythongh-106320: Remove private _PyObject C API (python#107159)
  Docs: fix typo in os.pwrite docstring (python#107087)
  pythongh-105291: Add link to migration guide for distutils (python#107130)
  pythongh-106948: Docs: Disable links for C standard library functions, OS utility functions and system calls (python#107062)
  pythongh-106320: Remove _PyBytes_Join() C API (python#107144)
  pythongh-106320: Remove private _PyObject C API (python#107147)
  pythongh-106320: Remove _PyTuple_MaybeUntrack() C API (python#107143)
  pythongh-106320: Remove _PyIsSelectable_fd() C API (python#107142)
  Remove superflous whitespaces in `layout.html`. (pythonGH-107067)
  pythongh-107122: Update what's news for dbm.*dbm.clear() method (pythongh-107135)
  pythongh-107122: Add clear method to dbm.ndbm module (pythongh-107126)
  pythongh-62519: Make pgettext search plurals when translation is not found (python#107118)
  pythongh-107122: Add clear method to dbm.gdbm.module (pythongh-107127)
  ...
@vstinner
vstinner deleted the pycore_dict branch September 13, 2023 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@methane methane methane approved these changes
@rhettinger rhettinger Awaiting requested review from rhettinger rhettinger is a code owner
@pablogsal pablogsal Awaiting requested review from pablogsal pablogsal is a code owner
@brettcannon brettcannon Awaiting requested review from brettcannon
@ericsnowcurrently ericsnowcurrently Awaiting requested review from ericsnowcurrently ericsnowcurrently is a code owner
@ncoghlan ncoghlan Awaiting requested review from ncoghlan
@warsaw warsaw Awaiting requested review from warsaw
@1st1 1st1 Awaiting requested review from 1st1
@asvetlov asvetlov Awaiting requested review from asvetlov
@gvanrossum gvanrossum Awaiting requested review from gvanrossum
@kumaraditya303 kumaraditya303 Awaiting requested review from kumaraditya303 kumaraditya303 is a code owner
@willingc willingc Awaiting requested review from willingc

Uh oh!

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

Assignees

No one assigned

Labels

skip news topic-C-API

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.

3 participants

@vstinner @methane @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 01402503 — 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.