Skip to content

Commit fe9f6e8

Browse files
authored
gh-133968: Add fast path to PyUnicodeWriter_WriteStr() (#133969)
Don't call PyObject_Str() if the input type is str.
1 parent fc3cddd commit fe9f6e8

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
@@ -13929,7 +13929,12 @@ _PyUnicodeWriter_WriteStr(_PyUnicodeWriter *writer, PyObject *str)
1392913929
int
1393013930
PyUnicodeWriter_WriteStr(PyUnicodeWriter *writer, PyObject *obj)
1393113931
{
13932-
if (Py_TYPE(obj) == &PyLong_Type) {
13932+
PyTypeObject *type = Py_TYPE(obj);
13933+
if (type == &PyUnicode_Type) {
13934+
return _PyUnicodeWriter_WriteStr((_PyUnicodeWriter*)writer, obj);
13935+
}
13936+
13937+
if (type == &PyLong_Type) {
1393313938
return _PyLong_FormatWriter((_PyUnicodeWriter*)writer, obj, 10, 0);
1393413939
}
1393513940

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