diff --git a/Doc/c-api/object.rst b/Doc/c-api/object.rst index 78599e704b1317c..56857929a5a72ac 100644 --- a/Doc/c-api/object.rst +++ b/Doc/c-api/object.rst @@ -600,7 +600,7 @@ Object Protocol Clear the managed dictionary of *obj*. - This function must only be called in a traverse function of the type which + This function must only be called in a clear function of the type which has the :c:macro:`Py_TPFLAGS_MANAGED_DICT` flag set. .. versionadded:: 3.13 diff --git a/Doc/c-api/typeobj.rst b/Doc/c-api/typeobj.rst index 8bd3144f88aa71a..5b7cf0c45026a9a 100644 --- a/Doc/c-api/typeobj.rst +++ b/Doc/c-api/typeobj.rst @@ -1704,7 +1704,7 @@ and :c:data:`PyType_Type` effectively act as defaults.) :c:func:`Py_CLEAR` macro performs the operations in a safe order. If the :c:macro:`Py_TPFLAGS_MANAGED_DICT` bit is set in the - :c:member:`~PyTypeObject.tp_flags` field, the traverse function must call + :c:member:`~PyTypeObject.tp_flags` field, the clear function must call :c:func:`PyObject_ClearManagedDict` like this:: PyObject_ClearManagedDict((PyObject*)self); diff --git a/Doc/using/cmdline.rst b/Doc/using/cmdline.rst index 74c18c2a6ede9c6..773fdabe99e0ed8 100644 --- a/Doc/using/cmdline.rst +++ b/Doc/using/cmdline.rst @@ -1277,9 +1277,8 @@ conflict. .. envvar:: PYTHON_BASIC_REPL If this variable is set to any value, the interpreter will not attempt to - load the Python-based :term:`REPL` that requires :mod:`curses` and - :mod:`readline`, and will instead use the traditional parser-based - :term:`REPL`. + load the Python-based :term:`REPL` that requires :mod:`readline`, and will + instead use the traditional parser-based :term:`REPL`. .. versionadded:: 3.13 diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2025-10-12-18-54-06.gh-issue-140009.-MbFh_.rst b/Misc/NEWS.d/next/Core_and_Builtins/2025-10-12-18-54-06.gh-issue-140009.-MbFh_.rst new file mode 100644 index 000000000000000..97b35c88e17e370 --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2025-10-12-18-54-06.gh-issue-140009.-MbFh_.rst @@ -0,0 +1 @@ +Improve performance of list extension by dictionary items. diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c index f0882191d3c3e81..c0ed8977d8fd6fa 100644 --- a/Modules/_tkinter.c +++ b/Modules/_tkinter.c @@ -82,33 +82,10 @@ typedef int Tcl_Size; #ifdef HAVE_CREATEFILEHANDLER -/* This bit is to ensure that TCL_UNIX_FD is defined and doesn't interfere - with the proper calculation of FHANDLETYPE == TCL_UNIX_FD below. */ -#ifndef TCL_UNIX_FD -# ifdef TCL_WIN_SOCKET -# define TCL_UNIX_FD (! TCL_WIN_SOCKET) -# else -# define TCL_UNIX_FD 1 -# endif -#endif - -/* Tcl_CreateFileHandler() changed several times; these macros deal with the - messiness. In Tcl 8.0 and later, it is not available on Windows (and on - Unix, only because Jack added it back); when available on Windows, it only - applies to sockets. */ - -#ifdef MS_WINDOWS -#define FHANDLETYPE TCL_WIN_SOCKET -#else -#define FHANDLETYPE TCL_UNIX_FD -#endif - /* If Tcl can wait for a Unix file descriptor, define the EventHook() routine which uses this to handle Tcl events while the user is typing commands. */ -#if FHANDLETYPE == TCL_UNIX_FD #define WAIT_FOR_STDIN -#endif #endif /* HAVE_CREATEFILEHANDLER */ diff --git a/Objects/listobject.c b/Objects/listobject.c index b2903e5c93ee9ff..1722ea60cdc68fb 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -1382,9 +1382,9 @@ list_extend_dictitems(PyListObject *self, PyDictObject *dict) PyObject **dest = self->ob_item + m; Py_ssize_t pos = 0; Py_ssize_t i = 0; - PyObject *key, *value; - while (_PyDict_Next((PyObject *)dict, &pos, &key, &value, NULL)) { - PyObject *item = PyTuple_Pack(2, key, value); + PyObject *key_value[2]; + while (_PyDict_Next((PyObject *)dict, &pos, &key_value[0], &key_value[1], NULL)) { + PyObject *item = PyTuple_FromArray(key_value, 2); if (item == NULL) { Py_SET_SIZE(self, m + i); return -1;