Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fe9f6e8

Browse filesBrowse 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
Copy full SHA for fe9f6e8

File tree

1 file changed

+6
-1
lines changed
Filter options

1 file changed

+6
-1
lines changed

‎Objects/unicodeobject.c

Copy file name to clipboardExpand all lines: Objects/unicodeobject.c
+6-1Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.