Skip to content

Conversation

@vstinner
Copy link
Member

@vstinnervstinner commented Jul 23, 2023

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
Copy link
MemberAuthor

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

@vstinner
Copy link
MemberAuthor

@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

@vstinner
Copy link
MemberAuthor

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.

@methane
Copy link
Member

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

@vstinner
Copy link
MemberAuthor

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.

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
Copy link
MemberAuthor

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.

@vstinnervstinner enabled auto-merge (squash) July 24, 2023 13:40
@vstinnervstinner merged commit fd66baf into python:mainJul 24, 2023
carljm added a commit to carljm/cpython that referenced this pull request Jul 24, 2023
* 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) ...
@vstinnervstinner deleted the pycore_dict branch September 13, 2023 16:09
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@vstinner@methane@bedevere-bot