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 function by vstinner · Pull Request #108449 · python/cpython

Conversation

@vstinner

@vstinner vstinner commented Aug 24, 2023 •
edited by bedevere-bot
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):

  • _PyDictView_Intersect()
  • _PyDictView_New()
  • _PyDict_ContainsId()
  • _PyDict_DelItemId()
  • _PyDict_DelItem_KnownHash()
  • _PyDict_GetItemIdWithError()
  • _PyDict_GetItem_KnownHash()
  • _PyDict_HasSplitTable()
  • _PyDict_NewPresized()
  • _PyDict_Next()
  • _PyDict_Pop()
  • _PyDict_SetItemId()
  • _PyDict_SetItem_KnownHash()
  • _PyDict_SizeOf()

No longer export most of these functions.

Move also the _PyDictViewObject to the internal C API.

Move dict_getitem_knownhash() function from _testcapi to the _testinternalcapi extension. Update test_capi.test_dict for this move.

  • 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.

Bobronium reacted with eyes emoji
All reactions
  • 👀 1 reaction
@vstinner
pythongh-106320: Remove private _PyDict function
e69215f
Move private _PyDict functions to the internal C API (pycore_dict.h):

* _PyDictView_Intersect()
* _PyDictView_New()
* _PyDict_ContainsId()
* _PyDict_DelItemId()
* _PyDict_DelItem_KnownHash()
* _PyDict_GetItemIdWithError()
* _PyDict_GetItem_KnownHash()
* _PyDict_HasSplitTable()
* _PyDict_NewPresized()
* _PyDict_Next()
* _PyDict_Pop()
* _PyDict_SetItemId()
* _PyDict_SetItem_KnownHash()
* _PyDict_SizeOf()

No longer export most of these functions.

Move also the _PyDictViewObject to the internal C API.

Move dict_getitem_knownhash() function from _testcapi to the
_testinternalcapi extension. Update test_capi.test_dict for this
move.
@vstinner vstinner added the skip news label Aug 24, 2023
@vstinner
vstinner requested review from 1st1, asvetlov, gvanrossum, kumaraditya303, rhettinger and willingc as code owners August 24, 2023 19:03
@bedevere-bot bedevere-bot mentioned this pull request Aug 24, 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 Aug 24, 2023
@vstinner
Export _PyDict_Pop() for _socket extension
814f867
@vstinner
vstinner enabled auto-merge (squash) August 24, 2023 19:38
@vstinner
vstinner merged commit 2689301 into python:main Aug 24, 2023
@bedevere-bot bedevere-bot removed the awaiting core review label Aug 24, 2023
@vstinner
vstinner deleted the pycore_dict2 branch August 24, 2023 23:23
@eendebakpt

eendebakpt commented Sep 13, 2023

Copy link
Copy Markdown
Contributor

@vstinner In this PR the method _PyDict_NewPresized was moved to the internal API. According to https://devguide.python.org/developer-workflow/c-api/#with-the-extern-keyword the method should still be available for stdlib extensions.

I am using the method in an extension module #91610, but the build is failing since this PR was merged with error message Error: _copy failed to import: /home/runner/work/cpython/cpython-builddir/build/lib.linux-x86_64-3.13-pydebug/_copy.cpython-313d-x86_64-linux-gnu.so: undefined symbol: _PyDict_NewPresized (but the build is successful for Windows platforms).

I added the correct header file #include "pycore_dict.h" and macros Py_BUILD_CORE_MODULE and Py_BUILD_CORE_BUILTIN. What else needs to be done to make use of _PyDict_NewPresized?

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner

vstinner commented Sep 13, 2023

Copy link
Copy Markdown
Member Author

I am using the method in an extension module #91610, but the build is failing since this PR was merged with error message Error: _copy failed to import: /home/runner/work/cpython/cpython-builddir/build/lib.linux-x86_64-3.13-pydebug/_copy.cpython-313d-x86_64-linux-gnu.so: undefined symbol: _PyDict_NewPresized (but the build is successful for Windows platforms).

If you want to use this function in a stdlib extension, you should replace extern with PyAPI_FUNC(). It's required to be able to use the function in extensions built as shared libraries.

eendebakpt 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.

scoder added a commit to scoder/cpython that referenced this pull request Oct 24, 2023
@scoder
pythongh-106320: Make some PyDict C-API functions public that should …
0eda761
…have been public right away.

See python#108449
scoder added a commit to scoder/cpython that referenced this pull request Oct 24, 2023
@scoder
pythongh-106320: Make some PyDict C-API functions public that should …
ce6b210
…have been public right away.

See python#108449
scoder added a commit to scoder/cpython that referenced this pull request Oct 24, 2023
@scoder
pythongh-106320: Make some PyDict C-API functions public that should …
b3dd067
…have been public right away.

See python#108449
scoder added a commit to scoder/cpython that referenced this pull request Oct 24, 2023
@scoder
pythongh-106320: Make some PyDict C-API functions public that should …
5674aa3
…have been public right away.

See python#108449
This was referenced Oct 24, 2023
Make _PyDict_Pop() public #111262
Closed
gh-111262: Make PyDict_Pop() public #111263
Closed
scoder added a commit to scoder/cpython that referenced this pull request Oct 24, 2023
@scoder
pythongh-106320: Make some PyDict C-API functions public that should …
9c8539b
…have been public right away.

See python#108449
scoder added a commit to scoder/cpython that referenced this pull request Oct 24, 2023
@scoder
pythongh-106320: Make some PyDict C-API functions public that should …
16a95d4
…have been public right away.

See python#108449
@MSeifert04 MSeifert04 mentioned this pull request Sep 24, 2024
Version 0.13: Python 3.13 compatibility and minor updates MSeifert04/iteration_utilities#346
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@rhettinger rhettinger Awaiting requested review from rhettinger rhettinger is a code owner
@kumaraditya303 kumaraditya303 Awaiting requested review from kumaraditya303 kumaraditya303 is a code owner
@1st1 1st1 Awaiting requested review from 1st1 1st1 is a code owner
@asvetlov asvetlov Awaiting requested review from asvetlov asvetlov is a code owner
@gvanrossum gvanrossum Awaiting requested review from gvanrossum
@willingc willingc Awaiting requested review from willingc willingc is a code owner

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.

3 participants

@vstinner @eendebakpt @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.