]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-106320: Move private _PySet API to the internal API (#107041)
authorVictor Stinner <vstinner@python.org>
Sat, 22 Jul 2023 15:04:34 +0000 (17:04 +0200)
committerGitHub <noreply@github.com>
Sat, 22 Jul 2023 15:04:34 +0000 (17:04 +0200)
* Add pycore_setobject.h header file.
* Move the following API to the internal C API:

  * _PySet_Dummy
  * _PySet_NextEntry()
  * _PySet_Update()

18 files changed:
Include/cpython/setobject.h
Include/internal/pycore_pymem.h
Include/internal/pycore_setobject.h [new file with mode: 0644]
Makefile.pre.in
Modules/_abc.c
Modules/_pickle.c
Objects/codeobject.c
Objects/dictobject.c
Objects/setobject.c
PCbuild/pythoncore.vcxproj
PCbuild/pythoncore.vcxproj.filters
Python/ast_opt.c
Python/bytecodes.c
Python/ceval.c
Python/compile.c
Python/executor.c
Python/marshal.c
Python/pylifecycle.c

index 20fd63eaae56e2a5a3612ad2e12245f41d9fa285..1778c778a05324c21fd49c97eb97c63f290a8099 100644 (file)
@@ -65,8 +65,3 @@ static inline Py_ssize_t PySet_GET_SIZE(PyObject *so) {
     return _PySet_CAST(so)->used;
 }
 #define PySet_GET_SIZE(so) PySet_GET_SIZE(_PyObject_CAST(so))
-
-PyAPI_DATA(PyObject *) _PySet_Dummy;
-
-PyAPI_FUNC(int) _PySet_NextEntry(PyObject *set, Py_ssize_t *pos, PyObject **key, Py_hash_t *hash);
-PyAPI_FUNC(int) _PySet_Update(PyObject *set, PyObject *iterable);
index 81a707a0a5ddf3e92c27e37c84860ae48a7beacf..c2f03254bb87609ba2617094c6f023079794bf4d 100644 (file)
@@ -95,4 +95,4 @@ PyAPI_FUNC(int) _PyMem_SetupAllocators(PyMemAllocatorName allocator);
 #ifdef __cplusplus
 }
 #endif
-#endif /* !Py_INTERNAL_PYMEM_H */
+#endif  // !Py_INTERNAL_PYMEM_H
diff --git a/Include/internal/pycore_setobject.h b/Include/internal/pycore_setobject.h
new file mode 100644 (file)
index 0000000..96f9aea
--- /dev/null
@@ -0,0 +1,25 @@
+#ifndef Py_INTERNAL_SETOBJECT_H
+#define Py_INTERNAL_SETOBJECT_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef Py_BUILD_CORE
+#  error "this header requires Py_BUILD_CORE define"
+#endif
+
+// _pickle shared extension uses _PySet_NextEntry() and _PySet_Update()
+PyAPI_FUNC(int) _PySet_NextEntry(
+    PyObject *set,
+    Py_ssize_t *pos,
+    PyObject **key,
+    Py_hash_t *hash);
+PyAPI_FUNC(int) _PySet_Update(PyObject *set, PyObject *iterable);
+
+// Export _PySet_Dummy for the gdb plugin's benefit
+PyAPI_DATA(PyObject *) _PySet_Dummy;
+
+#ifdef __cplusplus
+}
+#endif
+#endif  // !Py_INTERNAL_SETOBJECT_H
index f3a0db163ed48c1368f77748d4b2e5bfa23bc206..a4f76eaaaba52507c353e2f903f9e9da857b2c17 100644 (file)
@@ -1798,6 +1798,7 @@ PYTHON_HEADERS= \
                $(srcdir)/Include/internal/pycore_runtime.h \
                $(srcdir)/Include/internal/pycore_runtime_init_generated.h \
                $(srcdir)/Include/internal/pycore_runtime_init.h \
