1 /* Generated by Cython 0.29.24 */
2
3 #ifndef PY_SSIZE_T_CLEAN
4 #define PY_SSIZE_T_CLEAN
5 #endif /* PY_SSIZE_T_CLEAN */
6 #include "Python.h"
7 #ifndef Py_PYTHON_H
8 #error Python headers needed to compile C extensions, please install development version of Python.
9 #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
10 #error Cython requires Python 2.6+ or Python 3.3+.
11 #else
12 #define CYTHON_ABI "0_29_24"
13 #define CYTHON_HEX_VERSION 0x001D18F0
14 #define CYTHON_FUTURE_DIVISION 0
15 #include <stddef.h>
16 #ifndef offsetof
17 #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
18 #endif
19 #if !defined(WIN32) && !defined(MS_WINDOWS)
20 #ifndef __stdcall
21 #define __stdcall
22 #endif
23 #ifndef __cdecl
24 #define __cdecl
25 #endif
26 #ifndef __fastcall
27 #define __fastcall
28 #endif
29 #endif
30 #ifndef DL_IMPORT
31 #define DL_IMPORT(t) t
32 #endif
33 #ifndef DL_EXPORT
34 #define DL_EXPORT(t) t
35 #endif
36 #define __PYX_COMMA ,
37 #ifndef HAVE_LONG_LONG
38 #if PY_VERSION_HEX >= 0x02070000
39 #define HAVE_LONG_LONG
40 #endif
41 #endif
42 #ifndef PY_LONG_LONG
43 #define PY_LONG_LONG LONG_LONG
44 #endif
45 #ifndef Py_HUGE_VAL
46 #define Py_HUGE_VAL HUGE_VAL
47 #endif
48 #ifdef PYPY_VERSION
49 #define CYTHON_COMPILING_IN_PYPY 1
50 #define CYTHON_COMPILING_IN_PYSTON 0
51 #define CYTHON_COMPILING_IN_CPYTHON 0
52 #undef CYTHON_USE_TYPE_SLOTS
53 #define CYTHON_USE_TYPE_SLOTS 0
54 #undef CYTHON_USE_PYTYPE_LOOKUP
55 #define CYTHON_USE_PYTYPE_LOOKUP 0
56 #if PY_VERSION_HEX < 0x03050000
57 #undef CYTHON_USE_ASYNC_SLOTS
58 #define CYTHON_USE_ASYNC_SLOTS 0
59 #elif !defined(CYTHON_USE_ASYNC_SLOTS)
60 #define CYTHON_USE_ASYNC_SLOTS 1
61 #endif
62 #undef CYTHON_USE_PYLIST_INTERNALS
63 #define CYTHON_USE_PYLIST_INTERNALS 0
64 #undef CYTHON_USE_UNICODE_INTERNALS
65 #define CYTHON_USE_UNICODE_INTERNALS 0
66 #undef CYTHON_USE_UNICODE_WRITER
67 #define CYTHON_USE_UNICODE_WRITER 0
68 #undef CYTHON_USE_PYLONG_INTERNALS
69 #define CYTHON_USE_PYLONG_INTERNALS 0
70 #undef CYTHON_AVOID_BORROWED_REFS
71 #define CYTHON_AVOID_BORROWED_REFS 1
72 #undef CYTHON_ASSUME_SAFE_MACROS
73 #define CYTHON_ASSUME_SAFE_MACROS 0
74 #undef CYTHON_UNPACK_METHODS
75 #define CYTHON_UNPACK_METHODS 0
76 #undef CYTHON_FAST_THREAD_STATE
77 #define CYTHON_FAST_THREAD_STATE 0
78 #undef CYTHON_FAST_PYCALL
79 #define CYTHON_FAST_PYCALL 0
80 #undef CYTHON_PEP489_MULTI_PHASE_INIT
81 #define CYTHON_PEP489_MULTI_PHASE_INIT 0
82 #undef CYTHON_USE_TP_FINALIZE
83 #define CYTHON_USE_TP_FINALIZE 0
84 #undef CYTHON_USE_DICT_VERSIONS
85 #define CYTHON_USE_DICT_VERSIONS 0
86 #undef CYTHON_USE_EXC_INFO_STACK
87 #define CYTHON_USE_EXC_INFO_STACK 0
88 #elif defined(PYSTON_VERSION)
89 #define CYTHON_COMPILING_IN_PYPY 0
90 #define CYTHON_COMPILING_IN_PYSTON 1
91 #define CYTHON_COMPILING_IN_CPYTHON 0
92 #ifndef CYTHON_USE_TYPE_SLOTS
93 #define CYTHON_USE_TYPE_SLOTS 1
94 #endif
95 #undef CYTHON_USE_PYTYPE_LOOKUP
96 #define CYTHON_USE_PYTYPE_LOOKUP 0
97 #undef CYTHON_USE_ASYNC_SLOTS
98 #define CYTHON_USE_ASYNC_SLOTS 0
99 #undef CYTHON_USE_PYLIST_INTERNALS
100 #define CYTHON_USE_PYLIST_INTERNALS 0
101 #ifndef CYTHON_USE_UNICODE_INTERNALS
102 #define CYTHON_USE_UNICODE_INTERNALS 1
103 #endif
104 #undef CYTHON_USE_UNICODE_WRITER
105 #define CYTHON_USE_UNICODE_WRITER 0
106 #undef CYTHON_USE_PYLONG_INTERNALS
107 #define CYTHON_USE_PYLONG_INTERNALS 0
108 #ifndef CYTHON_AVOID_BORROWED_REFS
109 #define CYTHON_AVOID_BORROWED_REFS 0
110 #endif
111 #ifndef CYTHON_ASSUME_SAFE_MACROS
112 #define CYTHON_ASSUME_SAFE_MACROS 1
113 #endif
114 #ifndef CYTHON_UNPACK_METHODS
115 #define CYTHON_UNPACK_METHODS 1
116 #endif
117 #undef CYTHON_FAST_THREAD_STATE
118 #define CYTHON_FAST_THREAD_STATE 0
119 #undef CYTHON_FAST_PYCALL
120 #define CYTHON_FAST_PYCALL 0
121 #undef CYTHON_PEP489_MULTI_PHASE_INIT
122 #define CYTHON_PEP489_MULTI_PHASE_INIT 0
123 #undef CYTHON_USE_TP_FINALIZE
124 #define CYTHON_USE_TP_FINALIZE 0
125 #undef CYTHON_USE_DICT_VERSIONS
126 #define CYTHON_USE_DICT_VERSIONS 0
127 #undef CYTHON_USE_EXC_INFO_STACK
128 #define CYTHON_USE_EXC_INFO_STACK 0
129 #else
130 #define CYTHON_COMPILING_IN_PYPY 0
131 #define CYTHON_COMPILING_IN_PYSTON 0
132 #define CYTHON_COMPILING_IN_CPYTHON 1
133 #ifndef CYTHON_USE_TYPE_SLOTS
134 #define CYTHON_USE_TYPE_SLOTS 1
135 #endif
136 #if PY_VERSION_HEX < 0x02070000
137 #undef CYTHON_USE_PYTYPE_LOOKUP
138 #define CYTHON_USE_PYTYPE_LOOKUP 0
139 #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
140 #define CYTHON_USE_PYTYPE_LOOKUP 1
141 #endif
142 #if PY_MAJOR_VERSION < 3
143 #undef CYTHON_USE_ASYNC_SLOTS
144 #define CYTHON_USE_ASYNC_SLOTS 0
145 #elif !defined(CYTHON_USE_ASYNC_SLOTS)
146 #define CYTHON_USE_ASYNC_SLOTS 1
147 #endif
148 #if PY_VERSION_HEX < 0x02070000
149 #undef CYTHON_USE_PYLONG_INTERNALS
150 #define CYTHON_USE_PYLONG_INTERNALS 0
151 #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
152 #define CYTHON_USE_PYLONG_INTERNALS 1
153 #endif
154 #ifndef CYTHON_USE_PYLIST_INTERNALS
155 #define CYTHON_USE_PYLIST_INTERNALS 1
156 #endif
157 #ifndef CYTHON_USE_UNICODE_INTERNALS
158 #define CYTHON_USE_UNICODE_INTERNALS 1
159 #endif
160 #if PY_VERSION_HEX < 0x030300F0
161 #undef CYTHON_USE_UNICODE_WRITER
162 #define CYTHON_USE_UNICODE_WRITER 0
163 #elif !defined(CYTHON_USE_UNICODE_WRITER)
164 #define CYTHON_USE_UNICODE_WRITER 1
165 #endif
166 #ifndef CYTHON_AVOID_BORROWED_REFS
167 #define CYTHON_AVOID_BORROWED_REFS 0
168 #endif
169 #ifndef CYTHON_ASSUME_SAFE_MACROS
170 #define CYTHON_ASSUME_SAFE_MACROS 1
171 #endif
172 #ifndef CYTHON_UNPACK_METHODS
173 #define CYTHON_UNPACK_METHODS 1
174 #endif
175 #ifndef CYTHON_FAST_THREAD_STATE
176 #define CYTHON_FAST_THREAD_STATE 1
177 #endif
178 #ifndef CYTHON_FAST_PYCALL
179 #define CYTHON_FAST_PYCALL 1
180 #endif
181 #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
182 #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000)
183 #endif
184 #ifndef CYTHON_USE_TP_FINALIZE
185 #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
186 #endif
187 #ifndef CYTHON_USE_DICT_VERSIONS
188 #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1)
189 #endif
190 #ifndef CYTHON_USE_EXC_INFO_STACK
191 #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3)
192 #endif
193 #endif
194 #if !defined(CYTHON_FAST_PYCCALL)
195 #define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
196 #endif
197 #if CYTHON_USE_PYLONG_INTERNALS
198 #include "longintrepr.h"
199 #undef SHIFT
200 #undef BASE
201 #undef MASK
202 #ifdef SIZEOF_VOID_P
203 enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) };
204 #endif
205 #endif
206 #ifndef __has_attribute
207 #define __has_attribute(x) 0
208 #endif
209 #ifndef __has_cpp_attribute
210 #define __has_cpp_attribute(x) 0
211 #endif
212 #ifndef CYTHON_RESTRICT
213 #if defined(__GNUC__)
214 #define CYTHON_RESTRICT __restrict__
215 #elif defined(_MSC_VER) && _MSC_VER >= 1400
216 #define CYTHON_RESTRICT __restrict
217 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
218 #define CYTHON_RESTRICT restrict
219 #else
220 #define CYTHON_RESTRICT
221 #endif
222 #endif
223 #ifndef CYTHON_UNUSED
224 # if defined(__GNUC__)
225 # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
226 # define CYTHON_UNUSED __attribute__ ((__unused__))
227 # else
228 # define CYTHON_UNUSED
229 # endif
230 # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
231 # define CYTHON_UNUSED __attribute__ ((__unused__))
232 # else
233 # define CYTHON_UNUSED
234 # endif
235 #endif
236 #ifndef CYTHON_MAYBE_UNUSED_VAR
237 # if defined(__cplusplus)
CYTHON_MAYBE_UNUSED_VAR(const T &)238 template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
239 # else
240 # define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
241 # endif
242 #endif
243 #ifndef CYTHON_NCP_UNUSED
244 # if CYTHON_COMPILING_IN_CPYTHON
245 # define CYTHON_NCP_UNUSED
246 # else
247 # define CYTHON_NCP_UNUSED CYTHON_UNUSED
248 # endif
249 #endif
250 #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
251 #ifdef _MSC_VER
252 #ifndef _MSC_STDINT_H_
253 #if _MSC_VER < 1300
254 typedef unsigned char uint8_t;
255 typedef unsigned int uint32_t;
256 #else
257 typedef unsigned __int8 uint8_t;
258 typedef unsigned __int32 uint32_t;
259 #endif
260 #endif
261 #else
262 #include <stdint.h>
263 #endif
264 #ifndef CYTHON_FALLTHROUGH
265 #if defined(__cplusplus) && __cplusplus >= 201103L
266 #if __has_cpp_attribute(fallthrough)
267 #define CYTHON_FALLTHROUGH [[fallthrough]]
268 #elif __has_cpp_attribute(clang::fallthrough)
269 #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
270 #elif __has_cpp_attribute(gnu::fallthrough)
271 #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
272 #endif
273 #endif
274 #ifndef CYTHON_FALLTHROUGH
275 #if __has_attribute(fallthrough)
276 #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
277 #else
278 #define CYTHON_FALLTHROUGH
279 #endif
280 #endif
281 #if defined(__clang__ ) && defined(__apple_build_version__)
282 #if __apple_build_version__ < 7000000
283 #undef CYTHON_FALLTHROUGH
284 #define CYTHON_FALLTHROUGH
285 #endif
286 #endif
287 #endif
288
289 #ifndef CYTHON_INLINE
290 #if defined(__clang__)
291 #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
292 #elif defined(__GNUC__)
293 #define CYTHON_INLINE __inline__
294 #elif defined(_MSC_VER)
295 #define CYTHON_INLINE __inline
296 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
297 #define CYTHON_INLINE inline
298 #else
299 #define CYTHON_INLINE
300 #endif
301 #endif
302
303 #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
304 #define Py_OptimizeFlag 0
305 #endif
306 #define __PYX_BUILD_PY_SSIZE_T "n"
307 #define CYTHON_FORMAT_SSIZE_T "z"
308 #if PY_MAJOR_VERSION < 3
309 #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
310 #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
311 PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
312 #define __Pyx_DefaultClassType PyClass_Type
313 #else
314 #define __Pyx_BUILTIN_MODULE_NAME "builtins"
315 #if PY_VERSION_HEX >= 0x030800A4 && PY_VERSION_HEX < 0x030800B2
316 #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
317 PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
318 #else
319 #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
320 PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
321 #endif
322 #define __Pyx_DefaultClassType PyType_Type
323 #endif
324 #ifndef Py_TPFLAGS_CHECKTYPES
325 #define Py_TPFLAGS_CHECKTYPES 0
326 #endif
327 #ifndef Py_TPFLAGS_HAVE_INDEX
328 #define Py_TPFLAGS_HAVE_INDEX 0
329 #endif
330 #ifndef Py_TPFLAGS_HAVE_NEWBUFFER
331 #define Py_TPFLAGS_HAVE_NEWBUFFER 0
332 #endif
333 #ifndef Py_TPFLAGS_HAVE_FINALIZE
334 #define Py_TPFLAGS_HAVE_FINALIZE 0
335 #endif
336 #ifndef METH_STACKLESS
337 #define METH_STACKLESS 0
338 #endif
339 #if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
340 #ifndef METH_FASTCALL
341 #define METH_FASTCALL 0x80
342 #endif
343 typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
344 typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
345 Py_ssize_t nargs, PyObject *kwnames);
346 #else
347 #define __Pyx_PyCFunctionFast _PyCFunctionFast
348 #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
349 #endif
350 #if CYTHON_FAST_PYCCALL
351 #define __Pyx_PyFastCFunction_Check(func)\
352 ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)))))
353 #else
354 #define __Pyx_PyFastCFunction_Check(func) 0
355 #endif
356 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
357 #define PyObject_Malloc(s) PyMem_Malloc(s)
358 #define PyObject_Free(p) PyMem_Free(p)
359 #define PyObject_Realloc(p) PyMem_Realloc(p)
360 #endif
361 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1
362 #define PyMem_RawMalloc(n) PyMem_Malloc(n)
363 #define PyMem_RawRealloc(p, n) PyMem_Realloc(p, n)
364 #define PyMem_RawFree(p) PyMem_Free(p)
365 #endif
366 #if CYTHON_COMPILING_IN_PYSTON
367 #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co)
368 #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
369 #else
370 #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
371 #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
372 #endif
373 #if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
374 #define __Pyx_PyThreadState_Current PyThreadState_GET()
375 #elif PY_VERSION_HEX >= 0x03060000
376 #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
377 #elif PY_VERSION_HEX >= 0x03000000
378 #define __Pyx_PyThreadState_Current PyThreadState_GET()
379 #else
380 #define __Pyx_PyThreadState_Current _PyThreadState_Current
381 #endif
382 #if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
383 #include "pythread.h"
384 #define Py_tss_NEEDS_INIT 0
385 typedef int Py_tss_t;
PyThread_tss_create(Py_tss_t * key)386 static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
387 *key = PyThread_create_key();
388 return 0;
389 }
PyThread_tss_alloc(void)390 static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
391 Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
392 *key = Py_tss_NEEDS_INIT;
393 return key;
394 }
PyThread_tss_free(Py_tss_t * key)395 static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
396 PyObject_Free(key);
397 }
PyThread_tss_is_created(Py_tss_t * key)398 static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
399 return *key != Py_tss_NEEDS_INIT;
400 }
PyThread_tss_delete(Py_tss_t * key)401 static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
402 PyThread_delete_key(*key);
403 *key = Py_tss_NEEDS_INIT;
404 }
PyThread_tss_set(Py_tss_t * key,void * value)405 static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
406 return PyThread_set_key_value(*key, value);
407 }
PyThread_tss_get(Py_tss_t * key)408 static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
409 return PyThread_get_key_value(*key);
410 }
411 #endif
412 #if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
413 #define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
414 #else
415 #define __Pyx_PyDict_NewPresized(n) PyDict_New()
416 #endif
417 #if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
418 #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
419 #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
420 #else
421 #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
422 #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
423 #endif
424 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
425 #define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
426 #else
427 #define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name)
428 #endif
429 #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
430 #define CYTHON_PEP393_ENABLED 1
431 #if defined(PyUnicode_IS_READY)
432 #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
433 0 : _PyUnicode_Ready((PyObject *)(op)))
434 #else
435 #define __Pyx_PyUnicode_READY(op) (0)
436 #endif
437 #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
438 #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
439 #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
440 #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
441 #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
442 #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
443 #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch)
444 #if defined(PyUnicode_IS_READY) && defined(PyUnicode_GET_SIZE)
445 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03090000
446 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : ((PyCompactUnicodeObject *)(u))->wstr_length))
447 #else
448 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
449 #endif
450 #else
451 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_LENGTH(u))
452 #endif
453 #else
454 #define CYTHON_PEP393_ENABLED 0
455 #define PyUnicode_1BYTE_KIND 1
456 #define PyUnicode_2BYTE_KIND 2
457 #define PyUnicode_4BYTE_KIND 4
458 #define __Pyx_PyUnicode_READY(op) (0)
459 #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
460 #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
461 #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
462 #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
463 #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
464 #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
465 #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
466 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u))
467 #endif
468 #if CYTHON_COMPILING_IN_PYPY
469 #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
470 #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
471 #else
472 #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
473 #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
474 PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
475 #endif
476 #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
477 #define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
478 #endif
479 #if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
480 #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
481 #endif
482 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
483 #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
484 #endif
485 #define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
486 #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
487 #if PY_MAJOR_VERSION >= 3
488 #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
489 #else
490 #define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
491 #endif
492 #if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
493 #define PyObject_ASCII(o) PyObject_Repr(o)
494 #endif
495 #if PY_MAJOR_VERSION >= 3
496 #define PyBaseString_Type PyUnicode_Type
497 #define PyStringObject PyUnicodeObject
498 #define PyString_Type PyUnicode_Type
499 #define PyString_Check PyUnicode_Check
500 #define PyString_CheckExact PyUnicode_CheckExact
501 #ifndef PyObject_Unicode
502 #define PyObject_Unicode PyObject_Str
503 #endif
504 #endif
505 #if PY_MAJOR_VERSION >= 3
506 #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
507 #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
508 #else
509 #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
510 #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
511 #endif
512 #ifndef PySet_CheckExact
513 #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
514 #endif
515 #if PY_VERSION_HEX >= 0x030900A4
516 #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt)
517 #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size)
518 #else
519 #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt)
520 #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size)
521 #endif
522 #if CYTHON_ASSUME_SAFE_MACROS
523 #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq)
524 #else
525 #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq)
526 #endif
527 #if PY_MAJOR_VERSION >= 3
528 #define PyIntObject PyLongObject
529 #define PyInt_Type PyLong_Type
530 #define PyInt_Check(op) PyLong_Check(op)
531 #define PyInt_CheckExact(op) PyLong_CheckExact(op)
532 #define PyInt_FromString PyLong_FromString
533 #define PyInt_FromUnicode PyLong_FromUnicode
534 #define PyInt_FromLong PyLong_FromLong
535 #define PyInt_FromSize_t PyLong_FromSize_t
536 #define PyInt_FromSsize_t PyLong_FromSsize_t
537 #define PyInt_AsLong PyLong_AsLong
538 #define PyInt_AS_LONG PyLong_AS_LONG
539 #define PyInt_AsSsize_t PyLong_AsSsize_t
540 #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
541 #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
542 #define PyNumber_Int PyNumber_Long
543 #endif
544 #if PY_MAJOR_VERSION >= 3
545 #define PyBoolObject PyLongObject
546 #endif
547 #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
548 #ifndef PyUnicode_InternFromString
549 #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
550 #endif
551 #endif
552 #if PY_VERSION_HEX < 0x030200A4
553 typedef long Py_hash_t;
554 #define __Pyx_PyInt_FromHash_t PyInt_FromLong
555 #define __Pyx_PyInt_AsHash_t PyInt_AsLong
556 #else
557 #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
558 #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
559 #endif
560 #if PY_MAJOR_VERSION >= 3
561 #define __Pyx_PyMethod_New(func, self, klass) ((self) ? ((void)(klass), PyMethod_New(func, self)) : __Pyx_NewRef(func))
562 #else
563 #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
564 #endif
565 #if CYTHON_USE_ASYNC_SLOTS
566 #if PY_VERSION_HEX >= 0x030500B1
567 #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
568 #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
569 #else
570 #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
571 #endif
572 #else
573 #define __Pyx_PyType_AsAsync(obj) NULL
574 #endif
575 #ifndef __Pyx_PyAsyncMethodsStruct
576 typedef struct {
577 unaryfunc am_await;
578 unaryfunc am_aiter;
579 unaryfunc am_anext;
580 } __Pyx_PyAsyncMethodsStruct;
581 #endif
582
583 #if defined(WIN32) || defined(MS_WINDOWS)
584 #define _USE_MATH_DEFINES
585 #endif
586 #include <math.h>
587 #ifdef NAN
588 #define __PYX_NAN() ((float) NAN)
589 #else
__PYX_NAN()590 static CYTHON_INLINE float __PYX_NAN() {
591 float value;
592 memset(&value, 0xFF, sizeof(value));
593 return value;
594 }
595 #endif
596 #if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
597 #define __Pyx_truncl trunc
598 #else
599 #define __Pyx_truncl truncl
600 #endif
601
602 #define __PYX_MARK_ERR_POS(f_index, lineno) \
603 { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; }
604 #define __PYX_ERR(f_index, lineno, Ln_error) \
605 { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; }
606
607 #ifndef __PYX_EXTERN_C
608 #ifdef __cplusplus
609 #define __PYX_EXTERN_C extern "C"
610 #else
611 #define __PYX_EXTERN_C extern
612 #endif
613 #endif
614
615 #define __PYX_HAVE__Stemmer
616 #define __PYX_HAVE_API__Stemmer
617 /* Early includes */
618 #include "libstemmer.h"
619 #ifdef _OPENMP
620 #include <omp.h>
621 #endif /* _OPENMP */
622
623 #if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
624 #define CYTHON_WITHOUT_ASSERTIONS
625 #endif
626
627 typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
628 const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
629
630 #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
631 #define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0
632 #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8)
633 #define __PYX_DEFAULT_STRING_ENCODING ""
634 #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
635 #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
636 #define __Pyx_uchar_cast(c) ((unsigned char)c)
637 #define __Pyx_long_cast(x) ((long)x)
638 #define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
639 (sizeof(type) < sizeof(Py_ssize_t)) ||\
640 (sizeof(type) > sizeof(Py_ssize_t) &&\
641 likely(v < (type)PY_SSIZE_T_MAX ||\
642 v == (type)PY_SSIZE_T_MAX) &&\
643 (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
644 v == (type)PY_SSIZE_T_MIN))) ||\
645 (sizeof(type) == sizeof(Py_ssize_t) &&\
646 (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
647 v == (type)PY_SSIZE_T_MAX))) )
__Pyx_is_valid_index(Py_ssize_t i,Py_ssize_t limit)648 static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
649 return (size_t) i < (size_t) limit;
650 }
651 #if defined (__cplusplus) && __cplusplus >= 201103L
652 #include <cstdlib>
653 #define __Pyx_sst_abs(value) std::abs(value)
654 #elif SIZEOF_INT >= SIZEOF_SIZE_T
655 #define __Pyx_sst_abs(value) abs(value)
656 #elif SIZEOF_LONG >= SIZEOF_SIZE_T
657 #define __Pyx_sst_abs(value) labs(value)
658 #elif defined (_MSC_VER)
659 #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
660 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
661 #define __Pyx_sst_abs(value) llabs(value)
662 #elif defined (__GNUC__)
663 #define __Pyx_sst_abs(value) __builtin_llabs(value)
664 #else
665 #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
666 #endif
667 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
668 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
669 #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
670 #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
671 #define __Pyx_PyBytes_FromString PyBytes_FromString
672 #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
673 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
674 #if PY_MAJOR_VERSION < 3
675 #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
676 #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
677 #else
678 #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
679 #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
680 #endif
681 #define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s))
682 #define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s))
683 #define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s))
684 #define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s))
685 #define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s))
686 #define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s))
687 #define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s))
688 #define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
689 #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
690 #define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s))
691 #define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s))
692 #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
693 #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
694 #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
695 #define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s)
696 #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
__Pyx_Py_UNICODE_strlen(const Py_UNICODE * u)697 static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
698 const Py_UNICODE *u_end = u;
699 while (*u_end++) ;
700 return (size_t)(u_end - u - 1);
701 }
702 #define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
703 #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
704 #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
705 #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
706 #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
707 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
708 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
709 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
710 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
711 #define __Pyx_PySequence_Tuple(obj)\
712 (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
713 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
714 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
715 #if CYTHON_ASSUME_SAFE_MACROS
716 #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
717 #else
718 #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
719 #endif
720 #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
721 #if PY_MAJOR_VERSION >= 3
722 #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
723 #else
724 #define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
725 #endif
726 #define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
727 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
728 static int __Pyx_sys_getdefaultencoding_not_ascii;
__Pyx_init_sys_getdefaultencoding_params(void)729 static int __Pyx_init_sys_getdefaultencoding_params(void) {
730 PyObject* sys;
731 PyObject* default_encoding = NULL;
732 PyObject* ascii_chars_u = NULL;
733 PyObject* ascii_chars_b = NULL;
734 const char* default_encoding_c;
735 sys = PyImport_ImportModule("sys");
736 if (!sys) goto bad;
737 default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
738 Py_DECREF(sys);
739 if (!default_encoding) goto bad;
740 default_encoding_c = PyBytes_AsString(default_encoding);
741 if (!default_encoding_c) goto bad;
742 if (strcmp(default_encoding_c, "ascii") == 0) {
743 __Pyx_sys_getdefaultencoding_not_ascii = 0;
744 } else {
745 char ascii_chars[128];
746 int c;
747 for (c = 0; c < 128; c++) {
748 ascii_chars[c] = c;
749 }
750 __Pyx_sys_getdefaultencoding_not_ascii = 1;
751 ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
752 if (!ascii_chars_u) goto bad;
753 ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
754 if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
755 PyErr_Format(
756 PyExc_ValueError,
757 "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
758 default_encoding_c);
759 goto bad;
760 }
761 Py_DECREF(ascii_chars_u);
762 Py_DECREF(ascii_chars_b);
763 }
764 Py_DECREF(default_encoding);
765 return 0;
766 bad:
767 Py_XDECREF(default_encoding);
768 Py_XDECREF(ascii_chars_u);
769 Py_XDECREF(ascii_chars_b);
770 return -1;
771 }
772 #endif
773 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
774 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
775 #else
776 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
777 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
778 static char* __PYX_DEFAULT_STRING_ENCODING;
__Pyx_init_sys_getdefaultencoding_params(void)779 static int __Pyx_init_sys_getdefaultencoding_params(void) {
780 PyObject* sys;
781 PyObject* default_encoding = NULL;
782 char* default_encoding_c;
783 sys = PyImport_ImportModule("sys");
784 if (!sys) goto bad;
785 default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
786 Py_DECREF(sys);
787 if (!default_encoding) goto bad;
788 default_encoding_c = PyBytes_AsString(default_encoding);
789 if (!default_encoding_c) goto bad;
790 __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1);
791 if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
792 strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
793 Py_DECREF(default_encoding);
794 return 0;
795 bad:
796 Py_XDECREF(default_encoding);
797 return -1;
798 }
799 #endif
800 #endif
801
802
803 /* Test for GCC > 2.95 */
804 #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
805 #define likely(x) __builtin_expect(!!(x), 1)
806 #define unlikely(x) __builtin_expect(!!(x), 0)
807 #else /* !__GNUC__ or GCC < 2.95 */
808 #define likely(x) (x)
809 #define unlikely(x) (x)
810 #endif /* __GNUC__ */
__Pyx_pretend_to_initialize(void * ptr)811 static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
812
813 static PyObject *__pyx_m = NULL;
814 static PyObject *__pyx_d;
815 static PyObject *__pyx_b;
816 static PyObject *__pyx_cython_runtime = NULL;
817 static PyObject *__pyx_empty_tuple;
818 static PyObject *__pyx_empty_bytes;
819 static PyObject *__pyx_empty_unicode;
820 static int __pyx_lineno;
821 static int __pyx_clineno = 0;
822 static const char * __pyx_cfilenm= __FILE__;
823 static const char *__pyx_filename;
824
825
826 static const char *__pyx_f[] = {
827 "src/Stemmer.pyx",
828 "stringsource",
829 };
830
831 /*--- Type declarations ---*/
832 struct __pyx_obj_7Stemmer_Stemmer;
833
834 /* "Stemmer.pyx":81
835 * return '2.0.1'
836 *
837 * cdef class Stemmer: # <<<<<<<<<<<<<<
838 * """An instance of a stemming algorithm.
839 *
840 */
841 struct __pyx_obj_7Stemmer_Stemmer {
842 PyObject_HEAD
843 struct sb_stemmer *cobj;
844 PyObject *cache;
845 PyObject *counter;
846 int max_cache_size;
847 };
848
849
850 /* --- Runtime support code (head) --- */
851 /* Refnanny.proto */
852 #ifndef CYTHON_REFNANNY
853 #define CYTHON_REFNANNY 0
854 #endif
855 #if CYTHON_REFNANNY
856 typedef struct {
857 void (*INCREF)(void*, PyObject*, int);
858 void (*DECREF)(void*, PyObject*, int);
859 void (*GOTREF)(void*, PyObject*, int);
860 void (*GIVEREF)(void*, PyObject*, int);
861 void* (*SetupContext)(const char*, int, const char*);
862 void (*FinishContext)(void**);
863 } __Pyx_RefNannyAPIStruct;
864 static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
865 static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
866 #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
867 #ifdef WITH_THREAD
868 #define __Pyx_RefNannySetupContext(name, acquire_gil)\
869 if (acquire_gil) {\
870 PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
871 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
872 PyGILState_Release(__pyx_gilstate_save);\
873 } else {\
874 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
875 }
876 #else
877 #define __Pyx_RefNannySetupContext(name, acquire_gil)\
878 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
879 #endif
880 #define __Pyx_RefNannyFinishContext()\
881 __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
882 #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
883 #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
884 #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
885 #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
886 #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
887 #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
888 #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
889 #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
890 #else
891 #define __Pyx_RefNannyDeclarations
892 #define __Pyx_RefNannySetupContext(name, acquire_gil)
893 #define __Pyx_RefNannyFinishContext()
894 #define __Pyx_INCREF(r) Py_INCREF(r)
895 #define __Pyx_DECREF(r) Py_DECREF(r)
896 #define __Pyx_GOTREF(r)
897 #define __Pyx_GIVEREF(r)
898 #define __Pyx_XINCREF(r) Py_XINCREF(r)
899 #define __Pyx_XDECREF(r) Py_XDECREF(r)
900 #define __Pyx_XGOTREF(r)
901 #define __Pyx_XGIVEREF(r)
902 #endif
903 #define __Pyx_XDECREF_SET(r, v) do {\
904 PyObject *tmp = (PyObject *) r;\
905 r = v; __Pyx_XDECREF(tmp);\
906 } while (0)
907 #define __Pyx_DECREF_SET(r, v) do {\
908 PyObject *tmp = (PyObject *) r;\
909 r = v; __Pyx_DECREF(tmp);\
910 } while (0)
911 #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
912 #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
913
914 /* PyObjectGetAttrStr.proto */
915 #if CYTHON_USE_TYPE_SLOTS
916 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
917 #else
918 #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
919 #endif
920
921 /* GetBuiltinName.proto */
922 static PyObject *__Pyx_GetBuiltinName(PyObject *name);
923
924 /* RaiseDoubleKeywords.proto */
925 static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
926
927 /* ParseKeywords.proto */
928 static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
929 PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
930 const char* function_name);
931
932 /* RaiseArgTupleInvalid.proto */
933 static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
934 Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
935
936 /* PyCFunctionFastCall.proto */
937 #if CYTHON_FAST_PYCCALL
938 static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
939 #else
940 #define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL)
941 #endif
942
943 /* PyFunctionFastCall.proto */
944 #if CYTHON_FAST_PYCALL
945 #define __Pyx_PyFunction_FastCall(func, args, nargs)\
946 __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
947 #if 1 || PY_VERSION_HEX < 0x030600B1
948 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs);
949 #else
950 #define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
951 #endif
952 #define __Pyx_BUILD_ASSERT_EXPR(cond)\
953 (sizeof(char [1 - 2*!(cond)]) - 1)
954 #ifndef Py_MEMBER_SIZE
955 #define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
956 #endif
957 static size_t __pyx_pyframe_localsplus_offset = 0;
958 #include "frameobject.h"
959 #define __Pxy_PyFrame_Initialize_Offsets()\
960 ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\
961 (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus)))
962 #define __Pyx_PyFrame_GetLocalsplus(frame)\
963 (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset))
964 #endif
965
966 /* PyObjectCall.proto */
967 #if CYTHON_COMPILING_IN_CPYTHON
968 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
969 #else
970 #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
971 #endif
972
973 /* PyObjectCall2Args.proto */
974 static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2);
975
976 /* PyObjectCallMethO.proto */
977 #if CYTHON_COMPILING_IN_CPYTHON
978 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
979 #endif
980
981 /* PyObjectCallOneArg.proto */
982 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
983
984 /* ListAppend.proto */
985 #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
__Pyx_PyList_Append(PyObject * list,PyObject * x)986 static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
987 PyListObject* L = (PyListObject*) list;
988 Py_ssize_t len = Py_SIZE(list);
989 if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) {
990 Py_INCREF(x);
991 PyList_SET_ITEM(list, len, x);
992 __Pyx_SET_SIZE(list, len + 1);
993 return 0;
994 }
995 return PyList_Append(list, x);
996 }
997 #else
998 #define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
999 #endif
1000
1001 /* PyThreadStateGet.proto */
1002 #if CYTHON_FAST_THREAD_STATE
1003 #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
1004 #define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current;
1005 #define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type
1006 #else
1007 #define __Pyx_PyThreadState_declare
1008 #define __Pyx_PyThreadState_assign
1009 #define __Pyx_PyErr_Occurred() PyErr_Occurred()
1010 #endif
1011
1012 /* PyErrFetchRestore.proto */
1013 #if CYTHON_FAST_THREAD_STATE
1014 #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
1015 #define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
1016 #define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
1017 #define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
1018 #define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
1019 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
1020 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1021 #if CYTHON_COMPILING_IN_CPYTHON
1022 #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
1023 #else
1024 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
1025 #endif
1026 #else
1027 #define __Pyx_PyErr_Clear() PyErr_Clear()
1028 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
1029 #define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
1030 #define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
1031 #define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb)
1032 #define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb)
1033 #define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
1034 #define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
1035 #endif
1036
1037 /* RaiseException.proto */
1038 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
1039
1040 /* PyObjectCallNoArg.proto */
1041 #if CYTHON_COMPILING_IN_CPYTHON
1042 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
1043 #else
1044 #define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
1045 #endif
1046
1047 /* None.proto */
1048 static CYTHON_INLINE long __Pyx_div_long(long, long);
1049
1050 /* IterFinish.proto */
1051 static CYTHON_INLINE int __Pyx_IterFinish(void);
1052
1053 /* PyObjectGetMethod.proto */
1054 static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method);
1055
1056 /* PyObjectCallMethod0.proto */
1057 static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name);
1058
1059 /* RaiseNeedMoreValuesToUnpack.proto */
1060 static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
1061
1062 /* RaiseTooManyValuesToUnpack.proto */
1063 static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
1064
1065 /* UnpackItemEndCheck.proto */
1066 static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected);
1067
1068 /* RaiseNoneIterError.proto */
1069 static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void);
1070
1071 /* UnpackTupleError.proto */
1072 static void __Pyx_UnpackTupleError(PyObject *, Py_ssize_t index);
1073
1074 /* UnpackTuple2.proto */
1075 #define __Pyx_unpack_tuple2(tuple, value1, value2, is_tuple, has_known_size, decref_tuple)\
1076 (likely(is_tuple || PyTuple_Check(tuple)) ?\
1077 (likely(has_known_size || PyTuple_GET_SIZE(tuple) == 2) ?\
1078 __Pyx_unpack_tuple2_exact(tuple, value1, value2, decref_tuple) :\
1079 (__Pyx_UnpackTupleError(tuple, 2), -1)) :\
1080 __Pyx_unpack_tuple2_generic(tuple, value1, value2, has_known_size, decref_tuple))
1081 static CYTHON_INLINE int __Pyx_unpack_tuple2_exact(
1082 PyObject* tuple, PyObject** value1, PyObject** value2, int decref_tuple);
1083 static int __Pyx_unpack_tuple2_generic(
1084 PyObject* tuple, PyObject** value1, PyObject** value2, int has_known_size, int decref_tuple);
1085
1086 /* dict_iter.proto */
1087 static CYTHON_INLINE PyObject* __Pyx_dict_iterator(PyObject* dict, int is_dict, PyObject* method_name,
1088 Py_ssize_t* p_orig_length, int* p_is_dict);
1089 static CYTHON_INLINE int __Pyx_dict_iter_next(PyObject* dict_or_iter, Py_ssize_t orig_length, Py_ssize_t* ppos,
1090 PyObject** pkey, PyObject** pvalue, PyObject** pitem, int is_dict);
1091
1092 /* GetItemInt.proto */
1093 #define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1094 (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1095 __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\
1096 (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
1097 __Pyx_GetItemInt_Generic(o, to_py_func(i))))
1098 #define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1099 (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1100 __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
1101 (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
1102 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
1103 int wraparound, int boundscheck);
1104 #define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1105 (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1106 __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
1107 (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
1108 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
1109 int wraparound, int boundscheck);
1110 static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
1111 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
1112 int is_list, int wraparound, int boundscheck);
1113
1114 /* ObjectGetItem.proto */
1115 #if CYTHON_USE_TYPE_SLOTS
1116 static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key);
1117 #else
1118 #define __Pyx_PyObject_GetItem(obj, key) PyObject_GetItem(obj, key)
1119 #endif
1120
1121 /* SetItemInt.proto */
1122 #define __Pyx_SetItemInt(o, i, v, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1123 (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1124 __Pyx_SetItemInt_Fast(o, (Py_ssize_t)i, v, is_list, wraparound, boundscheck) :\
1125 (is_list ? (PyErr_SetString(PyExc_IndexError, "list assignment index out of range"), -1) :\
1126 __Pyx_SetItemInt_Generic(o, to_py_func(i), v)))
1127 static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v);
1128 static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v,
1129 int is_list, int wraparound, int boundscheck);
1130
1131 /* PyIntBinop.proto */
1132 #if !CYTHON_COMPILING_IN_PYPY
1133 static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
1134 #else
1135 #define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace, zerodivision_check)\
1136 (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2))
1137 #endif
1138
1139 /* GetTopmostException.proto */
1140 #if CYTHON_USE_EXC_INFO_STACK
1141 static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate);
1142 #endif
1143
1144 /* SaveResetException.proto */
1145 #if CYTHON_FAST_THREAD_STATE
1146 #define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
1147 static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1148 #define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
1149 static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
1150 #else
1151 #define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb)
1152 #define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb)
1153 #endif
1154
1155 /* PyErrExceptionMatches.proto */
1156 #if CYTHON_FAST_THREAD_STATE
1157 #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
1158 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
1159 #else
1160 #define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err)
1161 #endif
1162
1163 /* GetException.proto */
1164 #if CYTHON_FAST_THREAD_STATE
1165 #define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb)
1166 static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1167 #else
1168 static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
1169 #endif
1170
1171 /* PyObject_GenericGetAttrNoDict.proto */
1172 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
1173 static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
1174 #else
1175 #define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
1176 #endif
1177
1178 /* PyObject_GenericGetAttr.proto */
1179 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
1180 static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name);
1181 #else
1182 #define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr
1183 #endif
1184
1185 /* PyObjectGetAttrStrNoError.proto */
1186 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name);
1187
1188 /* SetupReduce.proto */
1189 static int __Pyx_setup_reduce(PyObject* type_obj);
1190
1191 /* PyDictVersioning.proto */
1192 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
1193 #define __PYX_DICT_VERSION_INIT ((PY_UINT64_T) -1)
1194 #define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag)
1195 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
1196 (version_var) = __PYX_GET_DICT_VERSION(dict);\
1197 (cache_var) = (value);
1198 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
1199 static PY_UINT64_T __pyx_dict_version = 0;\
1200 static PyObject *__pyx_dict_cached_value = NULL;\
1201 if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
1202 (VAR) = __pyx_dict_cached_value;\
1203 } else {\
1204 (VAR) = __pyx_dict_cached_value = (LOOKUP);\
1205 __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
1206 }\
1207 }
1208 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj);
1209 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj);
1210 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version);
1211 #else
1212 #define __PYX_GET_DICT_VERSION(dict) (0)
1213 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
1214 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) (VAR) = (LOOKUP);
1215 #endif
1216
1217 /* CLineInTraceback.proto */
1218 #ifdef CYTHON_CLINE_IN_TRACEBACK
1219 #define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
1220 #else
1221 static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
1222 #endif
1223
1224 /* CodeObjectCache.proto */
1225 typedef struct {
1226 PyCodeObject* code_object;
1227 int code_line;
1228 } __Pyx_CodeObjectCacheEntry;
1229 struct __Pyx_CodeObjectCache {
1230 int count;
1231 int max_count;
1232 __Pyx_CodeObjectCacheEntry* entries;
1233 };
1234 static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
1235 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
1236 static PyCodeObject *__pyx_find_code_object(int code_line);
1237 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
1238
1239 /* AddTraceback.proto */
1240 static void __Pyx_AddTraceback(const char *funcname, int c_line,
1241 int py_line, const char *filename);
1242
1243 /* GCCDiagnostics.proto */
1244 #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
1245 #define __Pyx_HAS_GCC_DIAGNOSTIC
1246 #endif
1247
1248 /* CIntFromPy.proto */
1249 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
1250
1251 /* CIntToPy.proto */
1252 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
1253
1254 /* CIntToPy.proto */
1255 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
1256
1257 /* CIntFromPy.proto */
1258 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
1259
1260 /* FastTypeChecks.proto */
1261 #if CYTHON_COMPILING_IN_CPYTHON
1262 #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
1263 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
1264 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
1265 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
1266 #else
1267 #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
1268 #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
1269 #define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
1270 #endif
1271 #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
1272
1273 /* CheckBinaryVersion.proto */
1274 static int __Pyx_check_binary_version(void);
1275
1276 /* InitStrings.proto */
1277 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
1278
1279
1280 /* Module declarations from 'Stemmer' */
1281 static PyTypeObject *__pyx_ptype_7Stemmer_Stemmer = 0;
1282 #define __Pyx_MODULE_NAME "Stemmer"
1283 extern int __pyx_module_is_main_Stemmer;
1284 int __pyx_module_is_main_Stemmer = 0;
1285
1286 /* Implementation of 'Stemmer' */
1287 static PyObject *__pyx_builtin_KeyError;
1288 static PyObject *__pyx_builtin_TypeError;
1289 static const char __pyx_k_i[] = "i";
1290 static const char __pyx_k_alg[] = "alg";
1291 static const char __pyx_k_algs[] = "algs";
1292 static const char __pyx_k_main[] = "__main__";
1293 static const char __pyx_k_name[] = "__name__";
1294 static const char __pyx_k_test[] = "__test__";
1295 static const char __pyx_k_2_0_1[] = "2.0.1";
1296 static const char __pyx_k_ascii[] = "ascii";
1297 static const char __pyx_k_utf_8[] = "utf-8";
1298 static const char __pyx_k_decode[] = "decode";
1299 static const char __pyx_k_encode[] = "encode";
1300 static const char __pyx_k_reduce[] = "__reduce__";
1301 static const char __pyx_k_Stemmer[] = "Stemmer";
1302 static const char __pyx_k_aliases[] = "aliases";
1303 static const char __pyx_k_py_algs[] = "py_algs";
1304 static const char __pyx_k_version[] = "version";
1305 static const char __pyx_k_KeyError[] = "KeyError";
1306 static const char __pyx_k_getstate[] = "__getstate__";
1307 static const char __pyx_k_setstate[] = "__setstate__";
1308 static const char __pyx_k_stemWord[] = "stemWord";
1309 static const char __pyx_k_TypeError[] = "TypeError";
1310 static const char __pyx_k_algorithm[] = "algorithm";
1311 static const char __pyx_k_docformat[] = "__docformat__";
1312 static const char __pyx_k_iteritems[] = "iteritems";
1313 static const char __pyx_k_reduce_ex[] = "__reduce_ex__";
1314 static const char __pyx_k_algorithms[] = "algorithms";
1315 static const char __pyx_k_purgeCache[] = "__purgeCache";
1316 static const char __pyx_k_maxCacheSize[] = "maxCacheSize";
1317 static const char __pyx_k_reduce_cython[] = "__reduce_cython__";
1318 static const char __pyx_k_setstate_cython[] = "__setstate_cython__";
1319 static const char __pyx_k_src_Stemmer_pyx[] = "src/Stemmer.pyx";
1320 static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
1321 static const char __pyx_k_restructuredtext_en[] = "restructuredtext en";
1322 static const char __pyx_k_Stemming_algorithm_s_not_found[] = "Stemming algorithm '%s' not found";
1323 static const char __pyx_k_Stemmer_stemming_algorithms_from[] = "Stemmer: stemming algorithms from the snowball project.\n\n";
1324 static const char __pyx_k_self_cobj_cannot_be_converted_to[] = "self.cobj cannot be converted to a Python object for pickling";
1325 static PyObject *__pyx_kp_s_2_0_1;
1326 static PyObject *__pyx_n_s_KeyError;
1327 static PyObject *__pyx_n_s_Stemmer;
1328 static PyObject *__pyx_kp_s_Stemming_algorithm_s_not_found;
1329 static PyObject *__pyx_n_s_TypeError;
1330 static PyObject *__pyx_n_s_alg;
1331 static PyObject *__pyx_n_s_algorithm;
1332 static PyObject *__pyx_n_s_algorithms;
1333 static PyObject *__pyx_n_s_algs;
1334 static PyObject *__pyx_n_s_aliases;
1335 static PyObject *__pyx_n_u_ascii;
1336 static PyObject *__pyx_n_s_cline_in_traceback;
1337 static PyObject *__pyx_n_s_decode;
1338 static PyObject *__pyx_n_s_docformat;
1339 static PyObject *__pyx_n_s_encode;
1340 static PyObject *__pyx_n_s_getstate;
1341 static PyObject *__pyx_n_s_i;
1342 static PyObject *__pyx_n_s_iteritems;
1343 static PyObject *__pyx_n_s_main;
1344 static PyObject *__pyx_n_s_maxCacheSize;
1345 static PyObject *__pyx_n_s_name;
1346 static PyObject *__pyx_n_s_purgeCache;
1347 static PyObject *__pyx_n_s_py_algs;
1348 static PyObject *__pyx_n_s_reduce;
1349 static PyObject *__pyx_n_s_reduce_cython;
1350 static PyObject *__pyx_n_s_reduce_ex;
1351 static PyObject *__pyx_kp_s_restructuredtext_en;
1352 static PyObject *__pyx_kp_s_self_cobj_cannot_be_converted_to;
1353 static PyObject *__pyx_n_s_setstate;
1354 static PyObject *__pyx_n_s_setstate_cython;
1355 static PyObject *__pyx_kp_s_src_Stemmer_pyx;
1356 static PyObject *__pyx_n_s_stemWord;
1357 static PyObject *__pyx_n_s_test;
1358 static PyObject *__pyx_kp_u_utf_8;
1359 static PyObject *__pyx_n_s_version;
1360 static PyObject *__pyx_pf_7Stemmer_algorithms(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_aliases); /* proto */
1361 static PyObject *__pyx_pf_7Stemmer_2version(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
1362 static int __pyx_pf_7Stemmer_7Stemmer___init__(struct __pyx_obj_7Stemmer_Stemmer *__pyx_v_self, PyObject *__pyx_v_algorithm, int __pyx_v_maxCacheSize); /* proto */
1363 static void __pyx_pf_7Stemmer_7Stemmer_2__dealloc__(struct __pyx_obj_7Stemmer_Stemmer *__pyx_v_self); /* proto */
1364 static int __pyx_pf_7Stemmer_7Stemmer_12maxCacheSize___set__(struct __pyx_obj_7Stemmer_Stemmer *__pyx_v_self, int __pyx_v_size); /* proto */
1365 static PyObject *__pyx_pf_7Stemmer_7Stemmer_12maxCacheSize_2__get__(struct __pyx_obj_7Stemmer_Stemmer *__pyx_v_self); /* proto */
1366 static PyObject *__pyx_pf_7Stemmer_7Stemmer_4__purgeCache(struct __pyx_obj_7Stemmer_Stemmer *__pyx_v_self); /* proto */
1367 static PyObject *__pyx_pf_7Stemmer_7Stemmer_6stemWord(struct __pyx_obj_7Stemmer_Stemmer *__pyx_v_self, PyObject *__pyx_v_word); /* proto */
1368 static PyObject *__pyx_pf_7Stemmer_7Stemmer_8stemWords(struct __pyx_obj_7Stemmer_Stemmer *__pyx_v_self, PyObject *__pyx_v_words); /* proto */
1369 static PyObject *__pyx_pf_7Stemmer_7Stemmer_10__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_7Stemmer_Stemmer *__pyx_v_self); /* proto */
1370 static PyObject *__pyx_pf_7Stemmer_7Stemmer_12__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_7Stemmer_Stemmer *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
1371 static PyObject *__pyx_tp_new_7Stemmer_Stemmer(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
1372 static PyObject *__pyx_int_0;
1373 static PyObject *__pyx_int_1;
1374 static PyObject *__pyx_tuple_;
1375 static PyObject *__pyx_tuple__2;
1376 static PyObject *__pyx_tuple__3;
1377 static PyObject *__pyx_codeobj__4;
1378 static PyObject *__pyx_codeobj__5;
1379 /* Late includes */
1380
1381 /* "Stemmer.pyx":43
1382 * cdef int sb_stemmer_length(sb_stemmer * stemmer)
1383 *
1384 * def algorithms(aliases=False): # <<<<<<<<<<<<<<
1385 * """Get a list of the names of the available stemming algorithms.
1386 *
1387 */
1388
1389 /* Python wrapper */
1390 static PyObject *__pyx_pw_7Stemmer_1algorithms(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
1391 static char __pyx_doc_7Stemmer_algorithms[] = "Get a list of the names of the available stemming algorithms.\n \n Note that there are also aliases for these algorithm names, which are not\n included in this list by default. If the 'aliases' keyword parameter is\n False, this list is guaranteed to contain precisely one entry for each\n available stemming algorithm. Otherwise, all known aliases for algorithms\n will be included in the list.\n\n Note that the classic Porter stemming algorithm for English is\n available by default: although this has been superseded by an improved\n algorithm, the original algorithm may be of interest to information\n retrieval researchers wishing to reproduce results of earlier\n experiments. Most users will want to use the \"english\" algorithm,\n instead of the \"porter\" algorithm.\n\n ";
1392 static PyMethodDef __pyx_mdef_7Stemmer_1algorithms = {"algorithms", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7Stemmer_1algorithms, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7Stemmer_algorithms};
__pyx_pw_7Stemmer_1algorithms(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)1393 static PyObject *__pyx_pw_7Stemmer_1algorithms(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
1394 CYTHON_UNUSED PyObject *__pyx_v_aliases = 0;
1395 int __pyx_lineno = 0;
1396 const char *__pyx_filename = NULL;
1397 int __pyx_clineno = 0;
1398 PyObject *__pyx_r = 0;
1399 __Pyx_RefNannyDeclarations
1400 __Pyx_RefNannySetupContext("algorithms (wrapper)", 0);
1401 {
1402 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_aliases,0};
1403 PyObject* values[1] = {0};
1404 values[0] = ((PyObject *)Py_False);
1405 if (unlikely(__pyx_kwds)) {
1406 Py_ssize_t kw_args;
1407 const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
1408 switch (pos_args) {
1409 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1410 CYTHON_FALLTHROUGH;
1411 case 0: break;
1412 default: goto __pyx_L5_argtuple_error;
1413 }
1414 kw_args = PyDict_Size(__pyx_kwds);
1415 switch (pos_args) {
1416 case 0:
1417 if (kw_args > 0) {
1418 PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_aliases);
1419 if (value) { values[0] = value; kw_args--; }
1420 }
1421 }
1422 if (unlikely(kw_args > 0)) {
1423 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "algorithms") < 0)) __PYX_ERR(0, 43, __pyx_L3_error)
1424 }
1425 } else {
1426 switch (PyTuple_GET_SIZE(__pyx_args)) {
1427 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1428 CYTHON_FALLTHROUGH;
1429 case 0: break;
1430 default: goto __pyx_L5_argtuple_error;
1431 }
1432 }
1433 __pyx_v_aliases = values[0];
1434 }
1435 goto __pyx_L4_argument_unpacking_done;
1436 __pyx_L5_argtuple_error:;
1437 __Pyx_RaiseArgtupleInvalid("algorithms", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 43, __pyx_L3_error)
1438 __pyx_L3_error:;
1439 __Pyx_AddTraceback("Stemmer.algorithms", __pyx_clineno, __pyx_lineno, __pyx_filename);
1440 __Pyx_RefNannyFinishContext();
1441 return NULL;
1442 __pyx_L4_argument_unpacking_done:;
1443 __pyx_r = __pyx_pf_7Stemmer_algorithms(__pyx_self, __pyx_v_aliases);
1444
1445 /* function exit code */
1446 __Pyx_RefNannyFinishContext();
1447 return __pyx_r;
1448 }
1449
__pyx_pf_7Stemmer_algorithms(CYTHON_UNUSED PyObject * __pyx_self,CYTHON_UNUSED PyObject * __pyx_v_aliases)1450 static PyObject *__pyx_pf_7Stemmer_algorithms(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_aliases) {
1451 const char ** __pyx_v_algs;
1452 int __pyx_v_i;
1453 PyObject *__pyx_v_py_algs = NULL;
1454 PyObject *__pyx_v_alg = NULL;
1455 PyObject *__pyx_r = NULL;
1456 __Pyx_RefNannyDeclarations
1457 PyObject *__pyx_t_1 = NULL;
1458 int __pyx_t_2;
1459 PyObject *__pyx_t_3 = NULL;
1460 PyObject *__pyx_t_4 = NULL;
1461 int __pyx_t_5;
1462 int __pyx_lineno = 0;
1463 const char *__pyx_filename = NULL;
1464 int __pyx_clineno = 0;
1465 __Pyx_RefNannySetupContext("algorithms", 0);
1466
1467 /* "Stemmer.pyx":62
1468 * cdef const_char_ptr_ptr algs
1469 * cdef int i
1470 * py_algs = [] # <<<<<<<<<<<<<<
1471 * algs = sb_stemmer_list()
1472 * i = 0
1473 */
1474 __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 62, __pyx_L1_error)
1475 __Pyx_GOTREF(__pyx_t_1);
1476 __pyx_v_py_algs = ((PyObject*)__pyx_t_1);
1477 __pyx_t_1 = 0;
1478
1479 /* "Stemmer.pyx":63
1480 * cdef int i
1481 * py_algs = []
1482 * algs = sb_stemmer_list() # <<<<<<<<<<<<<<
1483 * i = 0
1484 * while algs[i] != NULL:
1485 */
1486 __pyx_v_algs = sb_stemmer_list();
1487
1488 /* "Stemmer.pyx":64
1489 * py_algs = []
1490 * algs = sb_stemmer_list()
1491 * i = 0 # <<<<<<<<<<<<<<
1492 * while algs[i] != NULL:
1493 * alg = algs[i]
1494 */
1495 __pyx_v_i = 0;
1496
1497 /* "Stemmer.pyx":65
1498 * algs = sb_stemmer_list()
1499 * i = 0
1500 * while algs[i] != NULL: # <<<<<<<<<<<<<<
1501 * alg = algs[i]
1502 * alg = alg.decode(u"ascii")
1503 */
1504 while (1) {
1505 __pyx_t_2 = (((__pyx_v_algs[__pyx_v_i]) != NULL) != 0);
1506 if (!__pyx_t_2) break;
1507
1508 /* "Stemmer.pyx":66
1509 * i = 0
1510 * while algs[i] != NULL:
1511 * alg = algs[i] # <<<<<<<<<<<<<<
1512 * alg = alg.decode(u"ascii")
1513 * py_algs.append(alg)
1514 */
1515 __pyx_t_1 = __Pyx_PyBytes_FromString((__pyx_v_algs[__pyx_v_i])); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 66, __pyx_L1_error)
1516 __Pyx_GOTREF(__pyx_t_1);
1517 __Pyx_XDECREF_SET(__pyx_v_alg, __pyx_t_1);
1518 __pyx_t_1 = 0;
1519
1520 /* "Stemmer.pyx":67
1521 * while algs[i] != NULL:
1522 * alg = algs[i]
1523 * alg = alg.decode(u"ascii") # <<<<<<<<<<<<<<
1524 * py_algs.append(alg)
1525 * i = i + 1
1526 */
1527 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_alg, __pyx_n_s_decode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 67, __pyx_L1_error)
1528 __Pyx_GOTREF(__pyx_t_3);
1529 __pyx_t_4 = NULL;
1530 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
1531 __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
1532 if (likely(__pyx_t_4)) {
1533 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
1534 __Pyx_INCREF(__pyx_t_4);
1535 __Pyx_INCREF(function);
1536 __Pyx_DECREF_SET(__pyx_t_3, function);
1537 }
1538 }
1539 __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_n_u_ascii) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_n_u_ascii);
1540 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
1541 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 67, __pyx_L1_error)
1542 __Pyx_GOTREF(__pyx_t_1);
1543 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1544 __Pyx_DECREF_SET(__pyx_v_alg, __pyx_t_1);
1545 __pyx_t_1 = 0;
1546
1547 /* "Stemmer.pyx":68
1548 * alg = algs[i]
1549 * alg = alg.decode(u"ascii")
1550 * py_algs.append(alg) # <<<<<<<<<<<<<<
1551 * i = i + 1
1552 * return py_algs
1553 */
1554 __pyx_t_5 = __Pyx_PyList_Append(__pyx_v_py_algs, __pyx_v_alg); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 68, __pyx_L1_error)
1555
1556 /* "Stemmer.pyx":69
1557 * alg = alg.decode(u"ascii")
1558 * py_algs.append(alg)
1559 * i = i + 1 # <<<<<<<<<<<<<<
1560 * return py_algs
1561 *
1562 */
1563 __pyx_v_i = (__pyx_v_i + 1);
1564 }
1565
1566 /* "Stemmer.pyx":70
1567 * py_algs.append(alg)
1568 * i = i + 1
1569 * return py_algs # <<<<<<<<<<<<<<
1570 *
1571 * def version():
1572 */
1573 __Pyx_XDECREF(__pyx_r);
1574 __Pyx_INCREF(__pyx_v_py_algs);
1575 __pyx_r = __pyx_v_py_algs;
1576 goto __pyx_L0;
1577
1578 /* "Stemmer.pyx":43
1579 * cdef int sb_stemmer_length(sb_stemmer * stemmer)
1580 *
1581 * def algorithms(aliases=False): # <<<<<<<<<<<<<<
1582 * """Get a list of the names of the available stemming algorithms.
1583 *
1584 */
1585
1586 /* function exit code */
1587 __pyx_L1_error:;
1588 __Pyx_XDECREF(__pyx_t_1);
1589 __Pyx_XDECREF(__pyx_t_3);
1590 __Pyx_XDECREF(__pyx_t_4);
1591 __Pyx_AddTraceback("Stemmer.algorithms", __pyx_clineno, __pyx_lineno, __pyx_filename);
1592 __pyx_r = NULL;
1593 __pyx_L0:;
1594 __Pyx_XDECREF(__pyx_v_py_algs);
1595 __Pyx_XDECREF(__pyx_v_alg);
1596 __Pyx_XGIVEREF(__pyx_r);
1597 __Pyx_RefNannyFinishContext();
1598 return __pyx_r;
1599 }
1600
1601 /* "Stemmer.pyx":72
1602 * return py_algs
1603 *
1604 * def version(): # <<<<<<<<<<<<<<
1605 * """Get the version string of the stemming module.
1606 *
1607 */
1608
1609 /* Python wrapper */
1610 static PyObject *__pyx_pw_7Stemmer_3version(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
1611 static char __pyx_doc_7Stemmer_2version[] = "Get the version string of the stemming module.\n\n This version number is for the Stemmer module as a whole (not for an\n individual stemming algorithm).\n\n ";
1612 static PyMethodDef __pyx_mdef_7Stemmer_3version = {"version", (PyCFunction)__pyx_pw_7Stemmer_3version, METH_NOARGS, __pyx_doc_7Stemmer_2version};
__pyx_pw_7Stemmer_3version(PyObject * __pyx_self,CYTHON_UNUSED PyObject * unused)1613 static PyObject *__pyx_pw_7Stemmer_3version(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
1614 PyObject *__pyx_r = 0;
1615 __Pyx_RefNannyDeclarations
1616 __Pyx_RefNannySetupContext("version (wrapper)", 0);
1617 __pyx_r = __pyx_pf_7Stemmer_2version(__pyx_self);
1618
1619 /* function exit code */
1620 __Pyx_RefNannyFinishContext();
1621 return __pyx_r;
1622 }
1623
__pyx_pf_7Stemmer_2version(CYTHON_UNUSED PyObject * __pyx_self)1624 static PyObject *__pyx_pf_7Stemmer_2version(CYTHON_UNUSED PyObject *__pyx_self) {
1625 PyObject *__pyx_r = NULL;
1626 __Pyx_RefNannyDeclarations
1627 __Pyx_RefNannySetupContext("version", 0);
1628
1629 /* "Stemmer.pyx":79
1630 *
1631 * """
1632 * return '2.0.1' # <<<<<<<<<<<<<<
1633 *
1634 * cdef class Stemmer:
1635 */
1636 __Pyx_XDECREF(__pyx_r);
1637 __Pyx_INCREF(__pyx_kp_s_2_0_1);
1638 __pyx_r = __pyx_kp_s_2_0_1;
1639 goto __pyx_L0;
1640
1641 /* "Stemmer.pyx":72
1642 * return py_algs
1643 *
1644 * def version(): # <<<<<<<<<<<<<<
1645 * """Get the version string of the stemming module.
1646 *
1647 */
1648
1649 /* function exit code */
1650 __pyx_L0:;
1651 __Pyx_XGIVEREF(__pyx_r);
1652 __Pyx_RefNannyFinishContext();
1653 return __pyx_r;
1654 }
1655
1656 /* "Stemmer.pyx":114
1657 * cdef int max_cache_size
1658 *
1659 * def __init__ (self, algorithm, int maxCacheSize = 10000): # <<<<<<<<<<<<<<
1660 * """Initialise a stemmer.
1661 *
1662 */
1663
1664 /* Python wrapper */
1665 static int __pyx_pw_7Stemmer_7Stemmer_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
1666 static char __pyx_doc_7Stemmer_7Stemmer___init__[] = "Initialise a stemmer.\n\n See the class documentation for details.\n\n ";
1667 #if CYTHON_COMPILING_IN_CPYTHON
1668 struct wrapperbase __pyx_wrapperbase_7Stemmer_7Stemmer___init__;
1669 #endif
__pyx_pw_7Stemmer_7Stemmer_1__init__(PyObject * __pyx_v_self,PyObject * __pyx_args,PyObject * __pyx_kwds)1670 static int __pyx_pw_7Stemmer_7Stemmer_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
1671 PyObject *__pyx_v_algorithm = 0;
1672 int __pyx_v_maxCacheSize;
1673 int __pyx_lineno = 0;
1674 const char *__pyx_filename = NULL;
1675 int __pyx_clineno = 0;
1676 int __pyx_r;
1677 __Pyx_RefNannyDeclarations
1678 __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
1679 {
1680 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_algorithm,&__pyx_n_s_maxCacheSize,0};
1681 PyObject* values[2] = {0,0};
1682 if (unlikely(__pyx_kwds)) {
1683 Py_ssize_t kw_args;
1684 const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
1685 switch (pos_args) {
1686 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
1687 CYTHON_FALLTHROUGH;
1688 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1689 CYTHON_FALLTHROUGH;
1690 case 0: break;
1691 default: goto __pyx_L5_argtuple_error;
1692 }
1693 kw_args = PyDict_Size(__pyx_kwds);
1694 switch (pos_args) {
1695 case 0:
1696 if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_algorithm)) != 0)) kw_args--;
1697 else goto __pyx_L5_argtuple_error;
1698 CYTHON_FALLTHROUGH;
1699 case 1:
1700 if (kw_args > 0) {
1701 PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_maxCacheSize);
1702 if (value) { values[1] = value; kw_args--; }
1703 }
1704 }
1705 if (unlikely(kw_args > 0)) {
1706 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 114, __pyx_L3_error)
1707 }
1708 } else {
1709 switch (PyTuple_GET_SIZE(__pyx_args)) {
1710 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
1711 CYTHON_FALLTHROUGH;
1712 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1713 break;
1714 default: goto __pyx_L5_argtuple_error;
1715 }
1716 }
1717 __pyx_v_algorithm = values[0];
1718 if (values[1]) {
1719 __pyx_v_maxCacheSize = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_maxCacheSize == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 114, __pyx_L3_error)
1720 } else {
1721 __pyx_v_maxCacheSize = ((int)0x2710);
1722 }
1723 }
1724 goto __pyx_L4_argument_unpacking_done;
1725 __pyx_L5_argtuple_error:;
1726 __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 114, __pyx_L3_error)
1727 __pyx_L3_error:;
1728 __Pyx_AddTraceback("Stemmer.Stemmer.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
1729 __Pyx_RefNannyFinishContext();
1730 return -1;
1731 __pyx_L4_argument_unpacking_done:;
1732 __pyx_r = __pyx_pf_7Stemmer_7Stemmer___init__(((struct __pyx_obj_7Stemmer_Stemmer *)__pyx_v_self), __pyx_v_algorithm, __pyx_v_maxCacheSize);
1733
1734 /* function exit code */
1735 __Pyx_RefNannyFinishContext();
1736 return __pyx_r;
1737 }
1738
__pyx_pf_7Stemmer_7Stemmer___init__(struct __pyx_obj_7Stemmer_Stemmer * __pyx_v_self,PyObject * __pyx_v_algorithm,int __pyx_v_maxCacheSize)1739 static int __pyx_pf_7Stemmer_7Stemmer___init__(struct __pyx_obj_7Stemmer_Stemmer *__pyx_v_self, PyObject *__pyx_v_algorithm, int __pyx_v_maxCacheSize) {
1740 PyObject *__pyx_v_alg = NULL;
1741 int __pyx_r;
1742 __Pyx_RefNannyDeclarations
1743 PyObject *__pyx_t_1 = NULL;
1744 PyObject *__pyx_t_2 = NULL;
1745 PyObject *__pyx_t_3 = NULL;
1746 char const *__pyx_t_4;
1747 int __pyx_t_5;
1748 int __pyx_lineno = 0;
1749 const char *__pyx_filename = NULL;
1750 int __pyx_clineno = 0;
1751 __Pyx_RefNannySetupContext("__init__", 0);
1752
1753 /* "Stemmer.pyx":120
1754 *
1755 * """
1756 * alg = algorithm.encode(u'ascii') # <<<<<<<<<<<<<<
1757 * self.cobj = sb_stemmer_new(alg, 'UTF_8')
1758 * if self.cobj == NULL:
1759 */
1760 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_algorithm, __pyx_n_s_encode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 120, __pyx_L1_error)
1761 __Pyx_GOTREF(__pyx_t_2);
1762 __pyx_t_3 = NULL;
1763 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
1764 __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
1765 if (likely(__pyx_t_3)) {
1766 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
1767 __Pyx_INCREF(__pyx_t_3);
1768 __Pyx_INCREF(function);
1769 __Pyx_DECREF_SET(__pyx_t_2, function);
1770 }
1771 }
1772 __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_n_u_ascii) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_n_u_ascii);
1773 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
1774 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 120, __pyx_L1_error)
1775 __Pyx_GOTREF(__pyx_t_1);
1776 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1777 __pyx_v_alg = __pyx_t_1;
1778 __pyx_t_1 = 0;
1779
1780 /* "Stemmer.pyx":121
1781 * """
1782 * alg = algorithm.encode(u'ascii')
1783 * self.cobj = sb_stemmer_new(alg, 'UTF_8') # <<<<<<<<<<<<<<
1784 * if self.cobj == NULL:
1785 * raise KeyError("Stemming algorithm '%s' not found" % algorithm)
1786 */
1787 __pyx_t_4 = __Pyx_PyObject_AsString(__pyx_v_alg); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) __PYX_ERR(0, 121, __pyx_L1_error)
1788 __pyx_v_self->cobj = sb_stemmer_new(__pyx_t_4, ((char const *)"UTF_8"));
1789
1790 /* "Stemmer.pyx":122
1791 * alg = algorithm.encode(u'ascii')
1792 * self.cobj = sb_stemmer_new(alg, 'UTF_8')
1793 * if self.cobj == NULL: # <<<<<<<<<<<<<<
1794 * raise KeyError("Stemming algorithm '%s' not found" % algorithm)
1795 * self.max_cache_size = maxCacheSize
1796 */
1797 __pyx_t_5 = ((__pyx_v_self->cobj == NULL) != 0);
1798 if (unlikely(__pyx_t_5)) {
1799
1800 /* "Stemmer.pyx":123
1801 * self.cobj = sb_stemmer_new(alg, 'UTF_8')
1802 * if self.cobj == NULL:
1803 * raise KeyError("Stemming algorithm '%s' not found" % algorithm) # <<<<<<<<<<<<<<
1804 * self.max_cache_size = maxCacheSize
1805 * self.counter = 0
1806 */
1807 __pyx_t_1 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Stemming_algorithm_s_not_found, __pyx_v_algorithm); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 123, __pyx_L1_error)
1808 __Pyx_GOTREF(__pyx_t_1);
1809 __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_KeyError, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 123, __pyx_L1_error)
1810 __Pyx_GOTREF(__pyx_t_2);
1811 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1812 __Pyx_Raise(__pyx_t_2, 0, 0, 0);
1813 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1814 __PYX_ERR(0, 123, __pyx_L1_error)
1815
1816 /* "Stemmer.pyx":122
1817 * alg = algorithm.encode(u'ascii')
1818 * self.cobj = sb_stemmer_new(alg, 'UTF_8')
1819 * if self.cobj == NULL: # <<<<<<<<<<<<<<
1820 * raise KeyError("Stemming algorithm '%s' not found" % algorithm)
1821 * self.max_cache_size = maxCacheSize
1822 */
1823 }
1824
1825 /* "Stemmer.pyx":124
1826 * if self.cobj == NULL:
1827 * raise KeyError("Stemming algorithm '%s' not found" % algorithm)
1828 * self.max_cache_size = maxCacheSize # <<<<<<<<<<<<<<
1829 * self.counter = 0
1830 * self.cache = {}
1831 */
1832 __pyx_v_self->max_cache_size = __pyx_v_maxCacheSize;
1833
1834 /* "Stemmer.pyx":125
1835 * raise KeyError("Stemming algorithm '%s' not found" % algorithm)
1836 * self.max_cache_size = maxCacheSize
1837 * self.counter = 0 # <<<<<<<<<<<<<<
1838 * self.cache = {}
1839 *
1840 */
1841 __Pyx_INCREF(__pyx_int_0);
1842 __Pyx_GIVEREF(__pyx_int_0);
1843 __Pyx_GOTREF(__pyx_v_self->counter);
1844 __Pyx_DECREF(__pyx_v_self->counter);
1845 __pyx_v_self->counter = __pyx_int_0;
1846
1847 /* "Stemmer.pyx":126
1848 * self.max_cache_size = maxCacheSize
1849 * self.counter = 0
1850 * self.cache = {} # <<<<<<<<<<<<<<
1851 *
1852 * def __dealloc__ (self):
1853 */
1854 __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 126, __pyx_L1_error)
1855 __Pyx_GOTREF(__pyx_t_2);
1856 __Pyx_GIVEREF(__pyx_t_2);
1857 __Pyx_GOTREF(__pyx_v_self->cache);
1858 __Pyx_DECREF(__pyx_v_self->cache);
1859 __pyx_v_self->cache = __pyx_t_2;
1860 __pyx_t_2 = 0;
1861
1862 /* "Stemmer.pyx":114
1863 * cdef int max_cache_size
1864 *
1865 * def __init__ (self, algorithm, int maxCacheSize = 10000): # <<<<<<<<<<<<<<
1866 * """Initialise a stemmer.
1867 *
1868 */
1869
1870 /* function exit code */
1871 __pyx_r = 0;
1872 goto __pyx_L0;
1873 __pyx_L1_error:;
1874 __Pyx_XDECREF(__pyx_t_1);
1875 __Pyx_XDECREF(__pyx_t_2);
1876 __Pyx_XDECREF(__pyx_t_3);
1877 __Pyx_AddTraceback("Stemmer.Stemmer.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
1878 __pyx_r = -1;
1879 __pyx_L0:;
1880 __Pyx_XDECREF(__pyx_v_alg);
1881 __Pyx_RefNannyFinishContext();
1882 return __pyx_r;
1883 }
1884
1885 /* "Stemmer.pyx":128
1886 * self.cache = {}
1887 *
1888 * def __dealloc__ (self): # <<<<<<<<<<<<<<
1889 * sb_stemmer_delete(self.cobj)
1890 *
1891 */
1892
1893 /* Python wrapper */
1894 static void __pyx_pw_7Stemmer_7Stemmer_3__dealloc__(PyObject *__pyx_v_self); /*proto*/
__pyx_pw_7Stemmer_7Stemmer_3__dealloc__(PyObject * __pyx_v_self)1895 static void __pyx_pw_7Stemmer_7Stemmer_3__dealloc__(PyObject *__pyx_v_self) {
1896 __Pyx_RefNannyDeclarations
1897 __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
1898 __pyx_pf_7Stemmer_7Stemmer_2__dealloc__(((struct __pyx_obj_7Stemmer_Stemmer *)__pyx_v_self));
1899
1900 /* function exit code */
1901 __Pyx_RefNannyFinishContext();
1902 }
1903
__pyx_pf_7Stemmer_7Stemmer_2__dealloc__(struct __pyx_obj_7Stemmer_Stemmer * __pyx_v_self)1904 static void __pyx_pf_7Stemmer_7Stemmer_2__dealloc__(struct __pyx_obj_7Stemmer_Stemmer *__pyx_v_self) {
1905 __Pyx_RefNannyDeclarations
1906 __Pyx_RefNannySetupContext("__dealloc__", 0);
1907
1908 /* "Stemmer.pyx":129
1909 *
1910 * def __dealloc__ (self):
1911 * sb_stemmer_delete(self.cobj) # <<<<<<<<<<<<<<
1912 *
1913 * property maxCacheSize:
1914 */
1915 sb_stemmer_delete(__pyx_v_self->cobj);
1916
1917 /* "Stemmer.pyx":128
1918 * self.cache = {}
1919 *
1920 * def __dealloc__ (self): # <<<<<<<<<<<<<<
1921 * sb_stemmer_delete(self.cobj)
1922 *
1923 */
1924
1925 /* function exit code */
1926 __Pyx_RefNannyFinishContext();
1927 }
1928
1929 /* "Stemmer.pyx":141
1930 *
1931 * """
1932 * def __set__(self, int size): # <<<<<<<<<<<<<<
1933 * self.max_cache_size = size
1934 * if size == 0:
1935 */
1936
1937 /* Python wrapper */
1938 static int __pyx_pw_7Stemmer_7Stemmer_12maxCacheSize_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_size); /*proto*/
__pyx_pw_7Stemmer_7Stemmer_12maxCacheSize_1__set__(PyObject * __pyx_v_self,PyObject * __pyx_arg_size)1939 static int __pyx_pw_7Stemmer_7Stemmer_12maxCacheSize_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_size) {
1940 int __pyx_v_size;
1941 int __pyx_lineno = 0;
1942 const char *__pyx_filename = NULL;
1943 int __pyx_clineno = 0;
1944 int __pyx_r;
1945 __Pyx_RefNannyDeclarations
1946 __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
1947 assert(__pyx_arg_size); {
1948 __pyx_v_size = __Pyx_PyInt_As_int(__pyx_arg_size); if (unlikely((__pyx_v_size == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 141, __pyx_L3_error)
1949 }
1950 goto __pyx_L4_argument_unpacking_done;
1951 __pyx_L3_error:;
1952 __Pyx_AddTraceback("Stemmer.Stemmer.maxCacheSize.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
1953 __Pyx_RefNannyFinishContext();
1954 return -1;
1955 __pyx_L4_argument_unpacking_done:;
1956 __pyx_r = __pyx_pf_7Stemmer_7Stemmer_12maxCacheSize___set__(((struct __pyx_obj_7Stemmer_Stemmer *)__pyx_v_self), ((int)__pyx_v_size));
1957
1958 /* function exit code */
1959 __Pyx_RefNannyFinishContext();
1960 return __pyx_r;
1961 }
1962
__pyx_pf_7Stemmer_7Stemmer_12maxCacheSize___set__(struct __pyx_obj_7Stemmer_Stemmer * __pyx_v_self,int __pyx_v_size)1963 static int __pyx_pf_7Stemmer_7Stemmer_12maxCacheSize___set__(struct __pyx_obj_7Stemmer_Stemmer *__pyx_v_self, int __pyx_v_size) {
1964 int __pyx_r;
1965 __Pyx_RefNannyDeclarations
1966 int __pyx_t_1;
1967 PyObject *__pyx_t_2 = NULL;
1968 PyObject *__pyx_t_3 = NULL;
1969 PyObject *__pyx_t_4 = NULL;
1970 int __pyx_lineno = 0;
1971 const char *__pyx_filename = NULL;
1972 int __pyx_clineno = 0;
1973 __Pyx_RefNannySetupContext("__set__", 0);
1974
1975 /* "Stemmer.pyx":142
1976 * """
1977 * def __set__(self, int size):
1978 * self.max_cache_size = size # <<<<<<<<<<<<<<
1979 * if size == 0:
1980 * self.cache = {}
1981 */
1982 __pyx_v_self->max_cache_size = __pyx_v_size;
1983
1984 /* "Stemmer.pyx":143
1985 * def __set__(self, int size):
1986 * self.max_cache_size = size
1987 * if size == 0: # <<<<<<<<<<<<<<
1988 * self.cache = {}
1989 * self.counter = 0
1990 */
1991 __pyx_t_1 = ((__pyx_v_size == 0) != 0);
1992 if (__pyx_t_1) {
1993
1994 /* "Stemmer.pyx":144
1995 * self.max_cache_size = size
1996 * if size == 0:
1997 * self.cache = {} # <<<<<<<<<<<<<<
1998 * self.counter = 0
1999 * else:
2000 */
2001 __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 144, __pyx_L1_error)
2002 __Pyx_GOTREF(__pyx_t_2);
2003 __Pyx_GIVEREF(__pyx_t_2);
2004 __Pyx_GOTREF(__pyx_v_self->cache);
2005 __Pyx_DECREF(__pyx_v_self->cache);
2006 __pyx_v_self->cache = __pyx_t_2;
2007 __pyx_t_2 = 0;
2008
2009 /* "Stemmer.pyx":145
2010 * if size == 0:
2011 * self.cache = {}
2012 * self.counter = 0 # <<<<<<<<<<<<<<
2013 * else:
2014 * self.__purgeCache()
2015 */
2016 __Pyx_INCREF(__pyx_int_0);
2017 __Pyx_GIVEREF(__pyx_int_0);
2018 __Pyx_GOTREF(__pyx_v_self->counter);
2019 __Pyx_DECREF(__pyx_v_self->counter);
2020 __pyx_v_self->counter = __pyx_int_0;
2021
2022 /* "Stemmer.pyx":143
2023 * def __set__(self, int size):
2024 * self.max_cache_size = size
2025 * if size == 0: # <<<<<<<<<<<<<<
2026 * self.cache = {}
2027 * self.counter = 0
2028 */
2029 goto __pyx_L3;
2030 }
2031
2032 /* "Stemmer.pyx":147
2033 * self.counter = 0
2034 * else:
2035 * self.__purgeCache() # <<<<<<<<<<<<<<
2036 * def __get__(self):
2037 * return self.max_cache_size
2038 */
2039 /*else*/ {
2040 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_purgeCache); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 147, __pyx_L1_error)
2041 __Pyx_GOTREF(__pyx_t_3);
2042 __pyx_t_4 = NULL;
2043 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
2044 __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
2045 if (likely(__pyx_t_4)) {
2046 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
2047 __Pyx_INCREF(__pyx_t_4);
2048 __Pyx_INCREF(function);
2049 __Pyx_DECREF_SET(__pyx_t_3, function);
2050 }
2051 }
2052 __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
2053 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
2054 if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 147, __pyx_L1_error)
2055 __Pyx_GOTREF(__pyx_t_2);
2056 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2057 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2058 }
2059 __pyx_L3:;
2060
2061 /* "Stemmer.pyx":141
2062 *
2063 * """
2064 * def __set__(self, int size): # <<<<<<<<<<<<<<
2065 * self.max_cache_size = size
2066 * if size == 0:
2067 */
2068
2069 /* function exit code */
2070 __pyx_r = 0;
2071 goto __pyx_L0;
2072 __pyx_L1_error:;
2073 __Pyx_XDECREF(__pyx_t_2);
2074 __Pyx_XDECREF(__pyx_t_3);
2075 __Pyx_XDECREF(__pyx_t_4);
2076 __Pyx_AddTraceback("Stemmer.Stemmer.maxCacheSize.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
2077 __pyx_r = -1;
2078 __pyx_L0:;
2079 __Pyx_RefNannyFinishContext();
2080 return __pyx_r;
2081 }
2082
2083 /* "Stemmer.pyx":148
2084 * else:
2085 * self.__purgeCache()
2086 * def __get__(self): # <<<<<<<<<<<<<<
2087 * return self.max_cache_size
2088 *
2089 */
2090
2091 /* Python wrapper */
2092 static PyObject *__pyx_pw_7Stemmer_7Stemmer_12maxCacheSize_3__get__(PyObject *__pyx_v_self); /*proto*/
__pyx_pw_7Stemmer_7Stemmer_12maxCacheSize_3__get__(PyObject * __pyx_v_self)2093 static PyObject *__pyx_pw_7Stemmer_7Stemmer_12maxCacheSize_3__get__(PyObject *__pyx_v_self) {
2094 PyObject *__pyx_r = 0;
2095 __Pyx_RefNannyDeclarations
2096 __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
2097 __pyx_r = __pyx_pf_7Stemmer_7Stemmer_12maxCacheSize_2__get__(((struct __pyx_obj_7Stemmer_Stemmer *)__pyx_v_self));
2098
2099 /* function exit code */
2100 __Pyx_RefNannyFinishContext();
2101 return __pyx_r;
2102 }
2103
__pyx_pf_7Stemmer_7Stemmer_12maxCacheSize_2__get__(struct __pyx_obj_7Stemmer_Stemmer * __pyx_v_self)2104 static PyObject *__pyx_pf_7Stemmer_7Stemmer_12maxCacheSize_2__get__(struct __pyx_obj_7Stemmer_Stemmer *__pyx_v_self) {
2105 PyObject *__pyx_r = NULL;
2106 __Pyx_RefNannyDeclarations
2107 PyObject *__pyx_t_1 = NULL;
2108 int __pyx_lineno = 0;
2109 const char *__pyx_filename = NULL;
2110 int __pyx_clineno = 0;
2111 __Pyx_RefNannySetupContext("__get__", 0);
2112
2113 /* "Stemmer.pyx":149
2114 * self.__purgeCache()
2115 * def __get__(self):
2116 * return self.max_cache_size # <<<<<<<<<<<<<<
2117 *
2118 * def __purgeCache (self):
2119 */
2120 __Pyx_XDECREF(__pyx_r);
2121 __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->max_cache_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 149, __pyx_L1_error)
2122 __Pyx_GOTREF(__pyx_t_1);
2123 __pyx_r = __pyx_t_1;
2124 __pyx_t_1 = 0;
2125 goto __pyx_L0;
2126
2127 /* "Stemmer.pyx":148
2128 * else:
2129 * self.__purgeCache()
2130 * def __get__(self): # <<<<<<<<<<<<<<
2131 * return self.max_cache_size
2132 *
2133 */
2134
2135 /* function exit code */
2136 __pyx_L1_error:;
2137 __Pyx_XDECREF(__pyx_t_1);
2138 __Pyx_AddTraceback("Stemmer.Stemmer.maxCacheSize.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
2139 __pyx_r = NULL;
2140 __pyx_L0:;
2141 __Pyx_XGIVEREF(__pyx_r);
2142 __Pyx_RefNannyFinishContext();
2143 return __pyx_r;
2144 }
2145
2146 /* "Stemmer.pyx":151
2147 * return self.max_cache_size
2148 *
2149 * def __purgeCache (self): # <<<<<<<<<<<<<<
2150 * if len(self.cache) < self.max_cache_size:
2151 * return
2152 */
2153
2154 /* Python wrapper */
2155 static PyObject *__pyx_pw_7Stemmer_7Stemmer_5__purgeCache(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pw_7Stemmer_7Stemmer_5__purgeCache(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)2156 static PyObject *__pyx_pw_7Stemmer_7Stemmer_5__purgeCache(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
2157 PyObject *__pyx_r = 0;
2158 __Pyx_RefNannyDeclarations
2159 __Pyx_RefNannySetupContext("__purgeCache (wrapper)", 0);
2160 __pyx_r = __pyx_pf_7Stemmer_7Stemmer_4__purgeCache(((struct __pyx_obj_7Stemmer_Stemmer *)__pyx_v_self));
2161
2162 /* function exit code */
2163 __Pyx_RefNannyFinishContext();
2164 return __pyx_r;
2165 }
2166
__pyx_pf_7Stemmer_7Stemmer_4__purgeCache(struct __pyx_obj_7Stemmer_Stemmer * __pyx_v_self)2167 static PyObject *__pyx_pf_7Stemmer_7Stemmer_4__purgeCache(struct __pyx_obj_7Stemmer_Stemmer *__pyx_v_self) {
2168 PyObject *__pyx_v_newcache = NULL;
2169 PyObject *__pyx_v_mincounter = NULL;
2170 PyObject *__pyx_v_word = NULL;
2171 PyObject *__pyx_v_cacheditem = NULL;
2172 PyObject *__pyx_r = NULL;
2173 __Pyx_RefNannyDeclarations
2174 PyObject *__pyx_t_1 = NULL;
2175 Py_ssize_t __pyx_t_2;
2176 int __pyx_t_3;
2177 PyObject *__pyx_t_4 = NULL;
2178 Py_ssize_t __pyx_t_5;
2179 int __pyx_t_6;
2180 PyObject *__pyx_t_7 = NULL;
2181 int __pyx_t_8;
2182 int __pyx_lineno = 0;
2183 const char *__pyx_filename = NULL;
2184 int __pyx_clineno = 0;
2185 __Pyx_RefNannySetupContext("__purgeCache", 0);
2186
2187 /* "Stemmer.pyx":152
2188 *
2189 * def __purgeCache (self):
2190 * if len(self.cache) < self.max_cache_size: # <<<<<<<<<<<<<<
2191 * return
2192 * newcache = {}
2193 */
2194 __pyx_t_1 = __pyx_v_self->cache;
2195 __Pyx_INCREF(__pyx_t_1);
2196 __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 152, __pyx_L1_error)
2197 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2198 __pyx_t_3 = ((__pyx_t_2 < __pyx_v_self->max_cache_size) != 0);
2199 if (__pyx_t_3) {
2200
2201 /* "Stemmer.pyx":153
2202 * def __purgeCache (self):
2203 * if len(self.cache) < self.max_cache_size:
2204 * return # <<<<<<<<<<<<<<
2205 * newcache = {}
2206 * mincounter = self.counter - int(self.max_cache_size * 8 / 10)
2207 */
2208 __Pyx_XDECREF(__pyx_r);
2209 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
2210 goto __pyx_L0;
2211
2212 /* "Stemmer.pyx":152
2213 *
2214 * def __purgeCache (self):
2215 * if len(self.cache) < self.max_cache_size: # <<<<<<<<<<<<<<
2216 * return
2217 * newcache = {}
2218 */
2219 }
2220
2221 /* "Stemmer.pyx":154
2222 * if len(self.cache) < self.max_cache_size:
2223 * return
2224 * newcache = {} # <<<<<<<<<<<<<<
2225 * mincounter = self.counter - int(self.max_cache_size * 8 / 10)
2226 * for (word, cacheditem) in self.cache.iteritems():
2227 */
2228 __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 154, __pyx_L1_error)
2229 __Pyx_GOTREF(__pyx_t_1);
2230 __pyx_v_newcache = ((PyObject*)__pyx_t_1);
2231 __pyx_t_1 = 0;
2232
2233 /* "Stemmer.pyx":155
2234 * return
2235 * newcache = {}
2236 * mincounter = self.counter - int(self.max_cache_size * 8 / 10) # <<<<<<<<<<<<<<
2237 * for (word, cacheditem) in self.cache.iteritems():
2238 * if cacheditem[1] > mincounter:
2239 */
2240 __pyx_t_1 = __Pyx_PyInt_From_long(__Pyx_div_long((__pyx_v_self->max_cache_size * 8), 10)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 155, __pyx_L1_error)
2241 __Pyx_GOTREF(__pyx_t_1);
2242 __pyx_t_4 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyInt_Type)), __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 155, __pyx_L1_error)
2243 __Pyx_GOTREF(__pyx_t_4);
2244 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2245 __pyx_t_1 = PyNumber_Subtract(__pyx_v_self->counter, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 155, __pyx_L1_error)
2246 __Pyx_GOTREF(__pyx_t_1);
2247 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2248 __pyx_v_mincounter = __pyx_t_1;
2249 __pyx_t_1 = 0;
2250
2251 /* "Stemmer.pyx":156
2252 * newcache = {}
2253 * mincounter = self.counter - int(self.max_cache_size * 8 / 10)
2254 * for (word, cacheditem) in self.cache.iteritems(): # <<<<<<<<<<<<<<
2255 * if cacheditem[1] > mincounter:
2256 * newcache[word] = cacheditem
2257 */
2258 __pyx_t_2 = 0;
2259 if (unlikely(__pyx_v_self->cache == Py_None)) {
2260 PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "iteritems");
2261 __PYX_ERR(0, 156, __pyx_L1_error)
2262 }
2263 __pyx_t_4 = __Pyx_dict_iterator(__pyx_v_self->cache, 0, __pyx_n_s_iteritems, (&__pyx_t_5), (&__pyx_t_6)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 156, __pyx_L1_error)
2264 __Pyx_GOTREF(__pyx_t_4);
2265 __Pyx_XDECREF(__pyx_t_1);
2266 __pyx_t_1 = __pyx_t_4;
2267 __pyx_t_4 = 0;
2268 while (1) {
2269 __pyx_t_8 = __Pyx_dict_iter_next(__pyx_t_1, __pyx_t_5, &__pyx_t_2, &__pyx_t_4, &__pyx_t_7, NULL, __pyx_t_6);
2270 if (unlikely(__pyx_t_8 == 0)) break;
2271 if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 156, __pyx_L1_error)
2272 __Pyx_GOTREF(__pyx_t_4);
2273 __Pyx_GOTREF(__pyx_t_7);
2274 __Pyx_XDECREF_SET(__pyx_v_word, __pyx_t_4);
2275 __pyx_t_4 = 0;
2276 __Pyx_XDECREF_SET(__pyx_v_cacheditem, __pyx_t_7);
2277 __pyx_t_7 = 0;
2278
2279 /* "Stemmer.pyx":157
2280 * mincounter = self.counter - int(self.max_cache_size * 8 / 10)
2281 * for (word, cacheditem) in self.cache.iteritems():
2282 * if cacheditem[1] > mincounter: # <<<<<<<<<<<<<<
2283 * newcache[word] = cacheditem
2284 * self.cache = newcache
2285 */
2286 __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_cacheditem, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 157, __pyx_L1_error)
2287 __Pyx_GOTREF(__pyx_t_7);
2288 __pyx_t_4 = PyObject_RichCompare(__pyx_t_7, __pyx_v_mincounter, Py_GT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 157, __pyx_L1_error)
2289 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
2290 __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 157, __pyx_L1_error)
2291 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2292 if (__pyx_t_3) {
2293
2294 /* "Stemmer.pyx":158
2295 * for (word, cacheditem) in self.cache.iteritems():
2296 * if cacheditem[1] > mincounter:
2297 * newcache[word] = cacheditem # <<<<<<<<<<<<<<
2298 * self.cache = newcache
2299 *
2300 */
2301 if (unlikely(PyDict_SetItem(__pyx_v_newcache, __pyx_v_word, __pyx_v_cacheditem) < 0)) __PYX_ERR(0, 158, __pyx_L1_error)
2302
2303 /* "Stemmer.pyx":157
2304 * mincounter = self.counter - int(self.max_cache_size * 8 / 10)
2305 * for (word, cacheditem) in self.cache.iteritems():
2306 * if cacheditem[1] > mincounter: # <<<<<<<<<<<<<<
2307 * newcache[word] = cacheditem
2308 * self.cache = newcache
2309 */
2310 }
2311 }
2312 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2313
2314 /* "Stemmer.pyx":159
2315 * if cacheditem[1] > mincounter:
2316 * newcache[word] = cacheditem
2317 * self.cache = newcache # <<<<<<<<<<<<<<
2318 *
2319 * def stemWord (self, word):
2320 */
2321 __Pyx_INCREF(__pyx_v_newcache);
2322 __Pyx_GIVEREF(__pyx_v_newcache);
2323 __Pyx_GOTREF(__pyx_v_self->cache);
2324 __Pyx_DECREF(__pyx_v_self->cache);
2325 __pyx_v_self->cache = __pyx_v_newcache;
2326
2327 /* "Stemmer.pyx":151
2328 * return self.max_cache_size
2329 *
2330 * def __purgeCache (self): # <<<<<<<<<<<<<<
2331 * if len(self.cache) < self.max_cache_size:
2332 * return
2333 */
2334
2335 /* function exit code */
2336 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
2337 goto __pyx_L0;
2338 __pyx_L1_error:;
2339 __Pyx_XDECREF(__pyx_t_1);
2340 __Pyx_XDECREF(__pyx_t_4);
2341 __Pyx_XDECREF(__pyx_t_7);
2342 __Pyx_AddTraceback("Stemmer.Stemmer.__purgeCache", __pyx_clineno, __pyx_lineno, __pyx_filename);
2343 __pyx_r = NULL;
2344 __pyx_L0:;
2345 __Pyx_XDECREF(__pyx_v_newcache);
2346 __Pyx_XDECREF(__pyx_v_mincounter);
2347 __Pyx_XDECREF(__pyx_v_word);
2348 __Pyx_XDECREF(__pyx_v_cacheditem);
2349 __Pyx_XGIVEREF(__pyx_r);
2350 __Pyx_RefNannyFinishContext();
2351 return __pyx_r;
2352 }
2353
2354 /* "Stemmer.pyx":161
2355 * self.cache = newcache
2356 *
2357 * def stemWord (self, word): # <<<<<<<<<<<<<<
2358 * """Stem a word.
2359 *
2360 */
2361
2362 /* Python wrapper */
2363 static PyObject *__pyx_pw_7Stemmer_7Stemmer_7stemWord(PyObject *__pyx_v_self, PyObject *__pyx_v_word); /*proto*/
2364 static char __pyx_doc_7Stemmer_7Stemmer_6stemWord[] = "Stem a word.\n\n This takes a single argument, ``word``, which should either be a UTF-8\n encoded string, or a unicode object.\n\n The result is the stemmed form of the word. If the word supplied\n was a unicode object, the result will be a unicode object: if the\n word supplied was a string, the result will be a UTF-8 encoded\n string.\n\n ";
__pyx_pw_7Stemmer_7Stemmer_7stemWord(PyObject * __pyx_v_self,PyObject * __pyx_v_word)2365 static PyObject *__pyx_pw_7Stemmer_7Stemmer_7stemWord(PyObject *__pyx_v_self, PyObject *__pyx_v_word) {
2366 PyObject *__pyx_r = 0;
2367 __Pyx_RefNannyDeclarations
2368 __Pyx_RefNannySetupContext("stemWord (wrapper)", 0);
2369 __pyx_r = __pyx_pf_7Stemmer_7Stemmer_6stemWord(((struct __pyx_obj_7Stemmer_Stemmer *)__pyx_v_self), ((PyObject *)__pyx_v_word));
2370
2371 /* function exit code */
2372 __Pyx_RefNannyFinishContext();
2373 return __pyx_r;
2374 }
2375
__pyx_pf_7Stemmer_7Stemmer_6stemWord(struct __pyx_obj_7Stemmer_Stemmer * __pyx_v_self,PyObject * __pyx_v_word)2376 static PyObject *__pyx_pf_7Stemmer_7Stemmer_6stemWord(struct __pyx_obj_7Stemmer_Stemmer *__pyx_v_self, PyObject *__pyx_v_word) {
2377 char const *__pyx_v_c_word;
2378 long __pyx_v_was_unicode;
2379 PyObject *__pyx_v_cacheditem = NULL;
2380 PyObject *__pyx_v_result = NULL;
2381 int __pyx_v_length;
2382 PyObject *__pyx_r = NULL;
2383 __Pyx_RefNannyDeclarations
2384 int __pyx_t_1;
2385 int __pyx_t_2;
2386 PyObject *__pyx_t_3 = NULL;
2387 PyObject *__pyx_t_4 = NULL;
2388 PyObject *__pyx_t_5 = NULL;
2389 PyObject *__pyx_t_6 = NULL;
2390 PyObject *__pyx_t_7 = NULL;
2391 PyObject *__pyx_t_8 = NULL;
2392 int __pyx_t_9;
2393 char const *__pyx_t_10;
2394 Py_ssize_t __pyx_t_11;
2395 PyObject *__pyx_t_12 = NULL;
2396 PyObject *__pyx_t_13 = NULL;
2397 PyObject *__pyx_t_14 = NULL;
2398 int __pyx_lineno = 0;
2399 const char *__pyx_filename = NULL;
2400 int __pyx_clineno = 0;
2401 __Pyx_RefNannySetupContext("stemWord", 0);
2402 __Pyx_INCREF(__pyx_v_word);
2403
2404 /* "Stemmer.pyx":174
2405 * """
2406 * cdef const char * c_word
2407 * was_unicode = 0 # <<<<<<<<<<<<<<
2408 * if isinstance(word, unicode):
2409 * was_unicode = 1
2410 */
2411 __pyx_v_was_unicode = 0;
2412
2413 /* "Stemmer.pyx":175
2414 * cdef const char * c_word
2415 * was_unicode = 0
2416 * if isinstance(word, unicode): # <<<<<<<<<<<<<<
2417 * was_unicode = 1
2418 * word = word.encode(u'utf-8');
2419 */
2420 __pyx_t_1 = PyUnicode_Check(__pyx_v_word);
2421 __pyx_t_2 = (__pyx_t_1 != 0);
2422 if (__pyx_t_2) {
2423
2424 /* "Stemmer.pyx":176
2425 * was_unicode = 0
2426 * if isinstance(word, unicode):
2427 * was_unicode = 1 # <<<<<<<<<<<<<<
2428 * word = word.encode(u'utf-8');
2429 *
2430 */
2431 __pyx_v_was_unicode = 1;
2432
2433 /* "Stemmer.pyx":177
2434 * if isinstance(word, unicode):
2435 * was_unicode = 1
2436 * word = word.encode(u'utf-8'); # <<<<<<<<<<<<<<
2437 *
2438 * if self.max_cache_size > 0:
2439 */
2440 __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_word, __pyx_n_s_encode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 177, __pyx_L1_error)
2441 __Pyx_GOTREF(__pyx_t_4);
2442 __pyx_t_5 = NULL;
2443 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
2444 __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
2445 if (likely(__pyx_t_5)) {
2446 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
2447 __Pyx_INCREF(__pyx_t_5);
2448 __Pyx_INCREF(function);
2449 __Pyx_DECREF_SET(__pyx_t_4, function);
2450 }
2451 }
2452 __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_kp_u_utf_8) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_kp_u_utf_8);
2453 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
2454 if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 177, __pyx_L1_error)
2455 __Pyx_GOTREF(__pyx_t_3);
2456 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2457 __Pyx_DECREF_SET(__pyx_v_word, __pyx_t_3);
2458 __pyx_t_3 = 0;
2459
2460 /* "Stemmer.pyx":175
2461 * cdef const char * c_word
2462 * was_unicode = 0
2463 * if isinstance(word, unicode): # <<<<<<<<<<<<<<
2464 * was_unicode = 1
2465 * word = word.encode(u'utf-8');
2466 */
2467 }
2468
2469 /* "Stemmer.pyx":179
2470 * word = word.encode(u'utf-8');
2471 *
2472 * if self.max_cache_size > 0: # <<<<<<<<<<<<<<
2473 * try:
2474 * cacheditem = self.cache[word]
2475 */
2476 __pyx_t_2 = ((__pyx_v_self->max_cache_size > 0) != 0);
2477 if (__pyx_t_2) {
2478
2479 /* "Stemmer.pyx":180
2480 *
2481 * if self.max_cache_size > 0:
2482 * try: # <<<<<<<<<<<<<<
2483 * cacheditem = self.cache[word]
2484 * result = cacheditem[0]
2485 */
2486 {
2487 __Pyx_PyThreadState_declare
2488 __Pyx_PyThreadState_assign
2489 __Pyx_ExceptionSave(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
2490 __Pyx_XGOTREF(__pyx_t_6);
2491 __Pyx_XGOTREF(__pyx_t_7);
2492 __Pyx_XGOTREF(__pyx_t_8);
2493 /*try:*/ {
2494
2495 /* "Stemmer.pyx":181
2496 * if self.max_cache_size > 0:
2497 * try:
2498 * cacheditem = self.cache[word] # <<<<<<<<<<<<<<
2499 * result = cacheditem[0]
2500 * cacheditem[1] = self.counter
2501 */
2502 __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_self->cache, __pyx_v_word); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 181, __pyx_L5_error)
2503 __Pyx_GOTREF(__pyx_t_3);
2504 __pyx_v_cacheditem = __pyx_t_3;
2505 __pyx_t_3 = 0;
2506
2507 /* "Stemmer.pyx":182
2508 * try:
2509 * cacheditem = self.cache[word]
2510 * result = cacheditem[0] # <<<<<<<<<<<<<<
2511 * cacheditem[1] = self.counter
2512 * self.counter = self.counter + 1
2513 */
2514 __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_cacheditem, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 182, __pyx_L5_error)
2515 __Pyx_GOTREF(__pyx_t_3);
2516 __pyx_v_result = __pyx_t_3;
2517 __pyx_t_3 = 0;
2518
2519 /* "Stemmer.pyx":183
2520 * cacheditem = self.cache[word]
2521 * result = cacheditem[0]
2522 * cacheditem[1] = self.counter # <<<<<<<<<<<<<<
2523 * self.counter = self.counter + 1
2524 * except KeyError:
2525 */
2526 __pyx_t_3 = __pyx_v_self->counter;
2527 __Pyx_INCREF(__pyx_t_3);
2528 if (unlikely(__Pyx_SetItemInt(__pyx_v_cacheditem, 1, __pyx_t_3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1) < 0)) __PYX_ERR(0, 183, __pyx_L5_error)
2529 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2530
2531 /* "Stemmer.pyx":184
2532 * result = cacheditem[0]
2533 * cacheditem[1] = self.counter
2534 * self.counter = self.counter + 1 # <<<<<<<<<<<<<<
2535 * except KeyError:
2536 * c_word = word
2537 */
2538 __pyx_t_3 = __Pyx_PyInt_AddObjC(__pyx_v_self->counter, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 184, __pyx_L5_error)
2539 __Pyx_GOTREF(__pyx_t_3);
2540 __Pyx_GIVEREF(__pyx_t_3);
2541 __Pyx_GOTREF(__pyx_v_self->counter);
2542 __Pyx_DECREF(__pyx_v_self->counter);
2543 __pyx_v_self->counter = __pyx_t_3;
2544 __pyx_t_3 = 0;
2545
2546 /* "Stemmer.pyx":180
2547 *
2548 * if self.max_cache_size > 0:
2549 * try: # <<<<<<<<<<<<<<
2550 * cacheditem = self.cache[word]
2551 * result = cacheditem[0]
2552 */
2553 }
2554 __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
2555 __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
2556 __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
2557 goto __pyx_L10_try_end;
2558 __pyx_L5_error:;
2559 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
2560 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
2561 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
2562
2563 /* "Stemmer.pyx":185
2564 * cacheditem[1] = self.counter
2565 * self.counter = self.counter + 1
2566 * except KeyError: # <<<<<<<<<<<<<<
2567 * c_word = word
2568 * c_word = <const char*>sb_stemmer_stem(self.cobj, <const sb_symbol*>c_word, len(word))
2569 */
2570 __pyx_t_9 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
2571 if (__pyx_t_9) {
2572 __Pyx_AddTraceback("Stemmer.Stemmer.stemWord", __pyx_clineno, __pyx_lineno, __pyx_filename);
2573 if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5) < 0) __PYX_ERR(0, 185, __pyx_L7_except_error)
2574 __Pyx_GOTREF(__pyx_t_3);
2575 __Pyx_GOTREF(__pyx_t_4);
2576 __Pyx_GOTREF(__pyx_t_5);
2577
2578 /* "Stemmer.pyx":186
2579 * self.counter = self.counter + 1
2580 * except KeyError:
2581 * c_word = word # <<<<<<<<<<<<<<
2582 * c_word = <const char*>sb_stemmer_stem(self.cobj, <const sb_symbol*>c_word, len(word))
2583 * length = sb_stemmer_length(self.cobj)
2584 */
2585 __pyx_t_10 = __Pyx_PyObject_AsString(__pyx_v_word); if (unlikely((!__pyx_t_10) && PyErr_Occurred())) __PYX_ERR(0, 186, __pyx_L7_except_error)
2586 __pyx_v_c_word = __pyx_t_10;
2587
2588 /* "Stemmer.pyx":187
2589 * except KeyError:
2590 * c_word = word
2591 * c_word = <const char*>sb_stemmer_stem(self.cobj, <const sb_symbol*>c_word, len(word)) # <<<<<<<<<<<<<<
2592 * length = sb_stemmer_length(self.cobj)
2593 * result = PyUnicode_FromStringAndSize (c_word, length)
2594 */
2595 __pyx_t_11 = PyObject_Length(__pyx_v_word); if (unlikely(__pyx_t_11 == ((Py_ssize_t)-1))) __PYX_ERR(0, 187, __pyx_L7_except_error)
2596 __pyx_v_c_word = ((char const *)sb_stemmer_stem(__pyx_v_self->cobj, ((sb_symbol const *)__pyx_v_c_word), __pyx_t_11));
2597
2598 /* "Stemmer.pyx":188
2599 * c_word = word
2600 * c_word = <const char*>sb_stemmer_stem(self.cobj, <const sb_symbol*>c_word, len(word))
2601 * length = sb_stemmer_length(self.cobj) # <<<<<<<<<<<<<<
2602 * result = PyUnicode_FromStringAndSize (c_word, length)
2603 * self.cache[word] = [result, self.counter]
2604 */
2605 __pyx_v_length = sb_stemmer_length(__pyx_v_self->cobj);
2606
2607 /* "Stemmer.pyx":189
2608 * c_word = <const char*>sb_stemmer_stem(self.cobj, <const sb_symbol*>c_word, len(word))
2609 * length = sb_stemmer_length(self.cobj)
2610 * result = PyUnicode_FromStringAndSize (c_word, length) # <<<<<<<<<<<<<<
2611 * self.cache[word] = [result, self.counter]
2612 * self.counter = self.counter + 1
2613 */
2614 __pyx_t_12 = PyUnicode_FromStringAndSize(__pyx_v_c_word, __pyx_v_length); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 189, __pyx_L7_except_error)
2615 __Pyx_GOTREF(__pyx_t_12);
2616 __Pyx_XDECREF_SET(__pyx_v_result, __pyx_t_12);
2617 __pyx_t_12 = 0;
2618
2619 /* "Stemmer.pyx":190
2620 * length = sb_stemmer_length(self.cobj)
2621 * result = PyUnicode_FromStringAndSize (c_word, length)
2622 * self.cache[word] = [result, self.counter] # <<<<<<<<<<<<<<
2623 * self.counter = self.counter + 1
2624 * self.__purgeCache()
2625 */
2626 __pyx_t_12 = PyList_New(2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 190, __pyx_L7_except_error)
2627 __Pyx_GOTREF(__pyx_t_12);
2628 __Pyx_INCREF(__pyx_v_result);
2629 __Pyx_GIVEREF(__pyx_v_result);
2630 PyList_SET_ITEM(__pyx_t_12, 0, __pyx_v_result);
2631 __Pyx_INCREF(__pyx_v_self->counter);
2632 __Pyx_GIVEREF(__pyx_v_self->counter);
2633 PyList_SET_ITEM(__pyx_t_12, 1, __pyx_v_self->counter);
2634 if (unlikely(PyObject_SetItem(__pyx_v_self->cache, __pyx_v_word, __pyx_t_12) < 0)) __PYX_ERR(0, 190, __pyx_L7_except_error)
2635 __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
2636
2637 /* "Stemmer.pyx":191
2638 * result = PyUnicode_FromStringAndSize (c_word, length)
2639 * self.cache[word] = [result, self.counter]
2640 * self.counter = self.counter + 1 # <<<<<<<<<<<<<<
2641 * self.__purgeCache()
2642 * else:
2643 */
2644 __pyx_t_12 = __Pyx_PyInt_AddObjC(__pyx_v_self->counter, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 191, __pyx_L7_except_error)
2645 __Pyx_GOTREF(__pyx_t_12);
2646 __Pyx_GIVEREF(__pyx_t_12);
2647 __Pyx_GOTREF(__pyx_v_self->counter);
2648 __Pyx_DECREF(__pyx_v_self->counter);
2649 __pyx_v_self->counter = __pyx_t_12;
2650 __pyx_t_12 = 0;
2651
2652 /* "Stemmer.pyx":192
2653 * self.cache[word] = [result, self.counter]
2654 * self.counter = self.counter + 1
2655 * self.__purgeCache() # <<<<<<<<<<<<<<
2656 * else:
2657 * c_word = word
2658 */
2659 __pyx_t_13 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_purgeCache); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 192, __pyx_L7_except_error)
2660 __Pyx_GOTREF(__pyx_t_13);
2661 __pyx_t_14 = NULL;
2662 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_13))) {
2663 __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_13);
2664 if (likely(__pyx_t_14)) {
2665 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
2666 __Pyx_INCREF(__pyx_t_14);
2667 __Pyx_INCREF(function);
2668 __Pyx_DECREF_SET(__pyx_t_13, function);
2669 }
2670 }
2671 __pyx_t_12 = (__pyx_t_14) ? __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_t_14) : __Pyx_PyObject_CallNoArg(__pyx_t_13);
2672 __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
2673 if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 192, __pyx_L7_except_error)
2674 __Pyx_GOTREF(__pyx_t_12);
2675 __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
2676 __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
2677 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
2678 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
2679 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
2680 goto __pyx_L6_exception_handled;
2681 }
2682 goto __pyx_L7_except_error;
2683 __pyx_L7_except_error:;
2684
2685 /* "Stemmer.pyx":180
2686 *
2687 * if self.max_cache_size > 0:
2688 * try: # <<<<<<<<<<<<<<
2689 * cacheditem = self.cache[word]
2690 * result = cacheditem[0]
2691 */
2692 __Pyx_XGIVEREF(__pyx_t_6);
2693 __Pyx_XGIVEREF(__pyx_t_7);
2694 __Pyx_XGIVEREF(__pyx_t_8);
2695 __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
2696 goto __pyx_L1_error;
2697 __pyx_L6_exception_handled:;
2698 __Pyx_XGIVEREF(__pyx_t_6);
2699 __Pyx_XGIVEREF(__pyx_t_7);
2700 __Pyx_XGIVEREF(__pyx_t_8);
2701 __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
2702 __pyx_L10_try_end:;
2703 }
2704
2705 /* "Stemmer.pyx":179
2706 * word = word.encode(u'utf-8');
2707 *
2708 * if self.max_cache_size > 0: # <<<<<<<<<<<<<<
2709 * try:
2710 * cacheditem = self.cache[word]
2711 */
2712 goto __pyx_L4;
2713 }
2714
2715 /* "Stemmer.pyx":194
2716 * self.__purgeCache()
2717 * else:
2718 * c_word = word # <<<<<<<<<<<<<<
2719 * c_word = <const char*>sb_stemmer_stem(self.cobj, <const sb_symbol*>c_word, len(word))
2720 * length = sb_stemmer_length(self.cobj)
2721 */
2722 /*else*/ {
2723 __pyx_t_10 = __Pyx_PyObject_AsString(__pyx_v_word); if (unlikely((!__pyx_t_10) && PyErr_Occurred())) __PYX_ERR(0, 194, __pyx_L1_error)
2724 __pyx_v_c_word = __pyx_t_10;
2725
2726 /* "Stemmer.pyx":195
2727 * else:
2728 * c_word = word
2729 * c_word = <const char*>sb_stemmer_stem(self.cobj, <const sb_symbol*>c_word, len(word)) # <<<<<<<<<<<<<<
2730 * length = sb_stemmer_length(self.cobj)
2731 * result = PyUnicode_FromStringAndSize (c_word, length)
2732 */
2733 __pyx_t_11 = PyObject_Length(__pyx_v_word); if (unlikely(__pyx_t_11 == ((Py_ssize_t)-1))) __PYX_ERR(0, 195, __pyx_L1_error)
2734 __pyx_v_c_word = ((char const *)sb_stemmer_stem(__pyx_v_self->cobj, ((sb_symbol const *)__pyx_v_c_word), __pyx_t_11));
2735
2736 /* "Stemmer.pyx":196
2737 * c_word = word
2738 * c_word = <const char*>sb_stemmer_stem(self.cobj, <const sb_symbol*>c_word, len(word))
2739 * length = sb_stemmer_length(self.cobj) # <<<<<<<<<<<<<<
2740 * result = PyUnicode_FromStringAndSize (c_word, length)
2741 *
2742 */
2743 __pyx_v_length = sb_stemmer_length(__pyx_v_self->cobj);
2744
2745 /* "Stemmer.pyx":197
2746 * c_word = <const char*>sb_stemmer_stem(self.cobj, <const sb_symbol*>c_word, len(word))
2747 * length = sb_stemmer_length(self.cobj)
2748 * result = PyUnicode_FromStringAndSize (c_word, length) # <<<<<<<<<<<<<<
2749 *
2750 * if not was_unicode:
2751 */
2752 __pyx_t_5 = PyUnicode_FromStringAndSize(__pyx_v_c_word, __pyx_v_length); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 197, __pyx_L1_error)
2753 __Pyx_GOTREF(__pyx_t_5);
2754 __pyx_v_result = __pyx_t_5;
2755 __pyx_t_5 = 0;
2756 }
2757 __pyx_L4:;
2758
2759 /* "Stemmer.pyx":199
2760 * result = PyUnicode_FromStringAndSize (c_word, length)
2761 *
2762 * if not was_unicode: # <<<<<<<<<<<<<<
2763 * return result.encode(u'utf-8')
2764 * return result
2765 */
2766 __pyx_t_2 = ((!(__pyx_v_was_unicode != 0)) != 0);
2767 if (__pyx_t_2) {
2768
2769 /* "Stemmer.pyx":200
2770 *
2771 * if not was_unicode:
2772 * return result.encode(u'utf-8') # <<<<<<<<<<<<<<
2773 * return result
2774 *
2775 */
2776 __Pyx_XDECREF(__pyx_r);
2777 __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_result, __pyx_n_s_encode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 200, __pyx_L1_error)
2778 __Pyx_GOTREF(__pyx_t_4);
2779 __pyx_t_3 = NULL;
2780 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
2781 __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
2782 if (likely(__pyx_t_3)) {
2783 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
2784 __Pyx_INCREF(__pyx_t_3);
2785 __Pyx_INCREF(function);
2786 __Pyx_DECREF_SET(__pyx_t_4, function);
2787 }
2788 }
2789 __pyx_t_5 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_3, __pyx_kp_u_utf_8) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_kp_u_utf_8);
2790 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
2791 if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 200, __pyx_L1_error)
2792 __Pyx_GOTREF(__pyx_t_5);
2793 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2794 __pyx_r = __pyx_t_5;
2795 __pyx_t_5 = 0;
2796 goto __pyx_L0;
2797
2798 /* "Stemmer.pyx":199
2799 * result = PyUnicode_FromStringAndSize (c_word, length)
2800 *
2801 * if not was_unicode: # <<<<<<<<<<<<<<
2802 * return result.encode(u'utf-8')
2803 * return result
2804 */
2805 }
2806
2807 /* "Stemmer.pyx":201
2808 * if not was_unicode:
2809 * return result.encode(u'utf-8')
2810 * return result # <<<<<<<<<<<<<<
2811 *
2812 * def stemWords (self, words):
2813 */
2814 __Pyx_XDECREF(__pyx_r);
2815 __Pyx_INCREF(__pyx_v_result);
2816 __pyx_r = __pyx_v_result;
2817 goto __pyx_L0;
2818
2819 /* "Stemmer.pyx":161
2820 * self.cache = newcache
2821 *
2822 * def stemWord (self, word): # <<<<<<<<<<<<<<
2823 * """Stem a word.
2824 *
2825 */
2826
2827 /* function exit code */
2828 __pyx_L1_error:;
2829 __Pyx_XDECREF(__pyx_t_3);
2830 __Pyx_XDECREF(__pyx_t_4);
2831 __Pyx_XDECREF(__pyx_t_5);
2832 __Pyx_XDECREF(__pyx_t_12);
2833 __Pyx_XDECREF(__pyx_t_13);
2834 __Pyx_XDECREF(__pyx_t_14);
2835 __Pyx_AddTraceback("Stemmer.Stemmer.stemWord", __pyx_clineno, __pyx_lineno, __pyx_filename);
2836 __pyx_r = NULL;
2837 __pyx_L0:;
2838 __Pyx_XDECREF(__pyx_v_cacheditem);
2839 __Pyx_XDECREF(__pyx_v_result);
2840 __Pyx_XDECREF(__pyx_v_word);
2841 __Pyx_XGIVEREF(__pyx_r);
2842 __Pyx_RefNannyFinishContext();
2843 return __pyx_r;
2844 }
2845
2846 /* "Stemmer.pyx":203
2847 * return result
2848 *
2849 * def stemWords (self, words): # <<<<<<<<<<<<<<
2850 * """Stem a list of words.
2851 *
2852 */
2853
2854 /* Python wrapper */
2855 static PyObject *__pyx_pw_7Stemmer_7Stemmer_9stemWords(PyObject *__pyx_v_self, PyObject *__pyx_v_words); /*proto*/
2856 static char __pyx_doc_7Stemmer_7Stemmer_8stemWords[] = "Stem a list of words.\n\n This takes a single argument, ``words``, which must be a sequence,\n iterator, generator or similar.\n\n The entries in ``words`` should either be UTF-8 encoded strings, or a\n unicode objects.\n\n The result is a list of the stemmed forms of the words. If the\n word supplied was a unicode object, the stemmed form will be a\n unicode object: if the word supplied was a string, the stemmed form\n will be a UTF-8 encoded string.\n\n ";
__pyx_pw_7Stemmer_7Stemmer_9stemWords(PyObject * __pyx_v_self,PyObject * __pyx_v_words)2857 static PyObject *__pyx_pw_7Stemmer_7Stemmer_9stemWords(PyObject *__pyx_v_self, PyObject *__pyx_v_words) {
2858 PyObject *__pyx_r = 0;
2859 __Pyx_RefNannyDeclarations
2860 __Pyx_RefNannySetupContext("stemWords (wrapper)", 0);
2861 __pyx_r = __pyx_pf_7Stemmer_7Stemmer_8stemWords(((struct __pyx_obj_7Stemmer_Stemmer *)__pyx_v_self), ((PyObject *)__pyx_v_words));
2862
2863 /* function exit code */
2864 __Pyx_RefNannyFinishContext();
2865 return __pyx_r;
2866 }
2867
__pyx_pf_7Stemmer_7Stemmer_8stemWords(struct __pyx_obj_7Stemmer_Stemmer * __pyx_v_self,PyObject * __pyx_v_words)2868 static PyObject *__pyx_pf_7Stemmer_7Stemmer_8stemWords(struct __pyx_obj_7Stemmer_Stemmer *__pyx_v_self, PyObject *__pyx_v_words) {
2869 PyObject *__pyx_v_result = NULL;
2870 PyObject *__pyx_v_word = NULL;
2871 PyObject *__pyx_r = NULL;
2872 __Pyx_RefNannyDeclarations
2873 PyObject *__pyx_t_1 = NULL;
2874 Py_ssize_t __pyx_t_2;
2875 PyObject *(*__pyx_t_3)(PyObject *);
2876 PyObject *__pyx_t_4 = NULL;
2877 PyObject *__pyx_t_5 = NULL;
2878 PyObject *__pyx_t_6 = NULL;
2879 int __pyx_t_7;
2880 int __pyx_lineno = 0;
2881 const char *__pyx_filename = NULL;
2882 int __pyx_clineno = 0;
2883 __Pyx_RefNannySetupContext("stemWords", 0);
2884
2885 /* "Stemmer.pyx":218
2886 *
2887 * """
2888 * result = [] # <<<<<<<<<<<<<<
2889 * for word in words:
2890 * result.append(self.stemWord(word))
2891 */
2892 __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 218, __pyx_L1_error)
2893 __Pyx_GOTREF(__pyx_t_1);
2894 __pyx_v_result = ((PyObject*)__pyx_t_1);
2895 __pyx_t_1 = 0;
2896
2897 /* "Stemmer.pyx":219
2898 * """
2899 * result = []
2900 * for word in words: # <<<<<<<<<<<<<<
2901 * result.append(self.stemWord(word))
2902 * return result
2903 */
2904 if (likely(PyList_CheckExact(__pyx_v_words)) || PyTuple_CheckExact(__pyx_v_words)) {
2905 __pyx_t_1 = __pyx_v_words; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
2906 __pyx_t_3 = NULL;
2907 } else {
2908 __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_words); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 219, __pyx_L1_error)
2909 __Pyx_GOTREF(__pyx_t_1);
2910 __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 219, __pyx_L1_error)
2911 }
2912 for (;;) {
2913 if (likely(!__pyx_t_3)) {
2914 if (likely(PyList_CheckExact(__pyx_t_1))) {
2915 if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
2916 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
2917 __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 219, __pyx_L1_error)
2918 #else
2919 __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 219, __pyx_L1_error)
2920 __Pyx_GOTREF(__pyx_t_4);
2921 #endif
2922 } else {
2923 if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
2924 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
2925 __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 219, __pyx_L1_error)
2926 #else
2927 __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 219, __pyx_L1_error)
2928 __Pyx_GOTREF(__pyx_t_4);
2929 #endif
2930 }
2931 } else {
2932 __pyx_t_4 = __pyx_t_3(__pyx_t_1);
2933 if (unlikely(!__pyx_t_4)) {
2934 PyObject* exc_type = PyErr_Occurred();
2935 if (exc_type) {
2936 if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
2937 else __PYX_ERR(0, 219, __pyx_L1_error)
2938 }
2939 break;
2940 }
2941 __Pyx_GOTREF(__pyx_t_4);
2942 }
2943 __Pyx_XDECREF_SET(__pyx_v_word, __pyx_t_4);
2944 __pyx_t_4 = 0;
2945
2946 /* "Stemmer.pyx":220
2947 * result = []
2948 * for word in words:
2949 * result.append(self.stemWord(word)) # <<<<<<<<<<<<<<
2950 * return result
2951 */
2952 __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_stemWord); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 220, __pyx_L1_error)
2953 __Pyx_GOTREF(__pyx_t_5);
2954 __pyx_t_6 = NULL;
2955 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
2956 __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
2957 if (likely(__pyx_t_6)) {
2958 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
2959 __Pyx_INCREF(__pyx_t_6);
2960 __Pyx_INCREF(function);
2961 __Pyx_DECREF_SET(__pyx_t_5, function);
2962 }
2963 }
2964 __pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, __pyx_v_word) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_word);
2965 __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
2966 if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 220, __pyx_L1_error)
2967 __Pyx_GOTREF(__pyx_t_4);
2968 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2969 __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_4); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 220, __pyx_L1_error)
2970 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2971
2972 /* "Stemmer.pyx":219
2973 * """
2974 * result = []
2975 * for word in words: # <<<<<<<<<<<<<<
2976 * result.append(self.stemWord(word))
2977 * return result
2978 */
2979 }
2980 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2981
2982 /* "Stemmer.pyx":221
2983 * for word in words:
2984 * result.append(self.stemWord(word))
2985 * return result # <<<<<<<<<<<<<<
2986 */
2987 __Pyx_XDECREF(__pyx_r);
2988 __Pyx_INCREF(__pyx_v_result);
2989 __pyx_r = __pyx_v_result;
2990 goto __pyx_L0;
2991
2992 /* "Stemmer.pyx":203
2993 * return result
2994 *
2995 * def stemWords (self, words): # <<<<<<<<<<<<<<
2996 * """Stem a list of words.
2997 *
2998 */
2999
3000 /* function exit code */
3001 __pyx_L1_error:;
3002 __Pyx_XDECREF(__pyx_t_1);
3003 __Pyx_XDECREF(__pyx_t_4);
3004 __Pyx_XDECREF(__pyx_t_5);
3005 __Pyx_XDECREF(__pyx_t_6);
3006 __Pyx_AddTraceback("Stemmer.Stemmer.stemWords", __pyx_clineno, __pyx_lineno, __pyx_filename);
3007 __pyx_r = NULL;
3008 __pyx_L0:;
3009 __Pyx_XDECREF(__pyx_v_result);
3010 __Pyx_XDECREF(__pyx_v_word);
3011 __Pyx_XGIVEREF(__pyx_r);
3012 __Pyx_RefNannyFinishContext();
3013 return __pyx_r;
3014 }
3015
3016 /* "(tree fragment)":1
3017 * def __reduce_cython__(self): # <<<<<<<<<<<<<<
3018 * raise TypeError("self.cobj cannot be converted to a Python object for pickling")
3019 * def __setstate_cython__(self, __pyx_state):
3020 */
3021
3022 /* Python wrapper */
3023 static PyObject *__pyx_pw_7Stemmer_7Stemmer_11__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pw_7Stemmer_7Stemmer_11__reduce_cython__(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)3024 static PyObject *__pyx_pw_7Stemmer_7Stemmer_11__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
3025 PyObject *__pyx_r = 0;
3026 __Pyx_RefNannyDeclarations
3027 __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
3028 __pyx_r = __pyx_pf_7Stemmer_7Stemmer_10__reduce_cython__(((struct __pyx_obj_7Stemmer_Stemmer *)__pyx_v_self));
3029
3030 /* function exit code */
3031 __Pyx_RefNannyFinishContext();
3032 return __pyx_r;
3033 }
3034
__pyx_pf_7Stemmer_7Stemmer_10__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_7Stemmer_Stemmer * __pyx_v_self)3035 static PyObject *__pyx_pf_7Stemmer_7Stemmer_10__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_7Stemmer_Stemmer *__pyx_v_self) {
3036 PyObject *__pyx_r = NULL;
3037 __Pyx_RefNannyDeclarations
3038 PyObject *__pyx_t_1 = NULL;
3039 int __pyx_lineno = 0;
3040 const char *__pyx_filename = NULL;
3041 int __pyx_clineno = 0;
3042 __Pyx_RefNannySetupContext("__reduce_cython__", 0);
3043
3044 /* "(tree fragment)":2
3045 * def __reduce_cython__(self):
3046 * raise TypeError("self.cobj cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<<
3047 * def __setstate_cython__(self, __pyx_state):
3048 * raise TypeError("self.cobj cannot be converted to a Python object for pickling")
3049 */
3050 __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error)
3051 __Pyx_GOTREF(__pyx_t_1);
3052 __Pyx_Raise(__pyx_t_1, 0, 0, 0);
3053 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3054 __PYX_ERR(1, 2, __pyx_L1_error)
3055
3056 /* "(tree fragment)":1
3057 * def __reduce_cython__(self): # <<<<<<<<<<<<<<
3058 * raise TypeError("self.cobj cannot be converted to a Python object for pickling")
3059 * def __setstate_cython__(self, __pyx_state):
3060 */
3061
3062 /* function exit code */
3063 __pyx_L1_error:;
3064 __Pyx_XDECREF(__pyx_t_1);
3065 __Pyx_AddTraceback("Stemmer.Stemmer.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
3066 __pyx_r = NULL;
3067 __Pyx_XGIVEREF(__pyx_r);
3068 __Pyx_RefNannyFinishContext();
3069 return __pyx_r;
3070 }
3071
3072 /* "(tree fragment)":3
3073 * def __reduce_cython__(self):
3074 * raise TypeError("self.cobj cannot be converted to a Python object for pickling")
3075 * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
3076 * raise TypeError("self.cobj cannot be converted to a Python object for pickling")
3077 */
3078
3079 /* Python wrapper */
3080 static PyObject *__pyx_pw_7Stemmer_7Stemmer_13__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
__pyx_pw_7Stemmer_7Stemmer_13__setstate_cython__(PyObject * __pyx_v_self,PyObject * __pyx_v___pyx_state)3081 static PyObject *__pyx_pw_7Stemmer_7Stemmer_13__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
3082 PyObject *__pyx_r = 0;
3083 __Pyx_RefNannyDeclarations
3084 __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
3085 __pyx_r = __pyx_pf_7Stemmer_7Stemmer_12__setstate_cython__(((struct __pyx_obj_7Stemmer_Stemmer *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
3086
3087 /* function exit code */
3088 __Pyx_RefNannyFinishContext();
3089 return __pyx_r;
3090 }
3091
__pyx_pf_7Stemmer_7Stemmer_12__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_7Stemmer_Stemmer * __pyx_v_self,CYTHON_UNUSED PyObject * __pyx_v___pyx_state)3092 static PyObject *__pyx_pf_7Stemmer_7Stemmer_12__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_7Stemmer_Stemmer *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
3093 PyObject *__pyx_r = NULL;
3094 __Pyx_RefNannyDeclarations
3095 PyObject *__pyx_t_1 = NULL;
3096 int __pyx_lineno = 0;
3097 const char *__pyx_filename = NULL;
3098 int __pyx_clineno = 0;
3099 __Pyx_RefNannySetupContext("__setstate_cython__", 0);
3100
3101 /* "(tree fragment)":4
3102 * raise TypeError("self.cobj cannot be converted to a Python object for pickling")
3103 * def __setstate_cython__(self, __pyx_state):
3104 * raise TypeError("self.cobj cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<<
3105 */
3106 __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error)
3107 __Pyx_GOTREF(__pyx_t_1);
3108 __Pyx_Raise(__pyx_t_1, 0, 0, 0);
3109 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3110 __PYX_ERR(1, 4, __pyx_L1_error)
3111
3112 /* "(tree fragment)":3
3113 * def __reduce_cython__(self):
3114 * raise TypeError("self.cobj cannot be converted to a Python object for pickling")
3115 * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
3116 * raise TypeError("self.cobj cannot be converted to a Python object for pickling")
3117 */
3118
3119 /* function exit code */
3120 __pyx_L1_error:;
3121 __Pyx_XDECREF(__pyx_t_1);
3122 __Pyx_AddTraceback("Stemmer.Stemmer.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
3123 __pyx_r = NULL;
3124 __Pyx_XGIVEREF(__pyx_r);
3125 __Pyx_RefNannyFinishContext();
3126 return __pyx_r;
3127 }
3128
__pyx_tp_new_7Stemmer_Stemmer(PyTypeObject * t,CYTHON_UNUSED PyObject * a,CYTHON_UNUSED PyObject * k)3129 static PyObject *__pyx_tp_new_7Stemmer_Stemmer(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
3130 struct __pyx_obj_7Stemmer_Stemmer *p;
3131 PyObject *o;
3132 if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
3133 o = (*t->tp_alloc)(t, 0);
3134 } else {
3135 o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
3136 }
3137 if (unlikely(!o)) return 0;
3138 p = ((struct __pyx_obj_7Stemmer_Stemmer *)o);
3139 p->cache = Py_None; Py_INCREF(Py_None);
3140 p->counter = Py_None; Py_INCREF(Py_None);
3141 return o;
3142 }
3143
__pyx_tp_dealloc_7Stemmer_Stemmer(PyObject * o)3144 static void __pyx_tp_dealloc_7Stemmer_Stemmer(PyObject *o) {
3145 struct __pyx_obj_7Stemmer_Stemmer *p = (struct __pyx_obj_7Stemmer_Stemmer *)o;
3146 #if CYTHON_USE_TP_FINALIZE
3147 if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
3148 if (PyObject_CallFinalizerFromDealloc(o)) return;
3149 }
3150 #endif
3151 PyObject_GC_UnTrack(o);
3152 {
3153 PyObject *etype, *eval, *etb;
3154 PyErr_Fetch(&etype, &eval, &etb);
3155 __Pyx_SET_REFCNT(o, Py_REFCNT(o) + 1);
3156 __pyx_pw_7Stemmer_7Stemmer_3__dealloc__(o);
3157 __Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1);
3158 PyErr_Restore(etype, eval, etb);
3159 }
3160 Py_CLEAR(p->cache);
3161 Py_CLEAR(p->counter);
3162 (*Py_TYPE(o)->tp_free)(o);
3163 }
3164
__pyx_tp_traverse_7Stemmer_Stemmer(PyObject * o,visitproc v,void * a)3165 static int __pyx_tp_traverse_7Stemmer_Stemmer(PyObject *o, visitproc v, void *a) {
3166 int e;
3167 struct __pyx_obj_7Stemmer_Stemmer *p = (struct __pyx_obj_7Stemmer_Stemmer *)o;
3168 if (p->cache) {
3169 e = (*v)(p->cache, a); if (e) return e;
3170 }
3171 if (p->counter) {
3172 e = (*v)(p->counter, a); if (e) return e;
3173 }
3174 return 0;
3175 }
3176
__pyx_tp_clear_7Stemmer_Stemmer(PyObject * o)3177 static int __pyx_tp_clear_7Stemmer_Stemmer(PyObject *o) {
3178 PyObject* tmp;
3179 struct __pyx_obj_7Stemmer_Stemmer *p = (struct __pyx_obj_7Stemmer_Stemmer *)o;
3180 tmp = ((PyObject*)p->cache);
3181 p->cache = Py_None; Py_INCREF(Py_None);
3182 Py_XDECREF(tmp);
3183 tmp = ((PyObject*)p->counter);
3184 p->counter = Py_None; Py_INCREF(Py_None);
3185 Py_XDECREF(tmp);
3186 return 0;
3187 }
3188
__pyx_getprop_7Stemmer_7Stemmer_maxCacheSize(PyObject * o,CYTHON_UNUSED void * x)3189 static PyObject *__pyx_getprop_7Stemmer_7Stemmer_maxCacheSize(PyObject *o, CYTHON_UNUSED void *x) {
3190 return __pyx_pw_7Stemmer_7Stemmer_12maxCacheSize_3__get__(o);
3191 }
3192
__pyx_setprop_7Stemmer_7Stemmer_maxCacheSize(PyObject * o,PyObject * v,CYTHON_UNUSED void * x)3193 static int __pyx_setprop_7Stemmer_7Stemmer_maxCacheSize(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
3194 if (v) {
3195 return __pyx_pw_7Stemmer_7Stemmer_12maxCacheSize_1__set__(o, v);
3196 }
3197 else {
3198 PyErr_SetString(PyExc_NotImplementedError, "__del__");
3199 return -1;
3200 }
3201 }
3202
3203 static PyMethodDef __pyx_methods_7Stemmer_Stemmer[] = {
3204 {"__purgeCache", (PyCFunction)__pyx_pw_7Stemmer_7Stemmer_5__purgeCache, METH_NOARGS, 0},
3205 {"stemWord", (PyCFunction)__pyx_pw_7Stemmer_7Stemmer_7stemWord, METH_O, __pyx_doc_7Stemmer_7Stemmer_6stemWord},
3206 {"stemWords", (PyCFunction)__pyx_pw_7Stemmer_7Stemmer_9stemWords, METH_O, __pyx_doc_7Stemmer_7Stemmer_8stemWords},
3207 {"__reduce_cython__", (PyCFunction)__pyx_pw_7Stemmer_7Stemmer_11__reduce_cython__, METH_NOARGS, 0},
3208 {"__setstate_cython__", (PyCFunction)__pyx_pw_7Stemmer_7Stemmer_13__setstate_cython__, METH_O, 0},
3209 {0, 0, 0, 0}
3210 };
3211
3212 static struct PyGetSetDef __pyx_getsets_7Stemmer_Stemmer[] = {
3213 {(char *)"maxCacheSize", __pyx_getprop_7Stemmer_7Stemmer_maxCacheSize, __pyx_setprop_7Stemmer_7Stemmer_maxCacheSize, (char *)"Maximum number of entries to allow in the cache.\n\n This may be set to zero to disable the cache entirely.\n\n The maximum cache size may be set at any point - setting the\n maximum size will purge entries from the cache if the new maximum\n size is smaller than the current size.\n\n ", 0},
3214 {0, 0, 0, 0, 0}
3215 };
3216
3217 static PyTypeObject __pyx_type_7Stemmer_Stemmer = {
3218 PyVarObject_HEAD_INIT(0, 0)
3219 "Stemmer.Stemmer", /*tp_name*/
3220 sizeof(struct __pyx_obj_7Stemmer_Stemmer), /*tp_basicsize*/
3221 0, /*tp_itemsize*/
3222 __pyx_tp_dealloc_7Stemmer_Stemmer, /*tp_dealloc*/
3223 #if PY_VERSION_HEX < 0x030800b4
3224 0, /*tp_print*/
3225 #endif
3226 #if PY_VERSION_HEX >= 0x030800b4
3227 0, /*tp_vectorcall_offset*/
3228 #endif
3229 0, /*tp_getattr*/
3230 0, /*tp_setattr*/
3231 #if PY_MAJOR_VERSION < 3
3232 0, /*tp_compare*/
3233 #endif
3234 #if PY_MAJOR_VERSION >= 3
3235 0, /*tp_as_async*/
3236 #endif
3237 0, /*tp_repr*/
3238 0, /*tp_as_number*/
3239 0, /*tp_as_sequence*/
3240 0, /*tp_as_mapping*/
3241 0, /*tp_hash*/
3242 0, /*tp_call*/
3243 0, /*tp_str*/
3244 0, /*tp_getattro*/
3245 0, /*tp_setattro*/
3246 0, /*tp_as_buffer*/
3247 Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
3248 "An instance of a stemming algorithm.\n\n The algorithm has internal state, so must not be called concurrently.\n ie, only a single thread should access the instance at any given time.\n\n When creating a `Stemmer` object, there is one required argument: the\n name of the algorithm to use in the new stemmer. A list of the valid\n algorithm names may be obtained by calling the `algorithms()` function\n in this module. In addition, the appropriate stemming algorithm for a\n given language may be obtained by using the 2 or 3 letter ISO 639\n language codes.\n\n A second optional argument to the constructor for `Stemmer` is the size\n of cache to use. The cache implemented in this module is not terribly\n efficient, but benchmarks show that it approximately doubles\n performance for typical text processing operations, without too much\n memory overhead. The cache may be disabled by passing a size of 0.\n The default size (10000 words) is probably appropriate in most\n situations. In pathological cases (for example, when no word is\n presented to the stemming algorithm more than once, so the cache is\n useless), the cache can severely damage performance.\n\n The \"benchmark.py\" script supplied with the PyStemmer distribution can\n be used to test the performance of the stemming algorithms with various\n cache sizes.\n\n ", /*tp_doc*/
3249 __pyx_tp_traverse_7Stemmer_Stemmer, /*tp_traverse*/
3250 __pyx_tp_clear_7Stemmer_Stemmer, /*tp_clear*/
3251 0, /*tp_richcompare*/
3252 0, /*tp_weaklistoffset*/
3253 0, /*tp_iter*/
3254 0, /*tp_iternext*/
3255 __pyx_methods_7Stemmer_Stemmer, /*tp_methods*/
3256 0, /*tp_members*/
3257 __pyx_getsets_7Stemmer_Stemmer, /*tp_getset*/
3258 0, /*tp_base*/
3259 0, /*tp_dict*/
3260 0, /*tp_descr_get*/
3261 0, /*tp_descr_set*/
3262 0, /*tp_dictoffset*/
3263 __pyx_pw_7Stemmer_7Stemmer_1__init__, /*tp_init*/
3264 0, /*tp_alloc*/
3265 __pyx_tp_new_7Stemmer_Stemmer, /*tp_new*/
3266 0, /*tp_free*/
3267 0, /*tp_is_gc*/
3268 0, /*tp_bases*/
3269 0, /*tp_mro*/
3270 0, /*tp_cache*/
3271 0, /*tp_subclasses*/
3272 0, /*tp_weaklist*/
3273 0, /*tp_del*/
3274 0, /*tp_version_tag*/
3275 #if PY_VERSION_HEX >= 0x030400a1
3276 0, /*tp_finalize*/
3277 #endif
3278 #if PY_VERSION_HEX >= 0x030800b1
3279 0, /*tp_vectorcall*/
3280 #endif
3281 #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
3282 0, /*tp_print*/
3283 #endif
3284 };
3285
3286 static PyMethodDef __pyx_methods[] = {
3287 {0, 0, 0, 0}
3288 };
3289
3290 #if PY_MAJOR_VERSION >= 3
3291 #if CYTHON_PEP489_MULTI_PHASE_INIT
3292 static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
3293 static int __pyx_pymod_exec_Stemmer(PyObject* module); /*proto*/
3294 static PyModuleDef_Slot __pyx_moduledef_slots[] = {
3295 {Py_mod_create, (void*)__pyx_pymod_create},
3296 {Py_mod_exec, (void*)__pyx_pymod_exec_Stemmer},
3297 {0, NULL}
3298 };
3299 #endif
3300
3301 static struct PyModuleDef __pyx_moduledef = {
3302 PyModuleDef_HEAD_INIT,
3303 "Stemmer",
3304 __pyx_k_Stemmer_stemming_algorithms_from, /* m_doc */
3305 #if CYTHON_PEP489_MULTI_PHASE_INIT
3306 0, /* m_size */
3307 #else
3308 -1, /* m_size */
3309 #endif
3310 __pyx_methods /* m_methods */,
3311 #if CYTHON_PEP489_MULTI_PHASE_INIT
3312 __pyx_moduledef_slots, /* m_slots */
3313 #else
3314 NULL, /* m_reload */
3315 #endif
3316 NULL, /* m_traverse */
3317 NULL, /* m_clear */
3318 NULL /* m_free */
3319 };
3320 #endif
3321 #ifndef CYTHON_SMALL_CODE
3322 #if defined(__clang__)
3323 #define CYTHON_SMALL_CODE
3324 #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
3325 #define CYTHON_SMALL_CODE __attribute__((cold))
3326 #else
3327 #define CYTHON_SMALL_CODE
3328 #endif
3329 #endif
3330
3331 static __Pyx_StringTabEntry __pyx_string_tab[] = {
3332 {&__pyx_kp_s_2_0_1, __pyx_k_2_0_1, sizeof(__pyx_k_2_0_1), 0, 0, 1, 0},
3333 {&__pyx_n_s_KeyError, __pyx_k_KeyError, sizeof(__pyx_k_KeyError), 0, 0, 1, 1},
3334 {&__pyx_n_s_Stemmer, __pyx_k_Stemmer, sizeof(__pyx_k_Stemmer), 0, 0, 1, 1},
3335 {&__pyx_kp_s_Stemming_algorithm_s_not_found, __pyx_k_Stemming_algorithm_s_not_found, sizeof(__pyx_k_Stemming_algorithm_s_not_found), 0, 0, 1, 0},
3336 {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1},
3337 {&__pyx_n_s_alg, __pyx_k_alg, sizeof(__pyx_k_alg), 0, 0, 1, 1},
3338 {&__pyx_n_s_algorithm, __pyx_k_algorithm, sizeof(__pyx_k_algorithm), 0, 0, 1, 1},
3339 {&__pyx_n_s_algorithms, __pyx_k_algorithms, sizeof(__pyx_k_algorithms), 0, 0, 1, 1},
3340 {&__pyx_n_s_algs, __pyx_k_algs, sizeof(__pyx_k_algs), 0, 0, 1, 1},
3341 {&__pyx_n_s_aliases, __pyx_k_aliases, sizeof(__pyx_k_aliases), 0, 0, 1, 1},
3342 {&__pyx_n_u_ascii, __pyx_k_ascii, sizeof(__pyx_k_ascii), 0, 1, 0, 1},
3343 {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
3344 {&__pyx_n_s_decode, __pyx_k_decode, sizeof(__pyx_k_decode), 0, 0, 1, 1},
3345 {&__pyx_n_s_docformat, __pyx_k_docformat, sizeof(__pyx_k_docformat), 0, 0, 1, 1},
3346 {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1},
3347 {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1},
3348 {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1},
3349 {&__pyx_n_s_iteritems, __pyx_k_iteritems, sizeof(__pyx_k_iteritems), 0, 0, 1, 1},
3350 {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
3351 {&__pyx_n_s_maxCacheSize, __pyx_k_maxCacheSize, sizeof(__pyx_k_maxCacheSize), 0, 0, 1, 1},
3352 {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
3353 {&__pyx_n_s_purgeCache, __pyx_k_purgeCache, sizeof(__pyx_k_purgeCache), 0, 0, 1, 1},
3354 {&__pyx_n_s_py_algs, __pyx_k_py_algs, sizeof(__pyx_k_py_algs), 0, 0, 1, 1},
3355 {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1},
3356 {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1},
3357 {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1},
3358 {&__pyx_kp_s_restructuredtext_en, __pyx_k_restructuredtext_en, sizeof(__pyx_k_restructuredtext_en), 0, 0, 1, 0},
3359 {&__pyx_kp_s_self_cobj_cannot_be_converted_to, __pyx_k_self_cobj_cannot_be_converted_to, sizeof(__pyx_k_self_cobj_cannot_be_converted_to), 0, 0, 1, 0},
3360 {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1},
3361 {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1},
3362 {&__pyx_kp_s_src_Stemmer_pyx, __pyx_k_src_Stemmer_pyx, sizeof(__pyx_k_src_Stemmer_pyx), 0, 0, 1, 0},
3363 {&__pyx_n_s_stemWord, __pyx_k_stemWord, sizeof(__pyx_k_stemWord), 0, 0, 1, 1},
3364 {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
3365 {&__pyx_kp_u_utf_8, __pyx_k_utf_8, sizeof(__pyx_k_utf_8), 0, 1, 0, 0},
3366 {&__pyx_n_s_version, __pyx_k_version, sizeof(__pyx_k_version), 0, 0, 1, 1},
3367 {0, 0, 0, 0, 0, 0, 0}
3368 };
__Pyx_InitCachedBuiltins(void)3369 static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
3370 __pyx_builtin_KeyError = __Pyx_GetBuiltinName(__pyx_n_s_KeyError); if (!__pyx_builtin_KeyError) __PYX_ERR(0, 123, __pyx_L1_error)
3371 __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(1, 2, __pyx_L1_error)
3372 return 0;
3373 __pyx_L1_error:;
3374 return -1;
3375 }
3376
__Pyx_InitCachedConstants(void)3377 static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
3378 __Pyx_RefNannyDeclarations
3379 __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
3380
3381 /* "(tree fragment)":2
3382 * def __reduce_cython__(self):
3383 * raise TypeError("self.cobj cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<<
3384 * def __setstate_cython__(self, __pyx_state):
3385 * raise TypeError("self.cobj cannot be converted to a Python object for pickling")
3386 */
3387 __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_self_cobj_cannot_be_converted_to); if (unlikely(!__pyx_tuple_)) __PYX_ERR(1, 2, __pyx_L1_error)
3388 __Pyx_GOTREF(__pyx_tuple_);
3389 __Pyx_GIVEREF(__pyx_tuple_);
3390
3391 /* "(tree fragment)":4
3392 * raise TypeError("self.cobj cannot be converted to a Python object for pickling")
3393 * def __setstate_cython__(self, __pyx_state):
3394 * raise TypeError("self.cobj cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<<
3395 */
3396 __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_self_cobj_cannot_be_converted_to); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(1, 4, __pyx_L1_error)
3397 __Pyx_GOTREF(__pyx_tuple__2);
3398 __Pyx_GIVEREF(__pyx_tuple__2);
3399
3400 /* "Stemmer.pyx":43
3401 * cdef int sb_stemmer_length(sb_stemmer * stemmer)
3402 *
3403 * def algorithms(aliases=False): # <<<<<<<<<<<<<<
3404 * """Get a list of the names of the available stemming algorithms.
3405 *
3406 */
3407 __pyx_tuple__3 = PyTuple_Pack(5, __pyx_n_s_aliases, __pyx_n_s_algs, __pyx_n_s_i, __pyx_n_s_py_algs, __pyx_n_s_alg); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 43, __pyx_L1_error)
3408 __Pyx_GOTREF(__pyx_tuple__3);
3409 __Pyx_GIVEREF(__pyx_tuple__3);
3410 __pyx_codeobj__4 = (PyObject*)__Pyx_PyCode_New(1, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__3, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_Stemmer_pyx, __pyx_n_s_algorithms, 43, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__4)) __PYX_ERR(0, 43, __pyx_L1_error)
3411
3412 /* "Stemmer.pyx":72
3413 * return py_algs
3414 *
3415 * def version(): # <<<<<<<<<<<<<<
3416 * """Get the version string of the stemming module.
3417 *
3418 */
3419 __pyx_codeobj__5 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_Stemmer_pyx, __pyx_n_s_version, 72, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__5)) __PYX_ERR(0, 72, __pyx_L1_error)
3420 __Pyx_RefNannyFinishContext();
3421 return 0;
3422 __pyx_L1_error:;
3423 __Pyx_RefNannyFinishContext();
3424 return -1;
3425 }
3426
__Pyx_InitGlobals(void)3427 static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
3428 if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
3429 __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error)
3430 __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error)
3431 return 0;
3432 __pyx_L1_error:;
3433 return -1;
3434 }
3435
3436 static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/
3437 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/
3438 static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/
3439 static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/
3440 static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/
3441 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/
3442 static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/
3443
__Pyx_modinit_global_init_code(void)3444 static int __Pyx_modinit_global_init_code(void) {
3445 __Pyx_RefNannyDeclarations
3446 __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
3447 /*--- Global init code ---*/
3448 __Pyx_RefNannyFinishContext();
3449 return 0;
3450 }
3451
__Pyx_modinit_variable_export_code(void)3452 static int __Pyx_modinit_variable_export_code(void) {
3453 __Pyx_RefNannyDeclarations
3454 __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
3455 /*--- Variable export code ---*/
3456 __Pyx_RefNannyFinishContext();
3457 return 0;
3458 }
3459
__Pyx_modinit_function_export_code(void)3460 static int __Pyx_modinit_function_export_code(void) {
3461 __Pyx_RefNannyDeclarations
3462 __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
3463 /*--- Function export code ---*/
3464 __Pyx_RefNannyFinishContext();
3465 return 0;
3466 }
3467
__Pyx_modinit_type_init_code(void)3468 static int __Pyx_modinit_type_init_code(void) {
3469 __Pyx_RefNannyDeclarations
3470 int __pyx_lineno = 0;
3471 const char *__pyx_filename = NULL;
3472 int __pyx_clineno = 0;
3473 __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
3474 /*--- Type init code ---*/
3475 if (PyType_Ready(&__pyx_type_7Stemmer_Stemmer) < 0) __PYX_ERR(0, 81, __pyx_L1_error)
3476 #if PY_VERSION_HEX < 0x030800B1
3477 __pyx_type_7Stemmer_Stemmer.tp_print = 0;
3478 #endif
3479 if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_7Stemmer_Stemmer.tp_dictoffset && __pyx_type_7Stemmer_Stemmer.tp_getattro == PyObject_GenericGetAttr)) {
3480 __pyx_type_7Stemmer_Stemmer.tp_getattro = __Pyx_PyObject_GenericGetAttr;
3481 }
3482 #if CYTHON_COMPILING_IN_CPYTHON
3483 {
3484 PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_7Stemmer_Stemmer, "__init__"); if (unlikely(!wrapper)) __PYX_ERR(0, 81, __pyx_L1_error)
3485 if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
3486 __pyx_wrapperbase_7Stemmer_7Stemmer___init__ = *((PyWrapperDescrObject *)wrapper)->d_base;
3487 __pyx_wrapperbase_7Stemmer_7Stemmer___init__.doc = __pyx_doc_7Stemmer_7Stemmer___init__;
3488 ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_7Stemmer_7Stemmer___init__;
3489 }
3490 }
3491 #endif
3492 if (PyObject_SetAttr(__pyx_m, __pyx_n_s_Stemmer, (PyObject *)&__pyx_type_7Stemmer_Stemmer) < 0) __PYX_ERR(0, 81, __pyx_L1_error)
3493 if (__Pyx_setup_reduce((PyObject*)&__pyx_type_7Stemmer_Stemmer) < 0) __PYX_ERR(0, 81, __pyx_L1_error)
3494 __pyx_ptype_7Stemmer_Stemmer = &__pyx_type_7Stemmer_Stemmer;
3495 __Pyx_RefNannyFinishContext();
3496 return 0;
3497 __pyx_L1_error:;
3498 __Pyx_RefNannyFinishContext();
3499 return -1;
3500 }
3501
__Pyx_modinit_type_import_code(void)3502 static int __Pyx_modinit_type_import_code(void) {
3503 __Pyx_RefNannyDeclarations
3504 __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
3505 /*--- Type import code ---*/
3506 __Pyx_RefNannyFinishContext();
3507 return 0;
3508 }
3509
__Pyx_modinit_variable_import_code(void)3510 static int __Pyx_modinit_variable_import_code(void) {
3511 __Pyx_RefNannyDeclarations
3512 __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
3513 /*--- Variable import code ---*/
3514 __Pyx_RefNannyFinishContext();
3515 return 0;
3516 }
3517
__Pyx_modinit_function_import_code(void)3518 static int __Pyx_modinit_function_import_code(void) {
3519 __Pyx_RefNannyDeclarations
3520 __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
3521 /*--- Function import code ---*/
3522 __Pyx_RefNannyFinishContext();
3523 return 0;
3524 }
3525
3526
3527 #ifndef CYTHON_NO_PYINIT_EXPORT
3528 #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
3529 #elif PY_MAJOR_VERSION < 3
3530 #ifdef __cplusplus
3531 #define __Pyx_PyMODINIT_FUNC extern "C" void
3532 #else
3533 #define __Pyx_PyMODINIT_FUNC void
3534 #endif
3535 #else
3536 #ifdef __cplusplus
3537 #define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
3538 #else
3539 #define __Pyx_PyMODINIT_FUNC PyObject *
3540 #endif
3541 #endif
3542
3543
3544 #if PY_MAJOR_VERSION < 3
3545 __Pyx_PyMODINIT_FUNC initStemmer(void) CYTHON_SMALL_CODE; /*proto*/
initStemmer(void)3546 __Pyx_PyMODINIT_FUNC initStemmer(void)
3547 #else
3548 __Pyx_PyMODINIT_FUNC PyInit_Stemmer(void) CYTHON_SMALL_CODE; /*proto*/
3549 __Pyx_PyMODINIT_FUNC PyInit_Stemmer(void)
3550 #if CYTHON_PEP489_MULTI_PHASE_INIT
3551 {
3552 return PyModuleDef_Init(&__pyx_moduledef);
3553 }
3554 static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
3555 #if PY_VERSION_HEX >= 0x030700A1
3556 static PY_INT64_T main_interpreter_id = -1;
3557 PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
3558 if (main_interpreter_id == -1) {
3559 main_interpreter_id = current_id;
3560 return (unlikely(current_id == -1)) ? -1 : 0;
3561 } else if (unlikely(main_interpreter_id != current_id))
3562 #else
3563 static PyInterpreterState *main_interpreter = NULL;
3564 PyInterpreterState *current_interpreter = PyThreadState_Get()->interp;
3565 if (!main_interpreter) {
3566 main_interpreter = current_interpreter;
3567 } else if (unlikely(main_interpreter != current_interpreter))
3568 #endif
3569 {
3570 PyErr_SetString(
3571 PyExc_ImportError,
3572 "Interpreter change detected - this module can only be loaded into one interpreter per process.");
3573 return -1;
3574 }
3575 return 0;
3576 }
3577 static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) {
3578 PyObject *value = PyObject_GetAttrString(spec, from_name);
3579 int result = 0;
3580 if (likely(value)) {
3581 if (allow_none || value != Py_None) {
3582 result = PyDict_SetItemString(moddict, to_name, value);
3583 }
3584 Py_DECREF(value);
3585 } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
3586 PyErr_Clear();
3587 } else {
3588 result = -1;
3589 }
3590 return result;
3591 }
3592 static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
3593 PyObject *module = NULL, *moddict, *modname;
3594 if (__Pyx_check_single_interpreter())
3595 return NULL;
3596 if (__pyx_m)
3597 return __Pyx_NewRef(__pyx_m);
3598 modname = PyObject_GetAttrString(spec, "name");
3599 if (unlikely(!modname)) goto bad;
3600 module = PyModule_NewObject(modname);
3601 Py_DECREF(modname);
3602 if (unlikely(!module)) goto bad;
3603 moddict = PyModule_GetDict(module);
3604 if (unlikely(!moddict)) goto bad;
3605 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
3606 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
3607 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
3608 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
3609 return module;
3610 bad:
3611 Py_XDECREF(module);
3612 return NULL;
3613 }
3614
3615
3616 static CYTHON_SMALL_CODE int __pyx_pymod_exec_Stemmer(PyObject *__pyx_pyinit_module)
3617 #endif
3618 #endif
3619 {
3620 PyObject *__pyx_t_1 = NULL;
3621 int __pyx_lineno = 0;
3622 const char *__pyx_filename = NULL;
3623 int __pyx_clineno = 0;
3624 __Pyx_RefNannyDeclarations
3625 #if CYTHON_PEP489_MULTI_PHASE_INIT
3626 if (__pyx_m) {
3627 if (__pyx_m == __pyx_pyinit_module) return 0;
3628 PyErr_SetString(PyExc_RuntimeError, "Module 'Stemmer' has already been imported. Re-initialisation is not supported.");
3629 return -1;
3630 }
3631 #elif PY_MAJOR_VERSION >= 3
3632 if (__pyx_m) return __Pyx_NewRef(__pyx_m);
3633 #endif
3634 #if CYTHON_REFNANNY
3635 __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
3636 if (!__Pyx_RefNanny) {
3637 PyErr_Clear();
3638 __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
3639 if (!__Pyx_RefNanny)
3640 Py_FatalError("failed to import 'refnanny' module");
3641 }
3642 #endif
3643 __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_Stemmer(void)", 0);
3644 if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3645 #ifdef __Pxy_PyFrame_Initialize_Offsets
3646 __Pxy_PyFrame_Initialize_Offsets();
3647 #endif
3648 __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
3649 __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
3650 __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
3651 #ifdef __Pyx_CyFunction_USED
3652 if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3653 #endif
3654 #ifdef __Pyx_FusedFunction_USED
3655 if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3656 #endif
3657 #ifdef __Pyx_Coroutine_USED
3658 if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3659 #endif
3660 #ifdef __Pyx_Generator_USED
3661 if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3662 #endif
3663 #ifdef __Pyx_AsyncGen_USED
3664 if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3665 #endif
3666 #ifdef __Pyx_StopAsyncIteration_USED
3667 if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3668 #endif
3669 /*--- Library function declarations ---*/
3670 /*--- Threads initialization code ---*/
3671 #if defined(WITH_THREAD) && PY_VERSION_HEX < 0x030700F0 && defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
3672 PyEval_InitThreads();
3673 #endif
3674 /*--- Module creation code ---*/
3675 #if CYTHON_PEP489_MULTI_PHASE_INIT
3676 __pyx_m = __pyx_pyinit_module;
3677 Py_INCREF(__pyx_m);
3678 #else
3679 #if PY_MAJOR_VERSION < 3
3680 __pyx_m = Py_InitModule4("Stemmer", __pyx_methods, __pyx_k_Stemmer_stemming_algorithms_from, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
3681 #else
3682 __pyx_m = PyModule_Create(&__pyx_moduledef);
3683 #endif
3684 if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
3685 #endif
3686 __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
3687 Py_INCREF(__pyx_d);
3688 __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
3689 Py_INCREF(__pyx_b);
3690 __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
3691 Py_INCREF(__pyx_cython_runtime);
3692 if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
3693 /*--- Initialize various global constants etc. ---*/
3694 if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3695 #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
3696 if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3697 #endif
3698 if (__pyx_module_is_main_Stemmer) {
3699 if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3700 }
3701 #if PY_MAJOR_VERSION >= 3
3702 {
3703 PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
3704 if (!PyDict_GetItemString(modules, "Stemmer")) {
3705 if (unlikely(PyDict_SetItemString(modules, "Stemmer", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
3706 }
3707 }
3708 #endif
3709 /*--- Builtin init code ---*/
3710 if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3711 /*--- Constants init code ---*/
3712 if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3713 /*--- Global type/function init code ---*/
3714 (void)__Pyx_modinit_global_init_code();
3715 (void)__Pyx_modinit_variable_export_code();
3716 (void)__Pyx_modinit_function_export_code();
3717 if (unlikely(__Pyx_modinit_type_init_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
3718 (void)__Pyx_modinit_type_import_code();
3719 (void)__Pyx_modinit_variable_import_code();
3720 (void)__Pyx_modinit_function_import_code();
3721 /*--- Execution code ---*/
3722 #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
3723 if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3724 #endif
3725
3726 /* "Stemmer.pyx":25
3727 *
3728 * """
3729 * __docformat__ = "restructuredtext en" # <<<<<<<<<<<<<<
3730 *
3731 * cdef extern from *:
3732 */
3733 if (PyDict_SetItem(__pyx_d, __pyx_n_s_docformat, __pyx_kp_s_restructuredtext_en) < 0) __PYX_ERR(0, 25, __pyx_L1_error)
3734
3735 /* "Stemmer.pyx":43
3736 * cdef int sb_stemmer_length(sb_stemmer * stemmer)
3737 *
3738 * def algorithms(aliases=False): # <<<<<<<<<<<<<<
3739 * """Get a list of the names of the available stemming algorithms.
3740 *
3741 */
3742 __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_7Stemmer_1algorithms, NULL, __pyx_n_s_Stemmer); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 43, __pyx_L1_error)
3743 __Pyx_GOTREF(__pyx_t_1);
3744 if (PyDict_SetItem(__pyx_d, __pyx_n_s_algorithms, __pyx_t_1) < 0) __PYX_ERR(0, 43, __pyx_L1_error)
3745 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3746
3747 /* "Stemmer.pyx":72
3748 * return py_algs
3749 *
3750 * def version(): # <<<<<<<<<<<<<<
3751 * """Get the version string of the stemming module.
3752 *
3753 */
3754 __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_7Stemmer_3version, NULL, __pyx_n_s_Stemmer); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 72, __pyx_L1_error)
3755 __Pyx_GOTREF(__pyx_t_1);
3756 if (PyDict_SetItem(__pyx_d, __pyx_n_s_version, __pyx_t_1) < 0) __PYX_ERR(0, 72, __pyx_L1_error)
3757 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3758
3759 /* "Stemmer.pyx":1
3760 * # Stemmer.pyx: Copyright (c) 2006, Richard Boulton # <<<<<<<<<<<<<<
3761 * # Pyrex interface to the snowball "libstemmer_c" library.
3762 * #
3763 */
3764 __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
3765 __Pyx_GOTREF(__pyx_t_1);
3766 if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3767 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3768
3769 /*--- Wrapped vars code ---*/
3770
3771 goto __pyx_L0;
3772 __pyx_L1_error:;
3773 __Pyx_XDECREF(__pyx_t_1);
3774 if (__pyx_m) {
3775 if (__pyx_d) {
3776 __Pyx_AddTraceback("init Stemmer", __pyx_clineno, __pyx_lineno, __pyx_filename);
3777 }
3778 Py_CLEAR(__pyx_m);
3779 } else if (!PyErr_Occurred()) {
3780 PyErr_SetString(PyExc_ImportError, "init Stemmer");
3781 }
3782 __pyx_L0:;
3783 __Pyx_RefNannyFinishContext();
3784 #if CYTHON_PEP489_MULTI_PHASE_INIT
3785 return (__pyx_m != NULL) ? 0 : -1;
3786 #elif PY_MAJOR_VERSION >= 3
3787 return __pyx_m;
3788 #else
3789 return;
3790 #endif
3791 }
3792
3793 /* --- Runtime support code --- */
3794 /* Refnanny */
3795 #if CYTHON_REFNANNY
__Pyx_RefNannyImportAPI(const char * modname)3796 static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
3797 PyObject *m = NULL, *p = NULL;
3798 void *r = NULL;
3799 m = PyImport_ImportModule(modname);
3800 if (!m) goto end;
3801 p = PyObject_GetAttrString(m, "RefNannyAPI");
3802 if (!p) goto end;
3803 r = PyLong_AsVoidPtr(p);
3804 end:
3805 Py_XDECREF(p);
3806 Py_XDECREF(m);
3807 return (__Pyx_RefNannyAPIStruct *)r;
3808 }
3809 #endif
3810
3811 /* PyObjectGetAttrStr */
3812 #if CYTHON_USE_TYPE_SLOTS
__Pyx_PyObject_GetAttrStr(PyObject * obj,PyObject * attr_name)3813 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
3814 PyTypeObject* tp = Py_TYPE(obj);
3815 if (likely(tp->tp_getattro))
3816 return tp->tp_getattro(obj, attr_name);
3817 #if PY_MAJOR_VERSION < 3
3818 if (likely(tp->tp_getattr))
3819 return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
3820 #endif
3821 return PyObject_GetAttr(obj, attr_name);
3822 }
3823 #endif
3824
3825 /* GetBuiltinName */
__Pyx_GetBuiltinName(PyObject * name)3826 static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
3827 PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
3828 if (unlikely(!result)) {
3829 PyErr_Format(PyExc_NameError,
3830 #if PY_MAJOR_VERSION >= 3
3831 "name '%U' is not defined", name);
3832 #else
3833 "name '%.200s' is not defined", PyString_AS_STRING(name));
3834 #endif
3835 }
3836 return result;
3837 }
3838
3839 /* RaiseDoubleKeywords */
__Pyx_RaiseDoubleKeywordsError(const char * func_name,PyObject * kw_name)3840 static void __Pyx_RaiseDoubleKeywordsError(
3841 const char* func_name,
3842 PyObject* kw_name)
3843 {
3844 PyErr_Format(PyExc_TypeError,
3845 #if PY_MAJOR_VERSION >= 3
3846 "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
3847 #else
3848 "%s() got multiple values for keyword argument '%s'", func_name,
3849 PyString_AsString(kw_name));
3850 #endif
3851 }
3852
3853 /* ParseKeywords */
__Pyx_ParseOptionalKeywords(PyObject * kwds,PyObject ** argnames[],PyObject * kwds2,PyObject * values[],Py_ssize_t num_pos_args,const char * function_name)3854 static int __Pyx_ParseOptionalKeywords(
3855 PyObject *kwds,
3856 PyObject **argnames[],
3857 PyObject *kwds2,
3858 PyObject *values[],
3859 Py_ssize_t num_pos_args,
3860 const char* function_name)
3861 {
3862 PyObject *key = 0, *value = 0;
3863 Py_ssize_t pos = 0;
3864 PyObject*** name;
3865 PyObject*** first_kw_arg = argnames + num_pos_args;
3866 while (PyDict_Next(kwds, &pos, &key, &value)) {
3867 name = first_kw_arg;
3868 while (*name && (**name != key)) name++;
3869 if (*name) {
3870 values[name-argnames] = value;
3871 continue;
3872 }
3873 name = first_kw_arg;
3874 #if PY_MAJOR_VERSION < 3
3875 if (likely(PyString_Check(key))) {
3876 while (*name) {
3877 if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
3878 && _PyString_Eq(**name, key)) {
3879 values[name-argnames] = value;
3880 break;
3881 }
3882 name++;
3883 }
3884 if (*name) continue;
3885 else {
3886 PyObject*** argname = argnames;
3887 while (argname != first_kw_arg) {
3888 if ((**argname == key) || (
3889 (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
3890 && _PyString_Eq(**argname, key))) {
3891 goto arg_passed_twice;
3892 }
3893 argname++;
3894 }
3895 }
3896 } else
3897 #endif
3898 if (likely(PyUnicode_Check(key))) {
3899 while (*name) {
3900 int cmp = (**name == key) ? 0 :
3901 #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
3902 (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
3903 #endif
3904 PyUnicode_Compare(**name, key);
3905 if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
3906 if (cmp == 0) {
3907 values[name-argnames] = value;
3908 break;
3909 }
3910 name++;
3911 }
3912 if (*name) continue;
3913 else {
3914 PyObject*** argname = argnames;
3915 while (argname != first_kw_arg) {
3916 int cmp = (**argname == key) ? 0 :
3917 #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
3918 (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
3919 #endif
3920 PyUnicode_Compare(**argname, key);
3921 if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
3922 if (cmp == 0) goto arg_passed_twice;
3923 argname++;
3924 }
3925 }
3926 } else
3927 goto invalid_keyword_type;
3928 if (kwds2) {
3929 if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
3930 } else {
3931 goto invalid_keyword;
3932 }
3933 }
3934 return 0;
3935 arg_passed_twice:
3936 __Pyx_RaiseDoubleKeywordsError(function_name, key);
3937 goto bad;
3938 invalid_keyword_type:
3939 PyErr_Format(PyExc_TypeError,
3940 "%.200s() keywords must be strings", function_name);
3941 goto bad;
3942 invalid_keyword:
3943 PyErr_Format(PyExc_TypeError,
3944 #if PY_MAJOR_VERSION < 3
3945 "%.200s() got an unexpected keyword argument '%.200s'",
3946 function_name, PyString_AsString(key));
3947 #else
3948 "%s() got an unexpected keyword argument '%U'",
3949 function_name, key);
3950 #endif
3951 bad:
3952 return -1;
3953 }
3954
3955 /* RaiseArgTupleInvalid */
__Pyx_RaiseArgtupleInvalid(const char * func_name,int exact,Py_ssize_t num_min,Py_ssize_t num_max,Py_ssize_t num_found)3956 static void __Pyx_RaiseArgtupleInvalid(
3957 const char* func_name,
3958 int exact,
3959 Py_ssize_t num_min,
3960 Py_ssize_t num_max,
3961 Py_ssize_t num_found)
3962 {
3963 Py_ssize_t num_expected;
3964 const char *more_or_less;
3965 if (num_found < num_min) {
3966 num_expected = num_min;
3967 more_or_less = "at least";
3968 } else {
3969 num_expected = num_max;
3970 more_or_less = "at most";
3971 }
3972 if (exact) {
3973 more_or_less = "exactly";
3974 }
3975 PyErr_Format(PyExc_TypeError,
3976 "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
3977 func_name, more_or_less, num_expected,
3978 (num_expected == 1) ? "" : "s", num_found);
3979 }
3980
3981 /* PyCFunctionFastCall */
3982 #if CYTHON_FAST_PYCCALL
__Pyx_PyCFunction_FastCall(PyObject * func_obj,PyObject ** args,Py_ssize_t nargs)3983 static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
3984 PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
3985 PyCFunction meth = PyCFunction_GET_FUNCTION(func);
3986 PyObject *self = PyCFunction_GET_SELF(func);
3987 int flags = PyCFunction_GET_FLAGS(func);
3988 assert(PyCFunction_Check(func));
3989 assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)));
3990 assert(nargs >= 0);
3991 assert(nargs == 0 || args != NULL);
3992 /* _PyCFunction_FastCallDict() must not be called with an exception set,
3993 because it may clear it (directly or indirectly) and so the
3994 caller loses its exception */
3995 assert(!PyErr_Occurred());
3996 if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
3997 return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL);
3998 } else {
3999 return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs);
4000 }
4001 }
4002 #endif
4003
4004 /* PyFunctionFastCall */
4005 #if CYTHON_FAST_PYCALL
__Pyx_PyFunction_FastCallNoKw(PyCodeObject * co,PyObject ** args,Py_ssize_t na,PyObject * globals)4006 static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
4007 PyObject *globals) {
4008 PyFrameObject *f;
4009 PyThreadState *tstate = __Pyx_PyThreadState_Current;
4010 PyObject **fastlocals;
4011 Py_ssize_t i;
4012 PyObject *result;
4013 assert(globals != NULL);
4014 /* XXX Perhaps we should create a specialized
4015 PyFrame_New() that doesn't take locals, but does
4016 take builtins without sanity checking them.
4017 */
4018 assert(tstate != NULL);
4019 f = PyFrame_New(tstate, co, globals, NULL);
4020 if (f == NULL) {
4021 return NULL;
4022 }
4023 fastlocals = __Pyx_PyFrame_GetLocalsplus(f);
4024 for (i = 0; i < na; i++) {
4025 Py_INCREF(*args);
4026 fastlocals[i] = *args++;
4027 }
4028 result = PyEval_EvalFrameEx(f,0);
4029 ++tstate->recursion_depth;
4030 Py_DECREF(f);
4031 --tstate->recursion_depth;
4032 return result;
4033 }
4034 #if 1 || PY_VERSION_HEX < 0x030600B1
__Pyx_PyFunction_FastCallDict(PyObject * func,PyObject ** args,Py_ssize_t nargs,PyObject * kwargs)4035 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) {
4036 PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
4037 PyObject *globals = PyFunction_GET_GLOBALS(func);
4038 PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
4039 PyObject *closure;
4040 #if PY_MAJOR_VERSION >= 3
4041 PyObject *kwdefs;
4042 #endif
4043 PyObject *kwtuple, **k;
4044 PyObject **d;
4045 Py_ssize_t nd;
4046 Py_ssize_t nk;
4047 PyObject *result;
4048 assert(kwargs == NULL || PyDict_Check(kwargs));
4049 nk = kwargs ? PyDict_Size(kwargs) : 0;
4050 if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
4051 return NULL;
4052 }
4053 if (
4054 #if PY_MAJOR_VERSION >= 3
4055 co->co_kwonlyargcount == 0 &&
4056 #endif
4057 likely(kwargs == NULL || nk == 0) &&
4058 co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
4059 if (argdefs == NULL && co->co_argcount == nargs) {
4060 result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
4061 goto done;
4062 }
4063 else if (nargs == 0 && argdefs != NULL
4064 && co->co_argcount == Py_SIZE(argdefs)) {
4065 /* function called with no arguments, but all parameters have
4066 a default value: use default values as arguments .*/
4067 args = &PyTuple_GET_ITEM(argdefs, 0);
4068 result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
4069 goto done;
4070 }
4071 }
4072 if (kwargs != NULL) {
4073 Py_ssize_t pos, i;
4074 kwtuple = PyTuple_New(2 * nk);
4075 if (kwtuple == NULL) {
4076 result = NULL;
4077 goto done;
4078 }
4079 k = &PyTuple_GET_ITEM(kwtuple, 0);
4080 pos = i = 0;
4081 while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
4082 Py_INCREF(k[i]);
4083 Py_INCREF(k[i+1]);
4084 i += 2;
4085 }
4086 nk = i / 2;
4087 }
4088 else {
4089 kwtuple = NULL;
4090 k = NULL;
4091 }
4092 closure = PyFunction_GET_CLOSURE(func);
4093 #if PY_MAJOR_VERSION >= 3
4094 kwdefs = PyFunction_GET_KW_DEFAULTS(func);
4095 #endif
4096 if (argdefs != NULL) {
4097 d = &PyTuple_GET_ITEM(argdefs, 0);
4098 nd = Py_SIZE(argdefs);
4099 }
4100 else {
4101 d = NULL;
4102 nd = 0;
4103 }
4104 #if PY_MAJOR_VERSION >= 3
4105 result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
4106 args, (int)nargs,
4107 k, (int)nk,
4108 d, (int)nd, kwdefs, closure);
4109 #else
4110 result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
4111 args, (int)nargs,
4112 k, (int)nk,
4113 d, (int)nd, closure);
4114 #endif
4115 Py_XDECREF(kwtuple);
4116 done:
4117 Py_LeaveRecursiveCall();
4118 return result;
4119 }
4120 #endif
4121 #endif
4122
4123 /* PyObjectCall */
4124 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_Call(PyObject * func,PyObject * arg,PyObject * kw)4125 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
4126 PyObject *result;
4127 ternaryfunc call = Py_TYPE(func)->tp_call;
4128 if (unlikely(!call))
4129 return PyObject_Call(func, arg, kw);
4130 if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
4131 return NULL;
4132 result = (*call)(func, arg, kw);
4133 Py_LeaveRecursiveCall();
4134 if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
4135 PyErr_SetString(
4136 PyExc_SystemError,
4137 "NULL result without error in PyObject_Call");
4138 }
4139 return result;
4140 }
4141 #endif
4142
4143 /* PyObjectCall2Args */
__Pyx_PyObject_Call2Args(PyObject * function,PyObject * arg1,PyObject * arg2)4144 static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) {
4145 PyObject *args, *result = NULL;
4146 #if CYTHON_FAST_PYCALL
4147 if (PyFunction_Check(function)) {
4148 PyObject *args[2] = {arg1, arg2};
4149 return __Pyx_PyFunction_FastCall(function, args, 2);
4150 }
4151 #endif
4152 #if CYTHON_FAST_PYCCALL
4153 if (__Pyx_PyFastCFunction_Check(function)) {
4154 PyObject *args[2] = {arg1, arg2};
4155 return __Pyx_PyCFunction_FastCall(function, args, 2);
4156 }
4157 #endif
4158 args = PyTuple_New(2);
4159 if (unlikely(!args)) goto done;
4160 Py_INCREF(arg1);
4161 PyTuple_SET_ITEM(args, 0, arg1);
4162 Py_INCREF(arg2);
4163 PyTuple_SET_ITEM(args, 1, arg2);
4164 Py_INCREF(function);
4165 result = __Pyx_PyObject_Call(function, args, NULL);
4166 Py_DECREF(args);
4167 Py_DECREF(function);
4168 done:
4169 return result;
4170 }
4171
4172 /* PyObjectCallMethO */
4173 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_CallMethO(PyObject * func,PyObject * arg)4174 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
4175 PyObject *self, *result;
4176 PyCFunction cfunc;
4177 cfunc = PyCFunction_GET_FUNCTION(func);
4178 self = PyCFunction_GET_SELF(func);
4179 if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
4180 return NULL;
4181 result = cfunc(self, arg);
4182 Py_LeaveRecursiveCall();
4183 if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
4184 PyErr_SetString(
4185 PyExc_SystemError,
4186 "NULL result without error in PyObject_Call");
4187 }
4188 return result;
4189 }
4190 #endif
4191
4192 /* PyObjectCallOneArg */
4193 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx__PyObject_CallOneArg(PyObject * func,PyObject * arg)4194 static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
4195 PyObject *result;
4196 PyObject *args = PyTuple_New(1);
4197 if (unlikely(!args)) return NULL;
4198 Py_INCREF(arg);
4199 PyTuple_SET_ITEM(args, 0, arg);
4200 result = __Pyx_PyObject_Call(func, args, NULL);
4201 Py_DECREF(args);
4202 return result;
4203 }
__Pyx_PyObject_CallOneArg(PyObject * func,PyObject * arg)4204 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
4205 #if CYTHON_FAST_PYCALL
4206 if (PyFunction_Check(func)) {
4207 return __Pyx_PyFunction_FastCall(func, &arg, 1);
4208 }
4209 #endif
4210 if (likely(PyCFunction_Check(func))) {
4211 if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
4212 return __Pyx_PyObject_CallMethO(func, arg);
4213 #if CYTHON_FAST_PYCCALL
4214 } else if (__Pyx_PyFastCFunction_Check(func)) {
4215 return __Pyx_PyCFunction_FastCall(func, &arg, 1);
4216 #endif
4217 }
4218 }
4219 return __Pyx__PyObject_CallOneArg(func, arg);
4220 }
4221 #else
__Pyx_PyObject_CallOneArg(PyObject * func,PyObject * arg)4222 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
4223 PyObject *result;
4224 PyObject *args = PyTuple_Pack(1, arg);
4225 if (unlikely(!args)) return NULL;
4226 result = __Pyx_PyObject_Call(func, args, NULL);
4227 Py_DECREF(args);
4228 return result;
4229 }
4230 #endif
4231
4232 /* PyErrFetchRestore */
4233 #if CYTHON_FAST_THREAD_STATE
__Pyx_ErrRestoreInState(PyThreadState * tstate,PyObject * type,PyObject * value,PyObject * tb)4234 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
4235 PyObject *tmp_type, *tmp_value, *tmp_tb;
4236 tmp_type = tstate->curexc_type;
4237 tmp_value = tstate->curexc_value;
4238 tmp_tb = tstate->curexc_traceback;
4239 tstate->curexc_type = type;
4240 tstate->curexc_value = value;
4241 tstate->curexc_traceback = tb;
4242 Py_XDECREF(tmp_type);
4243 Py_XDECREF(tmp_value);
4244 Py_XDECREF(tmp_tb);
4245 }
__Pyx_ErrFetchInState(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)4246 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
4247 *type = tstate->curexc_type;
4248 *value = tstate->curexc_value;
4249 *tb = tstate->curexc_traceback;
4250 tstate->curexc_type = 0;
4251 tstate->curexc_value = 0;
4252 tstate->curexc_traceback = 0;
4253 }
4254 #endif
4255
4256 /* RaiseException */
4257 #if PY_MAJOR_VERSION < 3
__Pyx_Raise(PyObject * type,PyObject * value,PyObject * tb,CYTHON_UNUSED PyObject * cause)4258 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
4259 CYTHON_UNUSED PyObject *cause) {
4260 __Pyx_PyThreadState_declare
4261 Py_XINCREF(type);
4262 if (!value || value == Py_None)
4263 value = NULL;
4264 else
4265 Py_INCREF(value);
4266 if (!tb || tb == Py_None)
4267 tb = NULL;
4268 else {
4269 Py_INCREF(tb);
4270 if (!PyTraceBack_Check(tb)) {
4271 PyErr_SetString(PyExc_TypeError,
4272 "raise: arg 3 must be a traceback or None");
4273 goto raise_error;
4274 }
4275 }
4276 if (PyType_Check(type)) {
4277 #if CYTHON_COMPILING_IN_PYPY
4278 if (!value) {
4279 Py_INCREF(Py_None);
4280 value = Py_None;
4281 }
4282 #endif
4283 PyErr_NormalizeException(&type, &value, &tb);
4284 } else {
4285 if (value) {
4286 PyErr_SetString(PyExc_TypeError,
4287 "instance exception may not have a separate value");
4288 goto raise_error;
4289 }
4290 value = type;
4291 type = (PyObject*) Py_TYPE(type);
4292 Py_INCREF(type);
4293 if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
4294 PyErr_SetString(PyExc_TypeError,
4295 "raise: exception class must be a subclass of BaseException");
4296 goto raise_error;
4297 }
4298 }
4299 __Pyx_PyThreadState_assign
4300 __Pyx_ErrRestore(type, value, tb);
4301 return;
4302 raise_error:
4303 Py_XDECREF(value);
4304 Py_XDECREF(type);
4305 Py_XDECREF(tb);
4306 return;
4307 }
4308 #else
__Pyx_Raise(PyObject * type,PyObject * value,PyObject * tb,PyObject * cause)4309 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
4310 PyObject* owned_instance = NULL;
4311 if (tb == Py_None) {
4312 tb = 0;
4313 } else if (tb && !PyTraceBack_Check(tb)) {
4314 PyErr_SetString(PyExc_TypeError,
4315 "raise: arg 3 must be a traceback or None");
4316 goto bad;
4317 }
4318 if (value == Py_None)
4319 value = 0;
4320 if (PyExceptionInstance_Check(type)) {
4321 if (value) {
4322 PyErr_SetString(PyExc_TypeError,
4323 "instance exception may not have a separate value");
4324 goto bad;
4325 }
4326 value = type;
4327 type = (PyObject*) Py_TYPE(value);
4328 } else if (PyExceptionClass_Check(type)) {
4329 PyObject *instance_class = NULL;
4330 if (value && PyExceptionInstance_Check(value)) {
4331 instance_class = (PyObject*) Py_TYPE(value);
4332 if (instance_class != type) {
4333 int is_subclass = PyObject_IsSubclass(instance_class, type);
4334 if (!is_subclass) {
4335 instance_class = NULL;
4336 } else if (unlikely(is_subclass == -1)) {
4337 goto bad;
4338 } else {
4339 type = instance_class;
4340 }
4341 }
4342 }
4343 if (!instance_class) {
4344 PyObject *args;
4345 if (!value)
4346 args = PyTuple_New(0);
4347 else if (PyTuple_Check(value)) {
4348 Py_INCREF(value);
4349 args = value;
4350 } else
4351 args = PyTuple_Pack(1, value);
4352 if (!args)
4353 goto bad;
4354 owned_instance = PyObject_Call(type, args, NULL);
4355 Py_DECREF(args);
4356 if (!owned_instance)
4357 goto bad;
4358 value = owned_instance;
4359 if (!PyExceptionInstance_Check(value)) {
4360 PyErr_Format(PyExc_TypeError,
4361 "calling %R should have returned an instance of "
4362 "BaseException, not %R",
4363 type, Py_TYPE(value));
4364 goto bad;
4365 }
4366 }
4367 } else {
4368 PyErr_SetString(PyExc_TypeError,
4369 "raise: exception class must be a subclass of BaseException");
4370 goto bad;
4371 }
4372 if (cause) {
4373 PyObject *fixed_cause;
4374 if (cause == Py_None) {
4375 fixed_cause = NULL;
4376 } else if (PyExceptionClass_Check(cause)) {
4377 fixed_cause = PyObject_CallObject(cause, NULL);
4378 if (fixed_cause == NULL)
4379 goto bad;
4380 } else if (PyExceptionInstance_Check(cause)) {
4381 fixed_cause = cause;
4382 Py_INCREF(fixed_cause);
4383 } else {
4384 PyErr_SetString(PyExc_TypeError,
4385 "exception causes must derive from "
4386 "BaseException");
4387 goto bad;
4388 }
4389 PyException_SetCause(value, fixed_cause);
4390 }
4391 PyErr_SetObject(type, value);
4392 if (tb) {
4393 #if CYTHON_COMPILING_IN_PYPY
4394 PyObject *tmp_type, *tmp_value, *tmp_tb;
4395 PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
4396 Py_INCREF(tb);
4397 PyErr_Restore(tmp_type, tmp_value, tb);
4398 Py_XDECREF(tmp_tb);
4399 #else
4400 PyThreadState *tstate = __Pyx_PyThreadState_Current;
4401 PyObject* tmp_tb = tstate->curexc_traceback;
4402 if (tb != tmp_tb) {
4403 Py_INCREF(tb);
4404 tstate->curexc_traceback = tb;
4405 Py_XDECREF(tmp_tb);
4406 }
4407 #endif
4408 }
4409 bad:
4410 Py_XDECREF(owned_instance);
4411 return;
4412 }
4413 #endif
4414
4415 /* PyObjectCallNoArg */
4416 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_CallNoArg(PyObject * func)4417 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
4418 #if CYTHON_FAST_PYCALL
4419 if (PyFunction_Check(func)) {
4420 return __Pyx_PyFunction_FastCall(func, NULL, 0);
4421 }
4422 #endif
4423 #ifdef __Pyx_CyFunction_USED
4424 if (likely(PyCFunction_Check(func) || __Pyx_CyFunction_Check(func)))
4425 #else
4426 if (likely(PyCFunction_Check(func)))
4427 #endif
4428 {
4429 if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
4430 return __Pyx_PyObject_CallMethO(func, NULL);
4431 }
4432 }
4433 return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
4434 }
4435 #endif
4436
4437 /* None */
__Pyx_div_long(long a,long b)4438 static CYTHON_INLINE long __Pyx_div_long(long a, long b) {
4439 long q = a / b;
4440 long r = a - q*b;
4441 q -= ((r != 0) & ((r ^ b) < 0));
4442 return q;
4443 }
4444
4445 /* IterFinish */
__Pyx_IterFinish(void)4446 static CYTHON_INLINE int __Pyx_IterFinish(void) {
4447 #if CYTHON_FAST_THREAD_STATE
4448 PyThreadState *tstate = __Pyx_PyThreadState_Current;
4449 PyObject* exc_type = tstate->curexc_type;
4450 if (unlikely(exc_type)) {
4451 if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) {
4452 PyObject *exc_value, *exc_tb;
4453 exc_value = tstate->curexc_value;
4454 exc_tb = tstate->curexc_traceback;
4455 tstate->curexc_type = 0;
4456 tstate->curexc_value = 0;
4457 tstate->curexc_traceback = 0;
4458 Py_DECREF(exc_type);
4459 Py_XDECREF(exc_value);
4460 Py_XDECREF(exc_tb);
4461 return 0;
4462 } else {
4463 return -1;
4464 }
4465 }
4466 return 0;
4467 #else
4468 if (unlikely(PyErr_Occurred())) {
4469 if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
4470 PyErr_Clear();
4471 return 0;
4472 } else {
4473 return -1;
4474 }
4475 }
4476 return 0;
4477 #endif
4478 }
4479
4480 /* PyObjectGetMethod */
__Pyx_PyObject_GetMethod(PyObject * obj,PyObject * name,PyObject ** method)4481 static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method) {
4482 PyObject *attr;
4483 #if CYTHON_UNPACK_METHODS && CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_PYTYPE_LOOKUP
4484 PyTypeObject *tp = Py_TYPE(obj);
4485 PyObject *descr;
4486 descrgetfunc f = NULL;
4487 PyObject **dictptr, *dict;
4488 int meth_found = 0;
4489 assert (*method == NULL);
4490 if (unlikely(tp->tp_getattro != PyObject_GenericGetAttr)) {
4491 attr = __Pyx_PyObject_GetAttrStr(obj, name);
4492 goto try_unpack;
4493 }
4494 if (unlikely(tp->tp_dict == NULL) && unlikely(PyType_Ready(tp) < 0)) {
4495 return 0;
4496 }
4497 descr = _PyType_Lookup(tp, name);
4498 if (likely(descr != NULL)) {
4499 Py_INCREF(descr);
4500 #if PY_MAJOR_VERSION >= 3
4501 #ifdef __Pyx_CyFunction_USED
4502 if (likely(PyFunction_Check(descr) || (Py_TYPE(descr) == &PyMethodDescr_Type) || __Pyx_CyFunction_Check(descr)))
4503 #else
4504 if (likely(PyFunction_Check(descr) || (Py_TYPE(descr) == &PyMethodDescr_Type)))
4505 #endif
4506 #else
4507 #ifdef __Pyx_CyFunction_USED
4508 if (likely(PyFunction_Check(descr) || __Pyx_CyFunction_Check(descr)))
4509 #else
4510 if (likely(PyFunction_Check(descr)))
4511 #endif
4512 #endif
4513 {
4514 meth_found = 1;
4515 } else {
4516 f = Py_TYPE(descr)->tp_descr_get;
4517 if (f != NULL && PyDescr_IsData(descr)) {
4518 attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
4519 Py_DECREF(descr);
4520 goto try_unpack;
4521 }
4522 }
4523 }
4524 dictptr = _PyObject_GetDictPtr(obj);
4525 if (dictptr != NULL && (dict = *dictptr) != NULL) {
4526 Py_INCREF(dict);
4527 attr = __Pyx_PyDict_GetItemStr(dict, name);
4528 if (attr != NULL) {
4529 Py_INCREF(attr);
4530 Py_DECREF(dict);
4531 Py_XDECREF(descr);
4532 goto try_unpack;
4533 }
4534 Py_DECREF(dict);
4535 }
4536 if (meth_found) {
4537 *method = descr;
4538 return 1;
4539 }
4540 if (f != NULL) {
4541 attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
4542 Py_DECREF(descr);
4543 goto try_unpack;
4544 }
4545 if (descr != NULL) {
4546 *method = descr;
4547 return 0;
4548 }
4549 PyErr_Format(PyExc_AttributeError,
4550 #if PY_MAJOR_VERSION >= 3
4551 "'%.50s' object has no attribute '%U'",
4552 tp->tp_name, name);
4553 #else
4554 "'%.50s' object has no attribute '%.400s'",
4555 tp->tp_name, PyString_AS_STRING(name));
4556 #endif
4557 return 0;
4558 #else
4559 attr = __Pyx_PyObject_GetAttrStr(obj, name);
4560 goto try_unpack;
4561 #endif
4562 try_unpack:
4563 #if CYTHON_UNPACK_METHODS
4564 if (likely(attr) && PyMethod_Check(attr) && likely(PyMethod_GET_SELF(attr) == obj)) {
4565 PyObject *function = PyMethod_GET_FUNCTION(attr);
4566 Py_INCREF(function);
4567 Py_DECREF(attr);
4568 *method = function;
4569 return 1;
4570 }
4571 #endif
4572 *method = attr;
4573 return 0;
4574 }
4575
4576 /* PyObjectCallMethod0 */
__Pyx_PyObject_CallMethod0(PyObject * obj,PyObject * method_name)4577 static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name) {
4578 PyObject *method = NULL, *result = NULL;
4579 int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method);
4580 if (likely(is_method)) {
4581 result = __Pyx_PyObject_CallOneArg(method, obj);
4582 Py_DECREF(method);
4583 return result;
4584 }
4585 if (unlikely(!method)) goto bad;
4586 result = __Pyx_PyObject_CallNoArg(method);
4587 Py_DECREF(method);
4588 bad:
4589 return result;
4590 }
4591
4592 /* RaiseNeedMoreValuesToUnpack */
__Pyx_RaiseNeedMoreValuesError(Py_ssize_t index)4593 static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
4594 PyErr_Format(PyExc_ValueError,
4595 "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
4596 index, (index == 1) ? "" : "s");
4597 }
4598
4599 /* RaiseTooManyValuesToUnpack */
__Pyx_RaiseTooManyValuesError(Py_ssize_t expected)4600 static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
4601 PyErr_Format(PyExc_ValueError,
4602 "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
4603 }
4604
4605 /* UnpackItemEndCheck */
__Pyx_IternextUnpackEndCheck(PyObject * retval,Py_ssize_t expected)4606 static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
4607 if (unlikely(retval)) {
4608 Py_DECREF(retval);
4609 __Pyx_RaiseTooManyValuesError(expected);
4610 return -1;
4611 } else {
4612 return __Pyx_IterFinish();
4613 }
4614 return 0;
4615 }
4616
4617 /* RaiseNoneIterError */
__Pyx_RaiseNoneNotIterableError(void)4618 static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
4619 PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
4620 }
4621
4622 /* UnpackTupleError */
__Pyx_UnpackTupleError(PyObject * t,Py_ssize_t index)4623 static void __Pyx_UnpackTupleError(PyObject *t, Py_ssize_t index) {
4624 if (t == Py_None) {
4625 __Pyx_RaiseNoneNotIterableError();
4626 } else if (PyTuple_GET_SIZE(t) < index) {
4627 __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(t));
4628 } else {
4629 __Pyx_RaiseTooManyValuesError(index);
4630 }
4631 }
4632
4633 /* UnpackTuple2 */
__Pyx_unpack_tuple2_exact(PyObject * tuple,PyObject ** pvalue1,PyObject ** pvalue2,int decref_tuple)4634 static CYTHON_INLINE int __Pyx_unpack_tuple2_exact(
4635 PyObject* tuple, PyObject** pvalue1, PyObject** pvalue2, int decref_tuple) {
4636 PyObject *value1 = NULL, *value2 = NULL;
4637 #if CYTHON_COMPILING_IN_PYPY
4638 value1 = PySequence_ITEM(tuple, 0); if (unlikely(!value1)) goto bad;
4639 value2 = PySequence_ITEM(tuple, 1); if (unlikely(!value2)) goto bad;
4640 #else
4641 value1 = PyTuple_GET_ITEM(tuple, 0); Py_INCREF(value1);
4642 value2 = PyTuple_GET_ITEM(tuple, 1); Py_INCREF(value2);
4643 #endif
4644 if (decref_tuple) {
4645 Py_DECREF(tuple);
4646 }
4647 *pvalue1 = value1;
4648 *pvalue2 = value2;
4649 return 0;
4650 #if CYTHON_COMPILING_IN_PYPY
4651 bad:
4652 Py_XDECREF(value1);
4653 Py_XDECREF(value2);
4654 if (decref_tuple) { Py_XDECREF(tuple); }
4655 return -1;
4656 #endif
4657 }
__Pyx_unpack_tuple2_generic(PyObject * tuple,PyObject ** pvalue1,PyObject ** pvalue2,int has_known_size,int decref_tuple)4658 static int __Pyx_unpack_tuple2_generic(PyObject* tuple, PyObject** pvalue1, PyObject** pvalue2,
4659 int has_known_size, int decref_tuple) {
4660 Py_ssize_t index;
4661 PyObject *value1 = NULL, *value2 = NULL, *iter = NULL;
4662 iternextfunc iternext;
4663 iter = PyObject_GetIter(tuple);
4664 if (unlikely(!iter)) goto bad;
4665 if (decref_tuple) { Py_DECREF(tuple); tuple = NULL; }
4666 iternext = Py_TYPE(iter)->tp_iternext;
4667 value1 = iternext(iter); if (unlikely(!value1)) { index = 0; goto unpacking_failed; }
4668 value2 = iternext(iter); if (unlikely(!value2)) { index = 1; goto unpacking_failed; }
4669 if (!has_known_size && unlikely(__Pyx_IternextUnpackEndCheck(iternext(iter), 2))) goto bad;
4670 Py_DECREF(iter);
4671 *pvalue1 = value1;
4672 *pvalue2 = value2;
4673 return 0;
4674 unpacking_failed:
4675 if (!has_known_size && __Pyx_IterFinish() == 0)
4676 __Pyx_RaiseNeedMoreValuesError(index);
4677 bad:
4678 Py_XDECREF(iter);
4679 Py_XDECREF(value1);
4680 Py_XDECREF(value2);
4681 if (decref_tuple) { Py_XDECREF(tuple); }
4682 return -1;
4683 }
4684
4685 /* dict_iter */
__Pyx_dict_iterator(PyObject * iterable,int is_dict,PyObject * method_name,Py_ssize_t * p_orig_length,int * p_source_is_dict)4686 static CYTHON_INLINE PyObject* __Pyx_dict_iterator(PyObject* iterable, int is_dict, PyObject* method_name,
4687 Py_ssize_t* p_orig_length, int* p_source_is_dict) {
4688 is_dict = is_dict || likely(PyDict_CheckExact(iterable));
4689 *p_source_is_dict = is_dict;
4690 if (is_dict) {
4691 #if !CYTHON_COMPILING_IN_PYPY
4692 *p_orig_length = PyDict_Size(iterable);
4693 Py_INCREF(iterable);
4694 return iterable;
4695 #elif PY_MAJOR_VERSION >= 3
4696 static PyObject *py_items = NULL, *py_keys = NULL, *py_values = NULL;
4697 PyObject **pp = NULL;
4698 if (method_name) {
4699 const char *name = PyUnicode_AsUTF8(method_name);
4700 if (strcmp(name, "iteritems") == 0) pp = &py_items;
4701 else if (strcmp(name, "iterkeys") == 0) pp = &py_keys;
4702 else if (strcmp(name, "itervalues") == 0) pp = &py_values;
4703 if (pp) {
4704 if (!*pp) {
4705 *pp = PyUnicode_FromString(name + 4);
4706 if (!*pp)
4707 return NULL;
4708 }
4709 method_name = *pp;
4710 }
4711 }
4712 #endif
4713 }
4714 *p_orig_length = 0;
4715 if (method_name) {
4716 PyObject* iter;
4717 iterable = __Pyx_PyObject_CallMethod0(iterable, method_name);
4718 if (!iterable)
4719 return NULL;
4720 #if !CYTHON_COMPILING_IN_PYPY
4721 if (PyTuple_CheckExact(iterable) || PyList_CheckExact(iterable))
4722 return iterable;
4723 #endif
4724 iter = PyObject_GetIter(iterable);
4725 Py_DECREF(iterable);
4726 return iter;
4727 }
4728 return PyObject_GetIter(iterable);
4729 }
__Pyx_dict_iter_next(PyObject * iter_obj,CYTHON_NCP_UNUSED Py_ssize_t orig_length,CYTHON_NCP_UNUSED Py_ssize_t * ppos,PyObject ** pkey,PyObject ** pvalue,PyObject ** pitem,int source_is_dict)4730 static CYTHON_INLINE int __Pyx_dict_iter_next(
4731 PyObject* iter_obj, CYTHON_NCP_UNUSED Py_ssize_t orig_length, CYTHON_NCP_UNUSED Py_ssize_t* ppos,
4732 PyObject** pkey, PyObject** pvalue, PyObject** pitem, int source_is_dict) {
4733 PyObject* next_item;
4734 #if !CYTHON_COMPILING_IN_PYPY
4735 if (source_is_dict) {
4736 PyObject *key, *value;
4737 if (unlikely(orig_length != PyDict_Size(iter_obj))) {
4738 PyErr_SetString(PyExc_RuntimeError, "dictionary changed size during iteration");
4739 return -1;
4740 }
4741 if (unlikely(!PyDict_Next(iter_obj, ppos, &key, &value))) {
4742 return 0;
4743 }
4744 if (pitem) {
4745 PyObject* tuple = PyTuple_New(2);
4746 if (unlikely(!tuple)) {
4747 return -1;
4748 }
4749 Py_INCREF(key);
4750 Py_INCREF(value);
4751 PyTuple_SET_ITEM(tuple, 0, key);
4752 PyTuple_SET_ITEM(tuple, 1, value);
4753 *pitem = tuple;
4754 } else {
4755 if (pkey) {
4756 Py_INCREF(key);
4757 *pkey = key;
4758 }
4759 if (pvalue) {
4760 Py_INCREF(value);
4761 *pvalue = value;
4762 }
4763 }
4764 return 1;
4765 } else if (PyTuple_CheckExact(iter_obj)) {
4766 Py_ssize_t pos = *ppos;
4767 if (unlikely(pos >= PyTuple_GET_SIZE(iter_obj))) return 0;
4768 *ppos = pos + 1;
4769 next_item = PyTuple_GET_ITEM(iter_obj, pos);
4770 Py_INCREF(next_item);
4771 } else if (PyList_CheckExact(iter_obj)) {
4772 Py_ssize_t pos = *ppos;
4773 if (unlikely(pos >= PyList_GET_SIZE(iter_obj))) return 0;
4774 *ppos = pos + 1;
4775 next_item = PyList_GET_ITEM(iter_obj, pos);
4776 Py_INCREF(next_item);
4777 } else
4778 #endif
4779 {
4780 next_item = PyIter_Next(iter_obj);
4781 if (unlikely(!next_item)) {
4782 return __Pyx_IterFinish();
4783 }
4784 }
4785 if (pitem) {
4786 *pitem = next_item;
4787 } else if (pkey && pvalue) {
4788 if (__Pyx_unpack_tuple2(next_item, pkey, pvalue, source_is_dict, source_is_dict, 1))
4789 return -1;
4790 } else if (pkey) {
4791 *pkey = next_item;
4792 } else {
4793 *pvalue = next_item;
4794 }
4795 return 1;
4796 }
4797
4798 /* GetItemInt */
__Pyx_GetItemInt_Generic(PyObject * o,PyObject * j)4799 static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
4800 PyObject *r;
4801 if (!j) return NULL;
4802 r = PyObject_GetItem(o, j);
4803 Py_DECREF(j);
4804 return r;
4805 }
__Pyx_GetItemInt_List_Fast(PyObject * o,Py_ssize_t i,CYTHON_NCP_UNUSED int wraparound,CYTHON_NCP_UNUSED int boundscheck)4806 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
4807 CYTHON_NCP_UNUSED int wraparound,
4808 CYTHON_NCP_UNUSED int boundscheck) {
4809 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
4810 Py_ssize_t wrapped_i = i;
4811 if (wraparound & unlikely(i < 0)) {
4812 wrapped_i += PyList_GET_SIZE(o);
4813 }
4814 if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) {
4815 PyObject *r = PyList_GET_ITEM(o, wrapped_i);
4816 Py_INCREF(r);
4817 return r;
4818 }
4819 return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
4820 #else
4821 return PySequence_GetItem(o, i);
4822 #endif
4823 }
__Pyx_GetItemInt_Tuple_Fast(PyObject * o,Py_ssize_t i,CYTHON_NCP_UNUSED int wraparound,CYTHON_NCP_UNUSED int boundscheck)4824 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
4825 CYTHON_NCP_UNUSED int wraparound,
4826 CYTHON_NCP_UNUSED int boundscheck) {
4827 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
4828 Py_ssize_t wrapped_i = i;
4829 if (wraparound & unlikely(i < 0)) {
4830 wrapped_i += PyTuple_GET_SIZE(o);
4831 }
4832 if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) {
4833 PyObject *r = PyTuple_GET_ITEM(o, wrapped_i);
4834 Py_INCREF(r);
4835 return r;
4836 }
4837 return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
4838 #else
4839 return PySequence_GetItem(o, i);
4840 #endif
4841 }
__Pyx_GetItemInt_Fast(PyObject * o,Py_ssize_t i,int is_list,CYTHON_NCP_UNUSED int wraparound,CYTHON_NCP_UNUSED int boundscheck)4842 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
4843 CYTHON_NCP_UNUSED int wraparound,
4844 CYTHON_NCP_UNUSED int boundscheck) {
4845 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
4846 if (is_list || PyList_CheckExact(o)) {
4847 Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
4848 if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) {
4849 PyObject *r = PyList_GET_ITEM(o, n);
4850 Py_INCREF(r);
4851 return r;
4852 }
4853 }
4854 else if (PyTuple_CheckExact(o)) {
4855 Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
4856 if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) {
4857 PyObject *r = PyTuple_GET_ITEM(o, n);
4858 Py_INCREF(r);
4859 return r;
4860 }
4861 } else {
4862 PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
4863 if (likely(m && m->sq_item)) {
4864 if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
4865 Py_ssize_t l = m->sq_length(o);
4866 if (likely(l >= 0)) {
4867 i += l;
4868 } else {
4869 if (!PyErr_ExceptionMatches(PyExc_OverflowError))
4870 return NULL;
4871 PyErr_Clear();
4872 }
4873 }
4874 return m->sq_item(o, i);
4875 }
4876 }
4877 #else
4878 if (is_list || PySequence_Check(o)) {
4879 return PySequence_GetItem(o, i);
4880 }
4881 #endif
4882 return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
4883 }
4884
4885 /* ObjectGetItem */
4886 #if CYTHON_USE_TYPE_SLOTS
__Pyx_PyObject_GetIndex(PyObject * obj,PyObject * index)4887 static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject* index) {
4888 PyObject *runerr;
4889 Py_ssize_t key_value;
4890 PySequenceMethods *m = Py_TYPE(obj)->tp_as_sequence;
4891 if (unlikely(!(m && m->sq_item))) {
4892 PyErr_Format(PyExc_TypeError, "'%.200s' object is not subscriptable", Py_TYPE(obj)->tp_name);
4893 return NULL;
4894 }
4895 key_value = __Pyx_PyIndex_AsSsize_t(index);
4896 if (likely(key_value != -1 || !(runerr = PyErr_Occurred()))) {
4897 return __Pyx_GetItemInt_Fast(obj, key_value, 0, 1, 1);
4898 }
4899 if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) {
4900 PyErr_Clear();
4901 PyErr_Format(PyExc_IndexError, "cannot fit '%.200s' into an index-sized integer", Py_TYPE(index)->tp_name);
4902 }
4903 return NULL;
4904 }
__Pyx_PyObject_GetItem(PyObject * obj,PyObject * key)4905 static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key) {
4906 PyMappingMethods *m = Py_TYPE(obj)->tp_as_mapping;
4907 if (likely(m && m->mp_subscript)) {
4908 return m->mp_subscript(obj, key);
4909 }
4910 return __Pyx_PyObject_GetIndex(obj, key);
4911 }
4912 #endif
4913
4914 /* SetItemInt */
__Pyx_SetItemInt_Generic(PyObject * o,PyObject * j,PyObject * v)4915 static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) {
4916 int r;
4917 if (!j) return -1;
4918 r = PyObject_SetItem(o, j, v);
4919 Py_DECREF(j);
4920 return r;
4921 }
__Pyx_SetItemInt_Fast(PyObject * o,Py_ssize_t i,PyObject * v,int is_list,CYTHON_NCP_UNUSED int wraparound,CYTHON_NCP_UNUSED int boundscheck)4922 static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, int is_list,
4923 CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) {
4924 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
4925 if (is_list || PyList_CheckExact(o)) {
4926 Py_ssize_t n = (!wraparound) ? i : ((likely(i >= 0)) ? i : i + PyList_GET_SIZE(o));
4927 if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o)))) {
4928 PyObject* old = PyList_GET_ITEM(o, n);
4929 Py_INCREF(v);
4930 PyList_SET_ITEM(o, n, v);
4931 Py_DECREF(old);
4932 return 1;
4933 }
4934 } else {
4935 PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
4936 if (likely(m && m->sq_ass_item)) {
4937 if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
4938 Py_ssize_t l = m->sq_length(o);
4939 if (likely(l >= 0)) {
4940 i += l;
4941 } else {
4942 if (!PyErr_ExceptionMatches(PyExc_OverflowError))
4943 return -1;
4944 PyErr_Clear();
4945 }
4946 }
4947 return m->sq_ass_item(o, i, v);
4948 }
4949 }
4950 #else
4951 #if CYTHON_COMPILING_IN_PYPY
4952 if (is_list || (PySequence_Check(o) && !PyDict_Check(o)))
4953 #else
4954 if (is_list || PySequence_Check(o))
4955 #endif
4956 {
4957 return PySequence_SetItem(o, i, v);
4958 }
4959 #endif
4960 return __Pyx_SetItemInt_Generic(o, PyInt_FromSsize_t(i), v);
4961 }
4962
4963 /* PyIntBinop */
4964 #if !CYTHON_COMPILING_IN_PYPY
__Pyx_PyInt_AddObjC(PyObject * op1,PyObject * op2,CYTHON_UNUSED long intval,int inplace,int zerodivision_check)4965 static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) {
4966 (void)inplace;
4967 (void)zerodivision_check;
4968 #if PY_MAJOR_VERSION < 3
4969 if (likely(PyInt_CheckExact(op1))) {
4970 const long b = intval;
4971 long x;
4972 long a = PyInt_AS_LONG(op1);
4973 x = (long)((unsigned long)a + b);
4974 if (likely((x^a) >= 0 || (x^b) >= 0))
4975 return PyInt_FromLong(x);
4976 return PyLong_Type.tp_as_number->nb_add(op1, op2);
4977 }
4978 #endif
4979 #if CYTHON_USE_PYLONG_INTERNALS
4980 if (likely(PyLong_CheckExact(op1))) {
4981 const long b = intval;
4982 long a, x;
4983 #ifdef HAVE_LONG_LONG
4984 const PY_LONG_LONG llb = intval;
4985 PY_LONG_LONG lla, llx;
4986 #endif
4987 const digit* digits = ((PyLongObject*)op1)->ob_digit;
4988 const Py_ssize_t size = Py_SIZE(op1);
4989 if (likely(__Pyx_sst_abs(size) <= 1)) {
4990 a = likely(size) ? digits[0] : 0;
4991 if (size == -1) a = -a;
4992 } else {
4993 switch (size) {
4994 case -2:
4995 if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
4996 a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
4997 break;
4998 #ifdef HAVE_LONG_LONG
4999 } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
5000 lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
5001 goto long_long;
5002 #endif
5003 }
5004 CYTHON_FALLTHROUGH;
5005 case 2:
5006 if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
5007 a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
5008 break;
5009 #ifdef HAVE_LONG_LONG
5010 } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
5011 lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
5012 goto long_long;
5013 #endif
5014 }
5015 CYTHON_FALLTHROUGH;
5016 case -3:
5017 if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
5018 a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
5019 break;
5020 #ifdef HAVE_LONG_LONG
5021 } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
5022 lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
5023 goto long_long;
5024 #endif
5025 }
5026 CYTHON_FALLTHROUGH;
5027 case 3:
5028 if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
5029 a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
5030 break;
5031 #ifdef HAVE_LONG_LONG
5032 } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
5033 lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
5034 goto long_long;
5035 #endif
5036 }
5037 CYTHON_FALLTHROUGH;
5038 case -4:
5039 if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
5040 a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
5041 break;
5042 #ifdef HAVE_LONG_LONG
5043 } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
5044 lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
5045 goto long_long;
5046 #endif
5047 }
5048 CYTHON_FALLTHROUGH;
5049 case 4:
5050 if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
5051 a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
5052 break;
5053 #ifdef HAVE_LONG_LONG
5054 } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
5055 lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
5056 goto long_long;
5057 #endif
5058 }
5059 CYTHON_FALLTHROUGH;
5060 default: return PyLong_Type.tp_as_number->nb_add(op1, op2);
5061 }
5062 }
5063 x = a + b;
5064 return PyLong_FromLong(x);
5065 #ifdef HAVE_LONG_LONG
5066 long_long:
5067 llx = lla + llb;
5068 return PyLong_FromLongLong(llx);
5069 #endif
5070
5071
5072 }
5073 #endif
5074 if (PyFloat_CheckExact(op1)) {
5075 const long b = intval;
5076 double a = PyFloat_AS_DOUBLE(op1);
5077 double result;
5078 PyFPE_START_PROTECT("add", return NULL)
5079 result = ((double)a) + (double)b;
5080 PyFPE_END_PROTECT(result)
5081 return PyFloat_FromDouble(result);
5082 }
5083 return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2);
5084 }
5085 #endif
5086
5087 /* GetTopmostException */
5088 #if CYTHON_USE_EXC_INFO_STACK
5089 static _PyErr_StackItem *
__Pyx_PyErr_GetTopmostException(PyThreadState * tstate)5090 __Pyx_PyErr_GetTopmostException(PyThreadState *tstate)
5091 {
5092 _PyErr_StackItem *exc_info = tstate->exc_info;
5093 while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) &&
5094 exc_info->previous_item != NULL)
5095 {
5096 exc_info = exc_info->previous_item;
5097 }
5098 return exc_info;
5099 }
5100 #endif
5101
5102 /* SaveResetException */
5103 #if CYTHON_FAST_THREAD_STATE
__Pyx__ExceptionSave(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)5104 static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
5105 #if CYTHON_USE_EXC_INFO_STACK
5106 _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
5107 *type = exc_info->exc_type;
5108 *value = exc_info->exc_value;
5109 *tb = exc_info->exc_traceback;
5110 #else
5111 *type = tstate->exc_type;
5112 *value = tstate->exc_value;
5113 *tb = tstate->exc_traceback;
5114 #endif
5115 Py_XINCREF(*type);
5116 Py_XINCREF(*value);
5117 Py_XINCREF(*tb);
5118 }
__Pyx__ExceptionReset(PyThreadState * tstate,PyObject * type,PyObject * value,PyObject * tb)5119 static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
5120 PyObject *tmp_type, *tmp_value, *tmp_tb;
5121 #if CYTHON_USE_EXC_INFO_STACK
5122 _PyErr_StackItem *exc_info = tstate->exc_info;
5123 tmp_type = exc_info->exc_type;
5124 tmp_value = exc_info->exc_value;
5125 tmp_tb = exc_info->exc_traceback;
5126 exc_info->exc_type = type;
5127 exc_info->exc_value = value;
5128 exc_info->exc_traceback = tb;
5129 #else
5130 tmp_type = tstate->exc_type;
5131 tmp_value = tstate->exc_value;
5132 tmp_tb = tstate->exc_traceback;
5133 tstate->exc_type = type;
5134 tstate->exc_value = value;
5135 tstate->exc_traceback = tb;
5136 #endif
5137 Py_XDECREF(tmp_type);
5138 Py_XDECREF(tmp_value);
5139 Py_XDECREF(tmp_tb);
5140 }
5141 #endif
5142
5143 /* PyErrExceptionMatches */
5144 #if CYTHON_FAST_THREAD_STATE
__Pyx_PyErr_ExceptionMatchesTuple(PyObject * exc_type,PyObject * tuple)5145 static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
5146 Py_ssize_t i, n;
5147 n = PyTuple_GET_SIZE(tuple);
5148 #if PY_MAJOR_VERSION >= 3
5149 for (i=0; i<n; i++) {
5150 if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
5151 }
5152 #endif
5153 for (i=0; i<n; i++) {
5154 if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
5155 }
5156 return 0;
5157 }
__Pyx_PyErr_ExceptionMatchesInState(PyThreadState * tstate,PyObject * err)5158 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
5159 PyObject *exc_type = tstate->curexc_type;
5160 if (exc_type == err) return 1;
5161 if (unlikely(!exc_type)) return 0;
5162 if (unlikely(PyTuple_Check(err)))
5163 return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
5164 return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
5165 }
5166 #endif
5167
5168 /* GetException */
5169 #if CYTHON_FAST_THREAD_STATE
__Pyx__GetException(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)5170 static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb)
5171 #else
5172 static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb)
5173 #endif
5174 {
5175 PyObject *local_type, *local_value, *local_tb;
5176 #if CYTHON_FAST_THREAD_STATE
5177 PyObject *tmp_type, *tmp_value, *tmp_tb;
5178 local_type = tstate->curexc_type;
5179 local_value = tstate->curexc_value;
5180 local_tb = tstate->curexc_traceback;
5181 tstate->curexc_type = 0;
5182 tstate->curexc_value = 0;
5183 tstate->curexc_traceback = 0;
5184 #else
5185 PyErr_Fetch(&local_type, &local_value, &local_tb);
5186 #endif
5187 PyErr_NormalizeException(&local_type, &local_value, &local_tb);
5188 #if CYTHON_FAST_THREAD_STATE
5189 if (unlikely(tstate->curexc_type))
5190 #else
5191 if (unlikely(PyErr_Occurred()))
5192 #endif
5193 goto bad;
5194 #if PY_MAJOR_VERSION >= 3
5195 if (local_tb) {
5196 if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
5197 goto bad;
5198 }
5199 #endif
5200 Py_XINCREF(local_tb);
5201 Py_XINCREF(local_type);
5202 Py_XINCREF(local_value);
5203 *type = local_type;
5204 *value = local_value;
5205 *tb = local_tb;
5206 #if CYTHON_FAST_THREAD_STATE
5207 #if CYTHON_USE_EXC_INFO_STACK
5208 {
5209 _PyErr_StackItem *exc_info = tstate->exc_info;
5210 tmp_type = exc_info->exc_type;
5211 tmp_value = exc_info->exc_value;
5212 tmp_tb = exc_info->exc_traceback;
5213 exc_info->exc_type = local_type;
5214 exc_info->exc_value = local_value;
5215 exc_info->exc_traceback = local_tb;
5216 }
5217 #else
5218 tmp_type = tstate->exc_type;
5219 tmp_value = tstate->exc_value;
5220 tmp_tb = tstate->exc_traceback;
5221 tstate->exc_type = local_type;
5222 tstate->exc_value = local_value;
5223 tstate->exc_traceback = local_tb;
5224 #endif
5225 Py_XDECREF(tmp_type);
5226 Py_XDECREF(tmp_value);
5227 Py_XDECREF(tmp_tb);
5228 #else
5229 PyErr_SetExcInfo(local_type, local_value, local_tb);
5230 #endif
5231 return 0;
5232 bad:
5233 *type = 0;
5234 *value = 0;
5235 *tb = 0;
5236 Py_XDECREF(local_type);
5237 Py_XDECREF(local_value);
5238 Py_XDECREF(local_tb);
5239 return -1;
5240 }
5241
5242 /* PyObject_GenericGetAttrNoDict */
5243 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
__Pyx_RaiseGenericGetAttributeError(PyTypeObject * tp,PyObject * attr_name)5244 static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
5245 PyErr_Format(PyExc_AttributeError,
5246 #if PY_MAJOR_VERSION >= 3
5247 "'%.50s' object has no attribute '%U'",
5248 tp->tp_name, attr_name);
5249 #else
5250 "'%.50s' object has no attribute '%.400s'",
5251 tp->tp_name, PyString_AS_STRING(attr_name));
5252 #endif
5253 return NULL;
5254 }
__Pyx_PyObject_GenericGetAttrNoDict(PyObject * obj,PyObject * attr_name)5255 static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
5256 PyObject *descr;
5257 PyTypeObject *tp = Py_TYPE(obj);
5258 if (unlikely(!PyString_Check(attr_name))) {
5259 return PyObject_GenericGetAttr(obj, attr_name);
5260 }
5261 assert(!tp->tp_dictoffset);
5262 descr = _PyType_Lookup(tp, attr_name);
5263 if (unlikely(!descr)) {
5264 return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
5265 }
5266 Py_INCREF(descr);
5267 #if PY_MAJOR_VERSION < 3
5268 if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
5269 #endif
5270 {
5271 descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
5272 if (unlikely(f)) {
5273 PyObject *res = f(descr, obj, (PyObject *)tp);
5274 Py_DECREF(descr);
5275 return res;
5276 }
5277 }
5278 return descr;
5279 }
5280 #endif
5281
5282 /* PyObject_GenericGetAttr */
5283 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
__Pyx_PyObject_GenericGetAttr(PyObject * obj,PyObject * attr_name)5284 static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) {
5285 if (unlikely(Py_TYPE(obj)->tp_dictoffset)) {
5286 return PyObject_GenericGetAttr(obj, attr_name);
5287 }
5288 return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name);
5289 }
5290 #endif
5291
5292 /* PyObjectGetAttrStrNoError */
__Pyx_PyObject_GetAttrStr_ClearAttributeError(void)5293 static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) {
5294 __Pyx_PyThreadState_declare
5295 __Pyx_PyThreadState_assign
5296 if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
5297 __Pyx_PyErr_Clear();
5298 }
__Pyx_PyObject_GetAttrStrNoError(PyObject * obj,PyObject * attr_name)5299 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) {
5300 PyObject *result;
5301 #if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS && PY_VERSION_HEX >= 0x030700B1
5302 PyTypeObject* tp = Py_TYPE(obj);
5303 if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) {
5304 return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1);
5305 }
5306 #endif
5307 result = __Pyx_PyObject_GetAttrStr(obj, attr_name);
5308 if (unlikely(!result)) {
5309 __Pyx_PyObject_GetAttrStr_ClearAttributeError();
5310 }
5311 return result;
5312 }
5313
5314 /* SetupReduce */
__Pyx_setup_reduce_is_named(PyObject * meth,PyObject * name)5315 static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) {
5316 int ret;
5317 PyObject *name_attr;
5318 name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name);
5319 if (likely(name_attr)) {
5320 ret = PyObject_RichCompareBool(name_attr, name, Py_EQ);
5321 } else {
5322 ret = -1;
5323 }
5324 if (unlikely(ret < 0)) {
5325 PyErr_Clear();
5326 ret = 0;
5327 }
5328 Py_XDECREF(name_attr);
5329 return ret;
5330 }
__Pyx_setup_reduce(PyObject * type_obj)5331 static int __Pyx_setup_reduce(PyObject* type_obj) {
5332 int ret = 0;
5333 PyObject *object_reduce = NULL;
5334 PyObject *object_reduce_ex = NULL;
5335 PyObject *reduce = NULL;
5336 PyObject *reduce_ex = NULL;
5337 PyObject *reduce_cython = NULL;
5338 PyObject *setstate = NULL;
5339 PyObject *setstate_cython = NULL;
5340 #if CYTHON_USE_PYTYPE_LOOKUP
5341 if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto __PYX_GOOD;
5342 #else
5343 if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto __PYX_GOOD;
5344 #endif
5345 #if CYTHON_USE_PYTYPE_LOOKUP
5346 object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
5347 #else
5348 object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
5349 #endif
5350 reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto __PYX_BAD;
5351 if (reduce_ex == object_reduce_ex) {
5352 #if CYTHON_USE_PYTYPE_LOOKUP
5353 object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
5354 #else
5355 object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
5356 #endif
5357 reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto __PYX_BAD;
5358 if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) {
5359 reduce_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_reduce_cython);
5360 if (likely(reduce_cython)) {
5361 ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
5362 ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
5363 } else if (reduce == object_reduce || PyErr_Occurred()) {
5364 goto __PYX_BAD;
5365 }
5366 setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate);
5367 if (!setstate) PyErr_Clear();
5368 if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) {
5369 setstate_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_setstate_cython);
5370 if (likely(setstate_cython)) {
5371 ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
5372 ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
5373 } else if (!setstate || PyErr_Occurred()) {
5374 goto __PYX_BAD;
5375 }
5376 }
5377 PyType_Modified((PyTypeObject*)type_obj);
5378 }
5379 }
5380 goto __PYX_GOOD;
5381 __PYX_BAD:
5382 if (!PyErr_Occurred())
5383 PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name);
5384 ret = -1;
5385 __PYX_GOOD:
5386 #if !CYTHON_USE_PYTYPE_LOOKUP
5387 Py_XDECREF(object_reduce);
5388 Py_XDECREF(object_reduce_ex);
5389 #endif
5390 Py_XDECREF(reduce);
5391 Py_XDECREF(reduce_ex);
5392 Py_XDECREF(reduce_cython);
5393 Py_XDECREF(setstate);
5394 Py_XDECREF(setstate_cython);
5395 return ret;
5396 }
5397
5398 /* PyDictVersioning */
5399 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
__Pyx_get_tp_dict_version(PyObject * obj)5400 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
5401 PyObject *dict = Py_TYPE(obj)->tp_dict;
5402 return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
5403 }
__Pyx_get_object_dict_version(PyObject * obj)5404 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
5405 PyObject **dictptr = NULL;
5406 Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
5407 if (offset) {
5408 #if CYTHON_COMPILING_IN_CPYTHON
5409 dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
5410 #else
5411 dictptr = _PyObject_GetDictPtr(obj);
5412 #endif
5413 }
5414 return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
5415 }
__Pyx_object_dict_version_matches(PyObject * obj,PY_UINT64_T tp_dict_version,PY_UINT64_T obj_dict_version)5416 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
5417 PyObject *dict = Py_TYPE(obj)->tp_dict;
5418 if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
5419 return 0;
5420 return obj_dict_version == __Pyx_get_object_dict_version(obj);
5421 }
5422 #endif
5423
5424 /* CLineInTraceback */
5425 #ifndef CYTHON_CLINE_IN_TRACEBACK
__Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState * tstate,int c_line)5426 static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) {
5427 PyObject *use_cline;
5428 PyObject *ptype, *pvalue, *ptraceback;
5429 #if CYTHON_COMPILING_IN_CPYTHON
5430 PyObject **cython_runtime_dict;
5431 #endif
5432 if (unlikely(!__pyx_cython_runtime)) {
5433 return c_line;
5434 }
5435 __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
5436 #if CYTHON_COMPILING_IN_CPYTHON
5437 cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
5438 if (likely(cython_runtime_dict)) {
5439 __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
5440 use_cline, *cython_runtime_dict,
5441 __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback))
5442 } else
5443 #endif
5444 {
5445 PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
5446 if (use_cline_obj) {
5447 use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
5448 Py_DECREF(use_cline_obj);
5449 } else {
5450 PyErr_Clear();
5451 use_cline = NULL;
5452 }
5453 }
5454 if (!use_cline) {
5455 c_line = 0;
5456 PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
5457 }
5458 else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
5459 c_line = 0;
5460 }
5461 __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
5462 return c_line;
5463 }
5464 #endif
5465
5466 /* CodeObjectCache */
__pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry * entries,int count,int code_line)5467 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
5468 int start = 0, mid = 0, end = count - 1;
5469 if (end >= 0 && code_line > entries[end].code_line) {
5470 return count;
5471 }
5472 while (start < end) {
5473 mid = start + (end - start) / 2;
5474 if (code_line < entries[mid].code_line) {
5475 end = mid;
5476 } else if (code_line > entries[mid].code_line) {
5477 start = mid + 1;
5478 } else {
5479 return mid;
5480 }
5481 }
5482 if (code_line <= entries[mid].code_line) {
5483 return mid;
5484 } else {
5485 return mid + 1;
5486 }
5487 }
__pyx_find_code_object(int code_line)5488 static PyCodeObject *__pyx_find_code_object(int code_line) {
5489 PyCodeObject* code_object;
5490 int pos;
5491 if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
5492 return NULL;
5493 }
5494 pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
5495 if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
5496 return NULL;
5497 }
5498 code_object = __pyx_code_cache.entries[pos].code_object;
5499 Py_INCREF(code_object);
5500 return code_object;
5501 }
__pyx_insert_code_object(int code_line,PyCodeObject * code_object)5502 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
5503 int pos, i;
5504 __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
5505 if (unlikely(!code_line)) {
5506 return;
5507 }
5508 if (unlikely(!entries)) {
5509 entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
5510 if (likely(entries)) {
5511 __pyx_code_cache.entries = entries;
5512 __pyx_code_cache.max_count = 64;
5513 __pyx_code_cache.count = 1;
5514 entries[0].code_line = code_line;
5515 entries[0].code_object = code_object;
5516 Py_INCREF(code_object);
5517 }
5518 return;
5519 }
5520 pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
5521 if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
5522 PyCodeObject* tmp = entries[pos].code_object;
5523 entries[pos].code_object = code_object;
5524 Py_DECREF(tmp);
5525 return;
5526 }
5527 if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
5528 int new_max = __pyx_code_cache.max_count + 64;
5529 entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
5530 __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry));
5531 if (unlikely(!entries)) {
5532 return;
5533 }
5534 __pyx_code_cache.entries = entries;
5535 __pyx_code_cache.max_count = new_max;
5536 }
5537 for (i=__pyx_code_cache.count; i>pos; i--) {
5538 entries[i] = entries[i-1];
5539 }
5540 entries[pos].code_line = code_line;
5541 entries[pos].code_object = code_object;
5542 __pyx_code_cache.count++;
5543 Py_INCREF(code_object);
5544 }
5545
5546 /* AddTraceback */
5547 #include "compile.h"
5548 #include "frameobject.h"
5549 #include "traceback.h"
__Pyx_CreateCodeObjectForTraceback(const char * funcname,int c_line,int py_line,const char * filename)5550 static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
5551 const char *funcname, int c_line,
5552 int py_line, const char *filename) {
5553 PyCodeObject *py_code = 0;
5554 PyObject *py_srcfile = 0;
5555 PyObject *py_funcname = 0;
5556 #if PY_MAJOR_VERSION < 3
5557 py_srcfile = PyString_FromString(filename);
5558 #else
5559 py_srcfile = PyUnicode_FromString(filename);
5560 #endif
5561 if (!py_srcfile) goto bad;
5562 if (c_line) {
5563 #if PY_MAJOR_VERSION < 3
5564 py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
5565 #else
5566 py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
5567 #endif
5568 }
5569 else {
5570 #if PY_MAJOR_VERSION < 3
5571 py_funcname = PyString_FromString(funcname);
5572 #else
5573 py_funcname = PyUnicode_FromString(funcname);
5574 #endif
5575 }
5576 if (!py_funcname) goto bad;
5577 py_code = __Pyx_PyCode_New(
5578 0,
5579 0,
5580 0,
5581 0,
5582 0,
5583 __pyx_empty_bytes, /*PyObject *code,*/
5584 __pyx_empty_tuple, /*PyObject *consts,*/
5585 __pyx_empty_tuple, /*PyObject *names,*/
5586 __pyx_empty_tuple, /*PyObject *varnames,*/
5587 __pyx_empty_tuple, /*PyObject *freevars,*/
5588 __pyx_empty_tuple, /*PyObject *cellvars,*/
5589 py_srcfile, /*PyObject *filename,*/
5590 py_funcname, /*PyObject *name,*/
5591 py_line,
5592 __pyx_empty_bytes /*PyObject *lnotab*/
5593 );
5594 Py_DECREF(py_srcfile);
5595 Py_DECREF(py_funcname);
5596 return py_code;
5597 bad:
5598 Py_XDECREF(py_srcfile);
5599 Py_XDECREF(py_funcname);
5600 return NULL;
5601 }
__Pyx_AddTraceback(const char * funcname,int c_line,int py_line,const char * filename)5602 static void __Pyx_AddTraceback(const char *funcname, int c_line,
5603 int py_line, const char *filename) {
5604 PyCodeObject *py_code = 0;
5605 PyFrameObject *py_frame = 0;
5606 PyThreadState *tstate = __Pyx_PyThreadState_Current;
5607 if (c_line) {
5608 c_line = __Pyx_CLineForTraceback(tstate, c_line);
5609 }
5610 py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
5611 if (!py_code) {
5612 py_code = __Pyx_CreateCodeObjectForTraceback(
5613 funcname, c_line, py_line, filename);
5614 if (!py_code) goto bad;
5615 __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
5616 }
5617 py_frame = PyFrame_New(
5618 tstate, /*PyThreadState *tstate,*/
5619 py_code, /*PyCodeObject *code,*/
5620 __pyx_d, /*PyObject *globals,*/
5621 0 /*PyObject *locals*/
5622 );
5623 if (!py_frame) goto bad;
5624 __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
5625 PyTraceBack_Here(py_frame);
5626 bad:
5627 Py_XDECREF(py_code);
5628 Py_XDECREF(py_frame);
5629 }
5630
5631 /* CIntFromPyVerify */
5632 #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
5633 __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
5634 #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
5635 __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
5636 #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
5637 {\
5638 func_type value = func_value;\
5639 if (sizeof(target_type) < sizeof(func_type)) {\
5640 if (unlikely(value != (func_type) (target_type) value)) {\
5641 func_type zero = 0;\
5642 if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
5643 return (target_type) -1;\
5644 if (is_unsigned && unlikely(value < zero))\
5645 goto raise_neg_overflow;\
5646 else\
5647 goto raise_overflow;\
5648 }\
5649 }\
5650 return (target_type) value;\
5651 }
5652
5653 /* CIntFromPy */
__Pyx_PyInt_As_int(PyObject * x)5654 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
5655 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
5656 #pragma GCC diagnostic push
5657 #pragma GCC diagnostic ignored "-Wconversion"
5658 #endif
5659 const int neg_one = (int) -1, const_zero = (int) 0;
5660 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
5661 #pragma GCC diagnostic pop
5662 #endif
5663 const int is_unsigned = neg_one > const_zero;
5664 #if PY_MAJOR_VERSION < 3
5665 if (likely(PyInt_Check(x))) {
5666 if (sizeof(int) < sizeof(long)) {
5667 __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
5668 } else {
5669 long val = PyInt_AS_LONG(x);
5670 if (is_unsigned && unlikely(val < 0)) {
5671 goto raise_neg_overflow;
5672 }
5673 return (int) val;
5674 }
5675 } else
5676 #endif
5677 if (likely(PyLong_Check(x))) {
5678 if (is_unsigned) {
5679 #if CYTHON_USE_PYLONG_INTERNALS
5680 const digit* digits = ((PyLongObject*)x)->ob_digit;
5681 switch (Py_SIZE(x)) {
5682 case 0: return (int) 0;
5683 case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
5684 case 2:
5685 if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
5686 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
5687 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
5688 } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
5689 return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
5690 }
5691 }
5692 break;
5693 case 3:
5694 if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
5695 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
5696 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
5697 } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
5698 return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
5699 }
5700 }
5701 break;
5702 case 4:
5703 if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
5704 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
5705 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
5706 } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
5707 return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
5708 }
5709 }
5710 break;
5711 }
5712 #endif
5713 #if CYTHON_COMPILING_IN_CPYTHON
5714 if (unlikely(Py_SIZE(x) < 0)) {
5715 goto raise_neg_overflow;
5716 }
5717 #else
5718 {
5719 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
5720 if (unlikely(result < 0))
5721 return (int) -1;
5722 if (unlikely(result == 1))
5723 goto raise_neg_overflow;
5724 }
5725 #endif
5726 if (sizeof(int) <= sizeof(unsigned long)) {
5727 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
5728 #ifdef HAVE_LONG_LONG
5729 } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
5730 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
5731 #endif
5732 }
5733 } else {
5734 #if CYTHON_USE_PYLONG_INTERNALS
5735 const digit* digits = ((PyLongObject*)x)->ob_digit;
5736 switch (Py_SIZE(x)) {
5737 case 0: return (int) 0;
5738 case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
5739 case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0])
5740 case -2:
5741 if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
5742 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
5743 __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
5744 } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
5745 return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
5746 }
5747 }
5748 break;
5749 case 2:
5750 if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
5751 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
5752 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
5753 } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
5754 return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
5755 }
5756 }
5757 break;
5758 case -3:
5759 if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
5760 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
5761 __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
5762 } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
5763 return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
5764 }
5765 }
5766 break;
5767 case 3:
5768 if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
5769 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
5770 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
5771 } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
5772 return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
5773 }
5774 }
5775 break;
5776 case -4:
5777 if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
5778 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
5779 __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
5780 } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
5781 return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
5782 }
5783 }
5784 break;
5785 case 4:
5786 if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
5787 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
5788 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
5789 } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
5790 return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
5791 }
5792 }
5793 break;
5794 }
5795 #endif
5796 if (sizeof(int) <= sizeof(long)) {
5797 __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
5798 #ifdef HAVE_LONG_LONG
5799 } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
5800 __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
5801 #endif
5802 }
5803 }
5804 {
5805 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
5806 PyErr_SetString(PyExc_RuntimeError,
5807 "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
5808 #else
5809 int val;
5810 PyObject *v = __Pyx_PyNumber_IntOrLong(x);
5811 #if PY_MAJOR_VERSION < 3
5812 if (likely(v) && !PyLong_Check(v)) {
5813 PyObject *tmp = v;
5814 v = PyNumber_Long(tmp);
5815 Py_DECREF(tmp);
5816 }
5817 #endif
5818 if (likely(v)) {
5819 int one = 1; int is_little = (int)*(unsigned char *)&one;
5820 unsigned char *bytes = (unsigned char *)&val;
5821 int ret = _PyLong_AsByteArray((PyLongObject *)v,
5822 bytes, sizeof(val),
5823 is_little, !is_unsigned);
5824 Py_DECREF(v);
5825 if (likely(!ret))
5826 return val;
5827 }
5828 #endif
5829 return (int) -1;
5830 }
5831 } else {
5832 int val;
5833 PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
5834 if (!tmp) return (int) -1;
5835 val = __Pyx_PyInt_As_int(tmp);
5836 Py_DECREF(tmp);
5837 return val;
5838 }
5839 raise_overflow:
5840 PyErr_SetString(PyExc_OverflowError,
5841 "value too large to convert to int");
5842 return (int) -1;
5843 raise_neg_overflow:
5844 PyErr_SetString(PyExc_OverflowError,
5845 "can't convert negative value to int");
5846 return (int) -1;
5847 }
5848
5849 /* CIntToPy */
__Pyx_PyInt_From_int(int value)5850 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
5851 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
5852 #pragma GCC diagnostic push
5853 #pragma GCC diagnostic ignored "-Wconversion"
5854 #endif
5855 const int neg_one = (int) -1, const_zero = (int) 0;
5856 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
5857 #pragma GCC diagnostic pop
5858 #endif
5859 const int is_unsigned = neg_one > const_zero;
5860 if (is_unsigned) {
5861 if (sizeof(int) < sizeof(long)) {
5862 return PyInt_FromLong((long) value);
5863 } else if (sizeof(int) <= sizeof(unsigned long)) {
5864 return PyLong_FromUnsignedLong((unsigned long) value);
5865 #ifdef HAVE_LONG_LONG
5866 } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
5867 return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
5868 #endif
5869 }
5870 } else {
5871 if (sizeof(int) <= sizeof(long)) {
5872 return PyInt_FromLong((long) value);
5873 #ifdef HAVE_LONG_LONG
5874 } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
5875 return PyLong_FromLongLong((PY_LONG_LONG) value);
5876 #endif
5877 }
5878 }
5879 {
5880 int one = 1; int little = (int)*(unsigned char *)&one;
5881 unsigned char *bytes = (unsigned char *)&value;
5882 return _PyLong_FromByteArray(bytes, sizeof(int),
5883 little, !is_unsigned);
5884 }
5885 }
5886
5887 /* CIntToPy */
__Pyx_PyInt_From_long(long value)5888 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
5889 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
5890 #pragma GCC diagnostic push
5891 #pragma GCC diagnostic ignored "-Wconversion"
5892 #endif
5893 const long neg_one = (long) -1, const_zero = (long) 0;
5894 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
5895 #pragma GCC diagnostic pop
5896 #endif
5897 const int is_unsigned = neg_one > const_zero;
5898 if (is_unsigned) {
5899 if (sizeof(long) < sizeof(long)) {
5900 return PyInt_FromLong((long) value);
5901 } else if (sizeof(long) <= sizeof(unsigned long)) {
5902 return PyLong_FromUnsignedLong((unsigned long) value);
5903 #ifdef HAVE_LONG_LONG
5904 } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
5905 return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
5906 #endif
5907 }
5908 } else {
5909 if (sizeof(long) <= sizeof(long)) {
5910 return PyInt_FromLong((long) value);
5911 #ifdef HAVE_LONG_LONG
5912 } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
5913 return PyLong_FromLongLong((PY_LONG_LONG) value);
5914 #endif
5915 }
5916 }
5917 {
5918 int one = 1; int little = (int)*(unsigned char *)&one;
5919 unsigned char *bytes = (unsigned char *)&value;
5920 return _PyLong_FromByteArray(bytes, sizeof(long),
5921 little, !is_unsigned);
5922 }
5923 }
5924
5925 /* CIntFromPy */
__Pyx_PyInt_As_long(PyObject * x)5926 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
5927 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
5928 #pragma GCC diagnostic push
5929 #pragma GCC diagnostic ignored "-Wconversion"
5930 #endif
5931 const long neg_one = (long) -1, const_zero = (long) 0;
5932 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
5933 #pragma GCC diagnostic pop
5934 #endif
5935 const int is_unsigned = neg_one > const_zero;
5936 #if PY_MAJOR_VERSION < 3
5937 if (likely(PyInt_Check(x))) {
5938 if (sizeof(long) < sizeof(long)) {
5939 __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
5940 } else {
5941 long val = PyInt_AS_LONG(x);
5942 if (is_unsigned && unlikely(val < 0)) {
5943 goto raise_neg_overflow;
5944 }
5945 return (long) val;
5946 }
5947 } else
5948 #endif
5949 if (likely(PyLong_Check(x))) {
5950 if (is_unsigned) {
5951 #if CYTHON_USE_PYLONG_INTERNALS
5952 const digit* digits = ((PyLongObject*)x)->ob_digit;
5953 switch (Py_SIZE(x)) {
5954 case 0: return (long) 0;
5955 case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
5956 case 2:
5957 if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
5958 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
5959 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
5960 } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
5961 return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
5962 }
5963 }
5964 break;
5965 case 3:
5966 if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
5967 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
5968 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
5969 } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
5970 return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
5971 }
5972 }
5973 break;
5974 case 4:
5975 if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
5976 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
5977 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
5978 } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
5979 return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
5980 }
5981 }
5982 break;
5983 }
5984 #endif
5985 #if CYTHON_COMPILING_IN_CPYTHON
5986 if (unlikely(Py_SIZE(x) < 0)) {
5987 goto raise_neg_overflow;
5988 }
5989 #else
5990 {
5991 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
5992 if (unlikely(result < 0))
5993 return (long) -1;
5994 if (unlikely(result == 1))
5995 goto raise_neg_overflow;
5996 }
5997 #endif
5998 if (sizeof(long) <= sizeof(unsigned long)) {
5999 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
6000 #ifdef HAVE_LONG_LONG
6001 } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
6002 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
6003 #endif
6004 }
6005 } else {
6006 #if CYTHON_USE_PYLONG_INTERNALS
6007 const digit* digits = ((PyLongObject*)x)->ob_digit;
6008 switch (Py_SIZE(x)) {
6009 case 0: return (long) 0;
6010 case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
6011 case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
6012 case -2:
6013 if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
6014 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
6015 __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
6016 } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
6017 return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
6018 }
6019 }
6020 break;
6021 case 2:
6022 if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
6023 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
6024 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
6025 } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
6026 return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
6027 }
6028 }
6029 break;
6030 case -3:
6031 if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
6032 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
6033 __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
6034 } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
6035 return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
6036 }
6037 }
6038 break;
6039 case 3:
6040 if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
6041 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
6042 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
6043 } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
6044 return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
6045 }
6046 }
6047 break;
6048 case -4:
6049 if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
6050 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
6051 __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
6052 } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
6053 return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
6054 }
6055 }
6056 break;
6057 case 4:
6058 if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
6059 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
6060 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
6061 } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
6062 return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
6063 }
6064 }
6065 break;
6066 }
6067 #endif
6068 if (sizeof(long) <= sizeof(long)) {
6069 __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
6070 #ifdef HAVE_LONG_LONG
6071 } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
6072 __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
6073 #endif
6074 }
6075 }
6076 {
6077 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
6078 PyErr_SetString(PyExc_RuntimeError,
6079 "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
6080 #else
6081 long val;
6082 PyObject *v = __Pyx_PyNumber_IntOrLong(x);
6083 #if PY_MAJOR_VERSION < 3
6084 if (likely(v) && !PyLong_Check(v)) {
6085 PyObject *tmp = v;
6086 v = PyNumber_Long(tmp);
6087 Py_DECREF(tmp);
6088 }
6089 #endif
6090 if (likely(v)) {
6091 int one = 1; int is_little = (int)*(unsigned char *)&one;
6092 unsigned char *bytes = (unsigned char *)&val;
6093 int ret = _PyLong_AsByteArray((PyLongObject *)v,
6094 bytes, sizeof(val),
6095 is_little, !is_unsigned);
6096 Py_DECREF(v);
6097 if (likely(!ret))
6098 return val;
6099 }
6100 #endif
6101 return (long) -1;
6102 }
6103 } else {
6104 long val;
6105 PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
6106 if (!tmp) return (long) -1;
6107 val = __Pyx_PyInt_As_long(tmp);
6108 Py_DECREF(tmp);
6109 return val;
6110 }
6111 raise_overflow:
6112 PyErr_SetString(PyExc_OverflowError,
6113 "value too large to convert to long");
6114 return (long) -1;
6115 raise_neg_overflow:
6116 PyErr_SetString(PyExc_OverflowError,
6117 "can't convert negative value to long");
6118 return (long) -1;
6119 }
6120
6121 /* FastTypeChecks */
6122 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_InBases(PyTypeObject * a,PyTypeObject * b)6123 static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
6124 while (a) {
6125 a = a->tp_base;
6126 if (a == b)
6127 return 1;
6128 }
6129 return b == &PyBaseObject_Type;
6130 }
__Pyx_IsSubtype(PyTypeObject * a,PyTypeObject * b)6131 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
6132 PyObject *mro;
6133 if (a == b) return 1;
6134 mro = a->tp_mro;
6135 if (likely(mro)) {
6136 Py_ssize_t i, n;
6137 n = PyTuple_GET_SIZE(mro);
6138 for (i = 0; i < n; i++) {
6139 if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
6140 return 1;
6141 }
6142 return 0;
6143 }
6144 return __Pyx_InBases(a, b);
6145 }
6146 #if PY_MAJOR_VERSION == 2
__Pyx_inner_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)6147 static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
6148 PyObject *exception, *value, *tb;
6149 int res;
6150 __Pyx_PyThreadState_declare
6151 __Pyx_PyThreadState_assign
6152 __Pyx_ErrFetch(&exception, &value, &tb);
6153 res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
6154 if (unlikely(res == -1)) {
6155 PyErr_WriteUnraisable(err);
6156 res = 0;
6157 }
6158 if (!res) {
6159 res = PyObject_IsSubclass(err, exc_type2);
6160 if (unlikely(res == -1)) {
6161 PyErr_WriteUnraisable(err);
6162 res = 0;
6163 }
6164 }
6165 __Pyx_ErrRestore(exception, value, tb);
6166 return res;
6167 }
6168 #else
__Pyx_inner_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)6169 static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
6170 int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
6171 if (!res) {
6172 res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
6173 }
6174 return res;
6175 }
6176 #endif
__Pyx_PyErr_GivenExceptionMatchesTuple(PyObject * exc_type,PyObject * tuple)6177 static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
6178 Py_ssize_t i, n;
6179 assert(PyExceptionClass_Check(exc_type));
6180 n = PyTuple_GET_SIZE(tuple);
6181 #if PY_MAJOR_VERSION >= 3
6182 for (i=0; i<n; i++) {
6183 if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
6184 }
6185 #endif
6186 for (i=0; i<n; i++) {
6187 PyObject *t = PyTuple_GET_ITEM(tuple, i);
6188 #if PY_MAJOR_VERSION < 3
6189 if (likely(exc_type == t)) return 1;
6190 #endif
6191 if (likely(PyExceptionClass_Check(t))) {
6192 if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
6193 } else {
6194 }
6195 }
6196 return 0;
6197 }
__Pyx_PyErr_GivenExceptionMatches(PyObject * err,PyObject * exc_type)6198 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
6199 if (likely(err == exc_type)) return 1;
6200 if (likely(PyExceptionClass_Check(err))) {
6201 if (likely(PyExceptionClass_Check(exc_type))) {
6202 return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
6203 } else if (likely(PyTuple_Check(exc_type))) {
6204 return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
6205 } else {
6206 }
6207 }
6208 return PyErr_GivenExceptionMatches(err, exc_type);
6209 }
__Pyx_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)6210 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
6211 assert(PyExceptionClass_Check(exc_type1));
6212 assert(PyExceptionClass_Check(exc_type2));
6213 if (likely(err == exc_type1 || err == exc_type2)) return 1;
6214 if (likely(PyExceptionClass_Check(err))) {
6215 return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
6216 }
6217 return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
6218 }
6219 #endif
6220
6221 /* CheckBinaryVersion */
__Pyx_check_binary_version(void)6222 static int __Pyx_check_binary_version(void) {
6223 char ctversion[4], rtversion[4];
6224 PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
6225 PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
6226 if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
6227 char message[200];
6228 PyOS_snprintf(message, sizeof(message),
6229 "compiletime version %s of module '%.100s' "
6230 "does not match runtime version %s",
6231 ctversion, __Pyx_MODULE_NAME, rtversion);
6232 return PyErr_WarnEx(NULL, message, 1);
6233 }
6234 return 0;
6235 }
6236
6237 /* InitStrings */
__Pyx_InitStrings(__Pyx_StringTabEntry * t)6238 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
6239 while (t->p) {
6240 #if PY_MAJOR_VERSION < 3
6241 if (t->is_unicode) {
6242 *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
6243 } else if (t->intern) {
6244 *t->p = PyString_InternFromString(t->s);
6245 } else {
6246 *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
6247 }
6248 #else
6249 if (t->is_unicode | t->is_str) {
6250 if (t->intern) {
6251 *t->p = PyUnicode_InternFromString(t->s);
6252 } else if (t->encoding) {
6253 *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
6254 } else {
6255 *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
6256 }
6257 } else {
6258 *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
6259 }
6260 #endif
6261 if (!*t->p)
6262 return -1;
6263 if (PyObject_Hash(*t->p) == -1)
6264 return -1;
6265 ++t;
6266 }
6267 return 0;
6268 }
6269
__Pyx_PyUnicode_FromString(const char * c_str)6270 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
6271 return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
6272 }
__Pyx_PyObject_AsString(PyObject * o)6273 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
6274 Py_ssize_t ignore;
6275 return __Pyx_PyObject_AsStringAndSize(o, &ignore);
6276 }
6277 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
6278 #if !CYTHON_PEP393_ENABLED
__Pyx_PyUnicode_AsStringAndSize(PyObject * o,Py_ssize_t * length)6279 static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
6280 char* defenc_c;
6281 PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
6282 if (!defenc) return NULL;
6283 defenc_c = PyBytes_AS_STRING(defenc);
6284 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
6285 {
6286 char* end = defenc_c + PyBytes_GET_SIZE(defenc);
6287 char* c;
6288 for (c = defenc_c; c < end; c++) {
6289 if ((unsigned char) (*c) >= 128) {
6290 PyUnicode_AsASCIIString(o);
6291 return NULL;
6292 }
6293 }
6294 }
6295 #endif
6296 *length = PyBytes_GET_SIZE(defenc);
6297 return defenc_c;
6298 }
6299 #else
__Pyx_PyUnicode_AsStringAndSize(PyObject * o,Py_ssize_t * length)6300 static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
6301 if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
6302 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
6303 if (likely(PyUnicode_IS_ASCII(o))) {
6304 *length = PyUnicode_GET_LENGTH(o);
6305 return PyUnicode_AsUTF8(o);
6306 } else {
6307 PyUnicode_AsASCIIString(o);
6308 return NULL;
6309 }
6310 #else
6311 return PyUnicode_AsUTF8AndSize(o, length);
6312 #endif
6313 }
6314 #endif
6315 #endif
__Pyx_PyObject_AsStringAndSize(PyObject * o,Py_ssize_t * length)6316 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
6317 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
6318 if (
6319 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
6320 __Pyx_sys_getdefaultencoding_not_ascii &&
6321 #endif
6322 PyUnicode_Check(o)) {
6323 return __Pyx_PyUnicode_AsStringAndSize(o, length);
6324 } else
6325 #endif
6326 #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
6327 if (PyByteArray_Check(o)) {
6328 *length = PyByteArray_GET_SIZE(o);
6329 return PyByteArray_AS_STRING(o);
6330 } else
6331 #endif
6332 {
6333 char* result;
6334 int r = PyBytes_AsStringAndSize(o, &result, length);
6335 if (unlikely(r < 0)) {
6336 return NULL;
6337 } else {
6338 return result;
6339 }
6340 }
6341 }
__Pyx_PyObject_IsTrue(PyObject * x)6342 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
6343 int is_true = x == Py_True;
6344 if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
6345 else return PyObject_IsTrue(x);
6346 }
__Pyx_PyObject_IsTrueAndDecref(PyObject * x)6347 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
6348 int retval;
6349 if (unlikely(!x)) return -1;
6350 retval = __Pyx_PyObject_IsTrue(x);
6351 Py_DECREF(x);
6352 return retval;
6353 }
__Pyx_PyNumber_IntOrLongWrongResultType(PyObject * result,const char * type_name)6354 static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
6355 #if PY_MAJOR_VERSION >= 3
6356 if (PyLong_Check(result)) {
6357 if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
6358 "__int__ returned non-int (type %.200s). "
6359 "The ability to return an instance of a strict subclass of int "
6360 "is deprecated, and may be removed in a future version of Python.",
6361 Py_TYPE(result)->tp_name)) {
6362 Py_DECREF(result);
6363 return NULL;
6364 }
6365 return result;
6366 }
6367 #endif
6368 PyErr_Format(PyExc_TypeError,
6369 "__%.4s__ returned non-%.4s (type %.200s)",
6370 type_name, type_name, Py_TYPE(result)->tp_name);
6371 Py_DECREF(result);
6372 return NULL;
6373 }
__Pyx_PyNumber_IntOrLong(PyObject * x)6374 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
6375 #if CYTHON_USE_TYPE_SLOTS
6376 PyNumberMethods *m;
6377 #endif
6378 const char *name = NULL;
6379 PyObject *res = NULL;
6380 #if PY_MAJOR_VERSION < 3
6381 if (likely(PyInt_Check(x) || PyLong_Check(x)))
6382 #else
6383 if (likely(PyLong_Check(x)))
6384 #endif
6385 return __Pyx_NewRef(x);
6386 #if CYTHON_USE_TYPE_SLOTS
6387 m = Py_TYPE(x)->tp_as_number;
6388 #if PY_MAJOR_VERSION < 3
6389 if (m && m->nb_int) {
6390 name = "int";
6391 res = m->nb_int(x);
6392 }
6393 else if (m && m->nb_long) {
6394 name = "long";
6395 res = m->nb_long(x);
6396 }
6397 #else
6398 if (likely(m && m->nb_int)) {
6399 name = "int";
6400 res = m->nb_int(x);
6401 }
6402 #endif
6403 #else
6404 if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
6405 res = PyNumber_Int(x);
6406 }
6407 #endif
6408 if (likely(res)) {
6409 #if PY_MAJOR_VERSION < 3
6410 if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
6411 #else
6412 if (unlikely(!PyLong_CheckExact(res))) {
6413 #endif
6414 return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
6415 }
6416 }
6417 else if (!PyErr_Occurred()) {
6418 PyErr_SetString(PyExc_TypeError,
6419 "an integer is required");
6420 }
6421 return res;
6422 }
6423 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
6424 Py_ssize_t ival;
6425 PyObject *x;
6426 #if PY_MAJOR_VERSION < 3
6427 if (likely(PyInt_CheckExact(b))) {
6428 if (sizeof(Py_ssize_t) >= sizeof(long))
6429 return PyInt_AS_LONG(b);
6430 else
6431 return PyInt_AsSsize_t(b);
6432 }
6433 #endif
6434 if (likely(PyLong_CheckExact(b))) {
6435 #if CYTHON_USE_PYLONG_INTERNALS
6436 const digit* digits = ((PyLongObject*)b)->ob_digit;
6437 const Py_ssize_t size = Py_SIZE(b);
6438 if (likely(__Pyx_sst_abs(size) <= 1)) {
6439 ival = likely(size) ? digits[0] : 0;
6440 if (size == -1) ival = -ival;
6441 return ival;
6442 } else {
6443 switch (size) {
6444 case 2:
6445 if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
6446 return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
6447 }
6448 break;
6449 case -2:
6450 if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
6451 return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
6452 }
6453 break;
6454 case 3:
6455 if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
6456 return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
6457 }
6458 break;
6459 case -3:
6460 if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
6461 return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
6462 }
6463 break;
6464 case 4:
6465 if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
6466 return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
6467 }
6468 break;
6469 case -4:
6470 if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
6471 return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
6472 }
6473 break;
6474 }
6475 }
6476 #endif
6477 return PyLong_AsSsize_t(b);
6478 }
6479 x = PyNumber_Index(b);
6480 if (!x) return -1;
6481 ival = PyInt_AsSsize_t(x);
6482 Py_DECREF(x);
6483 return ival;
6484 }
6485 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
6486 return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
6487 }
6488 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
6489 return PyInt_FromSize_t(ival);
6490 }
6491
6492
6493 #endif /* Py_PYTHON_H */
6494