Skip to content

Commit 9331087

Browse files
GH-90699: use statically allocated strings in typeobject.c (gh-93751)
1 parent ae1ca74 commit 9331087

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

Include/internal/pycore_global_strings.h

+2
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ struct _Py_global_strings {
9090
STRUCT_FOR_ID(__delete__)
9191
STRUCT_FOR_ID(__delitem__)
9292
STRUCT_FOR_ID(__dict__)
93+
STRUCT_FOR_ID(__dictoffset__)
9394
STRUCT_FOR_ID(__dir__)
9495
STRUCT_FOR_ID(__divmod__)
9596
STRUCT_FOR_ID(__doc__)
@@ -206,6 +207,7 @@ struct _Py_global_strings {
206207
STRUCT_FOR_ID(__typing_subst__)
207208
STRUCT_FOR_ID(__typing_unpacked_tuple_args__)
208209
STRUCT_FOR_ID(__warningregistry__)
210+
STRUCT_FOR_ID(__weaklistoffset__)
209211
STRUCT_FOR_ID(__weakref__)
210212
STRUCT_FOR_ID(__xor__)
211213
STRUCT_FOR_ID(_abc_impl)

Include/internal/pycore_runtime_init.h

+2
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,7 @@ extern "C" {
712712
INIT_ID(__delete__), \
713713
INIT_ID(__delitem__), \
714714
INIT_ID(__dict__), \
715+
INIT_ID(__dictoffset__), \
715716
INIT_ID(__dir__), \
716717
INIT_ID(__divmod__), \
717718
INIT_ID(__doc__), \
@@ -828,6 +829,7 @@ extern "C" {
828829
INIT_ID(__typing_subst__), \
829830
INIT_ID(__typing_unpacked_tuple_args__), \
830831
INIT_ID(__warningregistry__), \
832+
INIT_ID(__weaklistoffset__), \
831833
INIT_ID(__weakref__), \
832834
INIT_ID(__xor__), \
833835
INIT_ID(_abc_impl), \

Objects/typeobject.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -3637,13 +3637,13 @@ PyType_FromMetaclass(PyTypeObject *metaclass, PyObject *module,
36373637

36383638
if (weaklistoffset) {
36393639
type->tp_weaklistoffset = weaklistoffset;
3640-
if (PyDict_DelItemString((PyObject *)type->tp_dict, "__weaklistoffset__") < 0) {
3640+
if (PyDict_DelItem((PyObject *)type->tp_dict, &_Py_ID(__weaklistoffset__)) < 0) {
36413641
goto finally;
36423642
}
36433643
}
36443644
if (dictoffset) {
36453645
type->tp_dictoffset = dictoffset;
3646-
if (PyDict_DelItemString((PyObject *)type->tp_dict, "__dictoffset__") < 0) {
3646+
if (PyDict_DelItem((PyObject *)type->tp_dict, &_Py_ID(__dictoffset__)) < 0) {
36473647
goto finally;
36483648
}
36493649
}

0 commit comments

Comments
 (0)