+               $(srcdir)/Include/internal/pycore_setobject.h \
                $(srcdir)/Include/internal/pycore_signal.h \
                $(srcdir)/Include/internal/pycore_sliceobject.h \
                $(srcdir)/Include/internal/pycore_strhex.h \
index 8a3aa9cb88880f2b76134fb418dfcd314090bde6..9473905243d438d4701606635a829113a40cc07d 100644 (file)
@@ -7,6 +7,7 @@
 #include "pycore_moduleobject.h"  // _PyModule_GetState()
 #include "pycore_object.h"        // _PyType_GetSubclasses()
 #include "pycore_runtime.h"       // _Py_ID()
+#include "pycore_setobject.h"     // _PySet_NextEntry()
 #include "pycore_typeobject.h"    // _PyType_GetMRO()
 #include "pycore_weakref.h"       // _PyWeakref_GET_REF()
 #include "clinic/_abc.c.h"
index f2e98c10ef71882e82dcca8d10eaac71169df10f..d9395e35daf8b483f86fffee7461d4d6176be9f0 100644 (file)
@@ -15,6 +15,7 @@
 #include "pycore_object.h"        // _PyNone_Type
 #include "pycore_pystate.h"       // _PyThreadState_GET()
 #include "pycore_runtime.h"       // _Py_ID()
+#include "pycore_setobject.h"     // _PySet_NextEntry()
 #include "structmember.h"         // PyMemberDef
 
 #include <stdlib.h>               // strtol()
index d2670c71caa44a09a35ab9fb0fc5fb904e230e45..977e5b05b3d2a502322feb125ccbbd6b997f938e 100644 (file)
@@ -8,6 +8,7 @@
 #include "pycore_interp.h"        // PyInterpreterState.co_extra_freefuncs
 #include "pycore_opcode.h"        // _PyOpcode_Deopt
 #include "pycore_pystate.h"       // _PyInterpreterState_GET()
+#include "pycore_setobject.h"     // _PySet_NextEntry()
 #include "pycore_tuple.h"         // _PyTuple_ITEMS()
 #include "clinic/codeobject.c.h"
 
index 3f9297c8a411fce165d19dfba5315425d8bef279..26e2dc31e3664a419295438c668a44529d275e01 100644 (file)
@@ -121,6 +121,7 @@ As a consequence of this, split keys have a maximum size of 16.
 #include "pycore_object.h"        // _PyObject_GC_TRACK()
 #include "pycore_pyerrors.h"      // _PyErr_GetRaisedException()
 #include "pycore_pystate.h"       // _PyThreadState_GET()
+#include "pycore_setobject.h"     // _PySet_NextEntry()
 #include "stringlib/eq.h"         // unicode_eq()
 
 #include <stdbool.h>
index 4ac541b95097529fa32b2c17ba63f4ffc009c03b..2f12320254ec94b2a1851263d6f2b885e00fede2 100644 (file)
@@ -34,6 +34,7 @@
 #include "Python.h"
 #include "pycore_modsupport.h"    // _PyArg_NoKwnames()
 #include "pycore_object.h"        // _PyObject_GC_UNTRACK()
+#include "pycore_setobject.h"     // _PySet_NextEntry() definition
 #include <stddef.h>               // offsetof()
 
 /* Object used as dummy key to fill deleted entries */
index 0fe24082ca4ccde541a67924b4eaab83489ee35c..bfe59acf12a69d7728d80af068a616eb60f5af33 100644 (file)
     <ClInclude Include="..\Include\internal\pycore_runtime.h" />
     <ClInclude Include="..\Include\internal\pycore_runtime_init.h" />
     <ClInclude Include="..\Include\internal\pycore_runtime_init_generated.h" />
+    <ClInclude Include="..\Include\internal\pycore_setobject.h" />
     <ClInclude Include="..\Include\internal\pycore_signal.h" />
     <ClInclude Include="..\Include\internal\pycore_sliceobject.h" />
     <ClInclude Include="..\Include\internal\pycore_strhex.h" />
