Skip to content

Commit a92aec1

Browse files
authored
gh-133143: Use _Py_ID for the other literals in sys (GH-138698)
Follow-up refactoring after GH-133143, where we use `_Py_ID` for "big" and "little" in `abi_info.byteorder`. This uses `_Py_ID` for `sys.byteorder`, but also `float_repr_style` and a module name.
1 parent 074f3b2 commit a92aec1

File tree

5 files changed

+19
-5
lines changed

5 files changed

+19
-5
lines changed

Include/internal/pycore_global_objects_fini_generated.h

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_global_strings.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,7 @@ struct _Py_global_strings {
571571
STRUCT_FOR_ID(last_value)
572572
STRUCT_FOR_ID(latin1)
573573
STRUCT_FOR_ID(leaf_size)
574+
STRUCT_FOR_ID(legacy)
574575
STRUCT_FOR_ID(len)
575576
STRUCT_FOR_ID(length)
576577
STRUCT_FOR_ID(level)
@@ -744,6 +745,7 @@ struct _Py_global_strings {
744745
STRUCT_FOR_ID(setstate)
745746
STRUCT_FOR_ID(shape)
746747
STRUCT_FOR_ID(shared)
748+
STRUCT_FOR_ID(short)
747749
STRUCT_FOR_ID(show_cmd)
748750
STRUCT_FOR_ID(signed)
749751
STRUCT_FOR_ID(signum)

Include/internal/pycore_runtime_init_generated.h

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_unicodeobject_generated.h

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/sysmodule.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ sys_breakpointhook(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyOb
610610

611611
if (last_dot == NULL) {
612612
/* The breakpoint is a built-in, e.g. PYTHONBREAKPOINT=int */
613-
modulepath = PyUnicode_FromString("builtins");
613+
modulepath = &_Py_ID(builtins);
614614
attrname = envar;
615615
}
616616
else if (last_dot != envar) {
@@ -3873,9 +3873,9 @@ _PySys_InitCore(PyThreadState *tstate, PyObject *sysdict)
38733873
SET_SYS("builtin_module_names", list_builtin_module_names());
38743874
SET_SYS("stdlib_module_names", list_stdlib_module_names());
38753875
#if PY_BIG_ENDIAN
3876-
SET_SYS_FROM_STRING("byteorder", "big");
3876+
SET_SYS("byteorder", &_Py_ID(big));
38773877
#else
3878-
SET_SYS_FROM_STRING("byteorder", "little");
3878+
SET_SYS("byteorder", &_Py_ID(little));
38793879
#endif
38803880

38813881
#ifdef MS_COREDLL
@@ -3917,9 +3917,9 @@ _PySys_InitCore(PyThreadState *tstate, PyObject *sysdict)
39173917

39183918
/* float repr style: 0.03 (short) vs 0.029999999999999999 (legacy) */
39193919
#if _PY_SHORT_FLOAT_REPR == 1
3920-
SET_SYS_FROM_STRING("float_repr_style", "short");
3920+
SET_SYS("float_repr_style", &_Py_ID(short));
39213921
#else
3922-
SET_SYS_FROM_STRING("float_repr_style", "legacy");
3922+
SET_SYS("float_repr_style", &_Py_ID(legacy));
39233923
#endif
39243924

39253925
SET_SYS("thread_info", PyThread_GetInfo());

0 commit comments

Comments
 (0)