Commit cae601f6 authored by Stefan Behnel's avatar Stefan Behnel

reduce string formatting overhead for the very likely case of integer values

parent 6a17574f
......@@ -815,7 +815,17 @@ static CYTHON_INLINE int __Pyx_PyByteArray_Append(PyObject* bytearray, int value
//////////////////// PyObjectFormatSimple.proto ////////////////////
#define __Pyx_PyObject_FormatSimple(s, f) (likely(PyUnicode_CheckExact(s)) ? (Py_INCREF(s), s) : PyObject_Format(s, f))
#if PY_MAJOR_VERSION < 3 || !CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_PyObject_FormatSimple(s, f) ( \
likely(PyUnicode_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
#define __Pyx_PyObject_FormatSimple(s, f) ( \
likely(PyUnicode_CheckExact(s)) ? (Py_INCREF(s), s) : \
likely(PyLong_CheckExact(s)) ? PyLong_Type.tp_str(s) : \
PyObject_Format(s, f))
#endif
//////////////////// PyObjectFormatAndDecref.proto ////////////////////
......
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