From f9d1114696ff3a6eda20b64b3604d5839d64d3d4 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Sat, 13 Jan 2018 18:51:35 +0100 Subject: Reduce code overhead a little using a macro to get the sequence length of builtins. --- Cython/Utility/ModuleSetupCode.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'Cython/Utility/ModuleSetupCode.c') diff --git a/Cython/Utility/ModuleSetupCode.c b/Cython/Utility/ModuleSetupCode.c index acc20b7a2..655fede0b 100644 --- a/Cython/Utility/ModuleSetupCode.c +++ b/Cython/Utility/ModuleSetupCode.c @@ -572,6 +572,13 @@ static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) { #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) #endif +#if CYTHON_ASSUME_SAFE_MACROS + #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq) +#else + // NOTE: might fail with exception => check for -1 + #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq) +#endif + #if PY_MAJOR_VERSION >= 3 #define PyIntObject PyLongObject #define PyInt_Type PyLong_Type -- cgit v1.2.1