summaryrefslogtreecommitdiff
path: root/Cython/Utility/ModuleSetupCode.c
diff options
context:
space:
mode:
authorStefan Behnel <stefan_ml@behnel.de>2018-01-13 18:51:35 +0100
committerStefan Behnel <stefan_ml@behnel.de>2018-01-13 18:51:35 +0100
commitf9d1114696ff3a6eda20b64b3604d5839d64d3d4 (patch)
treea7c536c1cdd44c026c231eddbba4058c61c18229 /Cython/Utility/ModuleSetupCode.c
parent41e7e45635cd1d6897ff9cf11c7b80fa5a628aba (diff)
downloadcython-f9d1114696ff3a6eda20b64b3604d5839d64d3d4.tar.gz
Reduce code overhead a little using a macro to get the sequence length of builtins.
Diffstat (limited to 'Cython/Utility/ModuleSetupCode.c')
-rw-r--r--Cython/Utility/ModuleSetupCode.c7
1 files changed, 7 insertions, 0 deletions
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