diff options
author | Stefan Behnel <stefan_ml@behnel.de> | 2020-04-08 10:30:02 +0200 |
---|---|---|
committer | Stefan Behnel <stefan_ml@behnel.de> | 2020-04-08 10:30:02 +0200 |
commit | 4ef1a091ba19e330eb02e6081839abad3769cd41 (patch) | |
tree | dcfe4b8aa828e3707cfd261ffcf7d7c445f1328d /Cython/Utility/ModuleSetupCode.c | |
parent | c43bd7771fe6fe0064cdfa276f49fd693c277226 (diff) | |
download | cython-optimise_pysequence_list.tar.gz |
Avoid calling PySequence_List() in some cases where we can see that the argument is a new list already.optimise_pysequence_list
Diffstat (limited to 'Cython/Utility/ModuleSetupCode.c')
-rw-r--r-- | Cython/Utility/ModuleSetupCode.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Cython/Utility/ModuleSetupCode.c b/Cython/Utility/ModuleSetupCode.c index 0a1aa5ea2..182d3db05 100644 --- a/Cython/Utility/ModuleSetupCode.c +++ b/Cython/Utility/ModuleSetupCode.c @@ -760,6 +760,13 @@ static CYTHON_INLINE PyObject * __Pyx_PyDict_GetItemStrWithError(PyObject *dict, #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj)) #endif +#if CYTHON_COMPILING_IN_CPYTHON + #define __Pyx_PySequence_ListKeepNew(obj) \ + (likely(PyList_CheckExact(obj) && Py_REFCNT(obj) == 1) ? __Pyx_NewRef(obj) : PySequence_List(obj)) +#else + #define __Pyx_PySequence_ListKeepNew(obj) PySequence_List(obj) +#endif + #ifndef PySet_CheckExact #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) #endif |