mirror of
https://github.com/python/cpython.git
synced 2025-07-19 17:25:54 +00:00
GH-84436: Skip refcounting for known immortals (GH-107605)
This commit is contained in:
parent
ec0a0d2bd9
commit
05a824f294
19 changed files with 52 additions and 65 deletions
|
@ -1265,7 +1265,7 @@ initialize_locals(PyThreadState *tstate, PyFunctionObject *func,
|
|||
if (co->co_flags & CO_VARARGS) {
|
||||
PyObject *u = NULL;
|
||||
if (argcount == n) {
|
||||
u = Py_NewRef(&_Py_SINGLETON(tuple_empty));
|
||||
u = (PyObject *)&_Py_SINGLETON(tuple_empty);
|
||||
}
|
||||
else {
|
||||
assert(args != NULL);
|
||||
|
|
|
@ -1267,7 +1267,7 @@ PyTypeObject _PyContextTokenMissing_Type = {
|
|||
static PyObject *
|
||||
get_token_missing(void)
|
||||
{
|
||||
return Py_NewRef(&_Py_SINGLETON(context_token_missing));
|
||||
return (PyObject *)&_Py_SINGLETON(context_token_missing);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -105,7 +105,7 @@ _Py_device_encoding(int fd)
|
|||
#else
|
||||
if (_PyRuntime.preconfig.utf8_mode) {
|
||||
_Py_DECLARE_STR(utf_8, "utf-8");
|
||||
return Py_NewRef(&_Py_STR(utf_8));
|
||||
return &_Py_STR(utf_8);
|
||||
}
|
||||
return _Py_GetLocaleEncodingObject();
|
||||
#endif
|
||||
|
|
|
@ -514,7 +514,7 @@ hamt_node_bitmap_new(Py_ssize_t size)
|
|||
/* Since bitmap nodes are immutable, we can cache the instance
|
||||
for size=0 and reuse it whenever we need an empty bitmap node.
|
||||
*/
|
||||
return (PyHamtNode *)Py_NewRef(&_Py_SINGLETON(hamt_bitmap_node_empty));
|
||||
return (PyHamtNode *)&_Py_SINGLETON(hamt_bitmap_node_empty);
|
||||
}
|
||||
|
||||
assert(size >= 0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue