Skip to content

Commit 5632e93

Browse files
[3.14] gh-133968: Add fast path to PyUnicodeWriter_WriteStr() (GH-133969) (#133971)
gh-133968: Add fast path to PyUnicodeWriter_WriteStr() (GH-133969) Don't call PyObject_Str() if the input type is str. (cherry picked from commit fe9f6e8) Co-authored-by: Victor Stinner <vstinner@python.org>
1 parent 69b4387 commit 5632e93

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Objects/unicodeobject.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13954,7 +13954,12 @@ _PyUnicodeWriter_WriteStr(_PyUnicodeWriter *writer, PyObject *str)
1395413954
int
1395513955
PyUnicodeWriter_WriteStr(PyUnicodeWriter *writer, PyObject *obj)
1395613956
{
13957-
if (Py_TYPE(obj) == &PyLong_Type) {
13957+
PyTypeObject *type = Py_TYPE(obj);
13958+
if (type == &PyUnicode_Type) {
13959+
return _PyUnicodeWriter_WriteStr((_PyUnicodeWriter*)writer, obj);
13960+
}
13961+
13962+
if (type == &PyLong_Type) {
1395813963
return _PyLong_FormatWriter((_PyUnicodeWriter*)writer, obj, 10, 0);
1395913964
}
1396013965

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy