Skip to content

Commit 68c324d

Browse files
committed
Codegen string literals and use them
1 parent e51da7b commit 68c324d

5 files changed

Lines changed: 33 additions & 4 deletions

File tree

Include/internal/pycore_global_objects_fini_generated.h

Lines changed: 4 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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ struct _Py_global_strings {
324324
STRUCT_FOR_ID(byte_size)
325325
STRUCT_FOR_ID(byteorder)
326326
STRUCT_FOR_ID(bytes)
327+
STRUCT_FOR_ID(bytes_le)
327328
STRUCT_FOR_ID(bytes_per_sep)
328329
STRUCT_FOR_ID(c_call)
329330
STRUCT_FOR_ID(c_exception)
@@ -504,6 +505,7 @@ struct _Py_global_strings {
504505
STRUCT_FOR_ID(hash_name)
505506
STRUCT_FOR_ID(header)
506507
STRUCT_FOR_ID(headers)
508+
STRUCT_FOR_ID(hex)
507509
STRUCT_FOR_ID(hi)
508510
STRUCT_FOR_ID(hook)
509511
STRUCT_FOR_ID(hour)
@@ -535,13 +537,15 @@ struct _Py_global_strings {
535537
STRUCT_FOR_ID(insert_comments)
536538
STRUCT_FOR_ID(insert_pis)
537539
STRUCT_FOR_ID(instructions)
540+
STRUCT_FOR_ID(int)
538541
STRUCT_FOR_ID(intern)
539542
STRUCT_FOR_ID(intersection)
540543
STRUCT_FOR_ID(interval)
541544
STRUCT_FOR_ID(io)
542545
STRUCT_FOR_ID(is_compress)
543546
STRUCT_FOR_ID(is_raw)
544547
STRUCT_FOR_ID(is_running)
548+
STRUCT_FOR_ID(is_safe)
545549
STRUCT_FOR_ID(is_struct)
546550
STRUCT_FOR_ID(isatty)
547551
STRUCT_FOR_ID(isinstance)

Include/internal/pycore_runtime_init_generated.h

Lines changed: 4 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: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_uuidmodule.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "pycore_long.h" // _PyLong_FromByteArray, _PyLong_AsByteArray
2222
#include "pycore_pylifecycle.h" // _PyOS_URandom()
2323
#include "pycore_time.h" // PyTime_Time
24+
#include "pycore_runtime_init.h" // _Py_ID()
2425

2526
#if defined(HAVE_UUID_H)
2627
// AIX, FreeBSD, libuuid with pkgconf
@@ -1450,14 +1451,14 @@ _uuid_UUID___getstate___impl(uuidobject *self)
14501451
Py_DECREF(dict);
14511452
return NULL;
14521453
}
1453-
if (PyDict_SetItemString(dict, "int", int_value) < 0) {
1454+
if (PyDict_SetItem(dict, &_Py_ID(int), int_value) < 0) {
14541455
Py_DECREF(int_value);
14551456
Py_DECREF(dict);
14561457
return NULL;
14571458
}
14581459
Py_DECREF(int_value);
14591460

1460-
if (PyDict_SetItemString(dict, "is_safe", self->is_safe) < 0) {
1461+
if (PyDict_SetItem(dict, &_Py_ID(is_safe), self->is_safe) < 0) {
14611462
Py_DECREF(dict);
14621463
return NULL;
14631464
}
@@ -1488,7 +1489,7 @@ _uuid_UUID___setstate___impl(uuidobject *self, PyObject *state)
14881489
}
14891490

14901491
// Get and set the 'int' value
1491-
PyObject *int_value = PyDict_GetItemString(state, "int");
1492+
PyObject *int_value = PyDict_GetItem(state, &_Py_ID(int));
14921493
if (int_value == NULL) {
14931494
PyErr_SetString(PyExc_ValueError, "state must have 'int' key");
14941495
return NULL;
@@ -1499,7 +1500,7 @@ _uuid_UUID___setstate___impl(uuidobject *self, PyObject *state)
14991500
}
15001501

15011502
// Get and set 'is_safe' if present
1502-
PyObject *is_safe = PyDict_GetItemString(state, "is_safe");
1503+
PyObject *is_safe = PyDict_GetItem(state, &_Py_ID(is_safe));
15031504
if (is_safe != NULL) {
15041505
// is_safe is the integer value, we need to call SafeUUID(value)
15051506
PyObject *safe_uuid_member = PyObject_CallOneArg(module_state->safe_uuid, is_safe);

0 commit comments

Comments
 (0)