summaryrefslogtreecommitdiffstats
path: root/Objects/boolobject.c
diff options
context:
space:
mode:
authorEric Snow <ericsnowcurrently@gmail.com>2022-02-23 00:23:51 (GMT)
committerGitHub <noreply@github.com>2022-02-23 00:23:51 (GMT)
commit1f455361ecfb1892e375bdbee813cdf095b6cfb8 (patch)
treed7def4d5d167965a45c4b0e30bb5a1a0bb5c3b4a /Objects/boolobject.c
parentcff4d5c5d29528299ec1ac5b3b3a6f7735577c01 (diff)
downloadcpython-1f455361ecfb1892e375bdbee813cdf095b6cfb8.zip
cpython-1f455361ecfb1892e375bdbee813cdf095b6cfb8.tar.gz
cpython-1f455361ecfb1892e375bdbee813cdf095b6cfb8.tar.bz2
bpo-46765: Replace Locally Cached Strings with Statically Initialized Objects (gh-31366)
https://bugs.python.org/issue46765
Diffstat (limited to 'Objects/boolobject.c')
-rw-r--r--Objects/boolobject.c15
1 files changed, 2 insertions, 13 deletions
diff --git a/Objects/boolobject.c b/Objects/boolobject.c
index 53f8192..d86958a 100644
--- a/Objects/boolobject.c
+++ b/Objects/boolobject.c
@@ -1,26 +1,15 @@
/* Boolean type, a subtype of int */
#include "Python.h"
+#include "pycore_runtime.h" // _Py_ID()
#include "pycore_pyerrors.h" // _Py_FatalRefcountError()
/* We define bool_repr to return "False" or "True" */
-static PyObject *false_str = NULL;
-static PyObject *true_str = NULL;
-
static PyObject *
bool_repr(PyObject *self)
{
- PyObject *s;
-
- if (self == Py_True)
- s = true_str ? true_str :
- (true_str = PyUnicode_InternFromString("True"));
- else
- s = false_str ? false_str :
- (false_str = PyUnicode_InternFromString("False"));
- Py_XINCREF(s);
- return s;
+ return self == Py_True ? &_Py_ID(True) : &_Py_ID(False);
}
/* Function to return a bool from a C long */