Commit 20c17119 authored by Stefan Behnel's avatar Stefan Behnel

reduce string formatting overhead for the very likely case of str values in Py2

parent cae601f6
......@@ -815,9 +815,14 @@ static CYTHON_INLINE int __Pyx_PyByteArray_Append(PyObject* bytearray, int value
//////////////////// PyObjectFormatSimple.proto ////////////////////
#if PY_MAJOR_VERSION < 3 || !CYTHON_COMPILING_IN_CPYTHON
#if !CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_PyObject_FormatSimple(s, f) ( \
likely(PyUnicode_CheckExact(s)) ? (Py_INCREF(s), s) : \
likely(PyUnicode_CheckExact(s) ? (Py_INCREF(s), s) : \
PyObject_Format(s, f))
#elif PY_MAJOR_VERSION < 3
// Py2 can handle both unicode and str in PyUnicode_Join() which we (normally) call afterwards
#define __Pyx_PyObject_FormatSimple(s, f) ( \
likely(PyUnicode_CheckExact(s) | PyString_CheckExact(s)) ? (Py_INCREF(s), s) : \
PyObject_Format(s, f))
#else
// Py3 nicely returns unicode strings from str() which makes this quite efficient for builtin types
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment