Original file line numberDiff line numberDiff line change@@ -0,0 +1,30 @@
1+#ifndefPy_INTERNAL_BYTESOBJECT_H
2+#definePy_INTERNAL_BYTESOBJECT_H
3+#ifdef__cplusplus
4+extern"C" {
5+#endif
6+7+#ifndefPy_BUILD_CORE
8+# error "this header requires Py_BUILD_CORE define"
9+#endif
10+11+12+/* runtime lifecycle */
13+14+externPyStatus_PyBytes_InitGlobalObjects(PyInterpreterState*);
15+externPyStatus_PyBytes_InitTypes(PyInterpreterState*);
16+externvoid_PyBytes_Fini(PyInterpreterState*);
17+18+19+/* other API */
20+21+struct_Py_bytes_state {
22+PyObject*empty_string;
23+PyBytesObject*characters[256];
24+};
25+26+27+#ifdef__cplusplus
28+}
29+#endif
30+#endif/* !Py_INTERNAL_BYTESOBJECT_H */
Original file line numberDiff line numberDiff line change@@ -7,6 +7,32 @@
7788#include"pycore_hamt.h"/* PyHamtObject */
9910+11+/* runtime lifecycle */
12+13+PyStatus_PyContext_InitTypes(PyInterpreterState*);
14+void_PyContext_Fini(PyInterpreterState*);
15+16+17+/* other API */
18+19+#ifndefWITH_FREELISTS
20+// without freelists
21+# definePyContext_MAXFREELIST 0
22+#endif
23+24+#ifndefPyContext_MAXFREELIST
25+# definePyContext_MAXFREELIST 255
26+#endif
27+28+struct_Py_context_state {
29+#ifPyContext_MAXFREELIST>0
30+// List of free PyContext objects
31+PyContext*freelist;
32+intnumfree;
33+#endif
34+};
35+1036struct_pycontextobject {
1137PyObject_HEAD
1238PyContext*ctx_prev;
@@ -36,7 +62,4 @@ struct _pycontexttokenobject {
3662};
3763386439-int_PyContext_Init(void);
40-void_PyContext_Fini(PyInterpreterState*interp);
41-4265#endif/* !Py_INTERNAL_CONTEXT_H */
Original file line numberDiff line numberDiff line change@@ -10,6 +10,32 @@ extern "C" {
1010#endif
1111121213+/* runtime lifecycle */
14+15+externvoid_PyDict_Fini(PyInterpreterState*interp);
16+17+18+/* other API */
19+20+#ifndefWITH_FREELISTS
21+// without freelists
22+# definePyDict_MAXFREELIST 0
23+#endif
24+25+#ifndefPyDict_MAXFREELIST
26+# definePyDict_MAXFREELIST 80
27+#endif
28+29+struct_Py_dict_state {
30+#ifPyDict_MAXFREELIST>0
31+/* Dictionary reuse scheme to save calls to malloc and free */
32+PyDictObject*free_list[PyDict_MAXFREELIST];
33+intnumfree;
34+PyDictKeysObject*keys_free_list[PyDict_MAXFREELIST];
35+intkeys_numfree;
36+#endif
37+};
38+1339typedefstruct {
1440/* Cached hash code of me_key. */
1541Py_hash_tme_hash;
Original file line numberDiff line numberDiff line change@@ -0,0 +1,37 @@
1+#ifndefPy_INTERNAL_EXCEPTIONS_H
2+#definePy_INTERNAL_EXCEPTIONS_H
3+#ifdef__cplusplus
4+extern"C" {
5+#endif
6+7+#ifndefPy_BUILD_CORE
8+# error "this header requires Py_BUILD_CORE define"
9+#endif
10+11+12+/* runtime lifecycle */
13+14+externPyStatus_PyExc_InitState(PyInterpreterState*);
15+externPyStatus_PyExc_InitGlobalObjects(PyInterpreterState*);
16+externPyStatus_PyExc_InitTypes(PyInterpreterState*);
17+externvoid_PyExc_Fini(PyInterpreterState*);
18+19+20+/* other API */
21+22+struct_Py_exc_state {
23+// The dict mapping from errno codes to OSError subclasses
24+PyObject*errnomap;
25+PyBaseExceptionObject*memerrors_freelist;
26+intmemerrors_numfree;
27+// The ExceptionGroup type
28+PyObject*PyExc_ExceptionGroup;
29+};
30+31+externvoid_PyExc_ClearExceptionGroupType(PyInterpreterState*);
32+33+34+#ifdef__cplusplus
35+}
36+#endif
37+#endif/* !Py_INTERNAL_EXCEPTIONS_H */
Original file line numberDiff line numberDiff line change@@ -8,6 +8,35 @@ extern "C" {
88# error "this header requires Py_BUILD_CORE define"
99#endif
101011+12+/* runtime lifecycle */
13+14+externvoid_PyFloat_InitState(PyInterpreterState*);
15+externPyStatus_PyFloat_InitTypes(PyInterpreterState*);
16+externvoid_PyFloat_Fini(PyInterpreterState*);
17+18+19+/* other API */
20+21+#ifndefWITH_FREELISTS
22+// without freelists
23+# definePyFloat_MAXFREELIST 0
24+#endif
25+26+#ifndefPyFloat_MAXFREELIST
27+# definePyFloat_MAXFREELIST 100
28+#endif
29+30+struct_Py_float_state {
31+#ifPyFloat_MAXFREELIST>0
32+/* Special free list
33+ free_list is a singly-linked list of available PyFloatObjects,
34+ linked via abuse of their ob_type members. */
35+intnumfree;
36+PyFloatObject*free_list;
37+#endif
38+};
39+1140/* _PyFloat_{Pack,Unpack}{4,8}
1241 *
1342 * The struct and pickle (at least) modules need an efficient platform-
Original file line numberDiff line numberDiff line change@@ -4,6 +4,14 @@
44extern"C" {
55#endif
667+8+/* runtime lifecycle */
9+10+externvoid_PyFrame_Fini(PyInterpreterState*interp);
11+12+13+/* other API */
14+715/* These values are chosen so that the inline functions below all
816 * compare f_state to zero.
917 */
Original file line numberDiff line numberDiff line change@@ -0,0 +1,46 @@
1+#ifndefPy_INTERNAL_GENOBJECT_H
2+#definePy_INTERNAL_GENOBJECT_H
3+#ifdef__cplusplus
4+extern"C" {
5+#endif
6+7+#ifndefPy_BUILD_CORE
8+# error "this header requires Py_BUILD_CORE define"
9+#endif
10+11+12+/* runtime lifecycle */
13+14+externvoid_PyAsyncGen_Fini(PyInterpreterState*);
15+16+17+/* other API */
18+19+#ifndefWITH_FREELISTS
20+// without freelists
21+# define_PyAsyncGen_MAXFREELIST 0
22+#endif
23+24+#ifndef_PyAsyncGen_MAXFREELIST
25+# define_PyAsyncGen_MAXFREELIST 80
26+#endif
27+28+struct_Py_async_gen_state {
29+#if_PyAsyncGen_MAXFREELIST>0
30+/* Freelists boost performance 6-10%; they also reduce memory
31+ fragmentation, as _PyAsyncGenWrappedValue and PyAsyncGenASend
32+ are short-living objects that are instantiated for every
33+ __anext__() call. */
34+struct_PyAsyncGenWrappedValue*value_freelist[_PyAsyncGen_MAXFREELIST];
35+intvalue_numfree;
36+37+structPyAsyncGenASend*asend_freelist[_PyAsyncGen_MAXFREELIST];
38+intasend_numfree;
39+#endif
40+};
41+42+43+#ifdef__cplusplus
44+}
45+#endif
46+#endif/* !Py_INTERNAL_GENOBJECT_H */
Original file line numberDiff line numberDiff line change@@ -8,6 +8,14 @@
88#define_Py_HAMT_MAX_TREE_DEPTH 7
99101011+/* runtime lifecycle */
12+13+PyStatus_PyHamt_InitTypes(PyInterpreterState*);
14+void_PyHamt_Fini(PyInterpreterState*);
15+16+17+/* other API */
18+1119#definePyHamt_Check(o) Py_IS_TYPE(o, &_PyHamt_Type)
12201321@@ -110,7 +118,4 @@ PyObject * _PyHamt_NewIterValues(PyHamtObject *o);
110118/* Return a Items iterator over "o". */
111119PyObject*_PyHamt_NewIterItems(PyHamtObject*o);
112120113-int_PyHamt_Init(void);
114-void_PyHamt_Fini(void);
115-116121#endif/* !Py_INTERNAL_HAMT_H */