Skip to content

Commit 975ef40

Browse files
ericsnowcurrentlyethanfurman
authored andcommitted
pythongh-81057: Generate a Separate Initializer For Each Part of the Global Objects Initializer (pythongh-99389)
Up until now we had a single generated initializer macro for all the statically declared global objects in _PyRuntimeState, including several one-offs (e.g. the empty tuple). The one-offs don't need to be generated, but were because we had one big initializer. Having separate initializers for set of generated global objects allows us to generate only the ones we need to. This allows us to add initializers for one-off global objects without having to generate them. python#81057
1 parent d0573c7 commit 975ef40

File tree

4 files changed

+1528
-1517
lines changed

4 files changed

+1528
-1517
lines changed

Include/internal/pycore_global_objects_fini_generated.h

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_runtime_init.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,22 @@ extern "C" {
2828
until _PyInterpreterState_Enable() is called. */ \
2929
.next_id = -1, \
3030
}, \
31-
.global_objects = _Py_global_objects_INIT, \
31+
.global_objects = { \
32+
.singletons = { \
33+
.small_ints = _Py_small_ints_INIT, \
34+
.bytes_empty = _PyBytes_SIMPLE_INIT(0, 0), \
35+
.bytes_characters = _Py_bytes_characters_INIT, \
36+
.strings = { \
37+
.literals = _Py_str_literals_INIT, \
38+
.identifiers = _Py_str_identifiers_INIT, \
39+
.ascii = _Py_str_ascii_INIT, \
40+
.latin1 = _Py_str_latin1_INIT, \
41+
}, \
42+
.tuple_empty = { \
43+
.ob_base = _PyVarObject_IMMORTAL_INIT(&PyTuple_Type, 0) \
44+
}, \
45+
}, \
46+
}, \
3247
._main_interpreter = _PyInterpreterState_INIT, \
3348
}
3449

0 commit comments

Comments
 (0)