index 2b3793cb0f76e25c2adb9cd0a85a2dd26ced7474..0a8b0c3faf51e1e6019d03adcb0feb660299a19e 100644 (file)
     <ClInclude Include="..\Include\internal\pycore_runtime_init_generated.h">
       <Filter>Include\internal</Filter>
     </ClInclude>
+    <ClInclude Include="..\Include\internal\pycore_setobject.h">
+      <Filter>Include\internal</Filter>
+    </ClInclude>
     <ClInclude Include="..\Include\internal\pycore_signal.h">
       <Filter>Include\internal</Filter>
     </ClInclude>
index 276e910089a277d286a367c04fd1fc3759e71fa5..ad1e312b084b747ff610de1a208aae62f178106d 100644 (file)
@@ -1,9 +1,10 @@
 /* AST Optimizer */
 #include "Python.h"
 #include "pycore_ast.h"           // _PyAST_GetDocString()
-#include "pycore_long.h"           // _PyLong
-#include "pycore_pystate.h"       // _PyThreadState_GET()
 #include "pycore_format.h"        // F_LJUST
+#include "pycore_long.h"          // _PyLong
+#include "pycore_pystate.h"       // _PyThreadState_GET()
+#include "pycore_setobject.h"     // _PySet_NextEntry()
 
 
 typedef struct {
index 3a191aca730e9105283ff829ea47e273aaba0926..7ce8978e998b97bd6880fc2f068b6117491ee576 100644 (file)
 #include "pycore_abstract.h"      // _PyIndex_Check()
 #include "pycore_ceval.h"         // _PyEval_SignalAsyncExc()
 #include "pycore_code.h"
+#include "pycore_emscripten_signal.h"  // _Py_CHECK_EMSCRIPTEN_SIGNALS
 #include "pycore_function.h"
+#include "pycore_instruments.h"
 #include "pycore_intrinsics.h"
 #include "pycore_long.h"          // _PyLong_GetZero()
-#include "pycore_instruments.h"
-#include "pycore_object.h"        // _PyObject_GC_TRACK()
 #include "pycore_moduleobject.h"  // PyModuleObject
+#include "pycore_object.h"        // _PyObject_GC_TRACK()
 #include "pycore_opcode.h"        // EXTRA_CASES
 #include "pycore_opcode_metadata.h"  // uop names
 #include "pycore_opcode_utils.h"  // MAKE_FUNCTION_*
 #include "pycore_pyerrors.h"      // _PyErr_GetRaisedException()
 #include "pycore_pystate.h"       // _PyInterpreterState_GET()
 #include "pycore_range.h"         // _PyRangeIterObject
+#include "pycore_setobject.h"     // _PySet_NextEntry()
 #include "pycore_sliceobject.h"   // _PyBuildSlice_ConsumeRefs
 #include "pycore_sysmodule.h"     // _PySys_Audit()
 #include "pycore_tuple.h"         // _PyTuple_ITEMS()
 #include "pycore_typeobject.h"    // _PySuper_Lookup()
-#include "pycore_emscripten_signal.h"  // _Py_CHECK_EMSCRIPTEN_SIGNALS
 
 #include "pycore_dict.h"
 #include "dictobject.h"
index 9f2855f964ace1a05ce12f76e6c499e159361498..e9f082f85bd1b48ef6280306c88f322e6172a5c5 100644 (file)
@@ -7,24 +7,25 @@
 #include "pycore_call.h"          // _PyObject_CallNoArgs()
 #include "pycore_ceval.h"         // _PyEval_SignalAsyncExc()
 #include "pycore_code.h"
+#include "pycore_emscripten_signal.h"  // _Py_CHECK_EMSCRIPTEN_SIGNALS
 #include "pycore_function.h"
+#include "pycore_instruments.h"
 #include "pycore_intrinsics.h"
 #include "pycore_long.h"          // _PyLong_GetZero()
-#include "pycore_instruments.h"
-#include "pycore_object.h"        // _PyObject_GC_TRACK()
 #include "pycore_moduleobject.h"  // PyModuleObject
+#include "pycore_object.h"        // _PyObject_GC_TRACK()
 #include "pycore_opcode.h"        // EXTRA_CASES
 #include "pycore_opcode_metadata.h"
 #include "pycore_opcode_utils.h"  // MAKE_FUNCTION_*
 #include "pycore_pyerrors.h"      // _PyErr_GetRaisedException()
 #include "pycore_pystate.h"       // _PyInterpreterState_GET()
 #include "pycore_range.h"         // _PyRangeIterObject
+#include "pycore_setobject.h"     // _PySet_Update()
 #include "pycore_sliceobject.h"   // _PyBuildSlice_ConsumeRefs
 #include "pycore_sysmodule.h"     // _PySys_Audit()
 #include "pycore_tuple.h"         // _PyTuple_ITEMS()
 #include "pycore_typeobject.h"    // _PySuper_Lookup()
 #include "pycore_uops.h"          // _PyUOpExecutorObject
-#include "pycore_emscripten_signal.h"  // _Py_CHECK_EMSCRIPTEN_SIGNALS
 
 #include "pycore_dict.h"
 #include "dictobject.h"
index 9a13ab525d8a47144cf20f240e3b1794944eb186..600118768e639299e689ec68dd4b89f150bd72d8 100644 (file)
 #define NEED_OPCODE_TABLES
 #include "pycore_opcode_utils.h"
 #undef NEED_OPCODE_TABLES
-#include "pycore_flowgraph.h"
 #include "pycore_code.h"          // _PyCode_New()
 #include "pycore_compile.h"
+#include "pycore_flowgraph.h"
 #include "pycore_intrinsics.h"
 #include "pycore_long.h"          // _PyLong_GetZero()
 #include "pycore_pystate.h"       // _Py_GetConfig()
+#include "pycore_setobject.h"     // _PySet_NextEntry()
 #include "pycore_symtable.h"      // PySTEntryObject, _PyFuture_FromAST()
 
 #define NEED_OPCODE_METADATA
index 17322526a7bd7c8183b84077b04ba59792878fd4..57525df202d861a73a4a6c6322928af5129ac916 100644 (file)
@@ -11,6 +11,7 @@
 #include "pycore_opcode_utils.h"
 #include "pycore_pyerrors.h"
 #include "pycore_range.h"
+#include "pycore_setobject.h"     // _PySet_Update()
 #include "pycore_sliceobject.h"
 #include "pycore_uops.h"
 
index 517220a4463cf37858cb0b047827777f81971ce6..8940582c7f5328c9babffb5414d1dc7b207f4bac 100644 (file)
@@ -9,8 +9,9 @@
 #include "Python.h"
 #include "pycore_call.h"          // _PyObject_CallNoArgs()
 #include "pycore_code.h"          // _PyCode_New()
-#include "pycore_long.h"          // _PyLong_DigitCount
 #include "pycore_hashtable.h"     // _Py_hashtable_t
+#include "pycore_long.h"          // _PyLong_DigitCount
+#include "pycore_setobject.h"     // _PySet_NextEntry()
 #include "marshal.h"              // Py_MARSHAL_VERSION
 
 /*[clinic input]
index f91fac9379ec519672154c325786ad6bfeff6292..ceca7776a276ed3bece4552aa7a5eeb9609c72a1 100644 (file)
@@ -24,6 +24,7 @@
 #include "pycore_pystate.h"       // _PyThreadState_GET()
 #include "pycore_runtime.h"       // _Py_ID()
 #include "pycore_runtime_init.h"  // _PyRuntimeState_INIT
+#include "pycore_setobject.h"     // _PySet_NextEntry()
 #include "pycore_sliceobject.h"   // _PySlice_Fini()
 #include "pycore_sysmodule.h"     // _PySys_ClearAuditHooks()
 #include "pycore_traceback.h"     // _Py_DumpTracebackThreads()