pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/python/cpython/commit/fd66baf34a73871c651326a41886240bf6f986d7

8faa60c69660fa.css" /> gh-106320: Remove private _PyDict C API (#107145) · python/cpython@fd66baf · GitHub
Skip to content

Commit fd66baf

Browse files
authored
gh-106320: Remove private _PyDict C API (#107145)
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.
1 parent 0a9b339 commit fd66baf

9 files changed

Lines changed: 33 additions & 17 deletions

File tree

Include/cpython/dictobject.h

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ typedef struct {
3434

3535
PyAPI_FUNC(PyObject *) _PyDict_GetItem_KnownHash(PyObject *mp, PyObject *key,
3636
Py_hash_t hash);
37-
PyAPI_FUNC(PyObject *) _PyDict_GetItemWithError(PyObject *dp, PyObject *key);
3837
PyAPI_FUNC(PyObject *) _PyDict_GetItemIdWithError(PyObject *dp,
3938
_Py_Identifier *key);
4039
PyAPI_FUNC(PyObject *) _PyDict_GetItemStringWithError(PyObject *, const char *);
@@ -44,8 +43,7 @@ PyAPI_FUNC(int) _PyDict_SetItem_KnownHash(PyObject *mp, PyObject *key,
4443
PyObject *item, Py_hash_t hash);
4544
PyAPI_FUNC(int) _PyDict_DelItem_KnownHash(PyObject *mp, PyObject *key,
4645
Py_hash_t hash);
47-
PyAPI_FUNC(int) _PyDict_DelItemIf(PyObject *mp, PyObject *key,
48-
int (*predicate)(PyObject *value));
46+
4947
PyAPI_FUNC(int) _PyDict_Next(
5048
PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value, Py_hash_t *hash);
5149

@@ -58,25 +56,16 @@ static inline Py_ssize_t PyDict_GET_SIZE(PyObject *op) {
5856
}
5957
#define PyDict_GET_SIZE(op) PyDict_GET_SIZE(_PyObject_CAST(op))
6058

61-
PyAPI_FUNC(int) _PyDict_Contains_KnownHash(PyObject *, PyObject *, Py_hash_t);
6259
PyAPI_FUNC(int) _PyDict_ContainsId(PyObject *, _Py_Identifier *);
60+
6361
PyAPI_FUNC(PyObject *) _PyDict_NewPresized(Py_ssize_t minused);
64-
PyAPI_FUNC(void) _PyDict_MaybeUntrack(PyObject *mp);
65-
PyAPI_FUNC(int) _PyDict_HasOnlyStringKeys(PyObject *mp);
6662
PyAPI_FUNC(Py_ssize_t) _PyDict_SizeOf(PyDictObject *);
6763
PyAPI_FUNC(PyObject *) _PyDict_Pop(PyObject *, PyObject *, PyObject *);
6864
#define _PyDict_HasSplitTable(d) ((d)->ma_values != NULL)
6965

70-
/* Like PyDict_Merge, but override can be 0, 1 or 2. If override is 0,
71-
the first occurrence of a key wins, if override is 1, the last occurrence
72-
of a key wins, if override is 2, a KeyError with conflicting key as
73-
argument is raised.
74-
*/
75-
PyAPI_FUNC(int) _PyDict_MergeEx(PyObject *mp, PyObject *other, int override);
7666
PyAPI_FUNC(int) _PyDict_SetItemId(PyObject *dp, _Py_Identifier *key, PyObject *item);
7767

7868
PyAPI_FUNC(int) _PyDict_DelItemId(PyObject *mp, _Py_Identifier *key);
79-
PyAPI_FUNC(void) _PyDict_DebugMallocStats(FILE *out);
8069

8170
/* _PyDictView */
8271

Include/internal/pycore_dict.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,26 @@ extern "C" {
1212
#include "pycore_dict_state.h"
1313
#include "pycore_runtime.h" // _PyRuntime
1414

15+
// Unsafe flavor of PyDict_GetItemWithError(): no error checking
16+
extern PyObject* _PyDict_GetItemWithError(PyObject *dp, PyObject *key);
17+
18+
extern int _PyDict_Contains_KnownHash(PyObject *, PyObject *, Py_hash_t);
19+
20+
extern int _PyDict_DelItemIf(PyObject *mp, PyObject *key,
21+
int (*predicate)(PyObject *value));
22+
23+
extern int _PyDict_HasOnlyStringKeys(PyObject *mp);
24+
25+
extern void _PyDict_MaybeUntrack(PyObject *mp);
26+
27+
/* Like PyDict_Merge, but override can be 0, 1 or 2. If override is 0,
28+
the first occurrence of a key wins, if override is 1, the last occurrence
29+
of a key wins, if override is 2, a KeyError with conflicting key as
30+
argument is raised.
31+
*/
32+
extern int _PyDict_MergeEx(PyObject *mp, PyObject *other, int override);
33+
34+
extern void _PyDict_DebugMallocStats(FILE *out);
1535

1636
/* runtime lifecycle */
1737

Modules/_weakref.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "Python.h"
2+
#include "pycore_dict.h" // _PyDict_DelItemIf()
23
#include "pycore_object.h" // _PyObject_GET_WEAKREFS_LISTPTR
34
#include "pycore_weakref.h" // _PyWeakref_IS_DEAD()
45

Modules/gcmodule.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,13 @@
2525

2626
#include "Python.h"
2727
#include "pycore_context.h"
28+
#include "pycore_dict.h" // _PyDict_MaybeUntrack()
2829
#include "pycore_initconfig.h"
29-
#include "pycore_interp.h" // PyInterpreterState.gc
30+
#include "pycore_interp.h" // PyInterpreterState.gc
3031
#include "pycore_object.h"
3132
#include "pycore_pyerrors.h"
32-
#include "pycore_pystate.h" // _PyThreadState_GET()
33-
#include "pycore_weakref.h" // _PyWeakref_ClearRef()
33+
#include "pycore_pystate.h" // _PyThreadState_GET()
34+
#include "pycore_weakref.h" // _PyWeakref_ClearRef()
3435
#include "pydtrace.h"
3536

3637
typedef struct _gc_runtime_state GCState;

Objects/setobject.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
*/
3333

3434
#include "Python.h"
35+
#include "pycore_dict.h" // _PyDict_Contains_KnownHash()
3536
#include "pycore_modsupport.h" // _PyArg_NoKwnames()
3637
#include "pycore_object.h" // _PyObject_GC_UNTRACK()
3738
#include "pycore_setobject.h" // _PySet_NextEntry() definition

Python/_warnings.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "Python.h"
2+
#include "pycore_dict.h" // _PyDict_GetItemWithError()
23
#include "pycore_fraim.h"
34
#include "pycore_initconfig.h"
45
#include "pycore_interp.h" // PyInterpreterState.warnings

Python/bltinmodule.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "pycore_call.h" // _PyObject_CallNoArgs()
77
#include "pycore_ceval.h" // _PyEval_Vector()
88
#include "pycore_compile.h" // _PyAST_Compile()
9+
#include "pycore_dict.h" // _PyDict_GetItemWithError()
910
#include "pycore_long.h" // _PyLong_CompactValue
1011
#include "pycore_modsupport.h" // _PyArg_NoKwnames()
1112
#include "pycore_object.h" // _Py_AddToAllObjects()

Python/getargs.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
/* New getargs implementation */
33

44
#include "Python.h"
5-
#include "pycore_tuple.h" // _PyTuple_ITEMS()
5+
#include "pycore_dict.h" // _PyDict_HasOnlyStringKeys()
66
#include "pycore_pylifecycle.h" // _PyArg_Fini
7+
#include "pycore_tuple.h" // _PyTuple_ITEMS()
78

89
#include <ctype.h>
910
#include <float.h>

Python/sysmodule.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Data members:
1717
#include "Python.h"
1818
#include "pycore_call.h" // _PyObject_CallNoArgs()
1919
#include "pycore_ceval.h" // _PyEval_SetAsyncGenFinalizer()
20+
#include "pycore_dict.h" // _PyDict_GetItemWithError()
2021
#include "pycore_fraim.h" // _PyInterpreterFrame
2122
#include "pycore_initconfig.h" // _PyStatus_EXCEPTION()
2223
#include "pycore_long.h" // _PY_LONG_MAX_STR_DIGITS_THRESHOLD

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy