1 /* Generated by Cython 0.29.21 */
2
3 /* BEGIN: Cython Metadata
4 {
5 "distutils": {
6 "depends": [],
7 "language": "c",
8 "name": "gensim.corpora._mmreader",
9 "sources": [
10 "gensim/corpora/_mmreader.pyx"
11 ]
12 },
13 "module_name": "gensim.corpora._mmreader"
14 }
15 END: Cython Metadata */
16
17 #define PY_SSIZE_T_CLEAN
18 #include "Python.h"
19 #ifndef Py_PYTHON_H
20 #error Python headers needed to compile C extensions, please install development version of Python.
21 #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
22 #error Cython requires Python 2.6+ or Python 3.3+.
23 #else
24 #define CYTHON_ABI "0_29_21"
25 #define CYTHON_HEX_VERSION 0x001D15F0
26 #define CYTHON_FUTURE_DIVISION 0
27 #include <stddef.h>
28 #ifndef offsetof
29 #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
30 #endif
31 #if !defined(WIN32) && !defined(MS_WINDOWS)
32 #ifndef __stdcall
33 #define __stdcall
34 #endif
35 #ifndef __cdecl
36 #define __cdecl
37 #endif
38 #ifndef __fastcall
39 #define __fastcall
40 #endif
41 #endif
42 #ifndef DL_IMPORT
43 #define DL_IMPORT(t) t
44 #endif
45 #ifndef DL_EXPORT
46 #define DL_EXPORT(t) t
47 #endif
48 #define __PYX_COMMA ,
49 #ifndef HAVE_LONG_LONG
50 #if PY_VERSION_HEX >= 0x02070000
51 #define HAVE_LONG_LONG
52 #endif
53 #endif
54 #ifndef PY_LONG_LONG
55 #define PY_LONG_LONG LONG_LONG
56 #endif
57 #ifndef Py_HUGE_VAL
58 #define Py_HUGE_VAL HUGE_VAL
59 #endif
60 #ifdef PYPY_VERSION
61 #define CYTHON_COMPILING_IN_PYPY 1
62 #define CYTHON_COMPILING_IN_PYSTON 0
63 #define CYTHON_COMPILING_IN_CPYTHON 0
64 #undef CYTHON_USE_TYPE_SLOTS
65 #define CYTHON_USE_TYPE_SLOTS 0
66 #undef CYTHON_USE_PYTYPE_LOOKUP
67 #define CYTHON_USE_PYTYPE_LOOKUP 0
68 #if PY_VERSION_HEX < 0x03050000
69 #undef CYTHON_USE_ASYNC_SLOTS
70 #define CYTHON_USE_ASYNC_SLOTS 0
71 #elif !defined(CYTHON_USE_ASYNC_SLOTS)
72 #define CYTHON_USE_ASYNC_SLOTS 1
73 #endif
74 #undef CYTHON_USE_PYLIST_INTERNALS
75 #define CYTHON_USE_PYLIST_INTERNALS 0
76 #undef CYTHON_USE_UNICODE_INTERNALS
77 #define CYTHON_USE_UNICODE_INTERNALS 0
78 #undef CYTHON_USE_UNICODE_WRITER
79 #define CYTHON_USE_UNICODE_WRITER 0
80 #undef CYTHON_USE_PYLONG_INTERNALS
81 #define CYTHON_USE_PYLONG_INTERNALS 0
82 #undef CYTHON_AVOID_BORROWED_REFS
83 #define CYTHON_AVOID_BORROWED_REFS 1
84 #undef CYTHON_ASSUME_SAFE_MACROS
85 #define CYTHON_ASSUME_SAFE_MACROS 0
86 #undef CYTHON_UNPACK_METHODS
87 #define CYTHON_UNPACK_METHODS 0
88 #undef CYTHON_FAST_THREAD_STATE
89 #define CYTHON_FAST_THREAD_STATE 0
90 #undef CYTHON_FAST_PYCALL
91 #define CYTHON_FAST_PYCALL 0
92 #undef CYTHON_PEP489_MULTI_PHASE_INIT
93 #define CYTHON_PEP489_MULTI_PHASE_INIT 0
94 #undef CYTHON_USE_TP_FINALIZE
95 #define CYTHON_USE_TP_FINALIZE 0
96 #undef CYTHON_USE_DICT_VERSIONS
97 #define CYTHON_USE_DICT_VERSIONS 0
98 #undef CYTHON_USE_EXC_INFO_STACK
99 #define CYTHON_USE_EXC_INFO_STACK 0
100 #elif defined(PYSTON_VERSION)
101 #define CYTHON_COMPILING_IN_PYPY 0
102 #define CYTHON_COMPILING_IN_PYSTON 1
103 #define CYTHON_COMPILING_IN_CPYTHON 0
104 #ifndef CYTHON_USE_TYPE_SLOTS
105 #define CYTHON_USE_TYPE_SLOTS 1
106 #endif
107 #undef CYTHON_USE_PYTYPE_LOOKUP
108 #define CYTHON_USE_PYTYPE_LOOKUP 0
109 #undef CYTHON_USE_ASYNC_SLOTS
110 #define CYTHON_USE_ASYNC_SLOTS 0
111 #undef CYTHON_USE_PYLIST_INTERNALS
112 #define CYTHON_USE_PYLIST_INTERNALS 0
113 #ifndef CYTHON_USE_UNICODE_INTERNALS
114 #define CYTHON_USE_UNICODE_INTERNALS 1
115 #endif
116 #undef CYTHON_USE_UNICODE_WRITER
117 #define CYTHON_USE_UNICODE_WRITER 0
118 #undef CYTHON_USE_PYLONG_INTERNALS
119 #define CYTHON_USE_PYLONG_INTERNALS 0
120 #ifndef CYTHON_AVOID_BORROWED_REFS
121 #define CYTHON_AVOID_BORROWED_REFS 0
122 #endif
123 #ifndef CYTHON_ASSUME_SAFE_MACROS
124 #define CYTHON_ASSUME_SAFE_MACROS 1
125 #endif
126 #ifndef CYTHON_UNPACK_METHODS
127 #define CYTHON_UNPACK_METHODS 1
128 #endif
129 #undef CYTHON_FAST_THREAD_STATE
130 #define CYTHON_FAST_THREAD_STATE 0
131 #undef CYTHON_FAST_PYCALL
132 #define CYTHON_FAST_PYCALL 0
133 #undef CYTHON_PEP489_MULTI_PHASE_INIT
134 #define CYTHON_PEP489_MULTI_PHASE_INIT 0
135 #undef CYTHON_USE_TP_FINALIZE
136 #define CYTHON_USE_TP_FINALIZE 0
137 #undef CYTHON_USE_DICT_VERSIONS
138 #define CYTHON_USE_DICT_VERSIONS 0
139 #undef CYTHON_USE_EXC_INFO_STACK
140 #define CYTHON_USE_EXC_INFO_STACK 0
141 #else
142 #define CYTHON_COMPILING_IN_PYPY 0
143 #define CYTHON_COMPILING_IN_PYSTON 0
144 #define CYTHON_COMPILING_IN_CPYTHON 1
145 #ifndef CYTHON_USE_TYPE_SLOTS
146 #define CYTHON_USE_TYPE_SLOTS 1
147 #endif
148 #if PY_VERSION_HEX < 0x02070000
149 #undef CYTHON_USE_PYTYPE_LOOKUP
150 #define CYTHON_USE_PYTYPE_LOOKUP 0
151 #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
152 #define CYTHON_USE_PYTYPE_LOOKUP 1
153 #endif
154 #if PY_MAJOR_VERSION < 3
155 #undef CYTHON_USE_ASYNC_SLOTS
156 #define CYTHON_USE_ASYNC_SLOTS 0
157 #elif !defined(CYTHON_USE_ASYNC_SLOTS)
158 #define CYTHON_USE_ASYNC_SLOTS 1
159 #endif
160 #if PY_VERSION_HEX < 0x02070000
161 #undef CYTHON_USE_PYLONG_INTERNALS
162 #define CYTHON_USE_PYLONG_INTERNALS 0
163 #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
164 #define CYTHON_USE_PYLONG_INTERNALS 1
165 #endif
166 #ifndef CYTHON_USE_PYLIST_INTERNALS
167 #define CYTHON_USE_PYLIST_INTERNALS 1
168 #endif
169 #ifndef CYTHON_USE_UNICODE_INTERNALS
170 #define CYTHON_USE_UNICODE_INTERNALS 1
171 #endif
172 #if PY_VERSION_HEX < 0x030300F0
173 #undef CYTHON_USE_UNICODE_WRITER
174 #define CYTHON_USE_UNICODE_WRITER 0
175 #elif !defined(CYTHON_USE_UNICODE_WRITER)
176 #define CYTHON_USE_UNICODE_WRITER 1
177 #endif
178 #ifndef CYTHON_AVOID_BORROWED_REFS
179 #define CYTHON_AVOID_BORROWED_REFS 0
180 #endif
181 #ifndef CYTHON_ASSUME_SAFE_MACROS
182 #define CYTHON_ASSUME_SAFE_MACROS 1
183 #endif
184 #ifndef CYTHON_UNPACK_METHODS
185 #define CYTHON_UNPACK_METHODS 1
186 #endif
187 #ifndef CYTHON_FAST_THREAD_STATE
188 #define CYTHON_FAST_THREAD_STATE 1
189 #endif
190 #ifndef CYTHON_FAST_PYCALL
191 #define CYTHON_FAST_PYCALL 1
192 #endif
193 #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
194 #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000)
195 #endif
196 #ifndef CYTHON_USE_TP_FINALIZE
197 #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
198 #endif
199 #ifndef CYTHON_USE_DICT_VERSIONS
200 #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1)
201 #endif
202 #ifndef CYTHON_USE_EXC_INFO_STACK
203 #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3)
204 #endif
205 #endif
206 #if !defined(CYTHON_FAST_PYCCALL)
207 #define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
208 #endif
209 #if CYTHON_USE_PYLONG_INTERNALS
210 #include "longintrepr.h"
211 #undef SHIFT
212 #undef BASE
213 #undef MASK
214 #ifdef SIZEOF_VOID_P
215 enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) };
216 #endif
217 #endif
218 #ifndef __has_attribute
219 #define __has_attribute(x) 0
220 #endif
221 #ifndef __has_cpp_attribute
222 #define __has_cpp_attribute(x) 0
223 #endif
224 #ifndef CYTHON_RESTRICT
225 #if defined(__GNUC__)
226 #define CYTHON_RESTRICT __restrict__
227 #elif defined(_MSC_VER) && _MSC_VER >= 1400
228 #define CYTHON_RESTRICT __restrict
229 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
230 #define CYTHON_RESTRICT restrict
231 #else
232 #define CYTHON_RESTRICT
233 #endif
234 #endif
235 #ifndef CYTHON_UNUSED
236 # if defined(__GNUC__)
237 # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
238 # define CYTHON_UNUSED __attribute__ ((__unused__))
239 # else
240 # define CYTHON_UNUSED
241 # endif
242 # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
243 # define CYTHON_UNUSED __attribute__ ((__unused__))
244 # else
245 # define CYTHON_UNUSED
246 # endif
247 #endif
248 #ifndef CYTHON_MAYBE_UNUSED_VAR
249 # if defined(__cplusplus)
CYTHON_MAYBE_UNUSED_VAR(const T &)250 template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
251 # else
252 # define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
253 # endif
254 #endif
255 #ifndef CYTHON_NCP_UNUSED
256 # if CYTHON_COMPILING_IN_CPYTHON
257 # define CYTHON_NCP_UNUSED
258 # else
259 # define CYTHON_NCP_UNUSED CYTHON_UNUSED
260 # endif
261 #endif
262 #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
263 #ifdef _MSC_VER
264 #ifndef _MSC_STDINT_H_
265 #if _MSC_VER < 1300
266 typedef unsigned char uint8_t;
267 typedef unsigned int uint32_t;
268 #else
269 typedef unsigned __int8 uint8_t;
270 typedef unsigned __int32 uint32_t;
271 #endif
272 #endif
273 #else
274 #include <stdint.h>
275 #endif
276 #ifndef CYTHON_FALLTHROUGH
277 #if defined(__cplusplus) && __cplusplus >= 201103L
278 #if __has_cpp_attribute(fallthrough)
279 #define CYTHON_FALLTHROUGH [[fallthrough]]
280 #elif __has_cpp_attribute(clang::fallthrough)
281 #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
282 #elif __has_cpp_attribute(gnu::fallthrough)
283 #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
284 #endif
285 #endif
286 #ifndef CYTHON_FALLTHROUGH
287 #if __has_attribute(fallthrough)
288 #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
289 #else
290 #define CYTHON_FALLTHROUGH
291 #endif
292 #endif
293 #if defined(__clang__ ) && defined(__apple_build_version__)
294 #if __apple_build_version__ < 7000000
295 #undef CYTHON_FALLTHROUGH
296 #define CYTHON_FALLTHROUGH
297 #endif
298 #endif
299 #endif
300
301 #ifndef CYTHON_INLINE
302 #if defined(__clang__)
303 #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
304 #elif defined(__GNUC__)
305 #define CYTHON_INLINE __inline__
306 #elif defined(_MSC_VER)
307 #define CYTHON_INLINE __inline
308 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
309 #define CYTHON_INLINE inline
310 #else
311 #define CYTHON_INLINE
312 #endif
313 #endif
314
315 #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
316 #define Py_OptimizeFlag 0
317 #endif
318 #define __PYX_BUILD_PY_SSIZE_T "n"
319 #define CYTHON_FORMAT_SSIZE_T "z"
320 #if PY_MAJOR_VERSION < 3
321 #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
322 #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
323 PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
324 #define __Pyx_DefaultClassType PyClass_Type
325 #else
326 #define __Pyx_BUILTIN_MODULE_NAME "builtins"
327 #if PY_VERSION_HEX >= 0x030800A4 && PY_VERSION_HEX < 0x030800B2
328 #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
329 PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
330 #else
331 #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
332 PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
333 #endif
334 #define __Pyx_DefaultClassType PyType_Type
335 #endif
336 #ifndef Py_TPFLAGS_CHECKTYPES
337 #define Py_TPFLAGS_CHECKTYPES 0
338 #endif
339 #ifndef Py_TPFLAGS_HAVE_INDEX
340 #define Py_TPFLAGS_HAVE_INDEX 0
341 #endif
342 #ifndef Py_TPFLAGS_HAVE_NEWBUFFER
343 #define Py_TPFLAGS_HAVE_NEWBUFFER 0
344 #endif
345 #ifndef Py_TPFLAGS_HAVE_FINALIZE
346 #define Py_TPFLAGS_HAVE_FINALIZE 0
347 #endif
348 #ifndef METH_STACKLESS
349 #define METH_STACKLESS 0
350 #endif
351 #if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
352 #ifndef METH_FASTCALL
353 #define METH_FASTCALL 0x80
354 #endif
355 typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
356 typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
357 Py_ssize_t nargs, PyObject *kwnames);
358 #else
359 #define __Pyx_PyCFunctionFast _PyCFunctionFast
360 #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
361 #endif
362 #if CYTHON_FAST_PYCCALL
363 #define __Pyx_PyFastCFunction_Check(func)\
364 ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)))))
365 #else
366 #define __Pyx_PyFastCFunction_Check(func) 0
367 #endif
368 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
369 #define PyObject_Malloc(s) PyMem_Malloc(s)
370 #define PyObject_Free(p) PyMem_Free(p)
371 #define PyObject_Realloc(p) PyMem_Realloc(p)
372 #endif
373 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1
374 #define PyMem_RawMalloc(n) PyMem_Malloc(n)
375 #define PyMem_RawRealloc(p, n) PyMem_Realloc(p, n)
376 #define PyMem_RawFree(p) PyMem_Free(p)
377 #endif
378 #if CYTHON_COMPILING_IN_PYSTON
379 #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co)
380 #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
381 #else
382 #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
383 #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
384 #endif
385 #if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
386 #define __Pyx_PyThreadState_Current PyThreadState_GET()
387 #elif PY_VERSION_HEX >= 0x03060000
388 #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
389 #elif PY_VERSION_HEX >= 0x03000000
390 #define __Pyx_PyThreadState_Current PyThreadState_GET()
391 #else
392 #define __Pyx_PyThreadState_Current _PyThreadState_Current
393 #endif
394 #if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
395 #include "pythread.h"
396 #define Py_tss_NEEDS_INIT 0
397 typedef int Py_tss_t;
PyThread_tss_create(Py_tss_t * key)398 static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
399 *key = PyThread_create_key();
400 return 0;
401 }
PyThread_tss_alloc(void)402 static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
403 Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
404 *key = Py_tss_NEEDS_INIT;
405 return key;
406 }
PyThread_tss_free(Py_tss_t * key)407 static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
408 PyObject_Free(key);
409 }
PyThread_tss_is_created(Py_tss_t * key)410 static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
411 return *key != Py_tss_NEEDS_INIT;
412 }
PyThread_tss_delete(Py_tss_t * key)413 static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
414 PyThread_delete_key(*key);
415 *key = Py_tss_NEEDS_INIT;
416 }
PyThread_tss_set(Py_tss_t * key,void * value)417 static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
418 return PyThread_set_key_value(*key, value);
419 }
PyThread_tss_get(Py_tss_t * key)420 static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
421 return PyThread_get_key_value(*key);
422 }
423 #endif
424 #if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
425 #define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
426 #else
427 #define __Pyx_PyDict_NewPresized(n) PyDict_New()
428 #endif
429 #if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
430 #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
431 #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
432 #else
433 #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
434 #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
435 #endif
436 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
437 #define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
438 #else
439 #define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name)
440 #endif
441 #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
442 #define CYTHON_PEP393_ENABLED 1
443 #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
444 0 : _PyUnicode_Ready((PyObject *)(op)))
445 #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
446 #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
447 #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
448 #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
449 #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
450 #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
451 #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch)
452 #if defined(PyUnicode_IS_READY) && defined(PyUnicode_GET_SIZE)
453 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
454 #else
455 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_LENGTH(u))
456 #endif
457 #else
458 #define CYTHON_PEP393_ENABLED 0
459 #define PyUnicode_1BYTE_KIND 1
460 #define PyUnicode_2BYTE_KIND 2
461 #define PyUnicode_4BYTE_KIND 4
462 #define __Pyx_PyUnicode_READY(op) (0)
463 #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
464 #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
465 #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
466 #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
467 #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
468 #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
469 #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
470 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u))
471 #endif
472 #if CYTHON_COMPILING_IN_PYPY
473 #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
474 #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
475 #else
476 #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
477 #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
478 PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
479 #endif
480 #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
481 #define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
482 #endif
483 #if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
484 #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
485 #endif
486 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
487 #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
488 #endif
489 #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))
490 #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
491 #if PY_MAJOR_VERSION >= 3
492 #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
493 #else
494 #define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
495 #endif
496 #if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
497 #define PyObject_ASCII(o) PyObject_Repr(o)
498 #endif
499 #if PY_MAJOR_VERSION >= 3
500 #define PyBaseString_Type PyUnicode_Type
501 #define PyStringObject PyUnicodeObject
502 #define PyString_Type PyUnicode_Type
503 #define PyString_Check PyUnicode_Check
504 #define PyString_CheckExact PyUnicode_CheckExact
505 #ifndef PyObject_Unicode
506 #define PyObject_Unicode PyObject_Str
507 #endif
508 #endif
509 #if PY_MAJOR_VERSION >= 3
510 #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
511 #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
512 #else
513 #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
514 #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
515 #endif
516 #ifndef PySet_CheckExact
517 #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
518 #endif
519 #if PY_VERSION_HEX >= 0x030900A4
520 #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt)
521 #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size)
522 #else
523 #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt)
524 #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size)
525 #endif
526 #if CYTHON_ASSUME_SAFE_MACROS
527 #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq)
528 #else
529 #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq)
530 #endif
531 #if PY_MAJOR_VERSION >= 3
532 #define PyIntObject PyLongObject
533 #define PyInt_Type PyLong_Type
534 #define PyInt_Check(op) PyLong_Check(op)
535 #define PyInt_CheckExact(op) PyLong_CheckExact(op)
536 #define PyInt_FromString PyLong_FromString
537 #define PyInt_FromUnicode PyLong_FromUnicode
538 #define PyInt_FromLong PyLong_FromLong
539 #define PyInt_FromSize_t PyLong_FromSize_t
540 #define PyInt_FromSsize_t PyLong_FromSsize_t
541 #define PyInt_AsLong PyLong_AsLong
542 #define PyInt_AS_LONG PyLong_AS_LONG
543 #define PyInt_AsSsize_t PyLong_AsSsize_t
544 #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
545 #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
546 #define PyNumber_Int PyNumber_Long
547 #endif
548 #if PY_MAJOR_VERSION >= 3
549 #define PyBoolObject PyLongObject
550 #endif
551 #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
552 #ifndef PyUnicode_InternFromString
553 #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
554 #endif
555 #endif
556 #if PY_VERSION_HEX < 0x030200A4
557 typedef long Py_hash_t;
558 #define __Pyx_PyInt_FromHash_t PyInt_FromLong
559 #define __Pyx_PyInt_AsHash_t PyInt_AsLong
560 #else
561 #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
562 #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
563 #endif
564 #if PY_MAJOR_VERSION >= 3
565 #define __Pyx_PyMethod_New(func, self, klass) ((self) ? ((void)(klass), PyMethod_New(func, self)) : __Pyx_NewRef(func))
566 #else
567 #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
568 #endif
569 #if CYTHON_USE_ASYNC_SLOTS
570 #if PY_VERSION_HEX >= 0x030500B1
571 #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
572 #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
573 #else
574 #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
575 #endif
576 #else
577 #define __Pyx_PyType_AsAsync(obj) NULL
578 #endif
579 #ifndef __Pyx_PyAsyncMethodsStruct
580 typedef struct {
581 unaryfunc am_await;
582 unaryfunc am_aiter;
583 unaryfunc am_anext;
584 } __Pyx_PyAsyncMethodsStruct;
585 #endif
586
587 #if defined(WIN32) || defined(MS_WINDOWS)
588 #define _USE_MATH_DEFINES
589 #endif
590 #include <math.h>
591 #ifdef NAN
592 #define __PYX_NAN() ((float) NAN)
593 #else
__PYX_NAN()594 static CYTHON_INLINE float __PYX_NAN() {
595 float value;
596 memset(&value, 0xFF, sizeof(value));
597 return value;
598 }
599 #endif
600 #if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
601 #define __Pyx_truncl trunc
602 #else
603 #define __Pyx_truncl truncl
604 #endif
605
606 #define __PYX_MARK_ERR_POS(f_index, lineno) \
607 { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; }
608 #define __PYX_ERR(f_index, lineno, Ln_error) \
609 { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; }
610
611 #ifndef __PYX_EXTERN_C
612 #ifdef __cplusplus
613 #define __PYX_EXTERN_C extern "C"
614 #else
615 #define __PYX_EXTERN_C extern
616 #endif
617 #endif
618
619 #define __PYX_HAVE__gensim__corpora___mmreader
620 #define __PYX_HAVE_API__gensim__corpora___mmreader
621 /* Early includes */
622 #include <string.h>
623 #include <stdio.h>
624 #ifdef _OPENMP
625 #include <omp.h>
626 #endif /* _OPENMP */
627
628 #if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
629 #define CYTHON_WITHOUT_ASSERTIONS
630 #endif
631
632 typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
633 const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
634
635 #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
636 #define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0
637 #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8)
638 #define __PYX_DEFAULT_STRING_ENCODING ""
639 #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
640 #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
641 #define __Pyx_uchar_cast(c) ((unsigned char)c)
642 #define __Pyx_long_cast(x) ((long)x)
643 #define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
644 (sizeof(type) < sizeof(Py_ssize_t)) ||\
645 (sizeof(type) > sizeof(Py_ssize_t) &&\
646 likely(v < (type)PY_SSIZE_T_MAX ||\
647 v == (type)PY_SSIZE_T_MAX) &&\
648 (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
649 v == (type)PY_SSIZE_T_MIN))) ||\
650 (sizeof(type) == sizeof(Py_ssize_t) &&\
651 (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
652 v == (type)PY_SSIZE_T_MAX))) )
__Pyx_is_valid_index(Py_ssize_t i,Py_ssize_t limit)653 static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
654 return (size_t) i < (size_t) limit;
655 }
656 #if defined (__cplusplus) && __cplusplus >= 201103L
657 #include <cstdlib>
658 #define __Pyx_sst_abs(value) std::abs(value)
659 #elif SIZEOF_INT >= SIZEOF_SIZE_T
660 #define __Pyx_sst_abs(value) abs(value)
661 #elif SIZEOF_LONG >= SIZEOF_SIZE_T
662 #define __Pyx_sst_abs(value) labs(value)
663 #elif defined (_MSC_VER)
664 #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
665 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
666 #define __Pyx_sst_abs(value) llabs(value)
667 #elif defined (__GNUC__)
668 #define __Pyx_sst_abs(value) __builtin_llabs(value)
669 #else
670 #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
671 #endif
672 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
673 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
674 #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
675 #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
676 #define __Pyx_PyBytes_FromString PyBytes_FromString
677 #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
678 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
679 #if PY_MAJOR_VERSION < 3
680 #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
681 #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
682 #else
683 #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
684 #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
685 #endif
686 #define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s))
687 #define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s))
688 #define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s))
689 #define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s))
690 #define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s))
691 #define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s))
692 #define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s))
693 #define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
694 #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
695 #define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s))
696 #define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s))
697 #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
698 #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
699 #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
700 #define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s)
701 #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
__Pyx_Py_UNICODE_strlen(const Py_UNICODE * u)702 static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
703 const Py_UNICODE *u_end = u;
704 while (*u_end++) ;
705 return (size_t)(u_end - u - 1);
706 }
707 #define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
708 #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
709 #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
710 #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
711 #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
712 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
713 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
714 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
715 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
716 #define __Pyx_PySequence_Tuple(obj)\
717 (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
718 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
719 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
720 #if CYTHON_ASSUME_SAFE_MACROS
721 #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
722 #else
723 #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
724 #endif
725 #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
726 #if PY_MAJOR_VERSION >= 3
727 #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
728 #else
729 #define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
730 #endif
731 #define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
732 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
733 static int __Pyx_sys_getdefaultencoding_not_ascii;
__Pyx_init_sys_getdefaultencoding_params(void)734 static int __Pyx_init_sys_getdefaultencoding_params(void) {
735 PyObject* sys;
736 PyObject* default_encoding = NULL;
737 PyObject* ascii_chars_u = NULL;
738 PyObject* ascii_chars_b = NULL;
739 const char* default_encoding_c;
740 sys = PyImport_ImportModule("sys");
741 if (!sys) goto bad;
742 default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
743 Py_DECREF(sys);
744 if (!default_encoding) goto bad;
745 default_encoding_c = PyBytes_AsString(default_encoding);
746 if (!default_encoding_c) goto bad;
747 if (strcmp(default_encoding_c, "ascii") == 0) {
748 __Pyx_sys_getdefaultencoding_not_ascii = 0;
749 } else {
750 char ascii_chars[128];
751 int c;
752 for (c = 0; c < 128; c++) {
753 ascii_chars[c] = c;
754 }
755 __Pyx_sys_getdefaultencoding_not_ascii = 1;
756 ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
757 if (!ascii_chars_u) goto bad;
758 ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
759 if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
760 PyErr_Format(
761 PyExc_ValueError,
762 "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
763 default_encoding_c);
764 goto bad;
765 }
766 Py_DECREF(ascii_chars_u);
767 Py_DECREF(ascii_chars_b);
768 }
769 Py_DECREF(default_encoding);
770 return 0;
771 bad:
772 Py_XDECREF(default_encoding);
773 Py_XDECREF(ascii_chars_u);
774 Py_XDECREF(ascii_chars_b);
775 return -1;
776 }
777 #endif
778 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
779 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
780 #else
781 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
782 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
783 static char* __PYX_DEFAULT_STRING_ENCODING;
__Pyx_init_sys_getdefaultencoding_params(void)784 static int __Pyx_init_sys_getdefaultencoding_params(void) {
785 PyObject* sys;
786 PyObject* default_encoding = NULL;
787 char* default_encoding_c;
788 sys = PyImport_ImportModule("sys");
789 if (!sys) goto bad;
790 default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
791 Py_DECREF(sys);
792 if (!default_encoding) goto bad;
793 default_encoding_c = PyBytes_AsString(default_encoding);
794 if (!default_encoding_c) goto bad;
795 __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1);
796 if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
797 strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
798 Py_DECREF(default_encoding);
799 return 0;
800 bad:
801 Py_XDECREF(default_encoding);
802 return -1;
803 }
804 #endif
805 #endif
806
807
808 /* Test for GCC > 2.95 */
809 #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
810 #define likely(x) __builtin_expect(!!(x), 1)
811 #define unlikely(x) __builtin_expect(!!(x), 0)
812 #else /* !__GNUC__ or GCC < 2.95 */
813 #define likely(x) (x)
814 #define unlikely(x) (x)
815 #endif /* __GNUC__ */
__Pyx_pretend_to_initialize(void * ptr)816 static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
817
818 static PyObject *__pyx_m = NULL;
819 static PyObject *__pyx_d;
820 static PyObject *__pyx_b;
821 static PyObject *__pyx_cython_runtime = NULL;
822 static PyObject *__pyx_empty_tuple;
823 static PyObject *__pyx_empty_bytes;
824 static PyObject *__pyx_empty_unicode;
825 static int __pyx_lineno;
826 static int __pyx_clineno = 0;
827 static const char * __pyx_cfilenm= __FILE__;
828 static const char *__pyx_filename;
829
830
831 static const char *__pyx_f[] = {
832 "gensim/corpora/_mmreader.pyx",
833 "stringsource",
834 };
835
836 /*--- Type declarations ---*/
837 struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader;
838 struct __pyx_obj_6gensim_7corpora_9_mmreader___pyx_scope_struct____init__;
839 struct __pyx_obj_6gensim_7corpora_9_mmreader___pyx_scope_struct_1_genexpr;
840 struct __pyx_obj_6gensim_7corpora_9_mmreader___pyx_scope_struct_2___iter__;
841
842 /* "gensim/corpora/_mmreader.pyx":15
843 *
844 *
845 * cdef class MmReader(): # <<<<<<<<<<<<<<
846 * """Matrix market file reader (fast Cython version), used internally in :class:`~gensim.corpora.mmcorpus.MmCorpus`.
847 *
848 */
849 struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader {
850 PyObject_HEAD
851 PyObject *input;
852 int transposed;
853 PY_LONG_LONG num_docs;
854 PY_LONG_LONG num_terms;
855 PY_LONG_LONG num_nnz;
856 };
857
858
859 /* "gensim/corpora/_mmreader.pyx":40
860 * cdef public long long num_docs, num_terms, num_nnz
861 *
862 * def __init__(self, input, transposed=True): # <<<<<<<<<<<<<<
863 * """
864 *
865 */
866 struct __pyx_obj_6gensim_7corpora_9_mmreader___pyx_scope_struct____init__ {
867 PyObject_HEAD
868 PyObject *__pyx_v_line;
869 };
870
871
872 /* "gensim/corpora/_mmreader.pyx":70
873 * line = utils.to_unicode(line)
874 * if not line.startswith('%'):
875 * self.num_docs, self.num_terms, self.num_nnz = (int(x) for x in line.split()) # <<<<<<<<<<<<<<
876 * if not self.transposed:
877 * self.num_docs, self.num_terms = self.num_terms, self.num_docs
878 */
879 struct __pyx_obj_6gensim_7corpora_9_mmreader___pyx_scope_struct_1_genexpr {
880 PyObject_HEAD
881 struct __pyx_obj_6gensim_7corpora_9_mmreader___pyx_scope_struct____init__ *__pyx_outer_scope;
882 PyObject *__pyx_v_x;
883 PyObject *__pyx_t_0;
884 Py_ssize_t __pyx_t_1;
885 PyObject *(*__pyx_t_2)(PyObject *);
886 };
887
888
889 /* "gensim/corpora/_mmreader.pyx":102
890 * break
891 *
892 * def __iter__(self): # <<<<<<<<<<<<<<
893 * """Iterate through all documents in the corpus.
894 *
895 */
896 struct __pyx_obj_6gensim_7corpora_9_mmreader___pyx_scope_struct_2___iter__ {
897 PyObject_HEAD
898 PY_LONG_LONG __pyx_v_docid;
899 PyObject *__pyx_v_document;
900 PyObject *__pyx_v_line;
901 PyObject *__pyx_v_lines;
902 PY_LONG_LONG __pyx_v_previd;
903 struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *__pyx_v_self;
904 PY_LONG_LONG __pyx_v_termid;
905 double __pyx_v_val;
906 PyObject *__pyx_t_0;
907 PyObject *__pyx_t_1;
908 PyObject *__pyx_t_2;
909 PyObject *__pyx_t_3;
910 PyObject *__pyx_t_4;
911 Py_ssize_t __pyx_t_5;
912 PyObject *(*__pyx_t_6)(PyObject *);
913 PY_LONG_LONG __pyx_t_7;
914 PY_LONG_LONG __pyx_t_8;
915 PY_LONG_LONG __pyx_t_9;
916 };
917
918
919 /* --- Runtime support code (head) --- */
920 /* Refnanny.proto */
921 #ifndef CYTHON_REFNANNY
922 #define CYTHON_REFNANNY 0
923 #endif
924 #if CYTHON_REFNANNY
925 typedef struct {
926 void (*INCREF)(void*, PyObject*, int);
927 void (*DECREF)(void*, PyObject*, int);
928 void (*GOTREF)(void*, PyObject*, int);
929 void (*GIVEREF)(void*, PyObject*, int);
930 void* (*SetupContext)(const char*, int, const char*);
931 void (*FinishContext)(void**);
932 } __Pyx_RefNannyAPIStruct;
933 static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
934 static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
935 #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
936 #ifdef WITH_THREAD
937 #define __Pyx_RefNannySetupContext(name, acquire_gil)\
938 if (acquire_gil) {\
939 PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
940 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
941 PyGILState_Release(__pyx_gilstate_save);\
942 } else {\
943 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
944 }
945 #else
946 #define __Pyx_RefNannySetupContext(name, acquire_gil)\
947 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
948 #endif
949 #define __Pyx_RefNannyFinishContext()\
950 __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
951 #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
952 #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
953 #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
954 #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
955 #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
956 #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
957 #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
958 #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
959 #else
960 #define __Pyx_RefNannyDeclarations
961 #define __Pyx_RefNannySetupContext(name, acquire_gil)
962 #define __Pyx_RefNannyFinishContext()
963 #define __Pyx_INCREF(r) Py_INCREF(r)
964 #define __Pyx_DECREF(r) Py_DECREF(r)
965 #define __Pyx_GOTREF(r)
966 #define __Pyx_GIVEREF(r)
967 #define __Pyx_XINCREF(r) Py_XINCREF(r)
968 #define __Pyx_XDECREF(r) Py_XDECREF(r)
969 #define __Pyx_XGOTREF(r)
970 #define __Pyx_XGIVEREF(r)
971 #endif
972 #define __Pyx_XDECREF_SET(r, v) do {\
973 PyObject *tmp = (PyObject *) r;\
974 r = v; __Pyx_XDECREF(tmp);\
975 } while (0)
976 #define __Pyx_DECREF_SET(r, v) do {\
977 PyObject *tmp = (PyObject *) r;\
978 r = v; __Pyx_DECREF(tmp);\
979 } while (0)
980 #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
981 #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
982
983 /* PyObjectGetAttrStr.proto */
984 #if CYTHON_USE_TYPE_SLOTS
985 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
986 #else
987 #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
988 #endif
989
990 /* GetBuiltinName.proto */
991 static PyObject *__Pyx_GetBuiltinName(PyObject *name);
992
993 /* RaiseDoubleKeywords.proto */
994 static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
995
996 /* ParseKeywords.proto */
997 static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
998 PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
999 const char* function_name);
1000
1001 /* RaiseArgTupleInvalid.proto */
1002 static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
1003 Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
1004
1005 /* None.proto */
1006 static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname);
1007
1008 /* PyFunctionFastCall.proto */
1009 #if CYTHON_FAST_PYCALL
1010 #define __Pyx_PyFunction_FastCall(func, args, nargs)\
1011 __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
1012 #if 1 || PY_VERSION_HEX < 0x030600B1
1013 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs);
1014 #else
1015 #define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
1016 #endif
1017 #define __Pyx_BUILD_ASSERT_EXPR(cond)\
1018 (sizeof(char [1 - 2*!(cond)]) - 1)
1019 #ifndef Py_MEMBER_SIZE
1020 #define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
1021 #endif
1022 static size_t __pyx_pyframe_localsplus_offset = 0;
1023 #include "frameobject.h"
1024 #define __Pxy_PyFrame_Initialize_Offsets()\
1025 ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\
1026 (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus)))
1027 #define __Pyx_PyFrame_GetLocalsplus(frame)\
1028 (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset))
1029 #endif
1030
1031 /* PyObjectCall.proto */
1032 #if CYTHON_COMPILING_IN_CPYTHON
1033 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
1034 #else
1035 #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
1036 #endif
1037
1038 /* PyObjectCallMethO.proto */
1039 #if CYTHON_COMPILING_IN_CPYTHON
1040 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
1041 #endif
1042
1043 /* PyObjectCallNoArg.proto */
1044 #if CYTHON_COMPILING_IN_CPYTHON
1045 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
1046 #else
1047 #define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
1048 #endif
1049
1050 /* PyCFunctionFastCall.proto */
1051 #if CYTHON_FAST_PYCCALL
1052 static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
1053 #else
1054 #define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL)
1055 #endif
1056
1057 /* PyObjectCallOneArg.proto */
1058 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
1059
1060 /* PyDictVersioning.proto */
1061 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
1062 #define __PYX_DICT_VERSION_INIT ((PY_UINT64_T) -1)
1063 #define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag)
1064 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
1065 (version_var) = __PYX_GET_DICT_VERSION(dict);\
1066 (cache_var) = (value);
1067 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
1068 static PY_UINT64_T __pyx_dict_version = 0;\
1069 static PyObject *__pyx_dict_cached_value = NULL;\
1070 if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
1071 (VAR) = __pyx_dict_cached_value;\
1072 } else {\
1073 (VAR) = __pyx_dict_cached_value = (LOOKUP);\
1074 __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
1075 }\
1076 }
1077 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj);
1078 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj);
1079 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version);
1080 #else
1081 #define __PYX_GET_DICT_VERSION(dict) (0)
1082 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
1083 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) (VAR) = (LOOKUP);
1084 #endif
1085
1086 /* GetModuleGlobalName.proto */
1087 #if CYTHON_USE_DICT_VERSIONS
1088 #define __Pyx_GetModuleGlobalName(var, name) {\
1089 static PY_UINT64_T __pyx_dict_version = 0;\
1090 static PyObject *__pyx_dict_cached_value = NULL;\
1091 (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\
1092 (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\
1093 __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
1094 }
1095 #define __Pyx_GetModuleGlobalNameUncached(var, name) {\
1096 PY_UINT64_T __pyx_dict_version;\
1097 PyObject *__pyx_dict_cached_value;\
1098 (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
1099 }
1100 static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value);
1101 #else
1102 #define __Pyx_GetModuleGlobalName(var, name) (var) = __Pyx__GetModuleGlobalName(name)
1103 #define __Pyx_GetModuleGlobalNameUncached(var, name) (var) = __Pyx__GetModuleGlobalName(name)
1104 static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name);
1105 #endif
1106
1107 /* PyObjectCall2Args.proto */
1108 static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2);
1109
1110 /* PyObjectLookupSpecial.proto */
1111 #if CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
__Pyx_PyObject_LookupSpecial(PyObject * obj,PyObject * attr_name)1112 static CYTHON_INLINE PyObject* __Pyx_PyObject_LookupSpecial(PyObject* obj, PyObject* attr_name) {
1113 PyObject *res;
1114 PyTypeObject *tp = Py_TYPE(obj);
1115 #if PY_MAJOR_VERSION < 3
1116 if (unlikely(PyInstance_Check(obj)))
1117 return __Pyx_PyObject_GetAttrStr(obj, attr_name);
1118 #endif
1119 res = _PyType_Lookup(tp, attr_name);
1120 if (likely(res)) {
1121 descrgetfunc f = Py_TYPE(res)->tp_descr_get;
1122 if (!f) {
1123 Py_INCREF(res);
1124 } else {
1125 res = f(res, obj, (PyObject *)tp);
1126 }
1127 } else {
1128 PyErr_SetObject(PyExc_AttributeError, attr_name);
1129 }
1130 return res;
1131 }
1132 #else
1133 #define __Pyx_PyObject_LookupSpecial(o,n) __Pyx_PyObject_GetAttrStr(o,n)
1134 #endif
1135
1136 /* PyThreadStateGet.proto */
1137 #if CYTHON_FAST_THREAD_STATE
1138 #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
1139 #define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current;
1140 #define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type
1141 #else
1142 #define __Pyx_PyThreadState_declare
1143 #define __Pyx_PyThreadState_assign
1144 #define __Pyx_PyErr_Occurred() PyErr_Occurred()
1145 #endif
1146
1147 /* PyErrFetchRestore.proto */
1148 #if CYTHON_FAST_THREAD_STATE
1149 #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
1150 #define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
1151 #define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
1152 #define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
1153 #define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
1154 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
1155 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1156 #if CYTHON_COMPILING_IN_CPYTHON
1157 #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
1158 #else
1159 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
1160 #endif
1161 #else
1162 #define __Pyx_PyErr_Clear() PyErr_Clear()
1163 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
1164 #define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
1165 #define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
1166 #define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb)
1167 #define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb)
1168 #define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
1169 #define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
1170 #endif
1171
1172 /* IterNext.proto */
1173 #define __Pyx_PyIter_Next(obj) __Pyx_PyIter_Next2(obj, NULL)
1174 static CYTHON_INLINE PyObject *__Pyx_PyIter_Next2(PyObject *, PyObject *);
1175
1176 /* RaiseException.proto */
1177 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
1178
1179 /* GetTopmostException.proto */
1180 #if CYTHON_USE_EXC_INFO_STACK
1181 static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate);
1182 #endif
1183
1184 /* SaveResetException.proto */
1185 #if CYTHON_FAST_THREAD_STATE
1186 #define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
1187 static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1188 #define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
1189 static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
1190 #else
1191 #define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb)
1192 #define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb)
1193 #endif
1194
1195 /* PyErrExceptionMatches.proto */
1196 #if CYTHON_FAST_THREAD_STATE
1197 #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
1198 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
1199 #else
1200 #define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err)
1201 #endif
1202
1203 /* PyIntBinop.proto */
1204 #if !CYTHON_COMPILING_IN_PYPY
1205 static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
1206 #else
1207 #define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace, zerodivision_check)\
1208 (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2))
1209 #endif
1210
1211 /* RaiseTooManyValuesToUnpack.proto */
1212 static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
1213
1214 /* RaiseNeedMoreValuesToUnpack.proto */
1215 static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
1216
1217 /* IterFinish.proto */
1218 static CYTHON_INLINE int __Pyx_IterFinish(void);
1219
1220 /* UnpackItemEndCheck.proto */
1221 static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected);
1222
1223 /* GetException.proto */
1224 #if CYTHON_FAST_THREAD_STATE
1225 #define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb)
1226 static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1227 #else
1228 static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
1229 #endif
1230
1231 /* None.proto */
1232 static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname);
1233
1234 /* ListAppend.proto */
1235 #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
__Pyx_PyList_Append(PyObject * list,PyObject * x)1236 static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
1237 PyListObject* L = (PyListObject*) list;
1238 Py_ssize_t len = Py_SIZE(list);
1239 if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) {
1240 Py_INCREF(x);
1241 PyList_SET_ITEM(list, len, x);
1242 __Pyx_SET_SIZE(list, len + 1);
1243 return 0;
1244 }
1245 return PyList_Append(list, x);
1246 }
1247 #else
1248 #define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
1249 #endif
1250
1251 /* PyIntCompare.proto */
1252 static CYTHON_INLINE PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, long intval, long inplace);
1253
1254 /* GetAttr.proto */
1255 static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *);
1256
1257 /* GetAttr3.proto */
1258 static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *);
1259
1260 /* Import.proto */
1261 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
1262
1263 /* ImportFrom.proto */
1264 static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
1265
1266 /* GetItemInt.proto */
1267 #define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1268 (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1269 __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\
1270 (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
1271 __Pyx_GetItemInt_Generic(o, to_py_func(i))))
1272 #define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1273 (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1274 __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
1275 (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
1276 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
1277 int wraparound, int boundscheck);
1278 #define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1279 (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1280 __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
1281 (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
1282 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
1283 int wraparound, int boundscheck);
1284 static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
1285 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
1286 int is_list, int wraparound, int boundscheck);
1287
1288 /* HasAttr.proto */
1289 static CYTHON_INLINE int __Pyx_HasAttr(PyObject *, PyObject *);
1290
1291 /* IncludeStringH.proto */
1292 #include <string.h>
1293
1294 /* PyObject_GenericGetAttrNoDict.proto */
1295 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
1296 static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
1297 #else
1298 #define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
1299 #endif
1300
1301 /* PyObject_GenericGetAttr.proto */
1302 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
1303 static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name);
1304 #else
1305 #define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr
1306 #endif
1307
1308 /* PyObjectGetAttrStrNoError.proto */
1309 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name);
1310
1311 /* SetupReduce.proto */
1312 static int __Pyx_setup_reduce(PyObject* type_obj);
1313
1314 /* CLineInTraceback.proto */
1315 #ifdef CYTHON_CLINE_IN_TRACEBACK
1316 #define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
1317 #else
1318 static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
1319 #endif
1320
1321 /* CodeObjectCache.proto */
1322 typedef struct {
1323 PyCodeObject* code_object;
1324 int code_line;
1325 } __Pyx_CodeObjectCacheEntry;
1326 struct __Pyx_CodeObjectCache {
1327 int count;
1328 int max_count;
1329 __Pyx_CodeObjectCacheEntry* entries;
1330 };
1331 static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
1332 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
1333 static PyCodeObject *__pyx_find_code_object(int code_line);
1334 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
1335
1336 /* AddTraceback.proto */
1337 static void __Pyx_AddTraceback(const char *funcname, int c_line,
1338 int py_line, const char *filename);
1339
1340 /* CIntToPy.proto */
1341 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_PY_LONG_LONG(PY_LONG_LONG value);
1342
1343 /* CIntToPy.proto */
1344 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
1345
1346 /* CIntFromPy.proto */
1347 static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_As_PY_LONG_LONG(PyObject *);
1348
1349 /* CIntFromPy.proto */
1350 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
1351
1352 /* CIntFromPy.proto */
1353 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
1354
1355 /* FastTypeChecks.proto */
1356 #if CYTHON_COMPILING_IN_CPYTHON
1357 #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
1358 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
1359 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
1360 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
1361 #else
1362 #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
1363 #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
1364 #define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
1365 #endif
1366 #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
1367
1368 /* FetchCommonType.proto */
1369 static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);
1370
1371 /* SwapException.proto */
1372 #if CYTHON_FAST_THREAD_STATE
1373 #define __Pyx_ExceptionSwap(type, value, tb) __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb)
1374 static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1375 #else
1376 static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);
1377 #endif
1378
1379 /* PyObjectGetMethod.proto */
1380 static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method);
1381
1382 /* PyObjectCallMethod1.proto */
1383 static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg);
1384
1385 /* CoroutineBase.proto */
1386 typedef PyObject *(*__pyx_coroutine_body_t)(PyObject *, PyThreadState *, PyObject *);
1387 #if CYTHON_USE_EXC_INFO_STACK
1388 #define __Pyx_ExcInfoStruct _PyErr_StackItem
1389 #else
1390 typedef struct {
1391 PyObject *exc_type;
1392 PyObject *exc_value;
1393 PyObject *exc_traceback;
1394 } __Pyx_ExcInfoStruct;
1395 #endif
1396 typedef struct {
1397 PyObject_HEAD
1398 __pyx_coroutine_body_t body;
1399 PyObject *closure;
1400 __Pyx_ExcInfoStruct gi_exc_state;
1401 PyObject *gi_weakreflist;
1402 PyObject *classobj;
1403 PyObject *yieldfrom;
1404 PyObject *gi_name;
1405 PyObject *gi_qualname;
1406 PyObject *gi_modulename;
1407 PyObject *gi_code;
1408 int resume_label;
1409 char is_running;
1410 } __pyx_CoroutineObject;
1411 static __pyx_CoroutineObject *__Pyx__Coroutine_New(
1412 PyTypeObject *type, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
1413 PyObject *name, PyObject *qualname, PyObject *module_name);
1414 static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit(
1415 __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
1416 PyObject *name, PyObject *qualname, PyObject *module_name);
1417 static CYTHON_INLINE void __Pyx_Coroutine_ExceptionClear(__Pyx_ExcInfoStruct *self);
1418 static int __Pyx_Coroutine_clear(PyObject *self);
1419 static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value);
1420 static PyObject *__Pyx_Coroutine_Close(PyObject *self);
1421 static PyObject *__Pyx_Coroutine_Throw(PyObject *gen, PyObject *args);
1422 #if CYTHON_USE_EXC_INFO_STACK
1423 #define __Pyx_Coroutine_SwapException(self)
1424 #define __Pyx_Coroutine_ResetAndClearException(self) __Pyx_Coroutine_ExceptionClear(&(self)->gi_exc_state)
1425 #else
1426 #define __Pyx_Coroutine_SwapException(self) {\
1427 __Pyx_ExceptionSwap(&(self)->gi_exc_state.exc_type, &(self)->gi_exc_state.exc_value, &(self)->gi_exc_state.exc_traceback);\
1428 __Pyx_Coroutine_ResetFrameBackpointer(&(self)->gi_exc_state);\
1429 }
1430 #define __Pyx_Coroutine_ResetAndClearException(self) {\
1431 __Pyx_ExceptionReset((self)->gi_exc_state.exc_type, (self)->gi_exc_state.exc_value, (self)->gi_exc_state.exc_traceback);\
1432 (self)->gi_exc_state.exc_type = (self)->gi_exc_state.exc_value = (self)->gi_exc_state.exc_traceback = NULL;\
1433 }
1434 #endif
1435 #if CYTHON_FAST_THREAD_STATE
1436 #define __Pyx_PyGen_FetchStopIterationValue(pvalue)\
1437 __Pyx_PyGen__FetchStopIterationValue(__pyx_tstate, pvalue)
1438 #else
1439 #define __Pyx_PyGen_FetchStopIterationValue(pvalue)\
1440 __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, pvalue)
1441 #endif
1442 static int __Pyx_PyGen__FetchStopIterationValue(PyThreadState *tstate, PyObject **pvalue);
1443 static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__Pyx_ExcInfoStruct *exc_state);
1444
1445 /* PatchModuleWithCoroutine.proto */
1446 static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code);
1447
1448 /* PatchGeneratorABC.proto */
1449 static int __Pyx_patch_abc(void);
1450
1451 /* Generator.proto */
1452 #define __Pyx_Generator_USED
1453 static PyTypeObject *__pyx_GeneratorType = 0;
1454 #define __Pyx_Generator_CheckExact(obj) (Py_TYPE(obj) == __pyx_GeneratorType)
1455 #define __Pyx_Generator_New(body, code, closure, name, qualname, module_name)\
1456 __Pyx__Coroutine_New(__pyx_GeneratorType, body, code, closure, name, qualname, module_name)
1457 static PyObject *__Pyx_Generator_Next(PyObject *self);
1458 static int __pyx_Generator_init(void);
1459
1460 /* CheckBinaryVersion.proto */
1461 static int __Pyx_check_binary_version(void);
1462
1463 /* InitStrings.proto */
1464 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
1465
1466
1467 /* Module declarations from 'cython' */
1468
1469 /* Module declarations from 'libc.string' */
1470
1471 /* Module declarations from 'libc.stdio' */
1472
1473 /* Module declarations from 'gensim.corpora._mmreader' */
1474 static PyTypeObject *__pyx_ptype_6gensim_7corpora_9_mmreader_MmReader = 0;
1475 static PyTypeObject *__pyx_ptype_6gensim_7corpora_9_mmreader___pyx_scope_struct____init__ = 0;
1476 static PyTypeObject *__pyx_ptype_6gensim_7corpora_9_mmreader___pyx_scope_struct_1_genexpr = 0;
1477 static PyTypeObject *__pyx_ptype_6gensim_7corpora_9_mmreader___pyx_scope_struct_2___iter__ = 0;
1478 static PyObject *__pyx_f_6gensim_7corpora_9_mmreader___pyx_unpickle_MmReader__set_state(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *, PyObject *); /*proto*/
1479 #define __Pyx_MODULE_NAME "gensim.corpora._mmreader"
1480 extern int __pyx_module_is_main_gensim__corpora___mmreader;
1481 int __pyx_module_is_main_gensim__corpora___mmreader = 0;
1482
1483 /* Implementation of 'gensim.corpora._mmreader' */
1484 static PyObject *__pyx_builtin_ValueError;
1485 static PyObject *__pyx_builtin_StopIteration;
1486 static PyObject *__pyx_builtin_enumerate;
1487 static PyObject *__pyx_builtin_range;
1488 static const char __pyx_k_[] = "%";
1489 static const char __pyx_k_rb[] = "rb";
1490 static const char __pyx_k_new[] = "__new__";
1491 static const char __pyx_k_args[] = "args";
1492 static const char __pyx_k_dict[] = "__dict__";
1493 static const char __pyx_k_exit[] = "__exit__";
1494 static const char __pyx_k_info[] = "info";
1495 static const char __pyx_k_iter[] = "__iter__";
1496 static const char __pyx_k_main[] = "__main__";
1497 static const char __pyx_k_name[] = "__name__";
1498 static const char __pyx_k_open[] = "open";
1499 static const char __pyx_k_seek[] = "seek";
1500 static const char __pyx_k_send[] = "send";
1501 static const char __pyx_k_test[] = "__test__";
1502 static const char __pyx_k_close[] = "close";
1503 static const char __pyx_k_enter[] = "__enter__";
1504 static const char __pyx_k_input[] = "input";
1505 static const char __pyx_k_lower[] = "lower";
1506 static const char __pyx_k_range[] = "range";
1507 static const char __pyx_k_split[] = "split";
1508 static const char __pyx_k_strip[] = "strip";
1509 static const char __pyx_k_throw[] = "throw";
1510 static const char __pyx_k_utils[] = "utils";
1511 static const char __pyx_k_format[] = "format";
1512 static const char __pyx_k_gensim[] = "gensim";
1513 static const char __pyx_k_import[] = "__import__";
1514 static const char __pyx_k_logger[] = "logger";
1515 static const char __pyx_k_pickle[] = "pickle";
1516 static const char __pyx_k_reduce[] = "__reduce__";
1517 static const char __pyx_k_update[] = "update";
1518 static const char __pyx_k_genexpr[] = "genexpr";
1519 static const char __pyx_k_logging[] = "logging";
1520 static const char __pyx_k_MmReader[] = "MmReader";
1521 static const char __pyx_k_getstate[] = "__getstate__";
1522 static const char __pyx_k_pyx_type[] = "__pyx_type";
1523 static const char __pyx_k_setstate[] = "__setstate__";
1524 static const char __pyx_k_enumerate[] = "enumerate";
1525 static const char __pyx_k_getLogger[] = "getLogger";
1526 static const char __pyx_k_open_file[] = "open_file";
1527 static const char __pyx_k_pyx_state[] = "__pyx_state";
1528 static const char __pyx_k_reduce_ex[] = "__reduce_ex__";
1529 static const char __pyx_k_ValueError[] = "ValueError";
1530 static const char __pyx_k_pyx_result[] = "__pyx_result";
1531 static const char __pyx_k_startswith[] = "startswith";
1532 static const char __pyx_k_to_unicode[] = "to_unicode";
1533 static const char __pyx_k_transposed[] = "transposed";
1534 static const char __pyx_k_PickleError[] = "PickleError";
1535 static const char __pyx_k_pyx_checksum[] = "__pyx_checksum";
1536 static const char __pyx_k_skip_headers[] = "skip_headers";
1537 static const char __pyx_k_stringsource[] = "stringsource";
1538 static const char __pyx_k_StopIteration[] = "StopIteration";
1539 static const char __pyx_k_reduce_cython[] = "__reduce_cython__";
1540 static const char __pyx_k_MmReader___iter[] = "MmReader.__iter__";
1541 static const char __pyx_k_pyx_PickleError[] = "__pyx_PickleError";
1542 static const char __pyx_k_setstate_cython[] = "__setstate_cython__";
1543 static const char __pyx_k_file_or_filename[] = "file_or_filename";
1544 static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
1545 static const char __pyx_k_unable_to_parse_line[] = "unable to parse line: {}";
1546 static const char __pyx_k_init___locals_genexpr[] = "__init__.<locals>.genexpr";
1547 static const char __pyx_k_pyx_unpickle_MmReader[] = "__pyx_unpickle_MmReader";
1548 static const char __pyx_k_gensim_corpora__mmreader[] = "gensim.corpora._mmreader";
1549 static const char __pyx_k_matrixmarket_matrix_coordinate[] = "%%matrixmarket matrix coordinate real general";
1550 static const char __pyx_k_MmCorpus_i_documents_i_features[] = "MmCorpus(%i documents, %i features, %i non-zero entries)";
1551 static const char __pyx_k_Reader_for_corpus_in_the_Matrix[] = "Reader for corpus in the Matrix Market format.";
1552 static const char __pyx_k_File_s_not_in_Matrix_Market_form[] = "File %s not in Matrix Market format with coordinate real general; instead found: \n%s";
1553 static const char __pyx_k_Incompatible_checksums_s_vs_0xea[] = "Incompatible checksums (%s vs 0xea5fe92 = (input, num_docs, num_nnz, num_terms, transposed))";
1554 static const char __pyx_k_accepted_corpus_with_i_documents[] = "accepted corpus with %i documents, %i features, %i non-zero entries";
1555 static const char __pyx_k_initializing_cython_corpus_reade[] = "initializing cython corpus reader from %s";
1556 static const char __pyx_k_matrix_columns_must_come_in_asce[] = "matrix columns must come in ascending order";
1557 static PyObject *__pyx_kp_b_;
1558 static PyObject *__pyx_kp_s_;
1559 static PyObject *__pyx_kp_s_File_s_not_in_Matrix_Market_form;
1560 static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0xea;
1561 static PyObject *__pyx_kp_s_MmCorpus_i_documents_i_features;
1562 static PyObject *__pyx_n_s_MmReader;
1563 static PyObject *__pyx_n_s_MmReader___iter;
1564 static PyObject *__pyx_n_s_PickleError;
1565 static PyObject *__pyx_n_s_StopIteration;
1566 static PyObject *__pyx_n_s_ValueError;
1567 static PyObject *__pyx_kp_s_accepted_corpus_with_i_documents;
1568 static PyObject *__pyx_n_s_args;
1569 static PyObject *__pyx_n_s_cline_in_traceback;
1570 static PyObject *__pyx_n_s_close;
1571 static PyObject *__pyx_n_s_dict;
1572 static PyObject *__pyx_n_s_enter;
1573 static PyObject *__pyx_n_s_enumerate;
1574 static PyObject *__pyx_n_s_exit;
1575 static PyObject *__pyx_n_s_file_or_filename;
1576 static PyObject *__pyx_n_s_format;
1577 static PyObject *__pyx_n_s_genexpr;
1578 static PyObject *__pyx_n_s_gensim;
1579 static PyObject *__pyx_n_s_gensim_corpora__mmreader;
1580 static PyObject *__pyx_n_s_getLogger;
1581 static PyObject *__pyx_n_s_getstate;
1582 static PyObject *__pyx_n_s_import;
1583 static PyObject *__pyx_n_s_info;
1584 static PyObject *__pyx_n_s_init___locals_genexpr;
1585 static PyObject *__pyx_kp_s_initializing_cython_corpus_reade;
1586 static PyObject *__pyx_n_s_input;
1587 static PyObject *__pyx_n_s_iter;
1588 static PyObject *__pyx_n_s_logger;
1589 static PyObject *__pyx_n_s_logging;
1590 static PyObject *__pyx_n_s_lower;
1591 static PyObject *__pyx_n_s_main;
1592 static PyObject *__pyx_kp_s_matrix_columns_must_come_in_asce;
1593 static PyObject *__pyx_kp_s_matrixmarket_matrix_coordinate;
1594 static PyObject *__pyx_n_s_name;
1595 static PyObject *__pyx_n_s_new;
1596 static PyObject *__pyx_n_s_open;
1597 static PyObject *__pyx_n_s_open_file;
1598 static PyObject *__pyx_n_s_pickle;
1599 static PyObject *__pyx_n_s_pyx_PickleError;
1600 static PyObject *__pyx_n_s_pyx_checksum;
1601 static PyObject *__pyx_n_s_pyx_result;
1602 static PyObject *__pyx_n_s_pyx_state;
1603 static PyObject *__pyx_n_s_pyx_type;
1604 static PyObject *__pyx_n_s_pyx_unpickle_MmReader;
1605 static PyObject *__pyx_n_s_range;
1606 static PyObject *__pyx_n_s_rb;
1607 static PyObject *__pyx_n_s_reduce;
1608 static PyObject *__pyx_n_s_reduce_cython;
1609 static PyObject *__pyx_n_s_reduce_ex;
1610 static PyObject *__pyx_n_s_seek;
1611 static PyObject *__pyx_n_s_send;
1612 static PyObject *__pyx_n_s_setstate;
1613 static PyObject *__pyx_n_s_setstate_cython;
1614 static PyObject *__pyx_n_s_skip_headers;
1615 static PyObject *__pyx_n_s_split;
1616 static PyObject *__pyx_n_s_startswith;
1617 static PyObject *__pyx_kp_s_stringsource;
1618 static PyObject *__pyx_n_s_strip;
1619 static PyObject *__pyx_n_s_test;
1620 static PyObject *__pyx_n_s_throw;
1621 static PyObject *__pyx_n_s_to_unicode;
1622 static PyObject *__pyx_n_s_transposed;
1623 static PyObject *__pyx_kp_s_unable_to_parse_line;
1624 static PyObject *__pyx_n_s_update;
1625 static PyObject *__pyx_n_s_utils;
1626 static PyObject *__pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_8__init___genexpr(PyObject *__pyx_self); /* proto */
1627 static int __pyx_pf_6gensim_7corpora_9_mmreader_8MmReader___init__(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *__pyx_v_self, PyObject *__pyx_v_input, PyObject *__pyx_v_transposed); /* proto */
1628 static Py_ssize_t __pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_2__len__(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *__pyx_v_self); /* proto */
1629 static PyObject *__pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_4__str__(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *__pyx_v_self); /* proto */
1630 static PyObject *__pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_6skip_headers(CYTHON_UNUSED struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *__pyx_v_self, PyObject *__pyx_v_input_file); /* proto */
1631 static PyObject *__pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_8__iter__(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *__pyx_v_self); /* proto */
1632 static PyObject *__pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_11docbyoffset(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *__pyx_v_self, PyObject *__pyx_v_offset); /* proto */
1633 static PyObject *__pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_5input___get__(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *__pyx_v_self); /* proto */
1634 static int __pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_5input_2__set__(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
1635 static int __pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_5input_4__del__(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *__pyx_v_self); /* proto */
1636 static PyObject *__pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_10transposed___get__(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *__pyx_v_self); /* proto */
1637 static int __pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_10transposed_2__set__(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
1638 static PyObject *__pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_8num_docs___get__(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *__pyx_v_self); /* proto */
1639 static int __pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_8num_docs_2__set__(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
1640 static PyObject *__pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_9num_terms___get__(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *__pyx_v_self); /* proto */
1641 static int __pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_9num_terms_2__set__(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
1642 static PyObject *__pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_7num_nnz___get__(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *__pyx_v_self); /* proto */
1643 static int __pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_7num_nnz_2__set__(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
1644 static PyObject *__pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_13__reduce_cython__(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *__pyx_v_self); /* proto */
1645 static PyObject *__pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_15__setstate_cython__(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
1646 static PyObject *__pyx_pf_6gensim_7corpora_9_mmreader___pyx_unpickle_MmReader(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
1647 static PyObject *__pyx_tp_new_6gensim_7corpora_9_mmreader_MmReader(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
1648 static PyObject *__pyx_tp_new_6gensim_7corpora_9_mmreader___pyx_scope_struct____init__(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
1649 static PyObject *__pyx_tp_new_6gensim_7corpora_9_mmreader___pyx_scope_struct_1_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
1650 static PyObject *__pyx_tp_new_6gensim_7corpora_9_mmreader___pyx_scope_struct_2___iter__(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
1651 static PyObject *__pyx_int_0;
1652 static PyObject *__pyx_int_1;
1653 static PyObject *__pyx_int_245759634;
1654 static PyObject *__pyx_int_neg_1;
1655 static PyObject *__pyx_tuple__2;
1656 static PyObject *__pyx_tuple__3;
1657 static PyObject *__pyx_codeobj__4;
1658 /* Late includes */
1659
1660 /* "gensim/corpora/_mmreader.pyx":40
1661 * cdef public long long num_docs, num_terms, num_nnz
1662 *
1663 * def __init__(self, input, transposed=True): # <<<<<<<<<<<<<<
1664 * """
1665 *
1666 */
1667
1668 /* Python wrapper */
1669 static int __pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
1670 static char __pyx_doc_6gensim_7corpora_9_mmreader_8MmReader___init__[] = "\n\n Parameters\n ----------\n input : {str, file-like object}\n Path to the input file in MM format or a file-like object that supports `seek()`\n (e.g. smart_open objects).\n\n transposed : bool, optional\n Do lines represent `doc_id, term_id, value`, instead of `term_id, doc_id, value`?\n\n ";
1671 #if CYTHON_COMPILING_IN_CPYTHON
1672 struct wrapperbase __pyx_wrapperbase_6gensim_7corpora_9_mmreader_8MmReader___init__;
1673 #endif
__pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_1__init__(PyObject * __pyx_v_self,PyObject * __pyx_args,PyObject * __pyx_kwds)1674 static int __pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
1675 PyObject *__pyx_v_input = 0;
1676 PyObject *__pyx_v_transposed = 0;
1677 int __pyx_lineno = 0;
1678 const char *__pyx_filename = NULL;
1679 int __pyx_clineno = 0;
1680 int __pyx_r;
1681 __Pyx_RefNannyDeclarations
1682 __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
1683 {
1684 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_input,&__pyx_n_s_transposed,0};
1685 PyObject* values[2] = {0,0};
1686 values[1] = ((PyObject *)Py_True);
1687 if (unlikely(__pyx_kwds)) {
1688 Py_ssize_t kw_args;
1689 const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
1690 switch (pos_args) {
1691 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
1692 CYTHON_FALLTHROUGH;
1693 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1694 CYTHON_FALLTHROUGH;
1695 case 0: break;
1696 default: goto __pyx_L5_argtuple_error;
1697 }
1698 kw_args = PyDict_Size(__pyx_kwds);
1699 switch (pos_args) {
1700 case 0:
1701 if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_input)) != 0)) kw_args--;
1702 else goto __pyx_L5_argtuple_error;
1703 CYTHON_FALLTHROUGH;
1704 case 1:
1705 if (kw_args > 0) {
1706 PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_transposed);
1707 if (value) { values[1] = value; kw_args--; }
1708 }
1709 }
1710 if (unlikely(kw_args > 0)) {
1711 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 40, __pyx_L3_error)
1712 }
1713 } else {
1714 switch (PyTuple_GET_SIZE(__pyx_args)) {
1715 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
1716 CYTHON_FALLTHROUGH;
1717 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1718 break;
1719 default: goto __pyx_L5_argtuple_error;
1720 }
1721 }
1722 __pyx_v_input = values[0];
1723 __pyx_v_transposed = values[1];
1724 }
1725 goto __pyx_L4_argument_unpacking_done;
1726 __pyx_L5_argtuple_error:;
1727 __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 40, __pyx_L3_error)
1728 __pyx_L3_error:;
1729 __Pyx_AddTraceback("gensim.corpora._mmreader.MmReader.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
1730 __Pyx_RefNannyFinishContext();
1731 return -1;
1732 __pyx_L4_argument_unpacking_done:;
1733 __pyx_r = __pyx_pf_6gensim_7corpora_9_mmreader_8MmReader___init__(((struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *)__pyx_v_self), __pyx_v_input, __pyx_v_transposed);
1734
1735 /* function exit code */
1736 __Pyx_RefNannyFinishContext();
1737 return __pyx_r;
1738 }
1739 static PyObject *__pyx_gb_6gensim_7corpora_9_mmreader_8MmReader_8__init___2generator1(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */
1740
1741 /* "gensim/corpora/_mmreader.pyx":70
1742 * line = utils.to_unicode(line)
1743 * if not line.startswith('%'):
1744 * self.num_docs, self.num_terms, self.num_nnz = (int(x) for x in line.split()) # <<<<<<<<<<<<<<
1745 * if not self.transposed:
1746 * self.num_docs, self.num_terms = self.num_terms, self.num_docs
1747 */
1748
__pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_8__init___genexpr(PyObject * __pyx_self)1749 static PyObject *__pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_8__init___genexpr(PyObject *__pyx_self) {
1750 struct __pyx_obj_6gensim_7corpora_9_mmreader___pyx_scope_struct_1_genexpr *__pyx_cur_scope;
1751 PyObject *__pyx_r = NULL;
1752 __Pyx_RefNannyDeclarations
1753 int __pyx_lineno = 0;
1754 const char *__pyx_filename = NULL;
1755 int __pyx_clineno = 0;
1756 __Pyx_RefNannySetupContext("genexpr", 0);
1757 __pyx_cur_scope = (struct __pyx_obj_6gensim_7corpora_9_mmreader___pyx_scope_struct_1_genexpr *)__pyx_tp_new_6gensim_7corpora_9_mmreader___pyx_scope_struct_1_genexpr(__pyx_ptype_6gensim_7corpora_9_mmreader___pyx_scope_struct_1_genexpr, __pyx_empty_tuple, NULL);
1758 if (unlikely(!__pyx_cur_scope)) {
1759 __pyx_cur_scope = ((struct __pyx_obj_6gensim_7corpora_9_mmreader___pyx_scope_struct_1_genexpr *)Py_None);
1760 __Pyx_INCREF(Py_None);
1761 __PYX_ERR(0, 70, __pyx_L1_error)
1762 } else {
1763 __Pyx_GOTREF(__pyx_cur_scope);
1764 }
1765 __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_6gensim_7corpora_9_mmreader___pyx_scope_struct____init__ *) __pyx_self;
1766 __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope));
1767 __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope);
1768 {
1769 __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_6gensim_7corpora_9_mmreader_8MmReader_8__init___2generator1, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_init___locals_genexpr, __pyx_n_s_gensim_corpora__mmreader); if (unlikely(!gen)) __PYX_ERR(0, 70, __pyx_L1_error)
1770 __Pyx_DECREF(__pyx_cur_scope);
1771 __Pyx_RefNannyFinishContext();
1772 return (PyObject *) gen;
1773 }
1774
1775 /* function exit code */
1776 __pyx_L1_error:;
1777 __Pyx_AddTraceback("gensim.corpora._mmreader.MmReader.__init__.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
1778 __pyx_r = NULL;
1779 __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
1780 __Pyx_XGIVEREF(__pyx_r);
1781 __Pyx_RefNannyFinishContext();
1782 return __pyx_r;
1783 }
1784
__pyx_gb_6gensim_7corpora_9_mmreader_8MmReader_8__init___2generator1(__pyx_CoroutineObject * __pyx_generator,CYTHON_UNUSED PyThreadState * __pyx_tstate,PyObject * __pyx_sent_value)1785 static PyObject *__pyx_gb_6gensim_7corpora_9_mmreader_8MmReader_8__init___2generator1(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
1786 {
1787 struct __pyx_obj_6gensim_7corpora_9_mmreader___pyx_scope_struct_1_genexpr *__pyx_cur_scope = ((struct __pyx_obj_6gensim_7corpora_9_mmreader___pyx_scope_struct_1_genexpr *)__pyx_generator->closure);
1788 PyObject *__pyx_r = NULL;
1789 PyObject *__pyx_t_1 = NULL;
1790 PyObject *__pyx_t_2 = NULL;
1791 PyObject *__pyx_t_3 = NULL;
1792 Py_ssize_t __pyx_t_4;
1793 PyObject *(*__pyx_t_5)(PyObject *);
1794 int __pyx_lineno = 0;
1795 const char *__pyx_filename = NULL;
1796 int __pyx_clineno = 0;
1797 __Pyx_RefNannyDeclarations
1798 __Pyx_RefNannySetupContext("genexpr", 0);
1799 switch (__pyx_generator->resume_label) {
1800 case 0: goto __pyx_L3_first_run;
1801 case 1: goto __pyx_L6_resume_from_yield;
1802 default: /* CPython raises the right error here */
1803 __Pyx_RefNannyFinishContext();
1804 return NULL;
1805 }
1806 __pyx_L3_first_run:;
1807 if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 70, __pyx_L1_error)
1808 if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_line)) { __Pyx_RaiseClosureNameError("line"); __PYX_ERR(0, 70, __pyx_L1_error) }
1809 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_line, __pyx_n_s_split); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 70, __pyx_L1_error)
1810 __Pyx_GOTREF(__pyx_t_2);
1811 __pyx_t_3 = NULL;
1812 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
1813 __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
1814 if (likely(__pyx_t_3)) {
1815 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
1816 __Pyx_INCREF(__pyx_t_3);
1817 __Pyx_INCREF(function);
1818 __Pyx_DECREF_SET(__pyx_t_2, function);
1819 }
1820 }
1821 __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
1822 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
1823 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 70, __pyx_L1_error)
1824 __Pyx_GOTREF(__pyx_t_1);
1825 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1826 if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
1827 __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = 0;
1828 __pyx_t_5 = NULL;
1829 } else {
1830 __pyx_t_4 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 70, __pyx_L1_error)
1831 __Pyx_GOTREF(__pyx_t_2);
1832 __pyx_t_5 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 70, __pyx_L1_error)
1833 }
1834 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1835 for (;;) {
1836 if (likely(!__pyx_t_5)) {
1837 if (likely(PyList_CheckExact(__pyx_t_2))) {
1838 if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_2)) break;
1839 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
1840 __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 70, __pyx_L1_error)
1841 #else
1842 __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 70, __pyx_L1_error)
1843 __Pyx_GOTREF(__pyx_t_1);
1844 #endif
1845 } else {
1846 if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
1847 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
1848 __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 70, __pyx_L1_error)
1849 #else
1850 __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 70, __pyx_L1_error)
1851 __Pyx_GOTREF(__pyx_t_1);
1852 #endif
1853 }
1854 } else {
1855 __pyx_t_1 = __pyx_t_5(__pyx_t_2);
1856 if (unlikely(!__pyx_t_1)) {
1857 PyObject* exc_type = PyErr_Occurred();
1858 if (exc_type) {
1859 if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
1860 else __PYX_ERR(0, 70, __pyx_L1_error)
1861 }
1862 break;
1863 }
1864 __Pyx_GOTREF(__pyx_t_1);
1865 }
1866 __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_x);
1867 __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_x, __pyx_t_1);
1868 __Pyx_GIVEREF(__pyx_t_1);
1869 __pyx_t_1 = 0;
1870 __pyx_t_1 = __Pyx_PyNumber_Int(__pyx_cur_scope->__pyx_v_x); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 70, __pyx_L1_error)
1871 __Pyx_GOTREF(__pyx_t_1);
1872 __pyx_r = __pyx_t_1;
1873 __pyx_t_1 = 0;
1874 __Pyx_XGIVEREF(__pyx_t_2);
1875 __pyx_cur_scope->__pyx_t_0 = __pyx_t_2;
1876 __pyx_cur_scope->__pyx_t_1 = __pyx_t_4;
1877 __pyx_cur_scope->__pyx_t_2 = __pyx_t_5;
1878 __Pyx_XGIVEREF(__pyx_r);
1879 __Pyx_RefNannyFinishContext();
1880 __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
1881 /* return from generator, yielding value */
1882 __pyx_generator->resume_label = 1;
1883 return __pyx_r;
1884 __pyx_L6_resume_from_yield:;
1885 __pyx_t_2 = __pyx_cur_scope->__pyx_t_0;
1886 __pyx_cur_scope->__pyx_t_0 = 0;
1887 __Pyx_XGOTREF(__pyx_t_2);
1888 __pyx_t_4 = __pyx_cur_scope->__pyx_t_1;
1889 __pyx_t_5 = __pyx_cur_scope->__pyx_t_2;
1890 if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 70, __pyx_L1_error)
1891 }
1892 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1893 CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);
1894
1895 /* function exit code */
1896 PyErr_SetNone(PyExc_StopIteration);
1897 goto __pyx_L0;
1898 __pyx_L1_error:;
1899 __Pyx_XDECREF(__pyx_t_1);
1900 __Pyx_XDECREF(__pyx_t_2);
1901 __Pyx_XDECREF(__pyx_t_3);
1902 __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
1903 __pyx_L0:;
1904 __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
1905 #if !CYTHON_USE_EXC_INFO_STACK
1906 __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
1907 #endif
1908 __pyx_generator->resume_label = -1;
1909 __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
1910 __Pyx_RefNannyFinishContext();
1911 return __pyx_r;
1912 }
1913
1914 /* "gensim/corpora/_mmreader.pyx":40
1915 * cdef public long long num_docs, num_terms, num_nnz
1916 *
1917 * def __init__(self, input, transposed=True): # <<<<<<<<<<<<<<
1918 * """
1919 *
1920 */
1921
__pyx_pf_6gensim_7corpora_9_mmreader_8MmReader___init__(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader * __pyx_v_self,PyObject * __pyx_v_input,PyObject * __pyx_v_transposed)1922 static int __pyx_pf_6gensim_7corpora_9_mmreader_8MmReader___init__(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *__pyx_v_self, PyObject *__pyx_v_input, PyObject *__pyx_v_transposed) {
1923 struct __pyx_obj_6gensim_7corpora_9_mmreader___pyx_scope_struct____init__ *__pyx_cur_scope;
1924 PyObject *__pyx_v_lines = NULL;
1925 PyObject *__pyx_v_header = NULL;
1926 CYTHON_UNUSED PyObject *__pyx_v_lineno = NULL;
1927 int __pyx_r;
1928 __Pyx_RefNannyDeclarations
1929 PyObject *__pyx_t_1 = NULL;
1930 PyObject *__pyx_t_2 = NULL;
1931 PyObject *__pyx_t_3 = NULL;
1932 int __pyx_t_4;
1933 PyObject *__pyx_t_5 = NULL;
1934 int __pyx_t_6;
1935 PyObject *__pyx_t_7 = NULL;
1936 PyObject *__pyx_t_8 = NULL;
1937 PyObject *__pyx_t_9 = NULL;
1938 PyObject *__pyx_t_10 = NULL;
1939 PyObject *__pyx_t_11 = NULL;
1940 PyObject *__pyx_t_12 = NULL;
1941 PyObject *__pyx_t_13 = NULL;
1942 PyObject *__pyx_t_14 = NULL;
1943 int __pyx_t_15;
1944 Py_ssize_t __pyx_t_16;
1945 PyObject *(*__pyx_t_17)(PyObject *);
1946 PyObject *__pyx_t_18 = NULL;
1947 PyObject *__pyx_t_19 = NULL;
1948 PyObject *(*__pyx_t_20)(PyObject *);
1949 PY_LONG_LONG __pyx_t_21;
1950 PY_LONG_LONG __pyx_t_22;
1951 PY_LONG_LONG __pyx_t_23;
1952 int __pyx_lineno = 0;
1953 const char *__pyx_filename = NULL;
1954 int __pyx_clineno = 0;
1955 __Pyx_RefNannySetupContext("__init__", 0);
1956 __pyx_cur_scope = (struct __pyx_obj_6gensim_7corpora_9_mmreader___pyx_scope_struct____init__ *)__pyx_tp_new_6gensim_7corpora_9_mmreader___pyx_scope_struct____init__(__pyx_ptype_6gensim_7corpora_9_mmreader___pyx_scope_struct____init__, __pyx_empty_tuple, NULL);
1957 if (unlikely(!__pyx_cur_scope)) {
1958 __pyx_cur_scope = ((struct __pyx_obj_6gensim_7corpora_9_mmreader___pyx_scope_struct____init__ *)Py_None);
1959 __Pyx_INCREF(Py_None);
1960 __PYX_ERR(0, 40, __pyx_L1_error)
1961 } else {
1962 __Pyx_GOTREF(__pyx_cur_scope);
1963 }
1964
1965 /* "gensim/corpora/_mmreader.pyx":53
1966 *
1967 * """
1968 * logger.info("initializing cython corpus reader from %s", input) # <<<<<<<<<<<<<<
1969 * self.input, self.transposed = input, transposed
1970 * with utils.open_file(self.input) as lines:
1971 */
1972 __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 53, __pyx_L1_error)
1973 __Pyx_GOTREF(__pyx_t_2);
1974 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 53, __pyx_L1_error)
1975 __Pyx_GOTREF(__pyx_t_3);
1976 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1977 __pyx_t_2 = NULL;
1978 __pyx_t_4 = 0;
1979 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
1980 __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
1981 if (likely(__pyx_t_2)) {
1982 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
1983 __Pyx_INCREF(__pyx_t_2);
1984 __Pyx_INCREF(function);
1985 __Pyx_DECREF_SET(__pyx_t_3, function);
1986 __pyx_t_4 = 1;
1987 }
1988 }
1989 #if CYTHON_FAST_PYCALL
1990 if (PyFunction_Check(__pyx_t_3)) {
1991 PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_kp_s_initializing_cython_corpus_reade, __pyx_v_input};
1992 __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 53, __pyx_L1_error)
1993 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
1994 __Pyx_GOTREF(__pyx_t_1);
1995 } else
1996 #endif
1997 #if CYTHON_FAST_PYCCALL
1998 if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
1999 PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_kp_s_initializing_cython_corpus_reade, __pyx_v_input};
2000 __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 53, __pyx_L1_error)
2001 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
2002 __Pyx_GOTREF(__pyx_t_1);
2003 } else
2004 #endif
2005 {
2006 __pyx_t_5 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 53, __pyx_L1_error)
2007 __Pyx_GOTREF(__pyx_t_5);
2008 if (__pyx_t_2) {
2009 __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); __pyx_t_2 = NULL;
2010 }
2011 __Pyx_INCREF(__pyx_kp_s_initializing_cython_corpus_reade);
2012 __Pyx_GIVEREF(__pyx_kp_s_initializing_cython_corpus_reade);
2013 PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_kp_s_initializing_cython_corpus_reade);
2014 __Pyx_INCREF(__pyx_v_input);
2015 __Pyx_GIVEREF(__pyx_v_input);
2016 PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_input);
2017 __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 53, __pyx_L1_error)
2018 __Pyx_GOTREF(__pyx_t_1);
2019 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2020 }
2021 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2022 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2023
2024 /* "gensim/corpora/_mmreader.pyx":54
2025 * """
2026 * logger.info("initializing cython corpus reader from %s", input)
2027 * self.input, self.transposed = input, transposed # <<<<<<<<<<<<<<
2028 * with utils.open_file(self.input) as lines:
2029 * try:
2030 */
2031 __pyx_t_1 = __pyx_v_input;
2032 __Pyx_INCREF(__pyx_t_1);
2033 __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_transposed); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 54, __pyx_L1_error)
2034 __Pyx_GIVEREF(__pyx_t_1);
2035 __Pyx_GOTREF(__pyx_v_self->input);
2036 __Pyx_DECREF(__pyx_v_self->input);
2037 __pyx_v_self->input = __pyx_t_1;
2038 __pyx_t_1 = 0;
2039 __pyx_v_self->transposed = __pyx_t_6;
2040
2041 /* "gensim/corpora/_mmreader.pyx":55
2042 * logger.info("initializing cython corpus reader from %s", input)
2043 * self.input, self.transposed = input, transposed
2044 * with utils.open_file(self.input) as lines: # <<<<<<<<<<<<<<
2045 * try:
2046 * header = utils.to_unicode(next(lines)).strip()
2047 */
2048 /*with:*/ {
2049 __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_utils); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 55, __pyx_L1_error)
2050 __Pyx_GOTREF(__pyx_t_3);
2051 __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_open_file); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 55, __pyx_L1_error)
2052 __Pyx_GOTREF(__pyx_t_5);
2053 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2054 __pyx_t_3 = NULL;
2055 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
2056 __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
2057 if (likely(__pyx_t_3)) {
2058 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
2059 __Pyx_INCREF(__pyx_t_3);
2060 __Pyx_INCREF(function);
2061 __Pyx_DECREF_SET(__pyx_t_5, function);
2062 }
2063 }
2064 __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_3, __pyx_v_self->input) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_self->input);
2065 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
2066 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 55, __pyx_L1_error)
2067 __Pyx_GOTREF(__pyx_t_1);
2068 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2069 __pyx_t_7 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_n_s_exit); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 55, __pyx_L1_error)
2070 __Pyx_GOTREF(__pyx_t_7);
2071 __pyx_t_3 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_n_s_enter); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 55, __pyx_L3_error)
2072 __Pyx_GOTREF(__pyx_t_3);
2073 __pyx_t_2 = NULL;
2074 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
2075 __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
2076 if (likely(__pyx_t_2)) {
2077 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
2078 __Pyx_INCREF(__pyx_t_2);
2079 __Pyx_INCREF(function);
2080 __Pyx_DECREF_SET(__pyx_t_3, function);
2081 }
2082 }
2083 __pyx_t_5 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
2084 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
2085 if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 55, __pyx_L3_error)
2086 __Pyx_GOTREF(__pyx_t_5);
2087 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2088 __pyx_t_3 = __pyx_t_5;
2089 __pyx_t_5 = 0;
2090 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2091 /*try:*/ {
2092 {
2093 __Pyx_PyThreadState_declare
2094 __Pyx_PyThreadState_assign
2095 __Pyx_ExceptionSave(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
2096 __Pyx_XGOTREF(__pyx_t_8);
2097 __Pyx_XGOTREF(__pyx_t_9);
2098 __Pyx_XGOTREF(__pyx_t_10);
2099 /*try:*/ {
2100 __pyx_v_lines = __pyx_t_3;
2101 __pyx_t_3 = 0;
2102
2103 /* "gensim/corpora/_mmreader.pyx":56
2104 * self.input, self.transposed = input, transposed
2105 * with utils.open_file(self.input) as lines:
2106 * try: # <<<<<<<<<<<<<<
2107 * header = utils.to_unicode(next(lines)).strip()
2108 * if not header.lower().startswith('%%matrixmarket matrix coordinate real general'):
2109 */
2110 {
2111 __Pyx_PyThreadState_declare
2112 __Pyx_PyThreadState_assign
2113 __Pyx_ExceptionSave(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
2114 __Pyx_XGOTREF(__pyx_t_11);
2115 __Pyx_XGOTREF(__pyx_t_12);
2116 __Pyx_XGOTREF(__pyx_t_13);
2117 /*try:*/ {
2118
2119 /* "gensim/corpora/_mmreader.pyx":57
2120 * with utils.open_file(self.input) as lines:
2121 * try:
2122 * header = utils.to_unicode(next(lines)).strip() # <<<<<<<<<<<<<<
2123 * if not header.lower().startswith('%%matrixmarket matrix coordinate real general'):
2124 * raise ValueError(
2125 */
2126 __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_utils); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 57, __pyx_L13_error)
2127 __Pyx_GOTREF(__pyx_t_5);
2128 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_to_unicode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 57, __pyx_L13_error)
2129 __Pyx_GOTREF(__pyx_t_2);
2130 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2131 __pyx_t_5 = __Pyx_PyIter_Next(__pyx_v_lines); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 57, __pyx_L13_error)
2132 __Pyx_GOTREF(__pyx_t_5);
2133 __pyx_t_14 = NULL;
2134 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
2135 __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_2);
2136 if (likely(__pyx_t_14)) {
2137 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
2138 __Pyx_INCREF(__pyx_t_14);
2139 __Pyx_INCREF(function);
2140 __Pyx_DECREF_SET(__pyx_t_2, function);
2141 }
2142 }
2143 __pyx_t_1 = (__pyx_t_14) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_14, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5);
2144 __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
2145 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2146 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 57, __pyx_L13_error)
2147 __Pyx_GOTREF(__pyx_t_1);
2148 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2149 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_strip); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 57, __pyx_L13_error)
2150 __Pyx_GOTREF(__pyx_t_2);
2151 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2152 __pyx_t_1 = NULL;
2153 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
2154 __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
2155 if (likely(__pyx_t_1)) {
2156 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
2157 __Pyx_INCREF(__pyx_t_1);
2158 __Pyx_INCREF(function);
2159 __Pyx_DECREF_SET(__pyx_t_2, function);
2160 }
2161 }
2162 __pyx_t_3 = (__pyx_t_1) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_1) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
2163 __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
2164 if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 57, __pyx_L13_error)
2165 __Pyx_GOTREF(__pyx_t_3);
2166 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2167 __pyx_v_header = __pyx_t_3;
2168 __pyx_t_3 = 0;
2169
2170 /* "gensim/corpora/_mmreader.pyx":58
2171 * try:
2172 * header = utils.to_unicode(next(lines)).strip()
2173 * if not header.lower().startswith('%%matrixmarket matrix coordinate real general'): # <<<<<<<<<<<<<<
2174 * raise ValueError(
2175 * "File %s not in Matrix Market format with coordinate real general; instead found: \n%s" %
2176 */
2177 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_header, __pyx_n_s_lower); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 58, __pyx_L13_error)
2178 __Pyx_GOTREF(__pyx_t_1);
2179 __pyx_t_5 = NULL;
2180 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
2181 __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
2182 if (likely(__pyx_t_5)) {
2183 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
2184 __Pyx_INCREF(__pyx_t_5);
2185 __Pyx_INCREF(function);
2186 __Pyx_DECREF_SET(__pyx_t_1, function);
2187 }
2188 }
2189 __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_1);
2190 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
2191 if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 58, __pyx_L13_error)
2192 __Pyx_GOTREF(__pyx_t_2);
2193 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2194 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_startswith); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 58, __pyx_L13_error)
2195 __Pyx_GOTREF(__pyx_t_1);
2196 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2197 __pyx_t_2 = NULL;
2198 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
2199 __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1);
2200 if (likely(__pyx_t_2)) {
2201 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
2202 __Pyx_INCREF(__pyx_t_2);
2203 __Pyx_INCREF(function);
2204 __Pyx_DECREF_SET(__pyx_t_1, function);
2205 }
2206 }
2207 __pyx_t_3 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_2, __pyx_kp_s_matrixmarket_matrix_coordinate) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_kp_s_matrixmarket_matrix_coordinate);
2208 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
2209 if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 58, __pyx_L13_error)
2210 __Pyx_GOTREF(__pyx_t_3);
2211 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2212 __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 58, __pyx_L13_error)
2213 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2214 __pyx_t_15 = ((!__pyx_t_6) != 0);
2215 if (unlikely(__pyx_t_15)) {
2216
2217 /* "gensim/corpora/_mmreader.pyx":61
2218 * raise ValueError(
2219 * "File %s not in Matrix Market format with coordinate real general; instead found: \n%s" %
2220 * (self.input, header) # <<<<<<<<<<<<<<
2221 * )
2222 * except StopIteration:
2223 */
2224 __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 61, __pyx_L13_error)
2225 __Pyx_GOTREF(__pyx_t_3);
2226 __Pyx_INCREF(__pyx_v_self->input);
2227 __Pyx_GIVEREF(__pyx_v_self->input);
2228 PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_self->input);
2229 __Pyx_INCREF(__pyx_v_header);
2230 __Pyx_GIVEREF(__pyx_v_header);
2231 PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_header);
2232
2233 /* "gensim/corpora/_mmreader.pyx":60
2234 * if not header.lower().startswith('%%matrixmarket matrix coordinate real general'):
2235 * raise ValueError(
2236 * "File %s not in Matrix Market format with coordinate real general; instead found: \n%s" % # <<<<<<<<<<<<<<
2237 * (self.input, header)
2238 * )
2239 */
2240 __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_File_s_not_in_Matrix_Market_form, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 60, __pyx_L13_error)
2241 __Pyx_GOTREF(__pyx_t_1);
2242 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2243
2244 /* "gensim/corpora/_mmreader.pyx":59
2245 * header = utils.to_unicode(next(lines)).strip()
2246 * if not header.lower().startswith('%%matrixmarket matrix coordinate real general'):
2247 * raise ValueError( # <<<<<<<<<<<<<<
2248 * "File %s not in Matrix Market format with coordinate real general; instead found: \n%s" %
2249 * (self.input, header)
2250 */
2251 __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 59, __pyx_L13_error)
2252 __Pyx_GOTREF(__pyx_t_3);
2253 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2254 __Pyx_Raise(__pyx_t_3, 0, 0, 0);
2255 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2256 __PYX_ERR(0, 59, __pyx_L13_error)
2257
2258 /* "gensim/corpora/_mmreader.pyx":58
2259 * try:
2260 * header = utils.to_unicode(next(lines)).strip()
2261 * if not header.lower().startswith('%%matrixmarket matrix coordinate real general'): # <<<<<<<<<<<<<<
2262 * raise ValueError(
2263 * "File %s not in Matrix Market format with coordinate real general; instead found: \n%s" %
2264 */
2265 }
2266
2267 /* "gensim/corpora/_mmreader.pyx":56
2268 * self.input, self.transposed = input, transposed
2269 * with utils.open_file(self.input) as lines:
2270 * try: # <<<<<<<<<<<<<<
2271 * header = utils.to_unicode(next(lines)).strip()
2272 * if not header.lower().startswith('%%matrixmarket matrix coordinate real general'):
2273 */
2274 }
2275 __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
2276 __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
2277 __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
2278 goto __pyx_L18_try_end;
2279 __pyx_L13_error:;
2280 __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
2281 __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
2282 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
2283 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
2284 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
2285
2286 /* "gensim/corpora/_mmreader.pyx":63
2287 * (self.input, header)
2288 * )
2289 * except StopIteration: # <<<<<<<<<<<<<<
2290 * pass
2291 *
2292 */
2293 __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_StopIteration);
2294 if (__pyx_t_4) {
2295 __Pyx_ErrRestore(0,0,0);
2296 goto __pyx_L14_exception_handled;
2297 }
2298 goto __pyx_L15_except_error;
2299 __pyx_L15_except_error:;
2300
2301 /* "gensim/corpora/_mmreader.pyx":56
2302 * self.input, self.transposed = input, transposed
2303 * with utils.open_file(self.input) as lines:
2304 * try: # <<<<<<<<<<<<<<
2305 * header = utils.to_unicode(next(lines)).strip()
2306 * if not header.lower().startswith('%%matrixmarket matrix coordinate real general'):
2307 */
2308 __Pyx_XGIVEREF(__pyx_t_11);
2309 __Pyx_XGIVEREF(__pyx_t_12);
2310 __Pyx_XGIVEREF(__pyx_t_13);
2311 __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
2312 goto __pyx_L7_error;
2313 __pyx_L14_exception_handled:;
2314 __Pyx_XGIVEREF(__pyx_t_11);
2315 __Pyx_XGIVEREF(__pyx_t_12);
2316 __Pyx_XGIVEREF(__pyx_t_13);
2317 __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
2318 __pyx_L18_try_end:;
2319 }
2320
2321 /* "gensim/corpora/_mmreader.pyx":66
2322 * pass
2323 *
2324 * self.num_docs = self.num_terms = self.num_nnz = 0 # <<<<<<<<<<<<<<
2325 * for lineno, line in enumerate(lines):
2326 * line = utils.to_unicode(line)
2327 */
2328 __pyx_v_self->num_docs = 0;
2329 __pyx_v_self->num_terms = 0;
2330 __pyx_v_self->num_nnz = 0;
2331
2332 /* "gensim/corpora/_mmreader.pyx":67
2333 *
2334 * self.num_docs = self.num_terms = self.num_nnz = 0
2335 * for lineno, line in enumerate(lines): # <<<<<<<<<<<<<<
2336 * line = utils.to_unicode(line)
2337 * if not line.startswith('%'):
2338 */
2339 __Pyx_INCREF(__pyx_int_0);
2340 __pyx_t_3 = __pyx_int_0;
2341 if (likely(PyList_CheckExact(__pyx_v_lines)) || PyTuple_CheckExact(__pyx_v_lines)) {
2342 __pyx_t_1 = __pyx_v_lines; __Pyx_INCREF(__pyx_t_1); __pyx_t_16 = 0;
2343 __pyx_t_17 = NULL;
2344 } else {
2345 __pyx_t_16 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_lines); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 67, __pyx_L7_error)
2346 __Pyx_GOTREF(__pyx_t_1);
2347 __pyx_t_17 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 67, __pyx_L7_error)
2348 }
2349 for (;;) {
2350 if (likely(!__pyx_t_17)) {
2351 if (likely(PyList_CheckExact(__pyx_t_1))) {
2352 if (__pyx_t_16 >= PyList_GET_SIZE(__pyx_t_1)) break;
2353 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
2354 __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_16); __Pyx_INCREF(__pyx_t_2); __pyx_t_16++; if (unlikely(0 < 0)) __PYX_ERR(0, 67, __pyx_L7_error)
2355 #else
2356 __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_16); __pyx_t_16++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 67, __pyx_L7_error)
2357 __Pyx_GOTREF(__pyx_t_2);
2358 #endif
2359 } else {
2360 if (__pyx_t_16 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
2361 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
2362 __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_16); __Pyx_INCREF(__pyx_t_2); __pyx_t_16++; if (unlikely(0 < 0)) __PYX_ERR(0, 67, __pyx_L7_error)
2363 #else
2364 __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_16); __pyx_t_16++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 67, __pyx_L7_error)
2365 __Pyx_GOTREF(__pyx_t_2);
2366 #endif
2367 }
2368 } else {
2369 __pyx_t_2 = __pyx_t_17(__pyx_t_1);
2370 if (unlikely(!__pyx_t_2)) {
2371 PyObject* exc_type = PyErr_Occurred();
2372 if (exc_type) {
2373 if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
2374 else __PYX_ERR(0, 67, __pyx_L7_error)
2375 }
2376 break;
2377 }
2378 __Pyx_GOTREF(__pyx_t_2);
2379 }
2380 __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_line);
2381 __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_line, __pyx_t_2);
2382 __Pyx_GIVEREF(__pyx_t_2);
2383 __pyx_t_2 = 0;
2384 __Pyx_INCREF(__pyx_t_3);
2385 __Pyx_XDECREF_SET(__pyx_v_lineno, __pyx_t_3);
2386 __pyx_t_2 = __Pyx_PyInt_AddObjC(__pyx_t_3, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 67, __pyx_L7_error)
2387 __Pyx_GOTREF(__pyx_t_2);
2388 __Pyx_DECREF(__pyx_t_3);
2389 __pyx_t_3 = __pyx_t_2;
2390 __pyx_t_2 = 0;
2391
2392 /* "gensim/corpora/_mmreader.pyx":68
2393 * self.num_docs = self.num_terms = self.num_nnz = 0
2394 * for lineno, line in enumerate(lines):
2395 * line = utils.to_unicode(line) # <<<<<<<<<<<<<<
2396 * if not line.startswith('%'):
2397 * self.num_docs, self.num_terms, self.num_nnz = (int(x) for x in line.split())
2398 */
2399 __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_utils); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 68, __pyx_L7_error)
2400 __Pyx_GOTREF(__pyx_t_5);
2401 __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_to_unicode); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 68, __pyx_L7_error)
2402 __Pyx_GOTREF(__pyx_t_14);
2403 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2404 __pyx_t_5 = NULL;
2405 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_14))) {
2406 __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_14);
2407 if (likely(__pyx_t_5)) {
2408 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14);
2409 __Pyx_INCREF(__pyx_t_5);
2410 __Pyx_INCREF(function);
2411 __Pyx_DECREF_SET(__pyx_t_14, function);
2412 }
2413 }
2414 __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_14, __pyx_t_5, __pyx_cur_scope->__pyx_v_line) : __Pyx_PyObject_CallOneArg(__pyx_t_14, __pyx_cur_scope->__pyx_v_line);
2415 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
2416 if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 68, __pyx_L7_error)
2417 __Pyx_GOTREF(__pyx_t_2);
2418 __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
2419 __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_line);
2420 __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_line, __pyx_t_2);
2421 __Pyx_GIVEREF(__pyx_t_2);
2422 __pyx_t_2 = 0;
2423
2424 /* "gensim/corpora/_mmreader.pyx":69
2425 * for lineno, line in enumerate(lines):
2426 * line = utils.to_unicode(line)
2427 * if not line.startswith('%'): # <<<<<<<<<<<<<<
2428 * self.num_docs, self.num_terms, self.num_nnz = (int(x) for x in line.split())
2429 * if not self.transposed:
2430 */
2431 __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_line, __pyx_n_s_startswith); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 69, __pyx_L7_error)
2432 __Pyx_GOTREF(__pyx_t_14);
2433 __pyx_t_5 = NULL;
2434 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_14))) {
2435 __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_14);
2436 if (likely(__pyx_t_5)) {
2437 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14);
2438 __Pyx_INCREF(__pyx_t_5);
2439 __Pyx_INCREF(function);
2440 __Pyx_DECREF_SET(__pyx_t_14, function);
2441 }
2442 }
2443 __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_14, __pyx_t_5, __pyx_kp_s_) : __Pyx_PyObject_CallOneArg(__pyx_t_14, __pyx_kp_s_);
2444 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
2445 if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 69, __pyx_L7_error)
2446 __Pyx_GOTREF(__pyx_t_2);
2447 __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
2448 __pyx_t_15 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_15 < 0)) __PYX_ERR(0, 69, __pyx_L7_error)
2449 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2450 __pyx_t_6 = ((!__pyx_t_15) != 0);
2451 if (__pyx_t_6) {
2452
2453 /* "gensim/corpora/_mmreader.pyx":70
2454 * line = utils.to_unicode(line)
2455 * if not line.startswith('%'):
2456 * self.num_docs, self.num_terms, self.num_nnz = (int(x) for x in line.split()) # <<<<<<<<<<<<<<
2457 * if not self.transposed:
2458 * self.num_docs, self.num_terms = self.num_terms, self.num_docs
2459 */
2460 __pyx_t_2 = __pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_8__init___genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 70, __pyx_L7_error)
2461 __Pyx_GOTREF(__pyx_t_2);
2462 if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
2463 PyObject* sequence = __pyx_t_2;
2464 Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
2465 if (unlikely(size != 3)) {
2466 if (size > 3) __Pyx_RaiseTooManyValuesError(3);
2467 else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
2468 __PYX_ERR(0, 70, __pyx_L7_error)
2469 }
2470 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
2471 if (likely(PyTuple_CheckExact(sequence))) {
2472 __pyx_t_14 = PyTuple_GET_ITEM(sequence, 0);
2473 __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1);
2474 __pyx_t_18 = PyTuple_GET_ITEM(sequence, 2);
2475 } else {
2476 __pyx_t_14 = PyList_GET_ITEM(sequence, 0);
2477 __pyx_t_5 = PyList_GET_ITEM(sequence, 1);
2478 __pyx_t_18 = PyList_GET_ITEM(sequence, 2);
2479 }
2480 __Pyx_INCREF(__pyx_t_14);
2481 __Pyx_INCREF(__pyx_t_5);
2482 __Pyx_INCREF(__pyx_t_18);
2483 #else
2484 __pyx_t_14 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 70, __pyx_L7_error)
2485 __Pyx_GOTREF(__pyx_t_14);
2486 __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 70, __pyx_L7_error)
2487 __Pyx_GOTREF(__pyx_t_5);
2488 __pyx_t_18 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 70, __pyx_L7_error)
2489 __Pyx_GOTREF(__pyx_t_18);
2490 #endif
2491 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2492 } else {
2493 Py_ssize_t index = -1;
2494 __pyx_t_19 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 70, __pyx_L7_error)
2495 __Pyx_GOTREF(__pyx_t_19);
2496 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2497 __pyx_t_20 = Py_TYPE(__pyx_t_19)->tp_iternext;
2498 index = 0; __pyx_t_14 = __pyx_t_20(__pyx_t_19); if (unlikely(!__pyx_t_14)) goto __pyx_L23_unpacking_failed;
2499 __Pyx_GOTREF(__pyx_t_14);
2500 index = 1; __pyx_t_5 = __pyx_t_20(__pyx_t_19); if (unlikely(!__pyx_t_5)) goto __pyx_L23_unpacking_failed;
2501 __Pyx_GOTREF(__pyx_t_5);
2502 index = 2; __pyx_t_18 = __pyx_t_20(__pyx_t_19); if (unlikely(!__pyx_t_18)) goto __pyx_L23_unpacking_failed;
2503 __Pyx_GOTREF(__pyx_t_18);
2504 if (__Pyx_IternextUnpackEndCheck(__pyx_t_20(__pyx_t_19), 3) < 0) __PYX_ERR(0, 70, __pyx_L7_error)
2505 __pyx_t_20 = NULL;
2506 __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
2507 goto __pyx_L24_unpacking_done;
2508 __pyx_L23_unpacking_failed:;
2509 __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
2510 __pyx_t_20 = NULL;
2511 if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
2512 __PYX_ERR(0, 70, __pyx_L7_error)
2513 __pyx_L24_unpacking_done:;
2514 }
2515 __pyx_t_21 = __Pyx_PyInt_As_PY_LONG_LONG(__pyx_t_14); if (unlikely((__pyx_t_21 == (PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(0, 70, __pyx_L7_error)
2516 __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
2517 __pyx_t_22 = __Pyx_PyInt_As_PY_LONG_LONG(__pyx_t_5); if (unlikely((__pyx_t_22 == (PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(0, 70, __pyx_L7_error)
2518 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2519 __pyx_t_23 = __Pyx_PyInt_As_PY_LONG_LONG(__pyx_t_18); if (unlikely((__pyx_t_23 == (PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(0, 70, __pyx_L7_error)
2520 __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
2521 __pyx_v_self->num_docs = __pyx_t_21;
2522 __pyx_v_self->num_terms = __pyx_t_22;
2523 __pyx_v_self->num_nnz = __pyx_t_23;
2524
2525 /* "gensim/corpora/_mmreader.pyx":71
2526 * if not line.startswith('%'):
2527 * self.num_docs, self.num_terms, self.num_nnz = (int(x) for x in line.split())
2528 * if not self.transposed: # <<<<<<<<<<<<<<
2529 * self.num_docs, self.num_terms = self.num_terms, self.num_docs
2530 * break
2531 */
2532 __pyx_t_6 = ((!(__pyx_v_self->transposed != 0)) != 0);
2533 if (__pyx_t_6) {
2534
2535 /* "gensim/corpora/_mmreader.pyx":72
2536 * self.num_docs, self.num_terms, self.num_nnz = (int(x) for x in line.split())
2537 * if not self.transposed:
2538 * self.num_docs, self.num_terms = self.num_terms, self.num_docs # <<<<<<<<<<<<<<
2539 * break
2540 *
2541 */
2542 __pyx_t_23 = __pyx_v_self->num_terms;
2543 __pyx_t_22 = __pyx_v_self->num_docs;
2544 __pyx_v_self->num_docs = __pyx_t_23;
2545 __pyx_v_self->num_terms = __pyx_t_22;
2546
2547 /* "gensim/corpora/_mmreader.pyx":71
2548 * if not line.startswith('%'):
2549 * self.num_docs, self.num_terms, self.num_nnz = (int(x) for x in line.split())
2550 * if not self.transposed: # <<<<<<<<<<<<<<
2551 * self.num_docs, self.num_terms = self.num_terms, self.num_docs
2552 * break
2553 */
2554 }
2555
2556 /* "gensim/corpora/_mmreader.pyx":73
2557 * if not self.transposed:
2558 * self.num_docs, self.num_terms = self.num_terms, self.num_docs
2559 * break # <<<<<<<<<<<<<<
2560 *
2561 * logger.info(
2562 */
2563 goto __pyx_L21_break;
2564
2565 /* "gensim/corpora/_mmreader.pyx":69
2566 * for lineno, line in enumerate(lines):
2567 * line = utils.to_unicode(line)
2568 * if not line.startswith('%'): # <<<<<<<<<<<<<<
2569 * self.num_docs, self.num_terms, self.num_nnz = (int(x) for x in line.split())
2570 * if not self.transposed:
2571 */
2572 }
2573
2574 /* "gensim/corpora/_mmreader.pyx":67
2575 *
2576 * self.num_docs = self.num_terms = self.num_nnz = 0
2577 * for lineno, line in enumerate(lines): # <<<<<<<<<<<<<<
2578 * line = utils.to_unicode(line)
2579 * if not line.startswith('%'):
2580 */
2581 }
2582 __pyx_L21_break:;
2583 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2584 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2585
2586 /* "gensim/corpora/_mmreader.pyx":55
2587 * logger.info("initializing cython corpus reader from %s", input)
2588 * self.input, self.transposed = input, transposed
2589 * with utils.open_file(self.input) as lines: # <<<<<<<<<<<<<<
2590 * try:
2591 * header = utils.to_unicode(next(lines)).strip()
2592 */
2593 }
2594 __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
2595 __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
2596 __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
2597 goto __pyx_L12_try_end;
2598 __pyx_L7_error:;
2599 __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
2600 __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
2601 __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
2602 __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
2603 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
2604 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
2605 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
2606 /*except:*/ {
2607 __Pyx_AddTraceback("gensim.corpora._mmreader.MmReader.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
2608 if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_1, &__pyx_t_2) < 0) __PYX_ERR(0, 55, __pyx_L9_except_error)
2609 __Pyx_GOTREF(__pyx_t_3);
2610 __Pyx_GOTREF(__pyx_t_1);
2611 __Pyx_GOTREF(__pyx_t_2);
2612 __pyx_t_18 = PyTuple_Pack(3, __pyx_t_3, __pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 55, __pyx_L9_except_error)
2613 __Pyx_GOTREF(__pyx_t_18);
2614 __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_18, NULL);
2615 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
2616 __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
2617 if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 55, __pyx_L9_except_error)
2618 __Pyx_GOTREF(__pyx_t_13);
2619 __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_13);
2620 __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
2621 if (__pyx_t_6 < 0) __PYX_ERR(0, 55, __pyx_L9_except_error)
2622 __pyx_t_15 = ((!(__pyx_t_6 != 0)) != 0);
2623 if (__pyx_t_15) {
2624 __Pyx_GIVEREF(__pyx_t_3);
2625 __Pyx_GIVEREF(__pyx_t_1);
2626 __Pyx_XGIVEREF(__pyx_t_2);
2627 __Pyx_ErrRestoreWithState(__pyx_t_3, __pyx_t_1, __pyx_t_2);
2628 __pyx_t_3 = 0; __pyx_t_1 = 0; __pyx_t_2 = 0;
2629 __PYX_ERR(0, 55, __pyx_L9_except_error)
2630 }
2631 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
2632 __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
2633 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
2634 goto __pyx_L8_exception_handled;
2635 }
2636 __pyx_L9_except_error:;
2637 __Pyx_XGIVEREF(__pyx_t_8);
2638 __Pyx_XGIVEREF(__pyx_t_9);
2639 __Pyx_XGIVEREF(__pyx_t_10);
2640 __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
2641 goto __pyx_L1_error;
2642 __pyx_L8_exception_handled:;
2643 __Pyx_XGIVEREF(__pyx_t_8);
2644 __Pyx_XGIVEREF(__pyx_t_9);
2645 __Pyx_XGIVEREF(__pyx_t_10);
2646 __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
2647 __pyx_L12_try_end:;
2648 }
2649 }
2650 /*finally:*/ {
2651 /*normal exit:*/{
2652 if (__pyx_t_7) {
2653 __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_tuple__2, NULL);
2654 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
2655 if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 55, __pyx_L1_error)
2656 __Pyx_GOTREF(__pyx_t_10);
2657 __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
2658 }
2659 goto __pyx_L6;
2660 }
2661 __pyx_L6:;
2662 }
2663 goto __pyx_L29;
2664 __pyx_L3_error:;
2665 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
2666 goto __pyx_L1_error;
2667 __pyx_L29:;
2668 }
2669
2670 /* "gensim/corpora/_mmreader.pyx":75
2671 * break
2672 *
2673 * logger.info( # <<<<<<<<<<<<<<
2674 * "accepted corpus with %i documents, %i features, %i non-zero entries",
2675 * self.num_docs, self.num_terms, self.num_nnz
2676 */
2677 __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 75, __pyx_L1_error)
2678 __Pyx_GOTREF(__pyx_t_1);
2679 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 75, __pyx_L1_error)
2680 __Pyx_GOTREF(__pyx_t_3);
2681 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2682
2683 /* "gensim/corpora/_mmreader.pyx":77
2684 * logger.info(
2685 * "accepted corpus with %i documents, %i features, %i non-zero entries",
2686 * self.num_docs, self.num_terms, self.num_nnz # <<<<<<<<<<<<<<
2687 * )
2688 *
2689 */
2690 __pyx_t_1 = __Pyx_PyInt_From_PY_LONG_LONG(__pyx_v_self->num_docs); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 77, __pyx_L1_error)
2691 __Pyx_GOTREF(__pyx_t_1);
2692 __pyx_t_18 = __Pyx_PyInt_From_PY_LONG_LONG(__pyx_v_self->num_terms); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 77, __pyx_L1_error)
2693 __Pyx_GOTREF(__pyx_t_18);
2694 __pyx_t_5 = __Pyx_PyInt_From_PY_LONG_LONG(__pyx_v_self->num_nnz); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 77, __pyx_L1_error)
2695 __Pyx_GOTREF(__pyx_t_5);
2696 __pyx_t_14 = NULL;
2697 __pyx_t_4 = 0;
2698 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
2699 __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_3);
2700 if (likely(__pyx_t_14)) {
2701 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
2702 __Pyx_INCREF(__pyx_t_14);
2703 __Pyx_INCREF(function);
2704 __Pyx_DECREF_SET(__pyx_t_3, function);
2705 __pyx_t_4 = 1;
2706 }
2707 }
2708 #if CYTHON_FAST_PYCALL
2709 if (PyFunction_Check(__pyx_t_3)) {
2710 PyObject *__pyx_temp[5] = {__pyx_t_14, __pyx_kp_s_accepted_corpus_with_i_documents, __pyx_t_1, __pyx_t_18, __pyx_t_5};
2711 __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_4, 4+__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 75, __pyx_L1_error)
2712 __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
2713 __Pyx_GOTREF(__pyx_t_2);
2714 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2715 __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
2716 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2717 } else
2718 #endif
2719 #if CYTHON_FAST_PYCCALL
2720 if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
2721 PyObject *__pyx_temp[5] = {__pyx_t_14, __pyx_kp_s_accepted_corpus_with_i_documents, __pyx_t_1, __pyx_t_18, __pyx_t_5};
2722 __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_4, 4+__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 75, __pyx_L1_error)
2723 __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
2724 __Pyx_GOTREF(__pyx_t_2);
2725 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2726 __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
2727 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2728 } else
2729 #endif
2730 {
2731 __pyx_t_19 = PyTuple_New(4+__pyx_t_4); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 75, __pyx_L1_error)
2732 __Pyx_GOTREF(__pyx_t_19);
2733 if (__pyx_t_14) {
2734 __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_19, 0, __pyx_t_14); __pyx_t_14 = NULL;
2735 }
2736 __Pyx_INCREF(__pyx_kp_s_accepted_corpus_with_i_documents);
2737 __Pyx_GIVEREF(__pyx_kp_s_accepted_corpus_with_i_documents);
2738 PyTuple_SET_ITEM(__pyx_t_19, 0+__pyx_t_4, __pyx_kp_s_accepted_corpus_with_i_documents);
2739 __Pyx_GIVEREF(__pyx_t_1);
2740 PyTuple_SET_ITEM(__pyx_t_19, 1+__pyx_t_4, __pyx_t_1);
2741 __Pyx_GIVEREF(__pyx_t_18);
2742 PyTuple_SET_ITEM(__pyx_t_19, 2+__pyx_t_4, __pyx_t_18);
2743 __Pyx_GIVEREF(__pyx_t_5);
2744 PyTuple_SET_ITEM(__pyx_t_19, 3+__pyx_t_4, __pyx_t_5);
2745 __pyx_t_1 = 0;
2746 __pyx_t_18 = 0;
2747 __pyx_t_5 = 0;
2748 __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_19, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 75, __pyx_L1_error)
2749 __Pyx_GOTREF(__pyx_t_2);
2750 __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
2751 }
2752 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2753 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2754
2755 /* "gensim/corpora/_mmreader.pyx":40
2756 * cdef public long long num_docs, num_terms, num_nnz
2757 *
2758 * def __init__(self, input, transposed=True): # <<<<<<<<<<<<<<
2759 * """
2760 *
2761 */
2762
2763 /* function exit code */
2764 __pyx_r = 0;
2765 goto __pyx_L0;
2766 __pyx_L1_error:;
2767 __Pyx_XDECREF(__pyx_t_1);
2768 __Pyx_XDECREF(__pyx_t_2);
2769 __Pyx_XDECREF(__pyx_t_3);
2770 __Pyx_XDECREF(__pyx_t_5);
2771 __Pyx_XDECREF(__pyx_t_14);
2772 __Pyx_XDECREF(__pyx_t_18);
2773 __Pyx_XDECREF(__pyx_t_19);
2774 __Pyx_AddTraceback("gensim.corpora._mmreader.MmReader.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
2775 __pyx_r = -1;
2776 __pyx_L0:;
2777 __Pyx_XDECREF(__pyx_v_lines);
2778 __Pyx_XDECREF(__pyx_v_header);
2779 __Pyx_XDECREF(__pyx_v_lineno);
2780 __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
2781 __Pyx_RefNannyFinishContext();
2782 return __pyx_r;
2783 }
2784
2785 /* "gensim/corpora/_mmreader.pyx":80
2786 * )
2787 *
2788 * def __len__(self): # <<<<<<<<<<<<<<
2789 * """Get the corpus size: total number of documents."""
2790 * return self.num_docs
2791 */
2792
2793 /* Python wrapper */
2794 static Py_ssize_t __pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_3__len__(PyObject *__pyx_v_self); /*proto*/
2795 static char __pyx_doc_6gensim_7corpora_9_mmreader_8MmReader_2__len__[] = "Get the corpus size: total number of documents.";
2796 #if CYTHON_COMPILING_IN_CPYTHON
2797 struct wrapperbase __pyx_wrapperbase_6gensim_7corpora_9_mmreader_8MmReader_2__len__;
2798 #endif
__pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_3__len__(PyObject * __pyx_v_self)2799 static Py_ssize_t __pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_3__len__(PyObject *__pyx_v_self) {
2800 Py_ssize_t __pyx_r;
2801 __Pyx_RefNannyDeclarations
2802 __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
2803 __pyx_r = __pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_2__len__(((struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *)__pyx_v_self));
2804
2805 /* function exit code */
2806 __Pyx_RefNannyFinishContext();
2807 return __pyx_r;
2808 }
2809
__pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_2__len__(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader * __pyx_v_self)2810 static Py_ssize_t __pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_2__len__(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *__pyx_v_self) {
2811 Py_ssize_t __pyx_r;
2812 __Pyx_RefNannyDeclarations
2813 __Pyx_RefNannySetupContext("__len__", 0);
2814
2815 /* "gensim/corpora/_mmreader.pyx":82
2816 * def __len__(self):
2817 * """Get the corpus size: total number of documents."""
2818 * return self.num_docs # <<<<<<<<<<<<<<
2819 *
2820 * def __str__(self):
2821 */
2822 __pyx_r = __pyx_v_self->num_docs;
2823 goto __pyx_L0;
2824
2825 /* "gensim/corpora/_mmreader.pyx":80
2826 * )
2827 *
2828 * def __len__(self): # <<<<<<<<<<<<<<
2829 * """Get the corpus size: total number of documents."""
2830 * return self.num_docs
2831 */
2832
2833 /* function exit code */
2834 __pyx_L0:;
2835 __Pyx_RefNannyFinishContext();
2836 return __pyx_r;
2837 }
2838
2839 /* "gensim/corpora/_mmreader.pyx":84
2840 * return self.num_docs
2841 *
2842 * def __str__(self): # <<<<<<<<<<<<<<
2843 * return ("MmCorpus(%i documents, %i features, %i non-zero entries)" %
2844 * (self.num_docs, self.num_terms, self.num_nnz))
2845 */
2846
2847 /* Python wrapper */
2848 static PyObject *__pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_5__str__(PyObject *__pyx_v_self); /*proto*/
__pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_5__str__(PyObject * __pyx_v_self)2849 static PyObject *__pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_5__str__(PyObject *__pyx_v_self) {
2850 PyObject *__pyx_r = 0;
2851 __Pyx_RefNannyDeclarations
2852 __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
2853 __pyx_r = __pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_4__str__(((struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *)__pyx_v_self));
2854
2855 /* function exit code */
2856 __Pyx_RefNannyFinishContext();
2857 return __pyx_r;
2858 }
2859
__pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_4__str__(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader * __pyx_v_self)2860 static PyObject *__pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_4__str__(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *__pyx_v_self) {
2861 PyObject *__pyx_r = NULL;
2862 __Pyx_RefNannyDeclarations
2863 PyObject *__pyx_t_1 = NULL;
2864 PyObject *__pyx_t_2 = NULL;
2865 PyObject *__pyx_t_3 = NULL;
2866 PyObject *__pyx_t_4 = NULL;
2867 int __pyx_lineno = 0;
2868 const char *__pyx_filename = NULL;
2869 int __pyx_clineno = 0;
2870 __Pyx_RefNannySetupContext("__str__", 0);
2871
2872 /* "gensim/corpora/_mmreader.pyx":85
2873 *
2874 * def __str__(self):
2875 * return ("MmCorpus(%i documents, %i features, %i non-zero entries)" % # <<<<<<<<<<<<<<
2876 * (self.num_docs, self.num_terms, self.num_nnz))
2877 *
2878 */
2879 __Pyx_XDECREF(__pyx_r);
2880
2881 /* "gensim/corpora/_mmreader.pyx":86
2882 * def __str__(self):
2883 * return ("MmCorpus(%i documents, %i features, %i non-zero entries)" %
2884 * (self.num_docs, self.num_terms, self.num_nnz)) # <<<<<<<<<<<<<<
2885 *
2886 * def skip_headers(self, input_file):
2887 */
2888 __pyx_t_1 = __Pyx_PyInt_From_PY_LONG_LONG(__pyx_v_self->num_docs); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 86, __pyx_L1_error)
2889 __Pyx_GOTREF(__pyx_t_1);
2890 __pyx_t_2 = __Pyx_PyInt_From_PY_LONG_LONG(__pyx_v_self->num_terms); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 86, __pyx_L1_error)
2891 __Pyx_GOTREF(__pyx_t_2);
2892 __pyx_t_3 = __Pyx_PyInt_From_PY_LONG_LONG(__pyx_v_self->num_nnz); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 86, __pyx_L1_error)
2893 __Pyx_GOTREF(__pyx_t_3);
2894 __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 86, __pyx_L1_error)
2895 __Pyx_GOTREF(__pyx_t_4);
2896 __Pyx_GIVEREF(__pyx_t_1);
2897 PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
2898 __Pyx_GIVEREF(__pyx_t_2);
2899 PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
2900 __Pyx_GIVEREF(__pyx_t_3);
2901 PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_3);
2902 __pyx_t_1 = 0;
2903 __pyx_t_2 = 0;
2904 __pyx_t_3 = 0;
2905
2906 /* "gensim/corpora/_mmreader.pyx":85
2907 *
2908 * def __str__(self):
2909 * return ("MmCorpus(%i documents, %i features, %i non-zero entries)" % # <<<<<<<<<<<<<<
2910 * (self.num_docs, self.num_terms, self.num_nnz))
2911 *
2912 */
2913 __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_MmCorpus_i_documents_i_features, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 85, __pyx_L1_error)
2914 __Pyx_GOTREF(__pyx_t_3);
2915 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2916 __pyx_r = __pyx_t_3;
2917 __pyx_t_3 = 0;
2918 goto __pyx_L0;
2919
2920 /* "gensim/corpora/_mmreader.pyx":84
2921 * return self.num_docs
2922 *
2923 * def __str__(self): # <<<<<<<<<<<<<<
2924 * return ("MmCorpus(%i documents, %i features, %i non-zero entries)" %
2925 * (self.num_docs, self.num_terms, self.num_nnz))
2926 */
2927
2928 /* function exit code */
2929 __pyx_L1_error:;
2930 __Pyx_XDECREF(__pyx_t_1);
2931 __Pyx_XDECREF(__pyx_t_2);
2932 __Pyx_XDECREF(__pyx_t_3);
2933 __Pyx_XDECREF(__pyx_t_4);
2934 __Pyx_AddTraceback("gensim.corpora._mmreader.MmReader.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
2935 __pyx_r = NULL;
2936 __pyx_L0:;
2937 __Pyx_XGIVEREF(__pyx_r);
2938 __Pyx_RefNannyFinishContext();
2939 return __pyx_r;
2940 }
2941
2942 /* "gensim/corpora/_mmreader.pyx":88
2943 * (self.num_docs, self.num_terms, self.num_nnz))
2944 *
2945 * def skip_headers(self, input_file): # <<<<<<<<<<<<<<
2946 * """Skip file headers that appear before the first document.
2947 *
2948 */
2949
2950 /* Python wrapper */
2951 static PyObject *__pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_7skip_headers(PyObject *__pyx_v_self, PyObject *__pyx_v_input_file); /*proto*/
2952 static char __pyx_doc_6gensim_7corpora_9_mmreader_8MmReader_6skip_headers[] = "MmReader.skip_headers(self, input_file)\nSkip file headers that appear before the first document.\n\n Parameters\n ----------\n input_file : iterable of str\n Iterable taken from file in MM format.\n\n ";
__pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_7skip_headers(PyObject * __pyx_v_self,PyObject * __pyx_v_input_file)2953 static PyObject *__pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_7skip_headers(PyObject *__pyx_v_self, PyObject *__pyx_v_input_file) {
2954 PyObject *__pyx_r = 0;
2955 __Pyx_RefNannyDeclarations
2956 __Pyx_RefNannySetupContext("skip_headers (wrapper)", 0);
2957 __pyx_r = __pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_6skip_headers(((struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *)__pyx_v_self), ((PyObject *)__pyx_v_input_file));
2958
2959 /* function exit code */
2960 __Pyx_RefNannyFinishContext();
2961 return __pyx_r;
2962 }
2963
__pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_6skip_headers(CYTHON_UNUSED struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader * __pyx_v_self,PyObject * __pyx_v_input_file)2964 static PyObject *__pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_6skip_headers(CYTHON_UNUSED struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *__pyx_v_self, PyObject *__pyx_v_input_file) {
2965 PyObject *__pyx_v_line = NULL;
2966 PyObject *__pyx_r = NULL;
2967 __Pyx_RefNannyDeclarations
2968 PyObject *__pyx_t_1 = NULL;
2969 Py_ssize_t __pyx_t_2;
2970 PyObject *(*__pyx_t_3)(PyObject *);
2971 PyObject *__pyx_t_4 = NULL;
2972 PyObject *__pyx_t_5 = NULL;
2973 PyObject *__pyx_t_6 = NULL;
2974 int __pyx_t_7;
2975 int __pyx_lineno = 0;
2976 const char *__pyx_filename = NULL;
2977 int __pyx_clineno = 0;
2978 __Pyx_RefNannySetupContext("skip_headers", 0);
2979
2980 /* "gensim/corpora/_mmreader.pyx":97
2981 *
2982 * """
2983 * for line in input_file: # <<<<<<<<<<<<<<
2984 * if line.startswith(b'%'):
2985 * continue
2986 */
2987 if (likely(PyList_CheckExact(__pyx_v_input_file)) || PyTuple_CheckExact(__pyx_v_input_file)) {
2988 __pyx_t_1 = __pyx_v_input_file; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
2989 __pyx_t_3 = NULL;
2990 } else {
2991 __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_input_file); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 97, __pyx_L1_error)
2992 __Pyx_GOTREF(__pyx_t_1);
2993 __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 97, __pyx_L1_error)
2994 }
2995 for (;;) {
2996 if (likely(!__pyx_t_3)) {
2997 if (likely(PyList_CheckExact(__pyx_t_1))) {
2998 if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
2999 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
3000 __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, 97, __pyx_L1_error)
3001 #else
3002 __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 97, __pyx_L1_error)
3003 __Pyx_GOTREF(__pyx_t_4);
3004 #endif
3005 } else {
3006 if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
3007 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
3008 __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, 97, __pyx_L1_error)
3009 #else
3010 __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 97, __pyx_L1_error)
3011 __Pyx_GOTREF(__pyx_t_4);
3012 #endif
3013 }
3014 } else {
3015 __pyx_t_4 = __pyx_t_3(__pyx_t_1);
3016 if (unlikely(!__pyx_t_4)) {
3017 PyObject* exc_type = PyErr_Occurred();
3018 if (exc_type) {
3019 if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
3020 else __PYX_ERR(0, 97, __pyx_L1_error)
3021 }
3022 break;
3023 }
3024 __Pyx_GOTREF(__pyx_t_4);
3025 }
3026 __Pyx_XDECREF_SET(__pyx_v_line, __pyx_t_4);
3027 __pyx_t_4 = 0;
3028
3029 /* "gensim/corpora/_mmreader.pyx":98
3030 * """
3031 * for line in input_file:
3032 * if line.startswith(b'%'): # <<<<<<<<<<<<<<
3033 * continue
3034 * break
3035 */
3036 __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_line, __pyx_n_s_startswith); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 98, __pyx_L1_error)
3037 __Pyx_GOTREF(__pyx_t_5);
3038 __pyx_t_6 = NULL;
3039 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
3040 __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
3041 if (likely(__pyx_t_6)) {
3042 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
3043 __Pyx_INCREF(__pyx_t_6);
3044 __Pyx_INCREF(function);
3045 __Pyx_DECREF_SET(__pyx_t_5, function);
3046 }
3047 }
3048 __pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, __pyx_kp_b_) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_kp_b_);
3049 __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
3050 if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 98, __pyx_L1_error)
3051 __Pyx_GOTREF(__pyx_t_4);
3052 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
3053 __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 98, __pyx_L1_error)
3054 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3055 if (__pyx_t_7) {
3056
3057 /* "gensim/corpora/_mmreader.pyx":99
3058 * for line in input_file:
3059 * if line.startswith(b'%'):
3060 * continue # <<<<<<<<<<<<<<
3061 * break
3062 *
3063 */
3064 goto __pyx_L3_continue;
3065
3066 /* "gensim/corpora/_mmreader.pyx":98
3067 * """
3068 * for line in input_file:
3069 * if line.startswith(b'%'): # <<<<<<<<<<<<<<
3070 * continue
3071 * break
3072 */
3073 }
3074
3075 /* "gensim/corpora/_mmreader.pyx":100
3076 * if line.startswith(b'%'):
3077 * continue
3078 * break # <<<<<<<<<<<<<<
3079 *
3080 * def __iter__(self):
3081 */
3082 goto __pyx_L4_break;
3083
3084 /* "gensim/corpora/_mmreader.pyx":97
3085 *
3086 * """
3087 * for line in input_file: # <<<<<<<<<<<<<<
3088 * if line.startswith(b'%'):
3089 * continue
3090 */
3091 __pyx_L3_continue:;
3092 }
3093 __pyx_L4_break:;
3094 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3095
3096 /* "gensim/corpora/_mmreader.pyx":88
3097 * (self.num_docs, self.num_terms, self.num_nnz))
3098 *
3099 * def skip_headers(self, input_file): # <<<<<<<<<<<<<<
3100 * """Skip file headers that appear before the first document.
3101 *
3102 */
3103
3104 /* function exit code */
3105 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
3106 goto __pyx_L0;
3107 __pyx_L1_error:;
3108 __Pyx_XDECREF(__pyx_t_1);
3109 __Pyx_XDECREF(__pyx_t_4);
3110 __Pyx_XDECREF(__pyx_t_5);
3111 __Pyx_XDECREF(__pyx_t_6);
3112 __Pyx_AddTraceback("gensim.corpora._mmreader.MmReader.skip_headers", __pyx_clineno, __pyx_lineno, __pyx_filename);
3113 __pyx_r = NULL;
3114 __pyx_L0:;
3115 __Pyx_XDECREF(__pyx_v_line);
3116 __Pyx_XGIVEREF(__pyx_r);
3117 __Pyx_RefNannyFinishContext();
3118 return __pyx_r;
3119 }
3120 static PyObject *__pyx_gb_6gensim_7corpora_9_mmreader_8MmReader_10generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */
3121
3122 /* "gensim/corpora/_mmreader.pyx":102
3123 * break
3124 *
3125 * def __iter__(self): # <<<<<<<<<<<<<<
3126 * """Iterate through all documents in the corpus.
3127 *
3128 */
3129
3130 /* Python wrapper */
3131 static PyObject *__pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_9__iter__(PyObject *__pyx_v_self); /*proto*/
3132 static char __pyx_doc_6gensim_7corpora_9_mmreader_8MmReader_8__iter__[] = "Iterate through all documents in the corpus.\n\n Notes\n ------\n Note that the total number of vectors returned is always equal to the number of rows specified\n in the header: empty documents are inserted and yielded where appropriate, even if they are not explicitly\n stored in the Matrix Market file.\n\n Yields\n ------\n (int, list of (int, number))\n Document id and document in sparse bag-of-words format.\n\n ";
3133 #if CYTHON_COMPILING_IN_CPYTHON
3134 struct wrapperbase __pyx_wrapperbase_6gensim_7corpora_9_mmreader_8MmReader_8__iter__;
3135 #endif
__pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_9__iter__(PyObject * __pyx_v_self)3136 static PyObject *__pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_9__iter__(PyObject *__pyx_v_self) {
3137 PyObject *__pyx_r = 0;
3138 __Pyx_RefNannyDeclarations
3139 __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
3140 __pyx_r = __pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_8__iter__(((struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *)__pyx_v_self));
3141
3142 /* function exit code */
3143 __Pyx_RefNannyFinishContext();
3144 return __pyx_r;
3145 }
3146
__pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_8__iter__(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader * __pyx_v_self)3147 static PyObject *__pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_8__iter__(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *__pyx_v_self) {
3148 struct __pyx_obj_6gensim_7corpora_9_mmreader___pyx_scope_struct_2___iter__ *__pyx_cur_scope;
3149 PyObject *__pyx_r = NULL;
3150 __Pyx_RefNannyDeclarations
3151 int __pyx_lineno = 0;
3152 const char *__pyx_filename = NULL;
3153 int __pyx_clineno = 0;
3154 __Pyx_RefNannySetupContext("__iter__", 0);
3155 __pyx_cur_scope = (struct __pyx_obj_6gensim_7corpora_9_mmreader___pyx_scope_struct_2___iter__ *)__pyx_tp_new_6gensim_7corpora_9_mmreader___pyx_scope_struct_2___iter__(__pyx_ptype_6gensim_7corpora_9_mmreader___pyx_scope_struct_2___iter__, __pyx_empty_tuple, NULL);
3156 if (unlikely(!__pyx_cur_scope)) {
3157 __pyx_cur_scope = ((struct __pyx_obj_6gensim_7corpora_9_mmreader___pyx_scope_struct_2___iter__ *)Py_None);
3158 __Pyx_INCREF(Py_None);
3159 __PYX_ERR(0, 102, __pyx_L1_error)
3160 } else {
3161 __Pyx_GOTREF(__pyx_cur_scope);
3162 }
3163 __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
3164 __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
3165 __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
3166 {
3167 __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_6gensim_7corpora_9_mmreader_8MmReader_10generator, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_iter, __pyx_n_s_MmReader___iter, __pyx_n_s_gensim_corpora__mmreader); if (unlikely(!gen)) __PYX_ERR(0, 102, __pyx_L1_error)
3168 __Pyx_DECREF(__pyx_cur_scope);
3169 __Pyx_RefNannyFinishContext();
3170 return (PyObject *) gen;
3171 }
3172
3173 /* function exit code */
3174 __pyx_L1_error:;
3175 __Pyx_AddTraceback("gensim.corpora._mmreader.MmReader.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
3176 __pyx_r = NULL;
3177 __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
3178 __Pyx_XGIVEREF(__pyx_r);
3179 __Pyx_RefNannyFinishContext();
3180 return __pyx_r;
3181 }
3182
__pyx_gb_6gensim_7corpora_9_mmreader_8MmReader_10generator(__pyx_CoroutineObject * __pyx_generator,CYTHON_UNUSED PyThreadState * __pyx_tstate,PyObject * __pyx_sent_value)3183 static PyObject *__pyx_gb_6gensim_7corpora_9_mmreader_8MmReader_10generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
3184 {
3185 struct __pyx_obj_6gensim_7corpora_9_mmreader___pyx_scope_struct_2___iter__ *__pyx_cur_scope = ((struct __pyx_obj_6gensim_7corpora_9_mmreader___pyx_scope_struct_2___iter__ *)__pyx_generator->closure);
3186 PyObject *__pyx_r = NULL;
3187 PyObject *__pyx_t_1 = NULL;
3188 PyObject *__pyx_t_2 = NULL;
3189 PyObject *__pyx_t_3 = NULL;
3190 PyObject *__pyx_t_4 = NULL;
3191 PyObject *__pyx_t_5 = NULL;
3192 PyObject *__pyx_t_6 = NULL;
3193 PyObject *__pyx_t_7 = NULL;
3194 PyObject *__pyx_t_8 = NULL;
3195 Py_ssize_t __pyx_t_9;
3196 PyObject *(*__pyx_t_10)(PyObject *);
3197 char const *__pyx_t_11;
3198 int __pyx_t_12;
3199 PY_LONG_LONG __pyx_t_13;
3200 PY_LONG_LONG __pyx_t_14;
3201 PY_LONG_LONG __pyx_t_15;
3202 int __pyx_t_16;
3203 PyObject *__pyx_t_17 = NULL;
3204 int __pyx_t_18;
3205 int __pyx_lineno = 0;
3206 const char *__pyx_filename = NULL;
3207 int __pyx_clineno = 0;
3208 __Pyx_RefNannyDeclarations
3209 __Pyx_RefNannySetupContext("__iter__", 0);
3210 switch (__pyx_generator->resume_label) {
3211 case 0: goto __pyx_L3_first_run;
3212 case 1: goto __pyx_L20_resume_from_yield;
3213 case 2: goto __pyx_L23_resume_from_yield;
3214 case 3: goto __pyx_L29_resume_from_yield;
3215 case 4: goto __pyx_L32_resume_from_yield;
3216 default: /* CPython raises the right error here */
3217 __Pyx_RefNannyFinishContext();
3218 return NULL;
3219 }
3220 __pyx_L3_first_run:;
3221 if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 102, __pyx_L1_error)
3222
3223 /* "gensim/corpora/_mmreader.pyx":118
3224 * """
3225 * cdef long long docid, termid, previd
3226 * cdef double val = 0 # <<<<<<<<<<<<<<
3227 *
3228 * with utils.file_or_filename(self.input) as lines:
3229 */
3230 __pyx_cur_scope->__pyx_v_val = 0.0;
3231
3232 /* "gensim/corpora/_mmreader.pyx":120
3233 * cdef double val = 0
3234 *
3235 * with utils.file_or_filename(self.input) as lines: # <<<<<<<<<<<<<<
3236 * self.skip_headers(lines)
3237 *
3238 */
3239 /*with:*/ {
3240 __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_utils); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 120, __pyx_L1_error)
3241 __Pyx_GOTREF(__pyx_t_2);
3242 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_file_or_filename); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 120, __pyx_L1_error)
3243 __Pyx_GOTREF(__pyx_t_3);
3244 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3245 __pyx_t_2 = NULL;
3246 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
3247 __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
3248 if (likely(__pyx_t_2)) {
3249 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
3250 __Pyx_INCREF(__pyx_t_2);
3251 __Pyx_INCREF(function);
3252 __Pyx_DECREF_SET(__pyx_t_3, function);
3253 }
3254 }
3255 __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_cur_scope->__pyx_v_self->input) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_cur_scope->__pyx_v_self->input);
3256 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
3257 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 120, __pyx_L1_error)
3258 __Pyx_GOTREF(__pyx_t_1);
3259 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3260 __pyx_t_4 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_n_s_exit); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 120, __pyx_L1_error)
3261 __Pyx_GOTREF(__pyx_t_4);
3262 __pyx_t_2 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_n_s_enter); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 120, __pyx_L4_error)
3263 __Pyx_GOTREF(__pyx_t_2);
3264 __pyx_t_5 = NULL;
3265 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
3266 __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
3267 if (likely(__pyx_t_5)) {
3268 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
3269 __Pyx_INCREF(__pyx_t_5);
3270 __Pyx_INCREF(function);
3271 __Pyx_DECREF_SET(__pyx_t_2, function);
3272 }
3273 }
3274 __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
3275 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
3276 if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 120, __pyx_L4_error)
3277 __Pyx_GOTREF(__pyx_t_3);
3278 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3279 __pyx_t_2 = __pyx_t_3;
3280 __pyx_t_3 = 0;
3281 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3282 /*try:*/ {
3283 {
3284 __Pyx_ExceptionSave(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
3285 __Pyx_XGOTREF(__pyx_t_6);
3286 __Pyx_XGOTREF(__pyx_t_7);
3287 __Pyx_XGOTREF(__pyx_t_8);
3288 /*try:*/ {
3289 __Pyx_GIVEREF(__pyx_t_2);
3290 __pyx_cur_scope->__pyx_v_lines = __pyx_t_2;
3291 __pyx_t_2 = 0;
3292
3293 /* "gensim/corpora/_mmreader.pyx":121
3294 *
3295 * with utils.file_or_filename(self.input) as lines:
3296 * self.skip_headers(lines) # <<<<<<<<<<<<<<
3297 *
3298 * previd = -1
3299 */
3300 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s_skip_headers); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 121, __pyx_L8_error)
3301 __Pyx_GOTREF(__pyx_t_1);
3302 __pyx_t_3 = NULL;
3303 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
3304 __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
3305 if (likely(__pyx_t_3)) {
3306 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
3307 __Pyx_INCREF(__pyx_t_3);
3308 __Pyx_INCREF(function);
3309 __Pyx_DECREF_SET(__pyx_t_1, function);
3310 }
3311 }
3312 __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_3, __pyx_cur_scope->__pyx_v_lines) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_cur_scope->__pyx_v_lines);
3313 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
3314 if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 121, __pyx_L8_error)
3315 __Pyx_GOTREF(__pyx_t_2);
3316 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3317 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3318
3319 /* "gensim/corpora/_mmreader.pyx":123
3320 * self.skip_headers(lines)
3321 *
3322 * previd = -1 # <<<<<<<<<<<<<<
3323 * for line in lines:
3324 *
3325 */
3326 __pyx_cur_scope->__pyx_v_previd = -1LL;
3327
3328 /* "gensim/corpora/_mmreader.pyx":124
3329 *
3330 * previd = -1
3331 * for line in lines: # <<<<<<<<<<<<<<
3332 *
3333 * if (sscanf(line, "%lld %lld %lg", &docid, &termid, &val) != 3):
3334 */
3335 if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_v_lines)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_lines)) {
3336 __pyx_t_2 = __pyx_cur_scope->__pyx_v_lines; __Pyx_INCREF(__pyx_t_2); __pyx_t_9 = 0;
3337 __pyx_t_10 = NULL;
3338 } else {
3339 __pyx_t_9 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_lines); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 124, __pyx_L8_error)
3340 __Pyx_GOTREF(__pyx_t_2);
3341 __pyx_t_10 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 124, __pyx_L8_error)
3342 }
3343 for (;;) {
3344 if (likely(!__pyx_t_10)) {
3345 if (likely(PyList_CheckExact(__pyx_t_2))) {
3346 if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_2)) break;
3347 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
3348 __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_9); __Pyx_INCREF(__pyx_t_1); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 124, __pyx_L8_error)
3349 #else
3350 __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 124, __pyx_L8_error)
3351 __Pyx_GOTREF(__pyx_t_1);
3352 #endif
3353 } else {
3354 if (__pyx_t_9 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
3355 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
3356 __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_9); __Pyx_INCREF(__pyx_t_1); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 124, __pyx_L8_error)
3357 #else
3358 __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 124, __pyx_L8_error)
3359 __Pyx_GOTREF(__pyx_t_1);
3360 #endif
3361 }
3362 } else {
3363 __pyx_t_1 = __pyx_t_10(__pyx_t_2);
3364 if (unlikely(!__pyx_t_1)) {
3365 PyObject* exc_type = PyErr_Occurred();
3366 if (exc_type) {
3367 if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
3368 else __PYX_ERR(0, 124, __pyx_L8_error)
3369 }
3370 break;
3371 }
3372 __Pyx_GOTREF(__pyx_t_1);
3373 }
3374 __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_line);
3375 __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_line, __pyx_t_1);
3376 __Pyx_GIVEREF(__pyx_t_1);
3377 __pyx_t_1 = 0;
3378
3379 /* "gensim/corpora/_mmreader.pyx":126
3380 * for line in lines:
3381 *
3382 * if (sscanf(line, "%lld %lld %lg", &docid, &termid, &val) != 3): # <<<<<<<<<<<<<<
3383 * raise ValueError("unable to parse line: {}".format(line))
3384 *
3385 */
3386 __pyx_t_11 = __Pyx_PyObject_AsString(__pyx_cur_scope->__pyx_v_line); if (unlikely((!__pyx_t_11) && PyErr_Occurred())) __PYX_ERR(0, 126, __pyx_L8_error)
3387 __pyx_t_12 = ((sscanf(__pyx_t_11, ((char const *)"%lld %lld %lg"), (&__pyx_cur_scope->__pyx_v_docid), (&__pyx_cur_scope->__pyx_v_termid), (&__pyx_cur_scope->__pyx_v_val)) != 3) != 0);
3388 if (unlikely(__pyx_t_12)) {
3389
3390 /* "gensim/corpora/_mmreader.pyx":127
3391 *
3392 * if (sscanf(line, "%lld %lld %lg", &docid, &termid, &val) != 3):
3393 * raise ValueError("unable to parse line: {}".format(line)) # <<<<<<<<<<<<<<
3394 *
3395 * if not self.transposed:
3396 */
3397 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_unable_to_parse_line, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 127, __pyx_L8_error)
3398 __Pyx_GOTREF(__pyx_t_3);
3399 __pyx_t_5 = NULL;
3400 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
3401 __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
3402 if (likely(__pyx_t_5)) {
3403 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
3404 __Pyx_INCREF(__pyx_t_5);
3405 __Pyx_INCREF(function);
3406 __Pyx_DECREF_SET(__pyx_t_3, function);
3407 }
3408 }
3409 __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_5, __pyx_cur_scope->__pyx_v_line) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_cur_scope->__pyx_v_line);
3410 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
3411 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 127, __pyx_L8_error)
3412 __Pyx_GOTREF(__pyx_t_1);
3413 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3414 __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 127, __pyx_L8_error)
3415 __Pyx_GOTREF(__pyx_t_3);
3416 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3417 __Pyx_Raise(__pyx_t_3, 0, 0, 0);
3418 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3419 __PYX_ERR(0, 127, __pyx_L8_error)
3420
3421 /* "gensim/corpora/_mmreader.pyx":126
3422 * for line in lines:
3423 *
3424 * if (sscanf(line, "%lld %lld %lg", &docid, &termid, &val) != 3): # <<<<<<<<<<<<<<
3425 * raise ValueError("unable to parse line: {}".format(line))
3426 *
3427 */
3428 }
3429
3430 /* "gensim/corpora/_mmreader.pyx":129
3431 * raise ValueError("unable to parse line: {}".format(line))
3432 *
3433 * if not self.transposed: # <<<<<<<<<<<<<<
3434 * termid, docid = docid, termid
3435 *
3436 */
3437 __pyx_t_12 = ((!(__pyx_cur_scope->__pyx_v_self->transposed != 0)) != 0);
3438 if (__pyx_t_12) {
3439
3440 /* "gensim/corpora/_mmreader.pyx":130
3441 *
3442 * if not self.transposed:
3443 * termid, docid = docid, termid # <<<<<<<<<<<<<<
3444 *
3445 * # -1 because matrix market indexes are 1-based => convert to 0-based
3446 */
3447 __pyx_t_13 = __pyx_cur_scope->__pyx_v_docid;
3448 __pyx_t_14 = __pyx_cur_scope->__pyx_v_termid;
3449 __pyx_cur_scope->__pyx_v_termid = __pyx_t_13;
3450 __pyx_cur_scope->__pyx_v_docid = __pyx_t_14;
3451
3452 /* "gensim/corpora/_mmreader.pyx":129
3453 * raise ValueError("unable to parse line: {}".format(line))
3454 *
3455 * if not self.transposed: # <<<<<<<<<<<<<<
3456 * termid, docid = docid, termid
3457 *
3458 */
3459 }
3460
3461 /* "gensim/corpora/_mmreader.pyx":133
3462 *
3463 * # -1 because matrix market indexes are 1-based => convert to 0-based
3464 * docid -= 1 # <<<<<<<<<<<<<<
3465 * termid -= 1
3466 *
3467 */
3468 __pyx_cur_scope->__pyx_v_docid = (__pyx_cur_scope->__pyx_v_docid - 1);
3469
3470 /* "gensim/corpora/_mmreader.pyx":134
3471 * # -1 because matrix market indexes are 1-based => convert to 0-based
3472 * docid -= 1
3473 * termid -= 1 # <<<<<<<<<<<<<<
3474 *
3475 * assert previd <= docid, "matrix columns must come in ascending order"
3476 */
3477 __pyx_cur_scope->__pyx_v_termid = (__pyx_cur_scope->__pyx_v_termid - 1);
3478
3479 /* "gensim/corpora/_mmreader.pyx":136
3480 * termid -= 1
3481 *
3482 * assert previd <= docid, "matrix columns must come in ascending order" # <<<<<<<<<<<<<<
3483 * if docid != previd:
3484 * # change of document: return the document read so far (its id is prevId)
3485 */
3486 #ifndef CYTHON_WITHOUT_ASSERTIONS
3487 if (unlikely(!Py_OptimizeFlag)) {
3488 if (unlikely(!((__pyx_cur_scope->__pyx_v_previd <= __pyx_cur_scope->__pyx_v_docid) != 0))) {
3489 PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_matrix_columns_must_come_in_asce);
3490 __PYX_ERR(0, 136, __pyx_L8_error)
3491 }
3492 }
3493 #endif
3494
3495 /* "gensim/corpora/_mmreader.pyx":137
3496 *
3497 * assert previd <= docid, "matrix columns must come in ascending order"
3498 * if docid != previd: # <<<<<<<<<<<<<<
3499 * # change of document: return the document read so far (its id is prevId)
3500 * if previd >= 0:
3501 */
3502 __pyx_t_12 = ((__pyx_cur_scope->__pyx_v_docid != __pyx_cur_scope->__pyx_v_previd) != 0);
3503 if (__pyx_t_12) {
3504
3505 /* "gensim/corpora/_mmreader.pyx":139
3506 * if docid != previd:
3507 * # change of document: return the document read so far (its id is prevId)
3508 * if previd >= 0: # <<<<<<<<<<<<<<
3509 * yield previd, document # noqa:F821
3510 *
3511 */
3512 __pyx_t_12 = ((__pyx_cur_scope->__pyx_v_previd >= 0) != 0);
3513 if (__pyx_t_12) {
3514
3515 /* "gensim/corpora/_mmreader.pyx":140
3516 * # change of document: return the document read so far (its id is prevId)
3517 * if previd >= 0:
3518 * yield previd, document # noqa:F821 # <<<<<<<<<<<<<<
3519 *
3520 * # return implicit (empty) documents between previous id and new id
3521 */
3522 __pyx_t_3 = __Pyx_PyInt_From_PY_LONG_LONG(__pyx_cur_scope->__pyx_v_previd); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 140, __pyx_L8_error)
3523 __Pyx_GOTREF(__pyx_t_3);
3524 if (unlikely(!__pyx_cur_scope->__pyx_v_document)) { __Pyx_RaiseUnboundLocalError("document"); __PYX_ERR(0, 140, __pyx_L8_error) }
3525 __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 140, __pyx_L8_error)
3526 __Pyx_GOTREF(__pyx_t_1);
3527 __Pyx_GIVEREF(__pyx_t_3);
3528 PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
3529 __Pyx_INCREF(__pyx_cur_scope->__pyx_v_document);
3530 __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_document);
3531 PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_cur_scope->__pyx_v_document);
3532 __pyx_t_3 = 0;
3533 __pyx_r = __pyx_t_1;
3534 __pyx_t_1 = 0;
3535 __Pyx_XGIVEREF(__pyx_t_2);
3536 __pyx_cur_scope->__pyx_t_0 = __pyx_t_2;
3537 __Pyx_XGIVEREF(__pyx_t_4);
3538 __pyx_cur_scope->__pyx_t_1 = __pyx_t_4;
3539 __Pyx_XGIVEREF(__pyx_t_6);
3540 __pyx_cur_scope->__pyx_t_2 = __pyx_t_6;
3541 __Pyx_XGIVEREF(__pyx_t_7);
3542 __pyx_cur_scope->__pyx_t_3 = __pyx_t_7;
3543 __Pyx_XGIVEREF(__pyx_t_8);
3544 __pyx_cur_scope->__pyx_t_4 = __pyx_t_8;
3545 __pyx_cur_scope->__pyx_t_5 = __pyx_t_9;
3546 __pyx_cur_scope->__pyx_t_6 = __pyx_t_10;
3547 __Pyx_XGIVEREF(__pyx_r);
3548 __Pyx_RefNannyFinishContext();
3549 __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
3550 /* return from generator, yielding value */
3551 __pyx_generator->resume_label = 1;
3552 return __pyx_r;
3553 __pyx_L20_resume_from_yield:;
3554 __pyx_t_2 = __pyx_cur_scope->__pyx_t_0;
3555 __pyx_cur_scope->__pyx_t_0 = 0;
3556 __Pyx_XGOTREF(__pyx_t_2);
3557 __pyx_t_4 = __pyx_cur_scope->__pyx_t_1;
3558 __pyx_cur_scope->__pyx_t_1 = 0;
3559 __Pyx_XGOTREF(__pyx_t_4);
3560 __pyx_t_6 = __pyx_cur_scope->__pyx_t_2;
3561 __pyx_cur_scope->__pyx_t_2 = 0;
3562 __Pyx_XGOTREF(__pyx_t_6);
3563 __pyx_t_7 = __pyx_cur_scope->__pyx_t_3;
3564 __pyx_cur_scope->__pyx_t_3 = 0;
3565 __Pyx_XGOTREF(__pyx_t_7);
3566 __pyx_t_8 = __pyx_cur_scope->__pyx_t_4;
3567 __pyx_cur_scope->__pyx_t_4 = 0;
3568 __Pyx_XGOTREF(__pyx_t_8);
3569 __pyx_t_9 = __pyx_cur_scope->__pyx_t_5;
3570 __pyx_t_10 = __pyx_cur_scope->__pyx_t_6;
3571 if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 140, __pyx_L8_error)
3572
3573 /* "gensim/corpora/_mmreader.pyx":139
3574 * if docid != previd:
3575 * # change of document: return the document read so far (its id is prevId)
3576 * if previd >= 0: # <<<<<<<<<<<<<<
3577 * yield previd, document # noqa:F821
3578 *
3579 */
3580 }
3581
3582 /* "gensim/corpora/_mmreader.pyx":144
3583 * # return implicit (empty) documents between previous id and new id
3584 * # too, to keep consistent document numbering and corpus length
3585 * for previd in range(previd + 1, docid): # <<<<<<<<<<<<<<
3586 * yield previd, []
3587 *
3588 */
3589 __pyx_t_14 = __pyx_cur_scope->__pyx_v_docid;
3590 __pyx_t_13 = __pyx_t_14;
3591 for (__pyx_t_15 = (__pyx_cur_scope->__pyx_v_previd + 1); __pyx_t_15 < __pyx_t_13; __pyx_t_15+=1) {
3592 __pyx_cur_scope->__pyx_v_previd = __pyx_t_15;
3593
3594 /* "gensim/corpora/_mmreader.pyx":145
3595 * # too, to keep consistent document numbering and corpus length
3596 * for previd in range(previd + 1, docid):
3597 * yield previd, [] # <<<<<<<<<<<<<<
3598 *
3599 * # from now on start adding fields to a new document, with a new id
3600 */
3601 __pyx_t_1 = __Pyx_PyInt_From_PY_LONG_LONG(__pyx_cur_scope->__pyx_v_previd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 145, __pyx_L8_error)
3602 __Pyx_GOTREF(__pyx_t_1);
3603 __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 145, __pyx_L8_error)
3604 __Pyx_GOTREF(__pyx_t_3);
3605 __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 145, __pyx_L8_error)
3606 __Pyx_GOTREF(__pyx_t_5);
3607 __Pyx_GIVEREF(__pyx_t_1);
3608 PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
3609 __Pyx_GIVEREF(__pyx_t_3);
3610 PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3);
3611 __pyx_t_1 = 0;
3612 __pyx_t_3 = 0;
3613 __pyx_r = __pyx_t_5;
3614 __pyx_t_5 = 0;
3615 __Pyx_XGIVEREF(__pyx_t_2);
3616 __pyx_cur_scope->__pyx_t_0 = __pyx_t_2;
3617 __Pyx_XGIVEREF(__pyx_t_4);
3618 __pyx_cur_scope->__pyx_t_1 = __pyx_t_4;
3619 __Pyx_XGIVEREF(__pyx_t_6);
3620 __pyx_cur_scope->__pyx_t_2 = __pyx_t_6;
3621 __Pyx_XGIVEREF(__pyx_t_7);
3622 __pyx_cur_scope->__pyx_t_3 = __pyx_t_7;
3623 __Pyx_XGIVEREF(__pyx_t_8);
3624 __pyx_cur_scope->__pyx_t_4 = __pyx_t_8;
3625 __pyx_cur_scope->__pyx_t_5 = __pyx_t_9;
3626 __pyx_cur_scope->__pyx_t_6 = __pyx_t_10;
3627 __pyx_cur_scope->__pyx_t_7 = __pyx_t_13;
3628 __pyx_cur_scope->__pyx_t_8 = __pyx_t_14;
3629 __pyx_cur_scope->__pyx_t_9 = __pyx_t_15;
3630 __Pyx_XGIVEREF(__pyx_r);
3631 __Pyx_RefNannyFinishContext();
3632 __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
3633 /* return from generator, yielding value */
3634 __pyx_generator->resume_label = 2;
3635 return __pyx_r;
3636 __pyx_L23_resume_from_yield:;
3637 __pyx_t_2 = __pyx_cur_scope->__pyx_t_0;
3638 __pyx_cur_scope->__pyx_t_0 = 0;
3639 __Pyx_XGOTREF(__pyx_t_2);
3640 __pyx_t_4 = __pyx_cur_scope->__pyx_t_1;
3641 __pyx_cur_scope->__pyx_t_1 = 0;
3642 __Pyx_XGOTREF(__pyx_t_4);
3643 __pyx_t_6 = __pyx_cur_scope->__pyx_t_2;
3644 __pyx_cur_scope->__pyx_t_2 = 0;
3645 __Pyx_XGOTREF(__pyx_t_6);
3646 __pyx_t_7 = __pyx_cur_scope->__pyx_t_3;
3647 __pyx_cur_scope->__pyx_t_3 = 0;
3648 __Pyx_XGOTREF(__pyx_t_7);
3649 __pyx_t_8 = __pyx_cur_scope->__pyx_t_4;
3650 __pyx_cur_scope->__pyx_t_4 = 0;
3651 __Pyx_XGOTREF(__pyx_t_8);
3652 __pyx_t_9 = __pyx_cur_scope->__pyx_t_5;
3653 __pyx_t_10 = __pyx_cur_scope->__pyx_t_6;
3654 __pyx_t_13 = __pyx_cur_scope->__pyx_t_7;
3655 __pyx_t_14 = __pyx_cur_scope->__pyx_t_8;
3656 __pyx_t_15 = __pyx_cur_scope->__pyx_t_9;
3657 if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 145, __pyx_L8_error)
3658 }
3659
3660 /* "gensim/corpora/_mmreader.pyx":148
3661 *
3662 * # from now on start adding fields to a new document, with a new id
3663 * previd = docid # <<<<<<<<<<<<<<
3664 * document = []
3665 *
3666 */
3667 __pyx_cur_scope->__pyx_v_previd = __pyx_cur_scope->__pyx_v_docid;
3668
3669 /* "gensim/corpora/_mmreader.pyx":149
3670 * # from now on start adding fields to a new document, with a new id
3671 * previd = docid
3672 * document = [] # <<<<<<<<<<<<<<
3673 *
3674 * document.append((termid, val,)) # add another field to the current document
3675 */
3676 __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 149, __pyx_L8_error)
3677 __Pyx_GOTREF(__pyx_t_5);
3678 __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_document);
3679 __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_document, ((PyObject*)__pyx_t_5));
3680 __Pyx_GIVEREF(__pyx_t_5);
3681 __pyx_t_5 = 0;
3682
3683 /* "gensim/corpora/_mmreader.pyx":137
3684 *
3685 * assert previd <= docid, "matrix columns must come in ascending order"
3686 * if docid != previd: # <<<<<<<<<<<<<<
3687 * # change of document: return the document read so far (its id is prevId)
3688 * if previd >= 0:
3689 */
3690 }
3691
3692 /* "gensim/corpora/_mmreader.pyx":151
3693 * document = []
3694 *
3695 * document.append((termid, val,)) # add another field to the current document # <<<<<<<<<<<<<<
3696 *
3697 * # handle the last document, as a special case
3698 */
3699 if (unlikely(!__pyx_cur_scope->__pyx_v_document)) { __Pyx_RaiseUnboundLocalError("document"); __PYX_ERR(0, 151, __pyx_L8_error) }
3700 __pyx_t_5 = __Pyx_PyInt_From_PY_LONG_LONG(__pyx_cur_scope->__pyx_v_termid); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 151, __pyx_L8_error)
3701 __Pyx_GOTREF(__pyx_t_5);
3702 __pyx_t_3 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_val); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 151, __pyx_L8_error)
3703 __Pyx_GOTREF(__pyx_t_3);
3704 __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 151, __pyx_L8_error)
3705 __Pyx_GOTREF(__pyx_t_1);
3706 __Pyx_GIVEREF(__pyx_t_5);
3707 PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5);
3708 __Pyx_GIVEREF(__pyx_t_3);
3709 PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3);
3710 __pyx_t_5 = 0;
3711 __pyx_t_3 = 0;
3712 __pyx_t_16 = __Pyx_PyList_Append(__pyx_cur_scope->__pyx_v_document, __pyx_t_1); if (unlikely(__pyx_t_16 == ((int)-1))) __PYX_ERR(0, 151, __pyx_L8_error)
3713 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3714
3715 /* "gensim/corpora/_mmreader.pyx":124
3716 *
3717 * previd = -1
3718 * for line in lines: # <<<<<<<<<<<<<<
3719 *
3720 * if (sscanf(line, "%lld %lld %lg", &docid, &termid, &val) != 3):
3721 */
3722 }
3723 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3724
3725 /* "gensim/corpora/_mmreader.pyx":120
3726 * cdef double val = 0
3727 *
3728 * with utils.file_or_filename(self.input) as lines: # <<<<<<<<<<<<<<
3729 * self.skip_headers(lines)
3730 *
3731 */
3732 }
3733 __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
3734 __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
3735 __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
3736 goto __pyx_L13_try_end;
3737 __pyx_L8_error:;
3738 __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
3739 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
3740 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
3741 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
3742 /*except:*/ {
3743 __Pyx_AddTraceback("gensim.corpora._mmreader.MmReader.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
3744 if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_3) < 0) __PYX_ERR(0, 120, __pyx_L10_except_error)
3745 __Pyx_GOTREF(__pyx_t_2);
3746 __Pyx_GOTREF(__pyx_t_1);
3747 __Pyx_GOTREF(__pyx_t_3);
3748 __pyx_t_5 = PyTuple_Pack(3, __pyx_t_2, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 120, __pyx_L10_except_error)
3749 __Pyx_GOTREF(__pyx_t_5);
3750 __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL);
3751 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3752 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
3753 if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 120, __pyx_L10_except_error)
3754 __Pyx_GOTREF(__pyx_t_17);
3755 __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_17);
3756 __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
3757 if (__pyx_t_12 < 0) __PYX_ERR(0, 120, __pyx_L10_except_error)
3758 __pyx_t_18 = ((!(__pyx_t_12 != 0)) != 0);
3759 if (__pyx_t_18) {
3760 __Pyx_GIVEREF(__pyx_t_2);
3761 __Pyx_GIVEREF(__pyx_t_1);
3762 __Pyx_XGIVEREF(__pyx_t_3);
3763 __Pyx_ErrRestoreWithState(__pyx_t_2, __pyx_t_1, __pyx_t_3);
3764 __pyx_t_2 = 0; __pyx_t_1 = 0; __pyx_t_3 = 0;
3765 __PYX_ERR(0, 120, __pyx_L10_except_error)
3766 }
3767 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
3768 __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
3769 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
3770 goto __pyx_L9_exception_handled;
3771 }
3772 __pyx_L10_except_error:;
3773 __Pyx_XGIVEREF(__pyx_t_6);
3774 __Pyx_XGIVEREF(__pyx_t_7);
3775 __Pyx_XGIVEREF(__pyx_t_8);
3776 __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
3777 goto __pyx_L1_error;
3778 __pyx_L9_exception_handled:;
3779 __Pyx_XGIVEREF(__pyx_t_6);
3780 __Pyx_XGIVEREF(__pyx_t_7);
3781 __Pyx_XGIVEREF(__pyx_t_8);
3782 __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
3783 __pyx_L13_try_end:;
3784 }
3785 }
3786 /*finally:*/ {
3787 /*normal exit:*/{
3788 if (__pyx_t_4) {
3789 __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__2, NULL);
3790 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3791 if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 120, __pyx_L1_error)
3792 __Pyx_GOTREF(__pyx_t_8);
3793 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
3794 }
3795 goto __pyx_L7;
3796 }
3797 __pyx_L7:;
3798 }
3799 goto __pyx_L27;
3800 __pyx_L4_error:;
3801 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3802 goto __pyx_L1_error;
3803 __pyx_L27:;
3804 }
3805
3806 /* "gensim/corpora/_mmreader.pyx":154
3807 *
3808 * # handle the last document, as a special case
3809 * if previd >= 0: # <<<<<<<<<<<<<<
3810 * yield previd, document
3811 *
3812 */
3813 __pyx_t_18 = ((__pyx_cur_scope->__pyx_v_previd >= 0) != 0);
3814 if (__pyx_t_18) {
3815
3816 /* "gensim/corpora/_mmreader.pyx":155
3817 * # handle the last document, as a special case
3818 * if previd >= 0:
3819 * yield previd, document # <<<<<<<<<<<<<<
3820 *
3821 * # return empty documents between the last explicit document and the number
3822 */
3823 __pyx_t_3 = __Pyx_PyInt_From_PY_LONG_LONG(__pyx_cur_scope->__pyx_v_previd); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 155, __pyx_L1_error)
3824 __Pyx_GOTREF(__pyx_t_3);
3825 if (unlikely(!__pyx_cur_scope->__pyx_v_document)) { __Pyx_RaiseUnboundLocalError("document"); __PYX_ERR(0, 155, __pyx_L1_error) }
3826 __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 155, __pyx_L1_error)
3827 __Pyx_GOTREF(__pyx_t_1);
3828 __Pyx_GIVEREF(__pyx_t_3);
3829 PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
3830 __Pyx_INCREF(__pyx_cur_scope->__pyx_v_document);
3831 __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_document);
3832 PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_cur_scope->__pyx_v_document);
3833 __pyx_t_3 = 0;
3834 __pyx_r = __pyx_t_1;
3835 __pyx_t_1 = 0;
3836 __Pyx_XGIVEREF(__pyx_r);
3837 __Pyx_RefNannyFinishContext();
3838 __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
3839 /* return from generator, yielding value */
3840 __pyx_generator->resume_label = 3;
3841 return __pyx_r;
3842 __pyx_L29_resume_from_yield:;
3843 if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 155, __pyx_L1_error)
3844
3845 /* "gensim/corpora/_mmreader.pyx":154
3846 *
3847 * # handle the last document, as a special case
3848 * if previd >= 0: # <<<<<<<<<<<<<<
3849 * yield previd, document
3850 *
3851 */
3852 }
3853
3854 /* "gensim/corpora/_mmreader.pyx":159
3855 * # return empty documents between the last explicit document and the number
3856 * # of documents as specified in the header
3857 * for previd in range(previd + 1, self.num_docs): # <<<<<<<<<<<<<<
3858 * yield previd, []
3859 *
3860 */
3861 __pyx_t_14 = __pyx_cur_scope->__pyx_v_self->num_docs;
3862 __pyx_t_13 = __pyx_t_14;
3863 for (__pyx_t_15 = (__pyx_cur_scope->__pyx_v_previd + 1); __pyx_t_15 < __pyx_t_13; __pyx_t_15+=1) {
3864 __pyx_cur_scope->__pyx_v_previd = __pyx_t_15;
3865
3866 /* "gensim/corpora/_mmreader.pyx":160
3867 * # of documents as specified in the header
3868 * for previd in range(previd + 1, self.num_docs):
3869 * yield previd, [] # <<<<<<<<<<<<<<
3870 *
3871 * def docbyoffset(self, offset):
3872 */
3873 __pyx_t_1 = __Pyx_PyInt_From_PY_LONG_LONG(__pyx_cur_scope->__pyx_v_previd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 160, __pyx_L1_error)
3874 __Pyx_GOTREF(__pyx_t_1);
3875 __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 160, __pyx_L1_error)
3876 __Pyx_GOTREF(__pyx_t_3);
3877 __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 160, __pyx_L1_error)
3878 __Pyx_GOTREF(__pyx_t_2);
3879 __Pyx_GIVEREF(__pyx_t_1);
3880 PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
3881 __Pyx_GIVEREF(__pyx_t_3);
3882 PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3);
3883 __pyx_t_1 = 0;
3884 __pyx_t_3 = 0;
3885 __pyx_r = __pyx_t_2;
3886 __pyx_t_2 = 0;
3887 __pyx_cur_scope->__pyx_t_7 = __pyx_t_13;
3888 __pyx_cur_scope->__pyx_t_8 = __pyx_t_14;
3889 __pyx_cur_scope->__pyx_t_9 = __pyx_t_15;
3890 __Pyx_XGIVEREF(__pyx_r);
3891 __Pyx_RefNannyFinishContext();
3892 __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
3893 /* return from generator, yielding value */
3894 __pyx_generator->resume_label = 4;
3895 return __pyx_r;
3896 __pyx_L32_resume_from_yield:;
3897 __pyx_t_13 = __pyx_cur_scope->__pyx_t_7;
3898 __pyx_t_14 = __pyx_cur_scope->__pyx_t_8;
3899 __pyx_t_15 = __pyx_cur_scope->__pyx_t_9;
3900 if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 160, __pyx_L1_error)
3901 }
3902 CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);
3903
3904 /* "gensim/corpora/_mmreader.pyx":102
3905 * break
3906 *
3907 * def __iter__(self): # <<<<<<<<<<<<<<
3908 * """Iterate through all documents in the corpus.
3909 *
3910 */
3911
3912 /* function exit code */
3913 PyErr_SetNone(PyExc_StopIteration);
3914 goto __pyx_L0;
3915 __pyx_L1_error:;
3916 __Pyx_XDECREF(__pyx_t_1);
3917 __Pyx_XDECREF(__pyx_t_2);
3918 __Pyx_XDECREF(__pyx_t_3);
3919 __Pyx_XDECREF(__pyx_t_5);
3920 __Pyx_AddTraceback("__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
3921 __pyx_L0:;
3922 __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
3923 #if !CYTHON_USE_EXC_INFO_STACK
3924 __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
3925 #endif
3926 __pyx_generator->resume_label = -1;
3927 __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
3928 __Pyx_RefNannyFinishContext();
3929 return __pyx_r;
3930 }
3931
3932 /* "gensim/corpora/_mmreader.pyx":162
3933 * yield previd, []
3934 *
3935 * def docbyoffset(self, offset): # <<<<<<<<<<<<<<
3936 * """Get the document at file offset `offset` (in bytes).
3937 *
3938 */
3939
3940 /* Python wrapper */
3941 static PyObject *__pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_12docbyoffset(PyObject *__pyx_v_self, PyObject *__pyx_v_offset); /*proto*/
3942 static char __pyx_doc_6gensim_7corpora_9_mmreader_8MmReader_11docbyoffset[] = "MmReader.docbyoffset(self, offset)\nGet the document at file offset `offset` (in bytes).\n\n Parameters\n ----------\n offset : int\n File offset, in bytes, of the desired document.\n\n Returns\n ------\n list of (int, str)\n Document in sparse bag-of-words format.\n\n ";
__pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_12docbyoffset(PyObject * __pyx_v_self,PyObject * __pyx_v_offset)3943 static PyObject *__pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_12docbyoffset(PyObject *__pyx_v_self, PyObject *__pyx_v_offset) {
3944 PyObject *__pyx_r = 0;
3945 __Pyx_RefNannyDeclarations
3946 __Pyx_RefNannySetupContext("docbyoffset (wrapper)", 0);
3947 __pyx_r = __pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_11docbyoffset(((struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *)__pyx_v_self), ((PyObject *)__pyx_v_offset));
3948
3949 /* function exit code */
3950 __Pyx_RefNannyFinishContext();
3951 return __pyx_r;
3952 }
3953
__pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_11docbyoffset(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader * __pyx_v_self,PyObject * __pyx_v_offset)3954 static PyObject *__pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_11docbyoffset(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *__pyx_v_self, PyObject *__pyx_v_offset) {
3955 PY_LONG_LONG __pyx_v_docid;
3956 PY_LONG_LONG __pyx_v_termid;
3957 PY_LONG_LONG __pyx_v_previd;
3958 double __pyx_v_val;
3959 PyObject *__pyx_v_fin = NULL;
3960 int __pyx_v_close_fin;
3961 PyObject *__pyx_v_document = NULL;
3962 PyObject *__pyx_v_line = NULL;
3963 PyObject *__pyx_r = NULL;
3964 __Pyx_RefNannyDeclarations
3965 PyObject *__pyx_t_1 = NULL;
3966 int __pyx_t_2;
3967 int __pyx_t_3;
3968 PyObject *__pyx_t_4 = NULL;
3969 PyObject *__pyx_t_5 = NULL;
3970 int __pyx_t_6;
3971 PyObject *__pyx_t_7 = NULL;
3972 PY_LONG_LONG __pyx_t_8;
3973 Py_ssize_t __pyx_t_9;
3974 PyObject *(*__pyx_t_10)(PyObject *);
3975 char const *__pyx_t_11;
3976 PY_LONG_LONG __pyx_t_12;
3977 int __pyx_t_13;
3978 int __pyx_lineno = 0;
3979 const char *__pyx_filename = NULL;
3980 int __pyx_clineno = 0;
3981 __Pyx_RefNannySetupContext("docbyoffset", 0);
3982
3983 /* "gensim/corpora/_mmreader.pyx":181
3984 * cdef double val
3985 *
3986 * if offset == -1: # <<<<<<<<<<<<<<
3987 * return []
3988 * if isinstance(self.input, str):
3989 */
3990 __pyx_t_1 = __Pyx_PyInt_EqObjC(__pyx_v_offset, __pyx_int_neg_1, -1L, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 181, __pyx_L1_error)
3991 __Pyx_GOTREF(__pyx_t_1);
3992 __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 181, __pyx_L1_error)
3993 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3994 if (__pyx_t_2) {
3995
3996 /* "gensim/corpora/_mmreader.pyx":182
3997 *
3998 * if offset == -1:
3999 * return [] # <<<<<<<<<<<<<<
4000 * if isinstance(self.input, str):
4001 * fin, close_fin = utils.open(self.input, 'rb'), True
4002 */
4003 __Pyx_XDECREF(__pyx_r);
4004 __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 182, __pyx_L1_error)
4005 __Pyx_GOTREF(__pyx_t_1);
4006 __pyx_r = __pyx_t_1;
4007 __pyx_t_1 = 0;
4008 goto __pyx_L0;
4009
4010 /* "gensim/corpora/_mmreader.pyx":181
4011 * cdef double val
4012 *
4013 * if offset == -1: # <<<<<<<<<<<<<<
4014 * return []
4015 * if isinstance(self.input, str):
4016 */
4017 }
4018
4019 /* "gensim/corpora/_mmreader.pyx":183
4020 * if offset == -1:
4021 * return []
4022 * if isinstance(self.input, str): # <<<<<<<<<<<<<<
4023 * fin, close_fin = utils.open(self.input, 'rb'), True
4024 * else:
4025 */
4026 __pyx_t_1 = __pyx_v_self->input;
4027 __Pyx_INCREF(__pyx_t_1);
4028 __pyx_t_2 = PyString_Check(__pyx_t_1);
4029 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4030 __pyx_t_3 = (__pyx_t_2 != 0);
4031 if (__pyx_t_3) {
4032
4033 /* "gensim/corpora/_mmreader.pyx":184
4034 * return []
4035 * if isinstance(self.input, str):
4036 * fin, close_fin = utils.open(self.input, 'rb'), True # <<<<<<<<<<<<<<
4037 * else:
4038 * fin, close_fin = self.input, False
4039 */
4040 __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_utils); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 184, __pyx_L1_error)
4041 __Pyx_GOTREF(__pyx_t_4);
4042 __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_open); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 184, __pyx_L1_error)
4043 __Pyx_GOTREF(__pyx_t_5);
4044 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
4045 __pyx_t_4 = NULL;
4046 __pyx_t_6 = 0;
4047 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
4048 __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
4049 if (likely(__pyx_t_4)) {
4050 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
4051 __Pyx_INCREF(__pyx_t_4);
4052 __Pyx_INCREF(function);
4053 __Pyx_DECREF_SET(__pyx_t_5, function);
4054 __pyx_t_6 = 1;
4055 }
4056 }
4057 #if CYTHON_FAST_PYCALL
4058 if (PyFunction_Check(__pyx_t_5)) {
4059 PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_self->input, __pyx_n_s_rb};
4060 __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 184, __pyx_L1_error)
4061 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
4062 __Pyx_GOTREF(__pyx_t_1);
4063 } else
4064 #endif
4065 #if CYTHON_FAST_PYCCALL
4066 if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
4067 PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_self->input, __pyx_n_s_rb};
4068 __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 184, __pyx_L1_error)
4069 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
4070 __Pyx_GOTREF(__pyx_t_1);
4071 } else
4072 #endif
4073 {
4074 __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 184, __pyx_L1_error)
4075 __Pyx_GOTREF(__pyx_t_7);
4076 if (__pyx_t_4) {
4077 __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4); __pyx_t_4 = NULL;
4078 }
4079 __Pyx_INCREF(__pyx_v_self->input);
4080 __Pyx_GIVEREF(__pyx_v_self->input);
4081 PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_v_self->input);
4082 __Pyx_INCREF(__pyx_n_s_rb);
4083 __Pyx_GIVEREF(__pyx_n_s_rb);
4084 PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_n_s_rb);
4085 __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 184, __pyx_L1_error)
4086 __Pyx_GOTREF(__pyx_t_1);
4087 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
4088 }
4089 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
4090 __pyx_t_3 = 1;
4091 __pyx_v_fin = __pyx_t_1;
4092 __pyx_t_1 = 0;
4093 __pyx_v_close_fin = __pyx_t_3;
4094
4095 /* "gensim/corpora/_mmreader.pyx":183
4096 * if offset == -1:
4097 * return []
4098 * if isinstance(self.input, str): # <<<<<<<<<<<<<<
4099 * fin, close_fin = utils.open(self.input, 'rb'), True
4100 * else:
4101 */
4102 goto __pyx_L4;
4103 }
4104
4105 /* "gensim/corpora/_mmreader.pyx":186
4106 * fin, close_fin = utils.open(self.input, 'rb'), True
4107 * else:
4108 * fin, close_fin = self.input, False # <<<<<<<<<<<<<<
4109 *
4110 * fin.seek(offset) # works for gzip/bz2 input, too
4111 */
4112 /*else*/ {
4113 __pyx_t_1 = __pyx_v_self->input;
4114 __Pyx_INCREF(__pyx_t_1);
4115 __pyx_t_3 = 0;
4116 __pyx_v_fin = __pyx_t_1;
4117 __pyx_t_1 = 0;
4118 __pyx_v_close_fin = __pyx_t_3;
4119 }
4120 __pyx_L4:;
4121
4122 /* "gensim/corpora/_mmreader.pyx":188
4123 * fin, close_fin = self.input, False
4124 *
4125 * fin.seek(offset) # works for gzip/bz2 input, too # <<<<<<<<<<<<<<
4126 * previd, document = -1, []
4127 * for line in fin:
4128 */
4129 __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_fin, __pyx_n_s_seek); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 188, __pyx_L1_error)
4130 __Pyx_GOTREF(__pyx_t_5);
4131 __pyx_t_7 = NULL;
4132 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
4133 __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
4134 if (likely(__pyx_t_7)) {
4135 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
4136 __Pyx_INCREF(__pyx_t_7);
4137 __Pyx_INCREF(function);
4138 __Pyx_DECREF_SET(__pyx_t_5, function);
4139 }
4140 }
4141 __pyx_t_1 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_7, __pyx_v_offset) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_offset);
4142 __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
4143 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 188, __pyx_L1_error)
4144 __Pyx_GOTREF(__pyx_t_1);
4145 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
4146 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4147
4148 /* "gensim/corpora/_mmreader.pyx":189
4149 *
4150 * fin.seek(offset) # works for gzip/bz2 input, too
4151 * previd, document = -1, [] # <<<<<<<<<<<<<<
4152 * for line in fin:
4153 * if (sscanf(line, "%lld %lld %lg", &docid, &termid, &val) != 3):
4154 */
4155 __pyx_t_8 = -1LL;
4156 __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 189, __pyx_L1_error)
4157 __Pyx_GOTREF(__pyx_t_1);
4158 __pyx_v_previd = __pyx_t_8;
4159 __pyx_v_document = ((PyObject*)__pyx_t_1);
4160 __pyx_t_1 = 0;
4161
4162 /* "gensim/corpora/_mmreader.pyx":190
4163 * fin.seek(offset) # works for gzip/bz2 input, too
4164 * previd, document = -1, []
4165 * for line in fin: # <<<<<<<<<<<<<<
4166 * if (sscanf(line, "%lld %lld %lg", &docid, &termid, &val) != 3):
4167 * raise ValueError("unable to parse line: {}".format(line))
4168 */
4169 if (likely(PyList_CheckExact(__pyx_v_fin)) || PyTuple_CheckExact(__pyx_v_fin)) {
4170 __pyx_t_1 = __pyx_v_fin; __Pyx_INCREF(__pyx_t_1); __pyx_t_9 = 0;
4171 __pyx_t_10 = NULL;
4172 } else {
4173 __pyx_t_9 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_fin); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 190, __pyx_L1_error)
4174 __Pyx_GOTREF(__pyx_t_1);
4175 __pyx_t_10 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 190, __pyx_L1_error)
4176 }
4177 for (;;) {
4178 if (likely(!__pyx_t_10)) {
4179 if (likely(PyList_CheckExact(__pyx_t_1))) {
4180 if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_1)) break;
4181 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
4182 __pyx_t_5 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_9); __Pyx_INCREF(__pyx_t_5); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 190, __pyx_L1_error)
4183 #else
4184 __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 190, __pyx_L1_error)
4185 __Pyx_GOTREF(__pyx_t_5);
4186 #endif
4187 } else {
4188 if (__pyx_t_9 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
4189 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
4190 __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_9); __Pyx_INCREF(__pyx_t_5); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 190, __pyx_L1_error)
4191 #else
4192 __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 190, __pyx_L1_error)
4193 __Pyx_GOTREF(__pyx_t_5);
4194 #endif
4195 }
4196 } else {
4197 __pyx_t_5 = __pyx_t_10(__pyx_t_1);
4198 if (unlikely(!__pyx_t_5)) {
4199 PyObject* exc_type = PyErr_Occurred();
4200 if (exc_type) {
4201 if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
4202 else __PYX_ERR(0, 190, __pyx_L1_error)
4203 }
4204 break;
4205 }
4206 __Pyx_GOTREF(__pyx_t_5);
4207 }
4208 __Pyx_XDECREF_SET(__pyx_v_line, __pyx_t_5);
4209 __pyx_t_5 = 0;
4210
4211 /* "gensim/corpora/_mmreader.pyx":191
4212 * previd, document = -1, []
4213 * for line in fin:
4214 * if (sscanf(line, "%lld %lld %lg", &docid, &termid, &val) != 3): # <<<<<<<<<<<<<<
4215 * raise ValueError("unable to parse line: {}".format(line))
4216 *
4217 */
4218 __pyx_t_11 = __Pyx_PyObject_AsString(__pyx_v_line); if (unlikely((!__pyx_t_11) && PyErr_Occurred())) __PYX_ERR(0, 191, __pyx_L1_error)
4219 __pyx_t_3 = ((sscanf(__pyx_t_11, ((char const *)"%lld %lld %lg"), (&__pyx_v_docid), (&__pyx_v_termid), (&__pyx_v_val)) != 3) != 0);
4220 if (unlikely(__pyx_t_3)) {
4221
4222 /* "gensim/corpora/_mmreader.pyx":192
4223 * for line in fin:
4224 * if (sscanf(line, "%lld %lld %lg", &docid, &termid, &val) != 3):
4225 * raise ValueError("unable to parse line: {}".format(line)) # <<<<<<<<<<<<<<
4226 *
4227 * if not self.transposed:
4228 */
4229 __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_unable_to_parse_line, __pyx_n_s_format); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 192, __pyx_L1_error)
4230 __Pyx_GOTREF(__pyx_t_7);
4231 __pyx_t_4 = NULL;
4232 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
4233 __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_7);
4234 if (likely(__pyx_t_4)) {
4235 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
4236 __Pyx_INCREF(__pyx_t_4);
4237 __Pyx_INCREF(function);
4238 __Pyx_DECREF_SET(__pyx_t_7, function);
4239 }
4240 }
4241 __pyx_t_5 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_4, __pyx_v_line) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_v_line);
4242 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
4243 if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 192, __pyx_L1_error)
4244 __Pyx_GOTREF(__pyx_t_5);
4245 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
4246 __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 192, __pyx_L1_error)
4247 __Pyx_GOTREF(__pyx_t_7);
4248 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
4249 __Pyx_Raise(__pyx_t_7, 0, 0, 0);
4250 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
4251 __PYX_ERR(0, 192, __pyx_L1_error)
4252
4253 /* "gensim/corpora/_mmreader.pyx":191
4254 * previd, document = -1, []
4255 * for line in fin:
4256 * if (sscanf(line, "%lld %lld %lg", &docid, &termid, &val) != 3): # <<<<<<<<<<<<<<
4257 * raise ValueError("unable to parse line: {}".format(line))
4258 *
4259 */
4260 }
4261
4262 /* "gensim/corpora/_mmreader.pyx":194
4263 * raise ValueError("unable to parse line: {}".format(line))
4264 *
4265 * if not self.transposed: # <<<<<<<<<<<<<<
4266 * termid, docid = docid, termid
4267 *
4268 */
4269 __pyx_t_3 = ((!(__pyx_v_self->transposed != 0)) != 0);
4270 if (__pyx_t_3) {
4271
4272 /* "gensim/corpora/_mmreader.pyx":195
4273 *
4274 * if not self.transposed:
4275 * termid, docid = docid, termid # <<<<<<<<<<<<<<
4276 *
4277 * # -1 because matrix market indexes are 1-based => convert to 0-based
4278 */
4279 __pyx_t_8 = __pyx_v_docid;
4280 __pyx_t_12 = __pyx_v_termid;
4281 __pyx_v_termid = __pyx_t_8;
4282 __pyx_v_docid = __pyx_t_12;
4283
4284 /* "gensim/corpora/_mmreader.pyx":194
4285 * raise ValueError("unable to parse line: {}".format(line))
4286 *
4287 * if not self.transposed: # <<<<<<<<<<<<<<
4288 * termid, docid = docid, termid
4289 *
4290 */
4291 }
4292
4293 /* "gensim/corpora/_mmreader.pyx":198
4294 *
4295 * # -1 because matrix market indexes are 1-based => convert to 0-based
4296 * docid -= 1 # <<<<<<<<<<<<<<
4297 * termid -= 1
4298 *
4299 */
4300 __pyx_v_docid = (__pyx_v_docid - 1);
4301
4302 /* "gensim/corpora/_mmreader.pyx":199
4303 * # -1 because matrix market indexes are 1-based => convert to 0-based
4304 * docid -= 1
4305 * termid -= 1 # <<<<<<<<<<<<<<
4306 *
4307 * assert previd <= docid, "matrix columns must come in ascending order"
4308 */
4309 __pyx_v_termid = (__pyx_v_termid - 1);
4310
4311 /* "gensim/corpora/_mmreader.pyx":201
4312 * termid -= 1
4313 *
4314 * assert previd <= docid, "matrix columns must come in ascending order" # <<<<<<<<<<<<<<
4315 * if docid != previd:
4316 * if previd >= 0:
4317 */
4318 #ifndef CYTHON_WITHOUT_ASSERTIONS
4319 if (unlikely(!Py_OptimizeFlag)) {
4320 if (unlikely(!((__pyx_v_previd <= __pyx_v_docid) != 0))) {
4321 PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_matrix_columns_must_come_in_asce);
4322 __PYX_ERR(0, 201, __pyx_L1_error)
4323 }
4324 }
4325 #endif
4326
4327 /* "gensim/corpora/_mmreader.pyx":202
4328 *
4329 * assert previd <= docid, "matrix columns must come in ascending order"
4330 * if docid != previd: # <<<<<<<<<<<<<<
4331 * if previd >= 0:
4332 * break
4333 */
4334 __pyx_t_3 = ((__pyx_v_docid != __pyx_v_previd) != 0);
4335 if (__pyx_t_3) {
4336
4337 /* "gensim/corpora/_mmreader.pyx":203
4338 * assert previd <= docid, "matrix columns must come in ascending order"
4339 * if docid != previd:
4340 * if previd >= 0: # <<<<<<<<<<<<<<
4341 * break
4342 * previd = docid
4343 */
4344 __pyx_t_3 = ((__pyx_v_previd >= 0) != 0);
4345 if (__pyx_t_3) {
4346
4347 /* "gensim/corpora/_mmreader.pyx":204
4348 * if docid != previd:
4349 * if previd >= 0:
4350 * break # <<<<<<<<<<<<<<
4351 * previd = docid
4352 *
4353 */
4354 goto __pyx_L6_break;
4355
4356 /* "gensim/corpora/_mmreader.pyx":203
4357 * assert previd <= docid, "matrix columns must come in ascending order"
4358 * if docid != previd:
4359 * if previd >= 0: # <<<<<<<<<<<<<<
4360 * break
4361 * previd = docid
4362 */
4363 }
4364
4365 /* "gensim/corpora/_mmreader.pyx":205
4366 * if previd >= 0:
4367 * break
4368 * previd = docid # <<<<<<<<<<<<<<
4369 *
4370 * document.append((termid, val,)) # add another field to the current document
4371 */
4372 __pyx_v_previd = __pyx_v_docid;
4373
4374 /* "gensim/corpora/_mmreader.pyx":202
4375 *
4376 * assert previd <= docid, "matrix columns must come in ascending order"
4377 * if docid != previd: # <<<<<<<<<<<<<<
4378 * if previd >= 0:
4379 * break
4380 */
4381 }
4382
4383 /* "gensim/corpora/_mmreader.pyx":207
4384 * previd = docid
4385 *
4386 * document.append((termid, val,)) # add another field to the current document # <<<<<<<<<<<<<<
4387 *
4388 * if close_fin:
4389 */
4390 __pyx_t_7 = __Pyx_PyInt_From_PY_LONG_LONG(__pyx_v_termid); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 207, __pyx_L1_error)
4391 __Pyx_GOTREF(__pyx_t_7);
4392 __pyx_t_5 = PyFloat_FromDouble(__pyx_v_val); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 207, __pyx_L1_error)
4393 __Pyx_GOTREF(__pyx_t_5);
4394 __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 207, __pyx_L1_error)
4395 __Pyx_GOTREF(__pyx_t_4);
4396 __Pyx_GIVEREF(__pyx_t_7);
4397 PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_7);
4398 __Pyx_GIVEREF(__pyx_t_5);
4399 PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_5);
4400 __pyx_t_7 = 0;
4401 __pyx_t_5 = 0;
4402 __pyx_t_13 = __Pyx_PyList_Append(__pyx_v_document, __pyx_t_4); if (unlikely(__pyx_t_13 == ((int)-1))) __PYX_ERR(0, 207, __pyx_L1_error)
4403 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
4404
4405 /* "gensim/corpora/_mmreader.pyx":190
4406 * fin.seek(offset) # works for gzip/bz2 input, too
4407 * previd, document = -1, []
4408 * for line in fin: # <<<<<<<<<<<<<<
4409 * if (sscanf(line, "%lld %lld %lg", &docid, &termid, &val) != 3):
4410 * raise ValueError("unable to parse line: {}".format(line))
4411 */
4412 }
4413 __pyx_L6_break:;
4414 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4415
4416 /* "gensim/corpora/_mmreader.pyx":209
4417 * document.append((termid, val,)) # add another field to the current document
4418 *
4419 * if close_fin: # <<<<<<<<<<<<<<
4420 * fin.close()
4421 * return document
4422 */
4423 __pyx_t_3 = (__pyx_v_close_fin != 0);
4424 if (__pyx_t_3) {
4425
4426 /* "gensim/corpora/_mmreader.pyx":210
4427 *
4428 * if close_fin:
4429 * fin.close() # <<<<<<<<<<<<<<
4430 * return document
4431 */
4432 __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_fin, __pyx_n_s_close); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 210, __pyx_L1_error)
4433 __Pyx_GOTREF(__pyx_t_4);
4434 __pyx_t_5 = NULL;
4435 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
4436 __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
4437 if (likely(__pyx_t_5)) {
4438 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
4439 __Pyx_INCREF(__pyx_t_5);
4440 __Pyx_INCREF(function);
4441 __Pyx_DECREF_SET(__pyx_t_4, function);
4442 }
4443 }
4444 __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
4445 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
4446 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 210, __pyx_L1_error)
4447 __Pyx_GOTREF(__pyx_t_1);
4448 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
4449 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4450
4451 /* "gensim/corpora/_mmreader.pyx":209
4452 * document.append((termid, val,)) # add another field to the current document
4453 *
4454 * if close_fin: # <<<<<<<<<<<<<<
4455 * fin.close()
4456 * return document
4457 */
4458 }
4459
4460 /* "gensim/corpora/_mmreader.pyx":211
4461 * if close_fin:
4462 * fin.close()
4463 * return document # <<<<<<<<<<<<<<
4464 */
4465 __Pyx_XDECREF(__pyx_r);
4466 __Pyx_INCREF(__pyx_v_document);
4467 __pyx_r = __pyx_v_document;
4468 goto __pyx_L0;
4469
4470 /* "gensim/corpora/_mmreader.pyx":162
4471 * yield previd, []
4472 *
4473 * def docbyoffset(self, offset): # <<<<<<<<<<<<<<
4474 * """Get the document at file offset `offset` (in bytes).
4475 *
4476 */
4477
4478 /* function exit code */
4479 __pyx_L1_error:;
4480 __Pyx_XDECREF(__pyx_t_1);
4481 __Pyx_XDECREF(__pyx_t_4);
4482 __Pyx_XDECREF(__pyx_t_5);
4483 __Pyx_XDECREF(__pyx_t_7);
4484 __Pyx_AddTraceback("gensim.corpora._mmreader.MmReader.docbyoffset", __pyx_clineno, __pyx_lineno, __pyx_filename);
4485 __pyx_r = NULL;
4486 __pyx_L0:;
4487 __Pyx_XDECREF(__pyx_v_fin);
4488 __Pyx_XDECREF(__pyx_v_document);
4489 __Pyx_XDECREF(__pyx_v_line);
4490 __Pyx_XGIVEREF(__pyx_r);
4491 __Pyx_RefNannyFinishContext();
4492 return __pyx_r;
4493 }
4494
4495 /* "gensim/corpora/_mmreader.pyx":36
4496 * # Number of non-zero terms.
4497 * #
4498 * cdef public input # <<<<<<<<<<<<<<
4499 * cdef public bint transposed
4500 * cdef public long long num_docs, num_terms, num_nnz
4501 */
4502
4503 /* Python wrapper */
4504 static PyObject *__pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_5input_1__get__(PyObject *__pyx_v_self); /*proto*/
__pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_5input_1__get__(PyObject * __pyx_v_self)4505 static PyObject *__pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_5input_1__get__(PyObject *__pyx_v_self) {
4506 PyObject *__pyx_r = 0;
4507 __Pyx_RefNannyDeclarations
4508 __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
4509 __pyx_r = __pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_5input___get__(((struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *)__pyx_v_self));
4510
4511 /* function exit code */
4512 __Pyx_RefNannyFinishContext();
4513 return __pyx_r;
4514 }
4515
__pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_5input___get__(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader * __pyx_v_self)4516 static PyObject *__pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_5input___get__(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *__pyx_v_self) {
4517 PyObject *__pyx_r = NULL;
4518 __Pyx_RefNannyDeclarations
4519 __Pyx_RefNannySetupContext("__get__", 0);
4520 __Pyx_XDECREF(__pyx_r);
4521 __Pyx_INCREF(__pyx_v_self->input);
4522 __pyx_r = __pyx_v_self->input;
4523 goto __pyx_L0;
4524
4525 /* function exit code */
4526 __pyx_L0:;
4527 __Pyx_XGIVEREF(__pyx_r);
4528 __Pyx_RefNannyFinishContext();
4529 return __pyx_r;
4530 }
4531
4532 /* Python wrapper */
4533 static int __pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_5input_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
__pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_5input_3__set__(PyObject * __pyx_v_self,PyObject * __pyx_v_value)4534 static int __pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_5input_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
4535 int __pyx_r;
4536 __Pyx_RefNannyDeclarations
4537 __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
4538 __pyx_r = __pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_5input_2__set__(((struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *)__pyx_v_self), ((PyObject *)__pyx_v_value));
4539
4540 /* function exit code */
4541 __Pyx_RefNannyFinishContext();
4542 return __pyx_r;
4543 }
4544
__pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_5input_2__set__(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader * __pyx_v_self,PyObject * __pyx_v_value)4545 static int __pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_5input_2__set__(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *__pyx_v_self, PyObject *__pyx_v_value) {
4546 int __pyx_r;
4547 __Pyx_RefNannyDeclarations
4548 __Pyx_RefNannySetupContext("__set__", 0);
4549 __Pyx_INCREF(__pyx_v_value);
4550 __Pyx_GIVEREF(__pyx_v_value);
4551 __Pyx_GOTREF(__pyx_v_self->input);
4552 __Pyx_DECREF(__pyx_v_self->input);
4553 __pyx_v_self->input = __pyx_v_value;
4554
4555 /* function exit code */
4556 __pyx_r = 0;
4557 __Pyx_RefNannyFinishContext();
4558 return __pyx_r;
4559 }
4560
4561 /* Python wrapper */
4562 static int __pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_5input_5__del__(PyObject *__pyx_v_self); /*proto*/
__pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_5input_5__del__(PyObject * __pyx_v_self)4563 static int __pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_5input_5__del__(PyObject *__pyx_v_self) {
4564 int __pyx_r;
4565 __Pyx_RefNannyDeclarations
4566 __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
4567 __pyx_r = __pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_5input_4__del__(((struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *)__pyx_v_self));
4568
4569 /* function exit code */
4570 __Pyx_RefNannyFinishContext();
4571 return __pyx_r;
4572 }
4573
__pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_5input_4__del__(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader * __pyx_v_self)4574 static int __pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_5input_4__del__(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *__pyx_v_self) {
4575 int __pyx_r;
4576 __Pyx_RefNannyDeclarations
4577 __Pyx_RefNannySetupContext("__del__", 0);
4578 __Pyx_INCREF(Py_None);
4579 __Pyx_GIVEREF(Py_None);
4580 __Pyx_GOTREF(__pyx_v_self->input);
4581 __Pyx_DECREF(__pyx_v_self->input);
4582 __pyx_v_self->input = Py_None;
4583
4584 /* function exit code */
4585 __pyx_r = 0;
4586 __Pyx_RefNannyFinishContext();
4587 return __pyx_r;
4588 }
4589
4590 /* "gensim/corpora/_mmreader.pyx":37
4591 * #
4592 * cdef public input
4593 * cdef public bint transposed # <<<<<<<<<<<<<<
4594 * cdef public long long num_docs, num_terms, num_nnz
4595 *
4596 */
4597
4598 /* Python wrapper */
4599 static PyObject *__pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_10transposed_1__get__(PyObject *__pyx_v_self); /*proto*/
__pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_10transposed_1__get__(PyObject * __pyx_v_self)4600 static PyObject *__pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_10transposed_1__get__(PyObject *__pyx_v_self) {
4601 PyObject *__pyx_r = 0;
4602 __Pyx_RefNannyDeclarations
4603 __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
4604 __pyx_r = __pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_10transposed___get__(((struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *)__pyx_v_self));
4605
4606 /* function exit code */
4607 __Pyx_RefNannyFinishContext();
4608 return __pyx_r;
4609 }
4610
__pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_10transposed___get__(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader * __pyx_v_self)4611 static PyObject *__pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_10transposed___get__(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *__pyx_v_self) {
4612 PyObject *__pyx_r = NULL;
4613 __Pyx_RefNannyDeclarations
4614 PyObject *__pyx_t_1 = NULL;
4615 int __pyx_lineno = 0;
4616 const char *__pyx_filename = NULL;
4617 int __pyx_clineno = 0;
4618 __Pyx_RefNannySetupContext("__get__", 0);
4619 __Pyx_XDECREF(__pyx_r);
4620 __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->transposed); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 37, __pyx_L1_error)
4621 __Pyx_GOTREF(__pyx_t_1);
4622 __pyx_r = __pyx_t_1;
4623 __pyx_t_1 = 0;
4624 goto __pyx_L0;
4625
4626 /* function exit code */
4627 __pyx_L1_error:;
4628 __Pyx_XDECREF(__pyx_t_1);
4629 __Pyx_AddTraceback("gensim.corpora._mmreader.MmReader.transposed.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
4630 __pyx_r = NULL;
4631 __pyx_L0:;
4632 __Pyx_XGIVEREF(__pyx_r);
4633 __Pyx_RefNannyFinishContext();
4634 return __pyx_r;
4635 }
4636
4637 /* Python wrapper */
4638 static int __pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_10transposed_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
__pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_10transposed_3__set__(PyObject * __pyx_v_self,PyObject * __pyx_v_value)4639 static int __pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_10transposed_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
4640 int __pyx_r;
4641 __Pyx_RefNannyDeclarations
4642 __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
4643 __pyx_r = __pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_10transposed_2__set__(((struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *)__pyx_v_self), ((PyObject *)__pyx_v_value));
4644
4645 /* function exit code */
4646 __Pyx_RefNannyFinishContext();
4647 return __pyx_r;
4648 }
4649
__pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_10transposed_2__set__(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader * __pyx_v_self,PyObject * __pyx_v_value)4650 static int __pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_10transposed_2__set__(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *__pyx_v_self, PyObject *__pyx_v_value) {
4651 int __pyx_r;
4652 __Pyx_RefNannyDeclarations
4653 int __pyx_t_1;
4654 int __pyx_lineno = 0;
4655 const char *__pyx_filename = NULL;
4656 int __pyx_clineno = 0;
4657 __Pyx_RefNannySetupContext("__set__", 0);
4658 __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_value); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 37, __pyx_L1_error)
4659 __pyx_v_self->transposed = __pyx_t_1;
4660
4661 /* function exit code */
4662 __pyx_r = 0;
4663 goto __pyx_L0;
4664 __pyx_L1_error:;
4665 __Pyx_AddTraceback("gensim.corpora._mmreader.MmReader.transposed.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
4666 __pyx_r = -1;
4667 __pyx_L0:;
4668 __Pyx_RefNannyFinishContext();
4669 return __pyx_r;
4670 }
4671
4672 /* "gensim/corpora/_mmreader.pyx":38
4673 * cdef public input
4674 * cdef public bint transposed
4675 * cdef public long long num_docs, num_terms, num_nnz # <<<<<<<<<<<<<<
4676 *
4677 * def __init__(self, input, transposed=True):
4678 */
4679
4680 /* Python wrapper */
4681 static PyObject *__pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_8num_docs_1__get__(PyObject *__pyx_v_self); /*proto*/
__pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_8num_docs_1__get__(PyObject * __pyx_v_self)4682 static PyObject *__pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_8num_docs_1__get__(PyObject *__pyx_v_self) {
4683 PyObject *__pyx_r = 0;
4684 __Pyx_RefNannyDeclarations
4685 __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
4686 __pyx_r = __pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_8num_docs___get__(((struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *)__pyx_v_self));
4687
4688 /* function exit code */
4689 __Pyx_RefNannyFinishContext();
4690 return __pyx_r;
4691 }
4692
__pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_8num_docs___get__(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader * __pyx_v_self)4693 static PyObject *__pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_8num_docs___get__(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *__pyx_v_self) {
4694 PyObject *__pyx_r = NULL;
4695 __Pyx_RefNannyDeclarations
4696 PyObject *__pyx_t_1 = NULL;
4697 int __pyx_lineno = 0;
4698 const char *__pyx_filename = NULL;
4699 int __pyx_clineno = 0;
4700 __Pyx_RefNannySetupContext("__get__", 0);
4701 __Pyx_XDECREF(__pyx_r);
4702 __pyx_t_1 = __Pyx_PyInt_From_PY_LONG_LONG(__pyx_v_self->num_docs); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 38, __pyx_L1_error)
4703 __Pyx_GOTREF(__pyx_t_1);
4704 __pyx_r = __pyx_t_1;
4705 __pyx_t_1 = 0;
4706 goto __pyx_L0;
4707
4708 /* function exit code */
4709 __pyx_L1_error:;
4710 __Pyx_XDECREF(__pyx_t_1);
4711 __Pyx_AddTraceback("gensim.corpora._mmreader.MmReader.num_docs.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
4712 __pyx_r = NULL;
4713 __pyx_L0:;
4714 __Pyx_XGIVEREF(__pyx_r);
4715 __Pyx_RefNannyFinishContext();
4716 return __pyx_r;
4717 }
4718
4719 /* Python wrapper */
4720 static int __pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_8num_docs_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
__pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_8num_docs_3__set__(PyObject * __pyx_v_self,PyObject * __pyx_v_value)4721 static int __pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_8num_docs_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
4722 int __pyx_r;
4723 __Pyx_RefNannyDeclarations
4724 __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
4725 __pyx_r = __pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_8num_docs_2__set__(((struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *)__pyx_v_self), ((PyObject *)__pyx_v_value));
4726
4727 /* function exit code */
4728 __Pyx_RefNannyFinishContext();
4729 return __pyx_r;
4730 }
4731
__pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_8num_docs_2__set__(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader * __pyx_v_self,PyObject * __pyx_v_value)4732 static int __pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_8num_docs_2__set__(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *__pyx_v_self, PyObject *__pyx_v_value) {
4733 int __pyx_r;
4734 __Pyx_RefNannyDeclarations
4735 PY_LONG_LONG __pyx_t_1;
4736 int __pyx_lineno = 0;
4737 const char *__pyx_filename = NULL;
4738 int __pyx_clineno = 0;
4739 __Pyx_RefNannySetupContext("__set__", 0);
4740 __pyx_t_1 = __Pyx_PyInt_As_PY_LONG_LONG(__pyx_v_value); if (unlikely((__pyx_t_1 == (PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(0, 38, __pyx_L1_error)
4741 __pyx_v_self->num_docs = __pyx_t_1;
4742
4743 /* function exit code */
4744 __pyx_r = 0;
4745 goto __pyx_L0;
4746 __pyx_L1_error:;
4747 __Pyx_AddTraceback("gensim.corpora._mmreader.MmReader.num_docs.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
4748 __pyx_r = -1;
4749 __pyx_L0:;
4750 __Pyx_RefNannyFinishContext();
4751 return __pyx_r;
4752 }
4753
4754 /* Python wrapper */
4755 static PyObject *__pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_9num_terms_1__get__(PyObject *__pyx_v_self); /*proto*/
__pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_9num_terms_1__get__(PyObject * __pyx_v_self)4756 static PyObject *__pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_9num_terms_1__get__(PyObject *__pyx_v_self) {
4757 PyObject *__pyx_r = 0;
4758 __Pyx_RefNannyDeclarations
4759 __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
4760 __pyx_r = __pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_9num_terms___get__(((struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *)__pyx_v_self));
4761
4762 /* function exit code */
4763 __Pyx_RefNannyFinishContext();
4764 return __pyx_r;
4765 }
4766
__pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_9num_terms___get__(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader * __pyx_v_self)4767 static PyObject *__pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_9num_terms___get__(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *__pyx_v_self) {
4768 PyObject *__pyx_r = NULL;
4769 __Pyx_RefNannyDeclarations
4770 PyObject *__pyx_t_1 = NULL;
4771 int __pyx_lineno = 0;
4772 const char *__pyx_filename = NULL;
4773 int __pyx_clineno = 0;
4774 __Pyx_RefNannySetupContext("__get__", 0);
4775 __Pyx_XDECREF(__pyx_r);
4776 __pyx_t_1 = __Pyx_PyInt_From_PY_LONG_LONG(__pyx_v_self->num_terms); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 38, __pyx_L1_error)
4777 __Pyx_GOTREF(__pyx_t_1);
4778 __pyx_r = __pyx_t_1;
4779 __pyx_t_1 = 0;
4780 goto __pyx_L0;
4781
4782 /* function exit code */
4783 __pyx_L1_error:;
4784 __Pyx_XDECREF(__pyx_t_1);
4785 __Pyx_AddTraceback("gensim.corpora._mmreader.MmReader.num_terms.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
4786 __pyx_r = NULL;
4787 __pyx_L0:;
4788 __Pyx_XGIVEREF(__pyx_r);
4789 __Pyx_RefNannyFinishContext();
4790 return __pyx_r;
4791 }
4792
4793 /* Python wrapper */
4794 static int __pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_9num_terms_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
__pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_9num_terms_3__set__(PyObject * __pyx_v_self,PyObject * __pyx_v_value)4795 static int __pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_9num_terms_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
4796 int __pyx_r;
4797 __Pyx_RefNannyDeclarations
4798 __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
4799 __pyx_r = __pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_9num_terms_2__set__(((struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *)__pyx_v_self), ((PyObject *)__pyx_v_value));
4800
4801 /* function exit code */
4802 __Pyx_RefNannyFinishContext();
4803 return __pyx_r;
4804 }
4805
__pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_9num_terms_2__set__(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader * __pyx_v_self,PyObject * __pyx_v_value)4806 static int __pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_9num_terms_2__set__(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *__pyx_v_self, PyObject *__pyx_v_value) {
4807 int __pyx_r;
4808 __Pyx_RefNannyDeclarations
4809 PY_LONG_LONG __pyx_t_1;
4810 int __pyx_lineno = 0;
4811 const char *__pyx_filename = NULL;
4812 int __pyx_clineno = 0;
4813 __Pyx_RefNannySetupContext("__set__", 0);
4814 __pyx_t_1 = __Pyx_PyInt_As_PY_LONG_LONG(__pyx_v_value); if (unlikely((__pyx_t_1 == (PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(0, 38, __pyx_L1_error)
4815 __pyx_v_self->num_terms = __pyx_t_1;
4816
4817 /* function exit code */
4818 __pyx_r = 0;
4819 goto __pyx_L0;
4820 __pyx_L1_error:;
4821 __Pyx_AddTraceback("gensim.corpora._mmreader.MmReader.num_terms.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
4822 __pyx_r = -1;
4823 __pyx_L0:;
4824 __Pyx_RefNannyFinishContext();
4825 return __pyx_r;
4826 }
4827
4828 /* Python wrapper */
4829 static PyObject *__pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_7num_nnz_1__get__(PyObject *__pyx_v_self); /*proto*/
__pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_7num_nnz_1__get__(PyObject * __pyx_v_self)4830 static PyObject *__pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_7num_nnz_1__get__(PyObject *__pyx_v_self) {
4831 PyObject *__pyx_r = 0;
4832 __Pyx_RefNannyDeclarations
4833 __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
4834 __pyx_r = __pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_7num_nnz___get__(((struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *)__pyx_v_self));
4835
4836 /* function exit code */
4837 __Pyx_RefNannyFinishContext();
4838 return __pyx_r;
4839 }
4840
__pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_7num_nnz___get__(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader * __pyx_v_self)4841 static PyObject *__pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_7num_nnz___get__(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *__pyx_v_self) {
4842 PyObject *__pyx_r = NULL;
4843 __Pyx_RefNannyDeclarations
4844 PyObject *__pyx_t_1 = NULL;
4845 int __pyx_lineno = 0;
4846 const char *__pyx_filename = NULL;
4847 int __pyx_clineno = 0;
4848 __Pyx_RefNannySetupContext("__get__", 0);
4849 __Pyx_XDECREF(__pyx_r);
4850 __pyx_t_1 = __Pyx_PyInt_From_PY_LONG_LONG(__pyx_v_self->num_nnz); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 38, __pyx_L1_error)
4851 __Pyx_GOTREF(__pyx_t_1);
4852 __pyx_r = __pyx_t_1;
4853 __pyx_t_1 = 0;
4854 goto __pyx_L0;
4855
4856 /* function exit code */
4857 __pyx_L1_error:;
4858 __Pyx_XDECREF(__pyx_t_1);
4859 __Pyx_AddTraceback("gensim.corpora._mmreader.MmReader.num_nnz.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
4860 __pyx_r = NULL;
4861 __pyx_L0:;
4862 __Pyx_XGIVEREF(__pyx_r);
4863 __Pyx_RefNannyFinishContext();
4864 return __pyx_r;
4865 }
4866
4867 /* Python wrapper */
4868 static int __pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_7num_nnz_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
__pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_7num_nnz_3__set__(PyObject * __pyx_v_self,PyObject * __pyx_v_value)4869 static int __pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_7num_nnz_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
4870 int __pyx_r;
4871 __Pyx_RefNannyDeclarations
4872 __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
4873 __pyx_r = __pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_7num_nnz_2__set__(((struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *)__pyx_v_self), ((PyObject *)__pyx_v_value));
4874
4875 /* function exit code */
4876 __Pyx_RefNannyFinishContext();
4877 return __pyx_r;
4878 }
4879
__pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_7num_nnz_2__set__(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader * __pyx_v_self,PyObject * __pyx_v_value)4880 static int __pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_7num_nnz_2__set__(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *__pyx_v_self, PyObject *__pyx_v_value) {
4881 int __pyx_r;
4882 __Pyx_RefNannyDeclarations
4883 PY_LONG_LONG __pyx_t_1;
4884 int __pyx_lineno = 0;
4885 const char *__pyx_filename = NULL;
4886 int __pyx_clineno = 0;
4887 __Pyx_RefNannySetupContext("__set__", 0);
4888 __pyx_t_1 = __Pyx_PyInt_As_PY_LONG_LONG(__pyx_v_value); if (unlikely((__pyx_t_1 == (PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(0, 38, __pyx_L1_error)
4889 __pyx_v_self->num_nnz = __pyx_t_1;
4890
4891 /* function exit code */
4892 __pyx_r = 0;
4893 goto __pyx_L0;
4894 __pyx_L1_error:;
4895 __Pyx_AddTraceback("gensim.corpora._mmreader.MmReader.num_nnz.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
4896 __pyx_r = -1;
4897 __pyx_L0:;
4898 __Pyx_RefNannyFinishContext();
4899 return __pyx_r;
4900 }
4901
4902 /* "(tree fragment)":1
4903 * def __reduce_cython__(self): # <<<<<<<<<<<<<<
4904 * cdef tuple state
4905 * cdef object _dict
4906 */
4907
4908 /* Python wrapper */
4909 static PyObject *__pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_14__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
4910 static char __pyx_doc_6gensim_7corpora_9_mmreader_8MmReader_13__reduce_cython__[] = "MmReader.__reduce_cython__(self)";
__pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_14__reduce_cython__(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)4911 static PyObject *__pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_14__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
4912 PyObject *__pyx_r = 0;
4913 __Pyx_RefNannyDeclarations
4914 __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
4915 __pyx_r = __pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_13__reduce_cython__(((struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *)__pyx_v_self));
4916
4917 /* function exit code */
4918 __Pyx_RefNannyFinishContext();
4919 return __pyx_r;
4920 }
4921
__pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_13__reduce_cython__(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader * __pyx_v_self)4922 static PyObject *__pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_13__reduce_cython__(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *__pyx_v_self) {
4923 PyObject *__pyx_v_state = 0;
4924 PyObject *__pyx_v__dict = 0;
4925 int __pyx_v_use_setstate;
4926 PyObject *__pyx_r = NULL;
4927 __Pyx_RefNannyDeclarations
4928 PyObject *__pyx_t_1 = NULL;
4929 PyObject *__pyx_t_2 = NULL;
4930 PyObject *__pyx_t_3 = NULL;
4931 PyObject *__pyx_t_4 = NULL;
4932 PyObject *__pyx_t_5 = NULL;
4933 int __pyx_t_6;
4934 int __pyx_t_7;
4935 int __pyx_lineno = 0;
4936 const char *__pyx_filename = NULL;
4937 int __pyx_clineno = 0;
4938 __Pyx_RefNannySetupContext("__reduce_cython__", 0);
4939
4940 /* "(tree fragment)":5
4941 * cdef object _dict
4942 * cdef bint use_setstate
4943 * state = (self.input, self.num_docs, self.num_nnz, self.num_terms, self.transposed) # <<<<<<<<<<<<<<
4944 * _dict = getattr(self, '__dict__', None)
4945 * if _dict is not None:
4946 */
4947 __pyx_t_1 = __Pyx_PyInt_From_PY_LONG_LONG(__pyx_v_self->num_docs); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
4948 __Pyx_GOTREF(__pyx_t_1);
4949 __pyx_t_2 = __Pyx_PyInt_From_PY_LONG_LONG(__pyx_v_self->num_nnz); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
4950 __Pyx_GOTREF(__pyx_t_2);
4951 __pyx_t_3 = __Pyx_PyInt_From_PY_LONG_LONG(__pyx_v_self->num_terms); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
4952 __Pyx_GOTREF(__pyx_t_3);
4953 __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_self->transposed); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5, __pyx_L1_error)
4954 __Pyx_GOTREF(__pyx_t_4);
4955 __pyx_t_5 = PyTuple_New(5); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 5, __pyx_L1_error)
4956 __Pyx_GOTREF(__pyx_t_5);
4957 __Pyx_INCREF(__pyx_v_self->input);
4958 __Pyx_GIVEREF(__pyx_v_self->input);
4959 PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_self->input);
4960 __Pyx_GIVEREF(__pyx_t_1);
4961 PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1);
4962 __Pyx_GIVEREF(__pyx_t_2);
4963 PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_2);
4964 __Pyx_GIVEREF(__pyx_t_3);
4965 PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_3);
4966 __Pyx_GIVEREF(__pyx_t_4);
4967 PyTuple_SET_ITEM(__pyx_t_5, 4, __pyx_t_4);
4968 __pyx_t_1 = 0;
4969 __pyx_t_2 = 0;
4970 __pyx_t_3 = 0;
4971 __pyx_t_4 = 0;
4972 __pyx_v_state = ((PyObject*)__pyx_t_5);
4973 __pyx_t_5 = 0;
4974
4975 /* "(tree fragment)":6
4976 * cdef bint use_setstate
4977 * state = (self.input, self.num_docs, self.num_nnz, self.num_terms, self.transposed)
4978 * _dict = getattr(self, '__dict__', None) # <<<<<<<<<<<<<<
4979 * if _dict is not None:
4980 * state += (_dict,)
4981 */
4982 __pyx_t_5 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 6, __pyx_L1_error)
4983 __Pyx_GOTREF(__pyx_t_5);
4984 __pyx_v__dict = __pyx_t_5;
4985 __pyx_t_5 = 0;
4986
4987 /* "(tree fragment)":7
4988 * state = (self.input, self.num_docs, self.num_nnz, self.num_terms, self.transposed)
4989 * _dict = getattr(self, '__dict__', None)
4990 * if _dict is not None: # <<<<<<<<<<<<<<
4991 * state += (_dict,)
4992 * use_setstate = True
4993 */
4994 __pyx_t_6 = (__pyx_v__dict != Py_None);
4995 __pyx_t_7 = (__pyx_t_6 != 0);
4996 if (__pyx_t_7) {
4997
4998 /* "(tree fragment)":8
4999 * _dict = getattr(self, '__dict__', None)
5000 * if _dict is not None:
5001 * state += (_dict,) # <<<<<<<<<<<<<<
5002 * use_setstate = True
5003 * else:
5004 */
5005 __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 8, __pyx_L1_error)
5006 __Pyx_GOTREF(__pyx_t_5);
5007 __Pyx_INCREF(__pyx_v__dict);
5008 __Pyx_GIVEREF(__pyx_v__dict);
5009 PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v__dict);
5010 __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 8, __pyx_L1_error)
5011 __Pyx_GOTREF(__pyx_t_4);
5012 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
5013 __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_4));
5014 __pyx_t_4 = 0;
5015
5016 /* "(tree fragment)":9
5017 * if _dict is not None:
5018 * state += (_dict,)
5019 * use_setstate = True # <<<<<<<<<<<<<<
5020 * else:
5021 * use_setstate = self.input is not None
5022 */
5023 __pyx_v_use_setstate = 1;
5024
5025 /* "(tree fragment)":7
5026 * state = (self.input, self.num_docs, self.num_nnz, self.num_terms, self.transposed)
5027 * _dict = getattr(self, '__dict__', None)
5028 * if _dict is not None: # <<<<<<<<<<<<<<
5029 * state += (_dict,)
5030 * use_setstate = True
5031 */
5032 goto __pyx_L3;
5033 }
5034
5035 /* "(tree fragment)":11
5036 * use_setstate = True
5037 * else:
5038 * use_setstate = self.input is not None # <<<<<<<<<<<<<<
5039 * if use_setstate:
5040 * return __pyx_unpickle_MmReader, (type(self), 0xea5fe92, None), state
5041 */
5042 /*else*/ {
5043 __pyx_t_7 = (__pyx_v_self->input != Py_None);
5044 __pyx_v_use_setstate = __pyx_t_7;
5045 }
5046 __pyx_L3:;
5047
5048 /* "(tree fragment)":12
5049 * else:
5050 * use_setstate = self.input is not None
5051 * if use_setstate: # <<<<<<<<<<<<<<
5052 * return __pyx_unpickle_MmReader, (type(self), 0xea5fe92, None), state
5053 * else:
5054 */
5055 __pyx_t_7 = (__pyx_v_use_setstate != 0);
5056 if (__pyx_t_7) {
5057
5058 /* "(tree fragment)":13
5059 * use_setstate = self.input is not None
5060 * if use_setstate:
5061 * return __pyx_unpickle_MmReader, (type(self), 0xea5fe92, None), state # <<<<<<<<<<<<<<
5062 * else:
5063 * return __pyx_unpickle_MmReader, (type(self), 0xea5fe92, state)
5064 */
5065 __Pyx_XDECREF(__pyx_r);
5066 __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pyx_unpickle_MmReader); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 13, __pyx_L1_error)
5067 __Pyx_GOTREF(__pyx_t_4);
5068 __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 13, __pyx_L1_error)
5069 __Pyx_GOTREF(__pyx_t_5);
5070 __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
5071 __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
5072 PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
5073 __Pyx_INCREF(__pyx_int_245759634);
5074 __Pyx_GIVEREF(__pyx_int_245759634);
5075 PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_int_245759634);
5076 __Pyx_INCREF(Py_None);
5077 __Pyx_GIVEREF(Py_None);
5078 PyTuple_SET_ITEM(__pyx_t_5, 2, Py_None);
5079 __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 13, __pyx_L1_error)
5080 __Pyx_GOTREF(__pyx_t_3);
5081 __Pyx_GIVEREF(__pyx_t_4);
5082 PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
5083 __Pyx_GIVEREF(__pyx_t_5);
5084 PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_5);
5085 __Pyx_INCREF(__pyx_v_state);
5086 __Pyx_GIVEREF(__pyx_v_state);
5087 PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_state);
5088 __pyx_t_4 = 0;
5089 __pyx_t_5 = 0;
5090 __pyx_r = __pyx_t_3;
5091 __pyx_t_3 = 0;
5092 goto __pyx_L0;
5093
5094 /* "(tree fragment)":12
5095 * else:
5096 * use_setstate = self.input is not None
5097 * if use_setstate: # <<<<<<<<<<<<<<
5098 * return __pyx_unpickle_MmReader, (type(self), 0xea5fe92, None), state
5099 * else:
5100 */
5101 }
5102
5103 /* "(tree fragment)":15
5104 * return __pyx_unpickle_MmReader, (type(self), 0xea5fe92, None), state
5105 * else:
5106 * return __pyx_unpickle_MmReader, (type(self), 0xea5fe92, state) # <<<<<<<<<<<<<<
5107 * def __setstate_cython__(self, __pyx_state):
5108 * __pyx_unpickle_MmReader__set_state(self, __pyx_state)
5109 */
5110 /*else*/ {
5111 __Pyx_XDECREF(__pyx_r);
5112 __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_pyx_unpickle_MmReader); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 15, __pyx_L1_error)
5113 __Pyx_GOTREF(__pyx_t_3);
5114 __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 15, __pyx_L1_error)
5115 __Pyx_GOTREF(__pyx_t_5);
5116 __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
5117 __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
5118 PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
5119 __Pyx_INCREF(__pyx_int_245759634);
5120 __Pyx_GIVEREF(__pyx_int_245759634);
5121 PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_int_245759634);
5122 __Pyx_INCREF(__pyx_v_state);
5123 __Pyx_GIVEREF(__pyx_v_state);
5124 PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_state);
5125 __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 15, __pyx_L1_error)
5126 __Pyx_GOTREF(__pyx_t_4);
5127 __Pyx_GIVEREF(__pyx_t_3);
5128 PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
5129 __Pyx_GIVEREF(__pyx_t_5);
5130 PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_5);
5131 __pyx_t_3 = 0;
5132 __pyx_t_5 = 0;
5133 __pyx_r = __pyx_t_4;
5134 __pyx_t_4 = 0;
5135 goto __pyx_L0;
5136 }
5137
5138 /* "(tree fragment)":1
5139 * def __reduce_cython__(self): # <<<<<<<<<<<<<<
5140 * cdef tuple state
5141 * cdef object _dict
5142 */
5143
5144 /* function exit code */
5145 __pyx_L1_error:;
5146 __Pyx_XDECREF(__pyx_t_1);
5147 __Pyx_XDECREF(__pyx_t_2);
5148 __Pyx_XDECREF(__pyx_t_3);
5149 __Pyx_XDECREF(__pyx_t_4);
5150 __Pyx_XDECREF(__pyx_t_5);
5151 __Pyx_AddTraceback("gensim.corpora._mmreader.MmReader.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
5152 __pyx_r = NULL;
5153 __pyx_L0:;
5154 __Pyx_XDECREF(__pyx_v_state);
5155 __Pyx_XDECREF(__pyx_v__dict);
5156 __Pyx_XGIVEREF(__pyx_r);
5157 __Pyx_RefNannyFinishContext();
5158 return __pyx_r;
5159 }
5160
5161 /* "(tree fragment)":16
5162 * else:
5163 * return __pyx_unpickle_MmReader, (type(self), 0xea5fe92, state)
5164 * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
5165 * __pyx_unpickle_MmReader__set_state(self, __pyx_state)
5166 */
5167
5168 /* Python wrapper */
5169 static PyObject *__pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_16__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
5170 static char __pyx_doc_6gensim_7corpora_9_mmreader_8MmReader_15__setstate_cython__[] = "MmReader.__setstate_cython__(self, __pyx_state)";
__pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_16__setstate_cython__(PyObject * __pyx_v_self,PyObject * __pyx_v___pyx_state)5171 static PyObject *__pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_16__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
5172 PyObject *__pyx_r = 0;
5173 __Pyx_RefNannyDeclarations
5174 __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
5175 __pyx_r = __pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_15__setstate_cython__(((struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
5176
5177 /* function exit code */
5178 __Pyx_RefNannyFinishContext();
5179 return __pyx_r;
5180 }
5181
__pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_15__setstate_cython__(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader * __pyx_v_self,PyObject * __pyx_v___pyx_state)5182 static PyObject *__pyx_pf_6gensim_7corpora_9_mmreader_8MmReader_15__setstate_cython__(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
5183 PyObject *__pyx_r = NULL;
5184 __Pyx_RefNannyDeclarations
5185 PyObject *__pyx_t_1 = NULL;
5186 int __pyx_lineno = 0;
5187 const char *__pyx_filename = NULL;
5188 int __pyx_clineno = 0;
5189 __Pyx_RefNannySetupContext("__setstate_cython__", 0);
5190
5191 /* "(tree fragment)":17
5192 * return __pyx_unpickle_MmReader, (type(self), 0xea5fe92, state)
5193 * def __setstate_cython__(self, __pyx_state):
5194 * __pyx_unpickle_MmReader__set_state(self, __pyx_state) # <<<<<<<<<<<<<<
5195 */
5196 if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 17, __pyx_L1_error)
5197 __pyx_t_1 = __pyx_f_6gensim_7corpora_9_mmreader___pyx_unpickle_MmReader__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 17, __pyx_L1_error)
5198 __Pyx_GOTREF(__pyx_t_1);
5199 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5200
5201 /* "(tree fragment)":16
5202 * else:
5203 * return __pyx_unpickle_MmReader, (type(self), 0xea5fe92, state)
5204 * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
5205 * __pyx_unpickle_MmReader__set_state(self, __pyx_state)
5206 */
5207
5208 /* function exit code */
5209 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
5210 goto __pyx_L0;
5211 __pyx_L1_error:;
5212 __Pyx_XDECREF(__pyx_t_1);
5213 __Pyx_AddTraceback("gensim.corpora._mmreader.MmReader.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
5214 __pyx_r = NULL;
5215 __pyx_L0:;
5216 __Pyx_XGIVEREF(__pyx_r);
5217 __Pyx_RefNannyFinishContext();
5218 return __pyx_r;
5219 }
5220
5221 /* "(tree fragment)":1
5222 * def __pyx_unpickle_MmReader(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<<
5223 * cdef object __pyx_PickleError
5224 * cdef object __pyx_result
5225 */
5226
5227 /* Python wrapper */
5228 static PyObject *__pyx_pw_6gensim_7corpora_9_mmreader_1__pyx_unpickle_MmReader(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
5229 static char __pyx_doc_6gensim_7corpora_9_mmreader___pyx_unpickle_MmReader[] = "__pyx_unpickle_MmReader(__pyx_type, long __pyx_checksum, __pyx_state)";
5230 static PyMethodDef __pyx_mdef_6gensim_7corpora_9_mmreader_1__pyx_unpickle_MmReader = {"__pyx_unpickle_MmReader", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_6gensim_7corpora_9_mmreader_1__pyx_unpickle_MmReader, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gensim_7corpora_9_mmreader___pyx_unpickle_MmReader};
__pyx_pw_6gensim_7corpora_9_mmreader_1__pyx_unpickle_MmReader(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)5231 static PyObject *__pyx_pw_6gensim_7corpora_9_mmreader_1__pyx_unpickle_MmReader(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
5232 PyObject *__pyx_v___pyx_type = 0;
5233 long __pyx_v___pyx_checksum;
5234 PyObject *__pyx_v___pyx_state = 0;
5235 int __pyx_lineno = 0;
5236 const char *__pyx_filename = NULL;
5237 int __pyx_clineno = 0;
5238 PyObject *__pyx_r = 0;
5239 __Pyx_RefNannyDeclarations
5240 __Pyx_RefNannySetupContext("__pyx_unpickle_MmReader (wrapper)", 0);
5241 {
5242 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,0};
5243 PyObject* values[3] = {0,0,0};
5244 if (unlikely(__pyx_kwds)) {
5245 Py_ssize_t kw_args;
5246 const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
5247 switch (pos_args) {
5248 case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
5249 CYTHON_FALLTHROUGH;
5250 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
5251 CYTHON_FALLTHROUGH;
5252 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
5253 CYTHON_FALLTHROUGH;
5254 case 0: break;
5255 default: goto __pyx_L5_argtuple_error;
5256 }
5257 kw_args = PyDict_Size(__pyx_kwds);
5258 switch (pos_args) {
5259 case 0:
5260 if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
5261 else goto __pyx_L5_argtuple_error;
5262 CYTHON_FALLTHROUGH;
5263 case 1:
5264 if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
5265 else {
5266 __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_MmReader", 1, 3, 3, 1); __PYX_ERR(1, 1, __pyx_L3_error)
5267 }
5268 CYTHON_FALLTHROUGH;
5269 case 2:
5270 if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
5271 else {
5272 __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_MmReader", 1, 3, 3, 2); __PYX_ERR(1, 1, __pyx_L3_error)
5273 }
5274 }
5275 if (unlikely(kw_args > 0)) {
5276 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_MmReader") < 0)) __PYX_ERR(1, 1, __pyx_L3_error)
5277 }
5278 } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
5279 goto __pyx_L5_argtuple_error;
5280 } else {
5281 values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
5282 values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
5283 values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
5284 }
5285 __pyx_v___pyx_type = values[0];
5286 __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 1, __pyx_L3_error)
5287 __pyx_v___pyx_state = values[2];
5288 }
5289 goto __pyx_L4_argument_unpacking_done;
5290 __pyx_L5_argtuple_error:;
5291 __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_MmReader", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1, __pyx_L3_error)
5292 __pyx_L3_error:;
5293 __Pyx_AddTraceback("gensim.corpora._mmreader.__pyx_unpickle_MmReader", __pyx_clineno, __pyx_lineno, __pyx_filename);
5294 __Pyx_RefNannyFinishContext();
5295 return NULL;
5296 __pyx_L4_argument_unpacking_done:;
5297 __pyx_r = __pyx_pf_6gensim_7corpora_9_mmreader___pyx_unpickle_MmReader(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);
5298
5299 /* function exit code */
5300 __Pyx_RefNannyFinishContext();
5301 return __pyx_r;
5302 }
5303
__pyx_pf_6gensim_7corpora_9_mmreader___pyx_unpickle_MmReader(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v___pyx_type,long __pyx_v___pyx_checksum,PyObject * __pyx_v___pyx_state)5304 static PyObject *__pyx_pf_6gensim_7corpora_9_mmreader___pyx_unpickle_MmReader(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
5305 PyObject *__pyx_v___pyx_PickleError = 0;
5306 PyObject *__pyx_v___pyx_result = 0;
5307 PyObject *__pyx_r = NULL;
5308 __Pyx_RefNannyDeclarations
5309 int __pyx_t_1;
5310 PyObject *__pyx_t_2 = NULL;
5311 PyObject *__pyx_t_3 = NULL;
5312 PyObject *__pyx_t_4 = NULL;
5313 PyObject *__pyx_t_5 = NULL;
5314 int __pyx_t_6;
5315 int __pyx_lineno = 0;
5316 const char *__pyx_filename = NULL;
5317 int __pyx_clineno = 0;
5318 __Pyx_RefNannySetupContext("__pyx_unpickle_MmReader", 0);
5319
5320 /* "(tree fragment)":4
5321 * cdef object __pyx_PickleError
5322 * cdef object __pyx_result
5323 * if __pyx_checksum != 0xea5fe92: # <<<<<<<<<<<<<<
5324 * from pickle import PickleError as __pyx_PickleError
5325 * raise __pyx_PickleError("Incompatible checksums (%s vs 0xea5fe92 = (input, num_docs, num_nnz, num_terms, transposed))" % __pyx_checksum)
5326 */
5327 __pyx_t_1 = ((__pyx_v___pyx_checksum != 0xea5fe92) != 0);
5328 if (__pyx_t_1) {
5329
5330 /* "(tree fragment)":5
5331 * cdef object __pyx_result
5332 * if __pyx_checksum != 0xea5fe92:
5333 * from pickle import PickleError as __pyx_PickleError # <<<<<<<<<<<<<<
5334 * raise __pyx_PickleError("Incompatible checksums (%s vs 0xea5fe92 = (input, num_docs, num_nnz, num_terms, transposed))" % __pyx_checksum)
5335 * __pyx_result = MmReader.__new__(__pyx_type)
5336 */
5337 __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
5338 __Pyx_GOTREF(__pyx_t_2);
5339 __Pyx_INCREF(__pyx_n_s_PickleError);
5340 __Pyx_GIVEREF(__pyx_n_s_PickleError);
5341 PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
5342 __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
5343 __Pyx_GOTREF(__pyx_t_3);
5344 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5345 __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
5346 __Pyx_GOTREF(__pyx_t_2);
5347 __Pyx_INCREF(__pyx_t_2);
5348 __pyx_v___pyx_PickleError = __pyx_t_2;
5349 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5350 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5351
5352 /* "(tree fragment)":6
5353 * if __pyx_checksum != 0xea5fe92:
5354 * from pickle import PickleError as __pyx_PickleError
5355 * raise __pyx_PickleError("Incompatible checksums (%s vs 0xea5fe92 = (input, num_docs, num_nnz, num_terms, transposed))" % __pyx_checksum) # <<<<<<<<<<<<<<
5356 * __pyx_result = MmReader.__new__(__pyx_type)
5357 * if __pyx_state is not None:
5358 */
5359 __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6, __pyx_L1_error)
5360 __Pyx_GOTREF(__pyx_t_2);
5361 __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0xea, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error)
5362 __Pyx_GOTREF(__pyx_t_4);
5363 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5364 __Pyx_INCREF(__pyx_v___pyx_PickleError);
5365 __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
5366 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
5367 __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
5368 if (likely(__pyx_t_5)) {
5369 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
5370 __Pyx_INCREF(__pyx_t_5);
5371 __Pyx_INCREF(function);
5372 __Pyx_DECREF_SET(__pyx_t_2, function);
5373 }
5374 }
5375 __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
5376 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
5377 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5378 if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6, __pyx_L1_error)
5379 __Pyx_GOTREF(__pyx_t_3);
5380 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5381 __Pyx_Raise(__pyx_t_3, 0, 0, 0);
5382 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5383 __PYX_ERR(1, 6, __pyx_L1_error)
5384
5385 /* "(tree fragment)":4
5386 * cdef object __pyx_PickleError
5387 * cdef object __pyx_result
5388 * if __pyx_checksum != 0xea5fe92: # <<<<<<<<<<<<<<
5389 * from pickle import PickleError as __pyx_PickleError
5390 * raise __pyx_PickleError("Incompatible checksums (%s vs 0xea5fe92 = (input, num_docs, num_nnz, num_terms, transposed))" % __pyx_checksum)
5391 */
5392 }
5393
5394 /* "(tree fragment)":7
5395 * from pickle import PickleError as __pyx_PickleError
5396 * raise __pyx_PickleError("Incompatible checksums (%s vs 0xea5fe92 = (input, num_docs, num_nnz, num_terms, transposed))" % __pyx_checksum)
5397 * __pyx_result = MmReader.__new__(__pyx_type) # <<<<<<<<<<<<<<
5398 * if __pyx_state is not None:
5399 * __pyx_unpickle_MmReader__set_state(<MmReader> __pyx_result, __pyx_state)
5400 */
5401 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_6gensim_7corpora_9_mmreader_MmReader), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7, __pyx_L1_error)
5402 __Pyx_GOTREF(__pyx_t_2);
5403 __pyx_t_4 = NULL;
5404 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
5405 __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
5406 if (likely(__pyx_t_4)) {
5407 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
5408 __Pyx_INCREF(__pyx_t_4);
5409 __Pyx_INCREF(function);
5410 __Pyx_DECREF_SET(__pyx_t_2, function);
5411 }
5412 }
5413 __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type);
5414 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
5415 if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 7, __pyx_L1_error)
5416 __Pyx_GOTREF(__pyx_t_3);
5417 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5418 __pyx_v___pyx_result = __pyx_t_3;
5419 __pyx_t_3 = 0;
5420
5421 /* "(tree fragment)":8
5422 * raise __pyx_PickleError("Incompatible checksums (%s vs 0xea5fe92 = (input, num_docs, num_nnz, num_terms, transposed))" % __pyx_checksum)
5423 * __pyx_result = MmReader.__new__(__pyx_type)
5424 * if __pyx_state is not None: # <<<<<<<<<<<<<<
5425 * __pyx_unpickle_MmReader__set_state(<MmReader> __pyx_result, __pyx_state)
5426 * return __pyx_result
5427 */
5428 __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
5429 __pyx_t_6 = (__pyx_t_1 != 0);
5430 if (__pyx_t_6) {
5431
5432 /* "(tree fragment)":9
5433 * __pyx_result = MmReader.__new__(__pyx_type)
5434 * if __pyx_state is not None:
5435 * __pyx_unpickle_MmReader__set_state(<MmReader> __pyx_result, __pyx_state) # <<<<<<<<<<<<<<
5436 * return __pyx_result
5437 * cdef __pyx_unpickle_MmReader__set_state(MmReader __pyx_result, tuple __pyx_state):
5438 */
5439 if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 9, __pyx_L1_error)
5440 __pyx_t_3 = __pyx_f_6gensim_7corpora_9_mmreader___pyx_unpickle_MmReader__set_state(((struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 9, __pyx_L1_error)
5441 __Pyx_GOTREF(__pyx_t_3);
5442 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5443
5444 /* "(tree fragment)":8
5445 * raise __pyx_PickleError("Incompatible checksums (%s vs 0xea5fe92 = (input, num_docs, num_nnz, num_terms, transposed))" % __pyx_checksum)
5446 * __pyx_result = MmReader.__new__(__pyx_type)
5447 * if __pyx_state is not None: # <<<<<<<<<<<<<<
5448 * __pyx_unpickle_MmReader__set_state(<MmReader> __pyx_result, __pyx_state)
5449 * return __pyx_result
5450 */
5451 }
5452
5453 /* "(tree fragment)":10
5454 * if __pyx_state is not None:
5455 * __pyx_unpickle_MmReader__set_state(<MmReader> __pyx_result, __pyx_state)
5456 * return __pyx_result # <<<<<<<<<<<<<<
5457 * cdef __pyx_unpickle_MmReader__set_state(MmReader __pyx_result, tuple __pyx_state):
5458 * __pyx_result.input = __pyx_state[0]; __pyx_result.num_docs = __pyx_state[1]; __pyx_result.num_nnz = __pyx_state[2]; __pyx_result.num_terms = __pyx_state[3]; __pyx_result.transposed = __pyx_state[4]
5459 */
5460 __Pyx_XDECREF(__pyx_r);
5461 __Pyx_INCREF(__pyx_v___pyx_result);
5462 __pyx_r = __pyx_v___pyx_result;
5463 goto __pyx_L0;
5464
5465 /* "(tree fragment)":1
5466 * def __pyx_unpickle_MmReader(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<<
5467 * cdef object __pyx_PickleError
5468 * cdef object __pyx_result
5469 */
5470
5471 /* function exit code */
5472 __pyx_L1_error:;
5473 __Pyx_XDECREF(__pyx_t_2);
5474 __Pyx_XDECREF(__pyx_t_3);
5475 __Pyx_XDECREF(__pyx_t_4);
5476 __Pyx_XDECREF(__pyx_t_5);
5477 __Pyx_AddTraceback("gensim.corpora._mmreader.__pyx_unpickle_MmReader", __pyx_clineno, __pyx_lineno, __pyx_filename);
5478 __pyx_r = NULL;
5479 __pyx_L0:;
5480 __Pyx_XDECREF(__pyx_v___pyx_PickleError);
5481 __Pyx_XDECREF(__pyx_v___pyx_result);
5482 __Pyx_XGIVEREF(__pyx_r);
5483 __Pyx_RefNannyFinishContext();
5484 return __pyx_r;
5485 }
5486
5487 /* "(tree fragment)":11
5488 * __pyx_unpickle_MmReader__set_state(<MmReader> __pyx_result, __pyx_state)
5489 * return __pyx_result
5490 * cdef __pyx_unpickle_MmReader__set_state(MmReader __pyx_result, tuple __pyx_state): # <<<<<<<<<<<<<<
5491 * __pyx_result.input = __pyx_state[0]; __pyx_result.num_docs = __pyx_state[1]; __pyx_result.num_nnz = __pyx_state[2]; __pyx_result.num_terms = __pyx_state[3]; __pyx_result.transposed = __pyx_state[4]
5492 * if len(__pyx_state) > 5 and hasattr(__pyx_result, '__dict__'):
5493 */
5494
__pyx_f_6gensim_7corpora_9_mmreader___pyx_unpickle_MmReader__set_state(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader * __pyx_v___pyx_result,PyObject * __pyx_v___pyx_state)5495 static PyObject *__pyx_f_6gensim_7corpora_9_mmreader___pyx_unpickle_MmReader__set_state(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
5496 PyObject *__pyx_r = NULL;
5497 __Pyx_RefNannyDeclarations
5498 PyObject *__pyx_t_1 = NULL;
5499 PY_LONG_LONG __pyx_t_2;
5500 int __pyx_t_3;
5501 Py_ssize_t __pyx_t_4;
5502 int __pyx_t_5;
5503 int __pyx_t_6;
5504 PyObject *__pyx_t_7 = NULL;
5505 PyObject *__pyx_t_8 = NULL;
5506 PyObject *__pyx_t_9 = NULL;
5507 int __pyx_lineno = 0;
5508 const char *__pyx_filename = NULL;
5509 int __pyx_clineno = 0;
5510 __Pyx_RefNannySetupContext("__pyx_unpickle_MmReader__set_state", 0);
5511
5512 /* "(tree fragment)":12
5513 * return __pyx_result
5514 * cdef __pyx_unpickle_MmReader__set_state(MmReader __pyx_result, tuple __pyx_state):
5515 * __pyx_result.input = __pyx_state[0]; __pyx_result.num_docs = __pyx_state[1]; __pyx_result.num_nnz = __pyx_state[2]; __pyx_result.num_terms = __pyx_state[3]; __pyx_result.transposed = __pyx_state[4] # <<<<<<<<<<<<<<
5516 * if len(__pyx_state) > 5 and hasattr(__pyx_result, '__dict__'):
5517 * __pyx_result.__dict__.update(__pyx_state[5])
5518 */
5519 if (unlikely(__pyx_v___pyx_state == Py_None)) {
5520 PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
5521 __PYX_ERR(1, 12, __pyx_L1_error)
5522 }
5523 __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
5524 __Pyx_GOTREF(__pyx_t_1);
5525 __Pyx_GIVEREF(__pyx_t_1);
5526 __Pyx_GOTREF(__pyx_v___pyx_result->input);
5527 __Pyx_DECREF(__pyx_v___pyx_result->input);
5528 __pyx_v___pyx_result->input = __pyx_t_1;
5529 __pyx_t_1 = 0;
5530 if (unlikely(__pyx_v___pyx_state == Py_None)) {
5531 PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
5532 __PYX_ERR(1, 12, __pyx_L1_error)
5533 }
5534 __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
5535 __Pyx_GOTREF(__pyx_t_1);
5536 __pyx_t_2 = __Pyx_PyInt_As_PY_LONG_LONG(__pyx_t_1); if (unlikely((__pyx_t_2 == (PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)
5537 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5538 __pyx_v___pyx_result->num_docs = __pyx_t_2;
5539 if (unlikely(__pyx_v___pyx_state == Py_None)) {
5540 PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
5541 __PYX_ERR(1, 12, __pyx_L1_error)
5542 }
5543 __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
5544 __Pyx_GOTREF(__pyx_t_1);
5545 __pyx_t_2 = __Pyx_PyInt_As_PY_LONG_LONG(__pyx_t_1); if (unlikely((__pyx_t_2 == (PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)
5546 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5547 __pyx_v___pyx_result->num_nnz = __pyx_t_2;
5548 if (unlikely(__pyx_v___pyx_state == Py_None)) {
5549 PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
5550 __PYX_ERR(1, 12, __pyx_L1_error)
5551 }
5552 __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
5553 __Pyx_GOTREF(__pyx_t_1);
5554 __pyx_t_2 = __Pyx_PyInt_As_PY_LONG_LONG(__pyx_t_1); if (unlikely((__pyx_t_2 == (PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)
5555 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5556 __pyx_v___pyx_result->num_terms = __pyx_t_2;
5557 if (unlikely(__pyx_v___pyx_state == Py_None)) {
5558 PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
5559 __PYX_ERR(1, 12, __pyx_L1_error)
5560 }
5561 __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
5562 __Pyx_GOTREF(__pyx_t_1);
5563 __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)
5564 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5565 __pyx_v___pyx_result->transposed = __pyx_t_3;
5566
5567 /* "(tree fragment)":13
5568 * cdef __pyx_unpickle_MmReader__set_state(MmReader __pyx_result, tuple __pyx_state):
5569 * __pyx_result.input = __pyx_state[0]; __pyx_result.num_docs = __pyx_state[1]; __pyx_result.num_nnz = __pyx_state[2]; __pyx_result.num_terms = __pyx_state[3]; __pyx_result.transposed = __pyx_state[4]
5570 * if len(__pyx_state) > 5 and hasattr(__pyx_result, '__dict__'): # <<<<<<<<<<<<<<
5571 * __pyx_result.__dict__.update(__pyx_state[5])
5572 */
5573 if (unlikely(__pyx_v___pyx_state == Py_None)) {
5574 PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
5575 __PYX_ERR(1, 13, __pyx_L1_error)
5576 }
5577 __pyx_t_4 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
5578 __pyx_t_5 = ((__pyx_t_4 > 5) != 0);
5579 if (__pyx_t_5) {
5580 } else {
5581 __pyx_t_3 = __pyx_t_5;
5582 goto __pyx_L4_bool_binop_done;
5583 }
5584 __pyx_t_5 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
5585 __pyx_t_6 = (__pyx_t_5 != 0);
5586 __pyx_t_3 = __pyx_t_6;
5587 __pyx_L4_bool_binop_done:;
5588 if (__pyx_t_3) {
5589
5590 /* "(tree fragment)":14
5591 * __pyx_result.input = __pyx_state[0]; __pyx_result.num_docs = __pyx_state[1]; __pyx_result.num_nnz = __pyx_state[2]; __pyx_result.num_terms = __pyx_state[3]; __pyx_result.transposed = __pyx_state[4]
5592 * if len(__pyx_state) > 5 and hasattr(__pyx_result, '__dict__'):
5593 * __pyx_result.__dict__.update(__pyx_state[5]) # <<<<<<<<<<<<<<
5594 */
5595 __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
5596 __Pyx_GOTREF(__pyx_t_7);
5597 __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_update); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 14, __pyx_L1_error)
5598 __Pyx_GOTREF(__pyx_t_8);
5599 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
5600 if (unlikely(__pyx_v___pyx_state == Py_None)) {
5601 PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
5602 __PYX_ERR(1, 14, __pyx_L1_error)
5603 }
5604 __pyx_t_7 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 5, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
5605 __Pyx_GOTREF(__pyx_t_7);
5606 __pyx_t_9 = NULL;
5607 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
5608 __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
5609 if (likely(__pyx_t_9)) {
5610 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
5611 __Pyx_INCREF(__pyx_t_9);
5612 __Pyx_INCREF(function);
5613 __Pyx_DECREF_SET(__pyx_t_8, function);
5614 }
5615 }
5616 __pyx_t_1 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_9, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_7);
5617 __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
5618 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
5619 if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 14, __pyx_L1_error)
5620 __Pyx_GOTREF(__pyx_t_1);
5621 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
5622 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5623
5624 /* "(tree fragment)":13
5625 * cdef __pyx_unpickle_MmReader__set_state(MmReader __pyx_result, tuple __pyx_state):
5626 * __pyx_result.input = __pyx_state[0]; __pyx_result.num_docs = __pyx_state[1]; __pyx_result.num_nnz = __pyx_state[2]; __pyx_result.num_terms = __pyx_state[3]; __pyx_result.transposed = __pyx_state[4]
5627 * if len(__pyx_state) > 5 and hasattr(__pyx_result, '__dict__'): # <<<<<<<<<<<<<<
5628 * __pyx_result.__dict__.update(__pyx_state[5])
5629 */
5630 }
5631
5632 /* "(tree fragment)":11
5633 * __pyx_unpickle_MmReader__set_state(<MmReader> __pyx_result, __pyx_state)
5634 * return __pyx_result
5635 * cdef __pyx_unpickle_MmReader__set_state(MmReader __pyx_result, tuple __pyx_state): # <<<<<<<<<<<<<<
5636 * __pyx_result.input = __pyx_state[0]; __pyx_result.num_docs = __pyx_state[1]; __pyx_result.num_nnz = __pyx_state[2]; __pyx_result.num_terms = __pyx_state[3]; __pyx_result.transposed = __pyx_state[4]
5637 * if len(__pyx_state) > 5 and hasattr(__pyx_result, '__dict__'):
5638 */
5639
5640 /* function exit code */
5641 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
5642 goto __pyx_L0;
5643 __pyx_L1_error:;
5644 __Pyx_XDECREF(__pyx_t_1);
5645 __Pyx_XDECREF(__pyx_t_7);
5646 __Pyx_XDECREF(__pyx_t_8);
5647 __Pyx_XDECREF(__pyx_t_9);
5648 __Pyx_AddTraceback("gensim.corpora._mmreader.__pyx_unpickle_MmReader__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
5649 __pyx_r = 0;
5650 __pyx_L0:;
5651 __Pyx_XGIVEREF(__pyx_r);
5652 __Pyx_RefNannyFinishContext();
5653 return __pyx_r;
5654 }
5655
__pyx_tp_new_6gensim_7corpora_9_mmreader_MmReader(PyTypeObject * t,CYTHON_UNUSED PyObject * a,CYTHON_UNUSED PyObject * k)5656 static PyObject *__pyx_tp_new_6gensim_7corpora_9_mmreader_MmReader(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
5657 struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *p;
5658 PyObject *o;
5659 if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
5660 o = (*t->tp_alloc)(t, 0);
5661 } else {
5662 o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
5663 }
5664 if (unlikely(!o)) return 0;
5665 p = ((struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *)o);
5666 p->input = Py_None; Py_INCREF(Py_None);
5667 return o;
5668 }
5669
__pyx_tp_dealloc_6gensim_7corpora_9_mmreader_MmReader(PyObject * o)5670 static void __pyx_tp_dealloc_6gensim_7corpora_9_mmreader_MmReader(PyObject *o) {
5671 struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *p = (struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *)o;
5672 #if CYTHON_USE_TP_FINALIZE
5673 if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
5674 if (PyObject_CallFinalizerFromDealloc(o)) return;
5675 }
5676 #endif
5677 PyObject_GC_UnTrack(o);
5678 Py_CLEAR(p->input);
5679 (*Py_TYPE(o)->tp_free)(o);
5680 }
5681
__pyx_tp_traverse_6gensim_7corpora_9_mmreader_MmReader(PyObject * o,visitproc v,void * a)5682 static int __pyx_tp_traverse_6gensim_7corpora_9_mmreader_MmReader(PyObject *o, visitproc v, void *a) {
5683 int e;
5684 struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *p = (struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *)o;
5685 if (p->input) {
5686 e = (*v)(p->input, a); if (e) return e;
5687 }
5688 return 0;
5689 }
5690
__pyx_tp_clear_6gensim_7corpora_9_mmreader_MmReader(PyObject * o)5691 static int __pyx_tp_clear_6gensim_7corpora_9_mmreader_MmReader(PyObject *o) {
5692 PyObject* tmp;
5693 struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *p = (struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader *)o;
5694 tmp = ((PyObject*)p->input);
5695 p->input = Py_None; Py_INCREF(Py_None);
5696 Py_XDECREF(tmp);
5697 return 0;
5698 }
5699
__pyx_getprop_6gensim_7corpora_9_mmreader_8MmReader_input(PyObject * o,CYTHON_UNUSED void * x)5700 static PyObject *__pyx_getprop_6gensim_7corpora_9_mmreader_8MmReader_input(PyObject *o, CYTHON_UNUSED void *x) {
5701 return __pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_5input_1__get__(o);
5702 }
5703
__pyx_setprop_6gensim_7corpora_9_mmreader_8MmReader_input(PyObject * o,PyObject * v,CYTHON_UNUSED void * x)5704 static int __pyx_setprop_6gensim_7corpora_9_mmreader_8MmReader_input(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
5705 if (v) {
5706 return __pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_5input_3__set__(o, v);
5707 }
5708 else {
5709 return __pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_5input_5__del__(o);
5710 }
5711 }
5712
__pyx_getprop_6gensim_7corpora_9_mmreader_8MmReader_transposed(PyObject * o,CYTHON_UNUSED void * x)5713 static PyObject *__pyx_getprop_6gensim_7corpora_9_mmreader_8MmReader_transposed(PyObject *o, CYTHON_UNUSED void *x) {
5714 return __pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_10transposed_1__get__(o);
5715 }
5716
__pyx_setprop_6gensim_7corpora_9_mmreader_8MmReader_transposed(PyObject * o,PyObject * v,CYTHON_UNUSED void * x)5717 static int __pyx_setprop_6gensim_7corpora_9_mmreader_8MmReader_transposed(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
5718 if (v) {
5719 return __pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_10transposed_3__set__(o, v);
5720 }
5721 else {
5722 PyErr_SetString(PyExc_NotImplementedError, "__del__");
5723 return -1;
5724 }
5725 }
5726
__pyx_getprop_6gensim_7corpora_9_mmreader_8MmReader_num_docs(PyObject * o,CYTHON_UNUSED void * x)5727 static PyObject *__pyx_getprop_6gensim_7corpora_9_mmreader_8MmReader_num_docs(PyObject *o, CYTHON_UNUSED void *x) {
5728 return __pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_8num_docs_1__get__(o);
5729 }
5730
__pyx_setprop_6gensim_7corpora_9_mmreader_8MmReader_num_docs(PyObject * o,PyObject * v,CYTHON_UNUSED void * x)5731 static int __pyx_setprop_6gensim_7corpora_9_mmreader_8MmReader_num_docs(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
5732 if (v) {
5733 return __pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_8num_docs_3__set__(o, v);
5734 }
5735 else {
5736 PyErr_SetString(PyExc_NotImplementedError, "__del__");
5737 return -1;
5738 }
5739 }
5740
__pyx_getprop_6gensim_7corpora_9_mmreader_8MmReader_num_terms(PyObject * o,CYTHON_UNUSED void * x)5741 static PyObject *__pyx_getprop_6gensim_7corpora_9_mmreader_8MmReader_num_terms(PyObject *o, CYTHON_UNUSED void *x) {
5742 return __pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_9num_terms_1__get__(o);
5743 }
5744
__pyx_setprop_6gensim_7corpora_9_mmreader_8MmReader_num_terms(PyObject * o,PyObject * v,CYTHON_UNUSED void * x)5745 static int __pyx_setprop_6gensim_7corpora_9_mmreader_8MmReader_num_terms(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
5746 if (v) {
5747 return __pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_9num_terms_3__set__(o, v);
5748 }
5749 else {
5750 PyErr_SetString(PyExc_NotImplementedError, "__del__");
5751 return -1;
5752 }
5753 }
5754
__pyx_getprop_6gensim_7corpora_9_mmreader_8MmReader_num_nnz(PyObject * o,CYTHON_UNUSED void * x)5755 static PyObject *__pyx_getprop_6gensim_7corpora_9_mmreader_8MmReader_num_nnz(PyObject *o, CYTHON_UNUSED void *x) {
5756 return __pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_7num_nnz_1__get__(o);
5757 }
5758
__pyx_setprop_6gensim_7corpora_9_mmreader_8MmReader_num_nnz(PyObject * o,PyObject * v,CYTHON_UNUSED void * x)5759 static int __pyx_setprop_6gensim_7corpora_9_mmreader_8MmReader_num_nnz(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
5760 if (v) {
5761 return __pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_7num_nnz_3__set__(o, v);
5762 }
5763 else {
5764 PyErr_SetString(PyExc_NotImplementedError, "__del__");
5765 return -1;
5766 }
5767 }
5768
5769 static PyMethodDef __pyx_methods_6gensim_7corpora_9_mmreader_MmReader[] = {
5770 {"skip_headers", (PyCFunction)__pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_7skip_headers, METH_O, __pyx_doc_6gensim_7corpora_9_mmreader_8MmReader_6skip_headers},
5771 {"docbyoffset", (PyCFunction)__pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_12docbyoffset, METH_O, __pyx_doc_6gensim_7corpora_9_mmreader_8MmReader_11docbyoffset},
5772 {"__reduce_cython__", (PyCFunction)__pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_14__reduce_cython__, METH_NOARGS, __pyx_doc_6gensim_7corpora_9_mmreader_8MmReader_13__reduce_cython__},
5773 {"__setstate_cython__", (PyCFunction)__pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_16__setstate_cython__, METH_O, __pyx_doc_6gensim_7corpora_9_mmreader_8MmReader_15__setstate_cython__},
5774 {0, 0, 0, 0}
5775 };
5776
5777 static struct PyGetSetDef __pyx_getsets_6gensim_7corpora_9_mmreader_MmReader[] = {
5778 {(char *)"input", __pyx_getprop_6gensim_7corpora_9_mmreader_8MmReader_input, __pyx_setprop_6gensim_7corpora_9_mmreader_8MmReader_input, (char *)"input: object", 0},
5779 {(char *)"transposed", __pyx_getprop_6gensim_7corpora_9_mmreader_8MmReader_transposed, __pyx_setprop_6gensim_7corpora_9_mmreader_8MmReader_transposed, (char *)"transposed: 'bool'", 0},
5780 {(char *)"num_docs", __pyx_getprop_6gensim_7corpora_9_mmreader_8MmReader_num_docs, __pyx_setprop_6gensim_7corpora_9_mmreader_8MmReader_num_docs, (char *)"num_docs: 'long long'", 0},
5781 {(char *)"num_terms", __pyx_getprop_6gensim_7corpora_9_mmreader_8MmReader_num_terms, __pyx_setprop_6gensim_7corpora_9_mmreader_8MmReader_num_terms, (char *)"num_terms: 'long long'", 0},
5782 {(char *)"num_nnz", __pyx_getprop_6gensim_7corpora_9_mmreader_8MmReader_num_nnz, __pyx_setprop_6gensim_7corpora_9_mmreader_8MmReader_num_nnz, (char *)"num_nnz: 'long long'", 0},
5783 {0, 0, 0, 0, 0}
5784 };
5785
5786 static PySequenceMethods __pyx_tp_as_sequence_MmReader = {
5787 __pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_3__len__, /*sq_length*/
5788 0, /*sq_concat*/
5789 0, /*sq_repeat*/
5790 0, /*sq_item*/
5791 0, /*sq_slice*/
5792 0, /*sq_ass_item*/
5793 0, /*sq_ass_slice*/
5794 0, /*sq_contains*/
5795 0, /*sq_inplace_concat*/
5796 0, /*sq_inplace_repeat*/
5797 };
5798
5799 static PyMappingMethods __pyx_tp_as_mapping_MmReader = {
5800 __pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_3__len__, /*mp_length*/
5801 0, /*mp_subscript*/
5802 0, /*mp_ass_subscript*/
5803 };
5804
5805 static PyTypeObject __pyx_type_6gensim_7corpora_9_mmreader_MmReader = {
5806 PyVarObject_HEAD_INIT(0, 0)
5807 "gensim.corpora._mmreader.MmReader", /*tp_name*/
5808 sizeof(struct __pyx_obj_6gensim_7corpora_9_mmreader_MmReader), /*tp_basicsize*/
5809 0, /*tp_itemsize*/
5810 __pyx_tp_dealloc_6gensim_7corpora_9_mmreader_MmReader, /*tp_dealloc*/
5811 #if PY_VERSION_HEX < 0x030800b4
5812 0, /*tp_print*/
5813 #endif
5814 #if PY_VERSION_HEX >= 0x030800b4
5815 0, /*tp_vectorcall_offset*/
5816 #endif
5817 0, /*tp_getattr*/
5818 0, /*tp_setattr*/
5819 #if PY_MAJOR_VERSION < 3
5820 0, /*tp_compare*/
5821 #endif
5822 #if PY_MAJOR_VERSION >= 3
5823 0, /*tp_as_async*/
5824 #endif
5825 0, /*tp_repr*/
5826 0, /*tp_as_number*/
5827 &__pyx_tp_as_sequence_MmReader, /*tp_as_sequence*/
5828 &__pyx_tp_as_mapping_MmReader, /*tp_as_mapping*/
5829 0, /*tp_hash*/
5830 0, /*tp_call*/
5831 __pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_5__str__, /*tp_str*/
5832 0, /*tp_getattro*/
5833 0, /*tp_setattro*/
5834 0, /*tp_as_buffer*/
5835 Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
5836 "MmReader(input, transposed=True)\nMatrix market file reader (fast Cython version), used internally in :class:`~gensim.corpora.mmcorpus.MmCorpus`.\n\n Wrap a term-document matrix on disk (in matrix-market format), and present it\n as an object which supports iteration over the rows (~documents).\n\n Notes\n -----\n Note that the file is read into memory one document at a time, not the whole matrix at once\n (unlike e.g. `scipy.io.mmread` and other implementations).\n This allows us to process corpora which are larger than the available RAM.\n\n ", /*tp_doc*/
5837 __pyx_tp_traverse_6gensim_7corpora_9_mmreader_MmReader, /*tp_traverse*/
5838 __pyx_tp_clear_6gensim_7corpora_9_mmreader_MmReader, /*tp_clear*/
5839 0, /*tp_richcompare*/
5840 0, /*tp_weaklistoffset*/
5841 __pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_9__iter__, /*tp_iter*/
5842 0, /*tp_iternext*/
5843 __pyx_methods_6gensim_7corpora_9_mmreader_MmReader, /*tp_methods*/
5844 0, /*tp_members*/
5845 __pyx_getsets_6gensim_7corpora_9_mmreader_MmReader, /*tp_getset*/
5846 0, /*tp_base*/
5847 0, /*tp_dict*/
5848 0, /*tp_descr_get*/
5849 0, /*tp_descr_set*/
5850 0, /*tp_dictoffset*/
5851 __pyx_pw_6gensim_7corpora_9_mmreader_8MmReader_1__init__, /*tp_init*/
5852 0, /*tp_alloc*/
5853 __pyx_tp_new_6gensim_7corpora_9_mmreader_MmReader, /*tp_new*/
5854 0, /*tp_free*/
5855 0, /*tp_is_gc*/
5856 0, /*tp_bases*/
5857 0, /*tp_mro*/
5858 0, /*tp_cache*/
5859 0, /*tp_subclasses*/
5860 0, /*tp_weaklist*/
5861 0, /*tp_del*/
5862 0, /*tp_version_tag*/
5863 #if PY_VERSION_HEX >= 0x030400a1
5864 0, /*tp_finalize*/
5865 #endif
5866 #if PY_VERSION_HEX >= 0x030800b1
5867 0, /*tp_vectorcall*/
5868 #endif
5869 #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
5870 0, /*tp_print*/
5871 #endif
5872 };
5873
5874 static struct __pyx_obj_6gensim_7corpora_9_mmreader___pyx_scope_struct____init__ *__pyx_freelist_6gensim_7corpora_9_mmreader___pyx_scope_struct____init__[8];
5875 static int __pyx_freecount_6gensim_7corpora_9_mmreader___pyx_scope_struct____init__ = 0;
5876
__pyx_tp_new_6gensim_7corpora_9_mmreader___pyx_scope_struct____init__(PyTypeObject * t,CYTHON_UNUSED PyObject * a,CYTHON_UNUSED PyObject * k)5877 static PyObject *__pyx_tp_new_6gensim_7corpora_9_mmreader___pyx_scope_struct____init__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
5878 PyObject *o;
5879 if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_6gensim_7corpora_9_mmreader___pyx_scope_struct____init__ > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_6gensim_7corpora_9_mmreader___pyx_scope_struct____init__)))) {
5880 o = (PyObject*)__pyx_freelist_6gensim_7corpora_9_mmreader___pyx_scope_struct____init__[--__pyx_freecount_6gensim_7corpora_9_mmreader___pyx_scope_struct____init__];
5881 memset(o, 0, sizeof(struct __pyx_obj_6gensim_7corpora_9_mmreader___pyx_scope_struct____init__));
5882 (void) PyObject_INIT(o, t);
5883 PyObject_GC_Track(o);
5884 } else {
5885 o = (*t->tp_alloc)(t, 0);
5886 if (unlikely(!o)) return 0;
5887 }
5888 return o;
5889 }
5890
__pyx_tp_dealloc_6gensim_7corpora_9_mmreader___pyx_scope_struct____init__(PyObject * o)5891 static void __pyx_tp_dealloc_6gensim_7corpora_9_mmreader___pyx_scope_struct____init__(PyObject *o) {
5892 struct __pyx_obj_6gensim_7corpora_9_mmreader___pyx_scope_struct____init__ *p = (struct __pyx_obj_6gensim_7corpora_9_mmreader___pyx_scope_struct____init__ *)o;
5893 PyObject_GC_UnTrack(o);
5894 Py_CLEAR(p->__pyx_v_line);
5895 if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_6gensim_7corpora_9_mmreader___pyx_scope_struct____init__ < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_6gensim_7corpora_9_mmreader___pyx_scope_struct____init__)))) {
5896 __pyx_freelist_6gensim_7corpora_9_mmreader___pyx_scope_struct____init__[__pyx_freecount_6gensim_7corpora_9_mmreader___pyx_scope_struct____init__++] = ((struct __pyx_obj_6gensim_7corpora_9_mmreader___pyx_scope_struct____init__ *)o);
5897 } else {
5898 (*Py_TYPE(o)->tp_free)(o);
5899 }
5900 }
5901
__pyx_tp_traverse_6gensim_7corpora_9_mmreader___pyx_scope_struct____init__(PyObject * o,visitproc v,void * a)5902 static int __pyx_tp_traverse_6gensim_7corpora_9_mmreader___pyx_scope_struct____init__(PyObject *o, visitproc v, void *a) {
5903 int e;
5904 struct __pyx_obj_6gensim_7corpora_9_mmreader___pyx_scope_struct____init__ *p = (struct __pyx_obj_6gensim_7corpora_9_mmreader___pyx_scope_struct____init__ *)o;
5905 if (p->__pyx_v_line) {
5906 e = (*v)(p->__pyx_v_line, a); if (e) return e;
5907 }
5908 return 0;
5909 }
5910
__pyx_tp_clear_6gensim_7corpora_9_mmreader___pyx_scope_struct____init__(PyObject * o)5911 static int __pyx_tp_clear_6gensim_7corpora_9_mmreader___pyx_scope_struct____init__(PyObject *o) {
5912 PyObject* tmp;
5913 struct __pyx_obj_6gensim_7corpora_9_mmreader___pyx_scope_struct____init__ *p = (struct __pyx_obj_6gensim_7corpora_9_mmreader___pyx_scope_struct____init__ *)o;
5914 tmp = ((PyObject*)p->__pyx_v_line);
5915 p->__pyx_v_line = Py_None; Py_INCREF(Py_None);
5916 Py_XDECREF(tmp);
5917 return 0;
5918 }
5919
5920 static PyTypeObject __pyx_type_6gensim_7corpora_9_mmreader___pyx_scope_struct____init__ = {
5921 PyVarObject_HEAD_INIT(0, 0)
5922 "gensim.corpora._mmreader.__pyx_scope_struct____init__", /*tp_name*/
5923 sizeof(struct __pyx_obj_6gensim_7corpora_9_mmreader___pyx_scope_struct____init__), /*tp_basicsize*/
5924 0, /*tp_itemsize*/
5925 __pyx_tp_dealloc_6gensim_7corpora_9_mmreader___pyx_scope_struct____init__, /*tp_dealloc*/
5926 #if PY_VERSION_HEX < 0x030800b4
5927 0, /*tp_print*/
5928 #endif
5929 #if PY_VERSION_HEX >= 0x030800b4
5930 0, /*tp_vectorcall_offset*/
5931 #endif
5932 0, /*tp_getattr*/
5933 0, /*tp_setattr*/
5934 #if PY_MAJOR_VERSION < 3
5935 0, /*tp_compare*/
5936 #endif
5937 #if PY_MAJOR_VERSION >= 3
5938 0, /*tp_as_async*/
5939 #endif
5940 0, /*tp_repr*/
5941 0, /*tp_as_number*/
5942 0, /*tp_as_sequence*/
5943 0, /*tp_as_mapping*/
5944 0, /*tp_hash*/
5945 0, /*tp_call*/
5946 0, /*tp_str*/
5947 0, /*tp_getattro*/
5948 0, /*tp_setattro*/
5949 0, /*tp_as_buffer*/
5950 Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
5951 0, /*tp_doc*/
5952 __pyx_tp_traverse_6gensim_7corpora_9_mmreader___pyx_scope_struct____init__, /*tp_traverse*/
5953 __pyx_tp_clear_6gensim_7corpora_9_mmreader___pyx_scope_struct____init__, /*tp_clear*/
5954 0, /*tp_richcompare*/
5955 0, /*tp_weaklistoffset*/
5956 0, /*tp_iter*/
5957 0, /*tp_iternext*/
5958 0, /*tp_methods*/
5959 0, /*tp_members*/
5960 0, /*tp_getset*/
5961 0, /*tp_base*/
5962 0, /*tp_dict*/
5963 0, /*tp_descr_get*/
5964 0, /*tp_descr_set*/
5965 0, /*tp_dictoffset*/
5966 0, /*tp_init*/
5967 0, /*tp_alloc*/
5968 __pyx_tp_new_6gensim_7corpora_9_mmreader___pyx_scope_struct____init__, /*tp_new*/
5969 0, /*tp_free*/
5970 0, /*tp_is_gc*/
5971 0, /*tp_bases*/
5972 0, /*tp_mro*/
5973 0, /*tp_cache*/
5974 0, /*tp_subclasses*/
5975 0, /*tp_weaklist*/
5976 0, /*tp_del*/
5977 0, /*tp_version_tag*/
5978 #if PY_VERSION_HEX >= 0x030400a1
5979 0, /*tp_finalize*/
5980 #endif
5981 #if PY_VERSION_HEX >= 0x030800b1
5982 0, /*tp_vectorcall*/
5983 #endif
5984 #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
5985 0, /*tp_print*/
5986 #endif
5987 };
5988
5989 static struct __pyx_obj_6gensim_7corpora_9_mmreader___pyx_scope_struct_1_genexpr *__pyx_freelist_6gensim_7corpora_9_mmreader___pyx_scope_struct_1_genexpr[8];
5990 static int __pyx_freecount_6gensim_7corpora_9_mmreader___pyx_scope_struct_1_genexpr = 0;
5991
__pyx_tp_new_6gensim_7corpora_9_mmreader___pyx_scope_struct_1_genexpr(PyTypeObject * t,CYTHON_UNUSED PyObject * a,CYTHON_UNUSED PyObject * k)5992 static PyObject *__pyx_tp_new_6gensim_7corpora_9_mmreader___pyx_scope_struct_1_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
5993 PyObject *o;
5994 if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_6gensim_7corpora_9_mmreader___pyx_scope_struct_1_genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_6gensim_7corpora_9_mmreader___pyx_scope_struct_1_genexpr)))) {
5995 o = (PyObject*)__pyx_freelist_6gensim_7corpora_9_mmreader___pyx_scope_struct_1_genexpr[--__pyx_freecount_6gensim_7corpora_9_mmreader___pyx_scope_struct_1_genexpr];
5996 memset(o, 0, sizeof(struct __pyx_obj_6gensim_7corpora_9_mmreader___pyx_scope_struct_1_genexpr));
5997 (void) PyObject_INIT(o, t);
5998 PyObject_GC_Track(o);
5999 } else {
6000 o = (*t->tp_alloc)(t, 0);
6001 if (unlikely(!o)) return 0;
6002 }
6003 return o;
6004 }
6005
__pyx_tp_dealloc_6gensim_7corpora_9_mmreader___pyx_scope_struct_1_genexpr(PyObject * o)6006 static void __pyx_tp_dealloc_6gensim_7corpora_9_mmreader___pyx_scope_struct_1_genexpr(PyObject *o) {
6007 struct __pyx_obj_6gensim_7corpora_9_mmreader___pyx_scope_struct_1_genexpr *p = (struct __pyx_obj_6gensim_7corpora_9_mmreader___pyx_scope_struct_1_genexpr *)o;
6008 PyObject_GC_UnTrack(o);
6009 Py_CLEAR(p->__pyx_outer_scope);
6010 Py_CLEAR(p->__pyx_v_x);
6011 Py_CLEAR(p->__pyx_t_0);
6012 if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_6gensim_7corpora_9_mmreader___pyx_scope_struct_1_genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_6gensim_7corpora_9_mmreader___pyx_scope_struct_1_genexpr)))) {
6013 __pyx_freelist_6gensim_7corpora_9_mmreader___pyx_scope_struct_1_genexpr[__pyx_freecount_6gensim_7corpora_9_mmreader___pyx_scope_struct_1_genexpr++] = ((struct __pyx_obj_6gensim_7corpora_9_mmreader___pyx_scope_struct_1_genexpr *)o);
6014 } else {
6015 (*Py_TYPE(o)->tp_free)(o);
6016 }
6017 }
6018
__pyx_tp_traverse_6gensim_7corpora_9_mmreader___pyx_scope_struct_1_genexpr(PyObject * o,visitproc v,void * a)6019 static int __pyx_tp_traverse_6gensim_7corpora_9_mmreader___pyx_scope_struct_1_genexpr(PyObject *o, visitproc v, void *a) {
6020 int e;
6021 struct __pyx_obj_6gensim_7corpora_9_mmreader___pyx_scope_struct_1_genexpr *p = (struct __pyx_obj_6gensim_7corpora_9_mmreader___pyx_scope_struct_1_genexpr *)o;
6022 if (p->__pyx_outer_scope) {
6023 e = (*v)(((PyObject *)p->__pyx_outer_scope), a); if (e) return e;
6024 }
6025 if (p->__pyx_v_x) {
6026 e = (*v)(p->__pyx_v_x, a); if (e) return e;
6027 }
6028 if (p->__pyx_t_0) {
6029 e = (*v)(p->__pyx_t_0, a); if (e) return e;
6030 }
6031 return 0;
6032 }
6033
6034 static PyTypeObject __pyx_type_6gensim_7corpora_9_mmreader___pyx_scope_struct_1_genexpr = {
6035 PyVarObject_HEAD_INIT(0, 0)
6036 "gensim.corpora._mmreader.__pyx_scope_struct_1_genexpr", /*tp_name*/
6037 sizeof(struct __pyx_obj_6gensim_7corpora_9_mmreader___pyx_scope_struct_1_genexpr), /*tp_basicsize*/
6038 0, /*tp_itemsize*/
6039 __pyx_tp_dealloc_6gensim_7corpora_9_mmreader___pyx_scope_struct_1_genexpr, /*tp_dealloc*/
6040 #if PY_VERSION_HEX < 0x030800b4
6041 0, /*tp_print*/
6042 #endif
6043 #if PY_VERSION_HEX >= 0x030800b4
6044 0, /*tp_vectorcall_offset*/
6045 #endif
6046 0, /*tp_getattr*/
6047 0, /*tp_setattr*/
6048 #if PY_MAJOR_VERSION < 3
6049 0, /*tp_compare*/
6050 #endif
6051 #if PY_MAJOR_VERSION >= 3
6052 0, /*tp_as_async*/
6053 #endif
6054 0, /*tp_repr*/
6055 0, /*tp_as_number*/
6056 0, /*tp_as_sequence*/
6057 0, /*tp_as_mapping*/
6058 0, /*tp_hash*/
6059 0, /*tp_call*/
6060 0, /*tp_str*/
6061 0, /*tp_getattro*/
6062 0, /*tp_setattro*/
6063 0, /*tp_as_buffer*/
6064 Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
6065 0, /*tp_doc*/
6066 __pyx_tp_traverse_6gensim_7corpora_9_mmreader___pyx_scope_struct_1_genexpr, /*tp_traverse*/
6067 0, /*tp_clear*/
6068 0, /*tp_richcompare*/
6069 0, /*tp_weaklistoffset*/
6070 0, /*tp_iter*/
6071 0, /*tp_iternext*/
6072 0, /*tp_methods*/
6073 0, /*tp_members*/
6074 0, /*tp_getset*/
6075 0, /*tp_base*/
6076 0, /*tp_dict*/
6077 0, /*tp_descr_get*/
6078 0, /*tp_descr_set*/
6079 0, /*tp_dictoffset*/
6080 0, /*tp_init*/
6081 0, /*tp_alloc*/
6082 __pyx_tp_new_6gensim_7corpora_9_mmreader___pyx_scope_struct_1_genexpr, /*tp_new*/
6083 0, /*tp_free*/
6084 0, /*tp_is_gc*/
6085 0, /*tp_bases*/
6086 0, /*tp_mro*/
6087 0, /*tp_cache*/
6088 0, /*tp_subclasses*/
6089 0, /*tp_weaklist*/
6090 0, /*tp_del*/
6091 0, /*tp_version_tag*/
6092 #if PY_VERSION_HEX >= 0x030400a1
6093 0, /*tp_finalize*/
6094 #endif
6095 #if PY_VERSION_HEX >= 0x030800b1
6096 0, /*tp_vectorcall*/
6097 #endif
6098 #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
6099 0, /*tp_print*/
6100 #endif
6101 };
6102
6103 static struct __pyx_obj_6gensim_7corpora_9_mmreader___pyx_scope_struct_2___iter__ *__pyx_freelist_6gensim_7corpora_9_mmreader___pyx_scope_struct_2___iter__[8];
6104 static int __pyx_freecount_6gensim_7corpora_9_mmreader___pyx_scope_struct_2___iter__ = 0;
6105
__pyx_tp_new_6gensim_7corpora_9_mmreader___pyx_scope_struct_2___iter__(PyTypeObject * t,CYTHON_UNUSED PyObject * a,CYTHON_UNUSED PyObject * k)6106 static PyObject *__pyx_tp_new_6gensim_7corpora_9_mmreader___pyx_scope_struct_2___iter__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
6107 PyObject *o;
6108 if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_6gensim_7corpora_9_mmreader___pyx_scope_struct_2___iter__ > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_6gensim_7corpora_9_mmreader___pyx_scope_struct_2___iter__)))) {
6109 o = (PyObject*)__pyx_freelist_6gensim_7corpora_9_mmreader___pyx_scope_struct_2___iter__[--__pyx_freecount_6gensim_7corpora_9_mmreader___pyx_scope_struct_2___iter__];
6110 memset(o, 0, sizeof(struct __pyx_obj_6gensim_7corpora_9_mmreader___pyx_scope_struct_2___iter__));
6111 (void) PyObject_INIT(o, t);
6112 PyObject_GC_Track(o);
6113 } else {
6114 o = (*t->tp_alloc)(t, 0);
6115 if (unlikely(!o)) return 0;
6116 }
6117 return o;
6118 }
6119
__pyx_tp_dealloc_6gensim_7corpora_9_mmreader___pyx_scope_struct_2___iter__(PyObject * o)6120 static void __pyx_tp_dealloc_6gensim_7corpora_9_mmreader___pyx_scope_struct_2___iter__(PyObject *o) {
6121 struct __pyx_obj_6gensim_7corpora_9_mmreader___pyx_scope_struct_2___iter__ *p = (struct __pyx_obj_6gensim_7corpora_9_mmreader___pyx_scope_struct_2___iter__ *)o;
6122 PyObject_GC_UnTrack(o);
6123 Py_CLEAR(p->__pyx_v_document);
6124 Py_CLEAR(p->__pyx_v_line);
6125 Py_CLEAR(p->__pyx_v_lines);
6126 Py_CLEAR(p->__pyx_v_self);
6127 Py_CLEAR(p->__pyx_t_0);
6128 Py_CLEAR(p->__pyx_t_1);
6129 Py_CLEAR(p->__pyx_t_2);
6130 Py_CLEAR(p->__pyx_t_3);
6131 Py_CLEAR(p->__pyx_t_4);
6132 if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_6gensim_7corpora_9_mmreader___pyx_scope_struct_2___iter__ < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_6gensim_7corpora_9_mmreader___pyx_scope_struct_2___iter__)))) {
6133 __pyx_freelist_6gensim_7corpora_9_mmreader___pyx_scope_struct_2___iter__[__pyx_freecount_6gensim_7corpora_9_mmreader___pyx_scope_struct_2___iter__++] = ((struct __pyx_obj_6gensim_7corpora_9_mmreader___pyx_scope_struct_2___iter__ *)o);
6134 } else {
6135 (*Py_TYPE(o)->tp_free)(o);
6136 }
6137 }
6138
__pyx_tp_traverse_6gensim_7corpora_9_mmreader___pyx_scope_struct_2___iter__(PyObject * o,visitproc v,void * a)6139 static int __pyx_tp_traverse_6gensim_7corpora_9_mmreader___pyx_scope_struct_2___iter__(PyObject *o, visitproc v, void *a) {
6140 int e;
6141 struct __pyx_obj_6gensim_7corpora_9_mmreader___pyx_scope_struct_2___iter__ *p = (struct __pyx_obj_6gensim_7corpora_9_mmreader___pyx_scope_struct_2___iter__ *)o;
6142 if (p->__pyx_v_document) {
6143 e = (*v)(p->__pyx_v_document, a); if (e) return e;
6144 }
6145 if (p->__pyx_v_line) {
6146 e = (*v)(p->__pyx_v_line, a); if (e) return e;
6147 }
6148 if (p->__pyx_v_lines) {
6149 e = (*v)(p->__pyx_v_lines, a); if (e) return e;
6150 }
6151 if (p->__pyx_v_self) {
6152 e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
6153 }
6154 if (p->__pyx_t_0) {
6155 e = (*v)(p->__pyx_t_0, a); if (e) return e;
6156 }
6157 if (p->__pyx_t_1) {
6158 e = (*v)(p->__pyx_t_1, a); if (e) return e;
6159 }
6160 if (p->__pyx_t_2) {
6161 e = (*v)(p->__pyx_t_2, a); if (e) return e;
6162 }
6163 if (p->__pyx_t_3) {
6164 e = (*v)(p->__pyx_t_3, a); if (e) return e;
6165 }
6166 if (p->__pyx_t_4) {
6167 e = (*v)(p->__pyx_t_4, a); if (e) return e;
6168 }
6169 return 0;
6170 }
6171
6172 static PyTypeObject __pyx_type_6gensim_7corpora_9_mmreader___pyx_scope_struct_2___iter__ = {
6173 PyVarObject_HEAD_INIT(0, 0)
6174 "gensim.corpora._mmreader.__pyx_scope_struct_2___iter__", /*tp_name*/
6175 sizeof(struct __pyx_obj_6gensim_7corpora_9_mmreader___pyx_scope_struct_2___iter__), /*tp_basicsize*/
6176 0, /*tp_itemsize*/
6177 __pyx_tp_dealloc_6gensim_7corpora_9_mmreader___pyx_scope_struct_2___iter__, /*tp_dealloc*/
6178 #if PY_VERSION_HEX < 0x030800b4
6179 0, /*tp_print*/
6180 #endif
6181 #if PY_VERSION_HEX >= 0x030800b4
6182 0, /*tp_vectorcall_offset*/
6183 #endif
6184 0, /*tp_getattr*/
6185 0, /*tp_setattr*/
6186 #if PY_MAJOR_VERSION < 3
6187 0, /*tp_compare*/
6188 #endif
6189 #if PY_MAJOR_VERSION >= 3
6190 0, /*tp_as_async*/
6191 #endif
6192 0, /*tp_repr*/
6193 0, /*tp_as_number*/
6194 0, /*tp_as_sequence*/
6195 0, /*tp_as_mapping*/
6196 0, /*tp_hash*/
6197 0, /*tp_call*/
6198 0, /*tp_str*/
6199 0, /*tp_getattro*/
6200 0, /*tp_setattro*/
6201 0, /*tp_as_buffer*/
6202 Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
6203 0, /*tp_doc*/
6204 __pyx_tp_traverse_6gensim_7corpora_9_mmreader___pyx_scope_struct_2___iter__, /*tp_traverse*/
6205 0, /*tp_clear*/
6206 0, /*tp_richcompare*/
6207 0, /*tp_weaklistoffset*/
6208 0, /*tp_iter*/
6209 0, /*tp_iternext*/
6210 0, /*tp_methods*/
6211 0, /*tp_members*/
6212 0, /*tp_getset*/
6213 0, /*tp_base*/
6214 0, /*tp_dict*/
6215 0, /*tp_descr_get*/
6216 0, /*tp_descr_set*/
6217 0, /*tp_dictoffset*/
6218 0, /*tp_init*/
6219 0, /*tp_alloc*/
6220 __pyx_tp_new_6gensim_7corpora_9_mmreader___pyx_scope_struct_2___iter__, /*tp_new*/
6221 0, /*tp_free*/
6222 0, /*tp_is_gc*/
6223 0, /*tp_bases*/
6224 0, /*tp_mro*/
6225 0, /*tp_cache*/
6226 0, /*tp_subclasses*/
6227 0, /*tp_weaklist*/
6228 0, /*tp_del*/
6229 0, /*tp_version_tag*/
6230 #if PY_VERSION_HEX >= 0x030400a1
6231 0, /*tp_finalize*/
6232 #endif
6233 #if PY_VERSION_HEX >= 0x030800b1
6234 0, /*tp_vectorcall*/
6235 #endif
6236 #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
6237 0, /*tp_print*/
6238 #endif
6239 };
6240
6241 static PyMethodDef __pyx_methods[] = {
6242 {0, 0, 0, 0}
6243 };
6244
6245 #if PY_MAJOR_VERSION >= 3
6246 #if CYTHON_PEP489_MULTI_PHASE_INIT
6247 static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
6248 static int __pyx_pymod_exec__mmreader(PyObject* module); /*proto*/
6249 static PyModuleDef_Slot __pyx_moduledef_slots[] = {
6250 {Py_mod_create, (void*)__pyx_pymod_create},
6251 {Py_mod_exec, (void*)__pyx_pymod_exec__mmreader},
6252 {0, NULL}
6253 };
6254 #endif
6255
6256 static struct PyModuleDef __pyx_moduledef = {
6257 PyModuleDef_HEAD_INIT,
6258 "_mmreader",
6259 __pyx_k_Reader_for_corpus_in_the_Matrix, /* m_doc */
6260 #if CYTHON_PEP489_MULTI_PHASE_INIT
6261 0, /* m_size */
6262 #else
6263 -1, /* m_size */
6264 #endif
6265 __pyx_methods /* m_methods */,
6266 #if CYTHON_PEP489_MULTI_PHASE_INIT
6267 __pyx_moduledef_slots, /* m_slots */
6268 #else
6269 NULL, /* m_reload */
6270 #endif
6271 NULL, /* m_traverse */
6272 NULL, /* m_clear */
6273 NULL /* m_free */
6274 };
6275 #endif
6276 #ifndef CYTHON_SMALL_CODE
6277 #if defined(__clang__)
6278 #define CYTHON_SMALL_CODE
6279 #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
6280 #define CYTHON_SMALL_CODE __attribute__((cold))
6281 #else
6282 #define CYTHON_SMALL_CODE
6283 #endif
6284 #endif
6285
6286 static __Pyx_StringTabEntry __pyx_string_tab[] = {
6287 {&__pyx_kp_b_, __pyx_k_, sizeof(__pyx_k_), 0, 0, 0, 0},
6288 {&__pyx_kp_s_, __pyx_k_, sizeof(__pyx_k_), 0, 0, 1, 0},
6289 {&__pyx_kp_s_File_s_not_in_Matrix_Market_form, __pyx_k_File_s_not_in_Matrix_Market_form, sizeof(__pyx_k_File_s_not_in_Matrix_Market_form), 0, 0, 1, 0},
6290 {&__pyx_kp_s_Incompatible_checksums_s_vs_0xea, __pyx_k_Incompatible_checksums_s_vs_0xea, sizeof(__pyx_k_Incompatible_checksums_s_vs_0xea), 0, 0, 1, 0},
6291 {&__pyx_kp_s_MmCorpus_i_documents_i_features, __pyx_k_MmCorpus_i_documents_i_features, sizeof(__pyx_k_MmCorpus_i_documents_i_features), 0, 0, 1, 0},
6292 {&__pyx_n_s_MmReader, __pyx_k_MmReader, sizeof(__pyx_k_MmReader), 0, 0, 1, 1},
6293 {&__pyx_n_s_MmReader___iter, __pyx_k_MmReader___iter, sizeof(__pyx_k_MmReader___iter), 0, 0, 1, 1},
6294 {&__pyx_n_s_PickleError, __pyx_k_PickleError, sizeof(__pyx_k_PickleError), 0, 0, 1, 1},
6295 {&__pyx_n_s_StopIteration, __pyx_k_StopIteration, sizeof(__pyx_k_StopIteration), 0, 0, 1, 1},
6296 {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
6297 {&__pyx_kp_s_accepted_corpus_with_i_documents, __pyx_k_accepted_corpus_with_i_documents, sizeof(__pyx_k_accepted_corpus_with_i_documents), 0, 0, 1, 0},
6298 {&__pyx_n_s_args, __pyx_k_args, sizeof(__pyx_k_args), 0, 0, 1, 1},
6299 {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
6300 {&__pyx_n_s_close, __pyx_k_close, sizeof(__pyx_k_close), 0, 0, 1, 1},
6301 {&__pyx_n_s_dict, __pyx_k_dict, sizeof(__pyx_k_dict), 0, 0, 1, 1},
6302 {&__pyx_n_s_enter, __pyx_k_enter, sizeof(__pyx_k_enter), 0, 0, 1, 1},
6303 {&__pyx_n_s_enumerate, __pyx_k_enumerate, sizeof(__pyx_k_enumerate), 0, 0, 1, 1},
6304 {&__pyx_n_s_exit, __pyx_k_exit, sizeof(__pyx_k_exit), 0, 0, 1, 1},
6305 {&__pyx_n_s_file_or_filename, __pyx_k_file_or_filename, sizeof(__pyx_k_file_or_filename), 0, 0, 1, 1},
6306 {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1},
6307 {&__pyx_n_s_genexpr, __pyx_k_genexpr, sizeof(__pyx_k_genexpr), 0, 0, 1, 1},
6308 {&__pyx_n_s_gensim, __pyx_k_gensim, sizeof(__pyx_k_gensim), 0, 0, 1, 1},
6309 {&__pyx_n_s_gensim_corpora__mmreader, __pyx_k_gensim_corpora__mmreader, sizeof(__pyx_k_gensim_corpora__mmreader), 0, 0, 1, 1},
6310 {&__pyx_n_s_getLogger, __pyx_k_getLogger, sizeof(__pyx_k_getLogger), 0, 0, 1, 1},
6311 {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1},
6312 {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
6313 {&__pyx_n_s_info, __pyx_k_info, sizeof(__pyx_k_info), 0, 0, 1, 1},
6314 {&__pyx_n_s_init___locals_genexpr, __pyx_k_init___locals_genexpr, sizeof(__pyx_k_init___locals_genexpr), 0, 0, 1, 1},
6315 {&__pyx_kp_s_initializing_cython_corpus_reade, __pyx_k_initializing_cython_corpus_reade, sizeof(__pyx_k_initializing_cython_corpus_reade), 0, 0, 1, 0},
6316 {&__pyx_n_s_input, __pyx_k_input, sizeof(__pyx_k_input), 0, 0, 1, 1},
6317 {&__pyx_n_s_iter, __pyx_k_iter, sizeof(__pyx_k_iter), 0, 0, 1, 1},
6318 {&__pyx_n_s_logger, __pyx_k_logger, sizeof(__pyx_k_logger), 0, 0, 1, 1},
6319 {&__pyx_n_s_logging, __pyx_k_logging, sizeof(__pyx_k_logging), 0, 0, 1, 1},
6320 {&__pyx_n_s_lower, __pyx_k_lower, sizeof(__pyx_k_lower), 0, 0, 1, 1},
6321 {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
6322 {&__pyx_kp_s_matrix_columns_must_come_in_asce, __pyx_k_matrix_columns_must_come_in_asce, sizeof(__pyx_k_matrix_columns_must_come_in_asce), 0, 0, 1, 0},
6323 {&__pyx_kp_s_matrixmarket_matrix_coordinate, __pyx_k_matrixmarket_matrix_coordinate, sizeof(__pyx_k_matrixmarket_matrix_coordinate), 0, 0, 1, 0},
6324 {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
6325 {&__pyx_n_s_new, __pyx_k_new, sizeof(__pyx_k_new), 0, 0, 1, 1},
6326 {&__pyx_n_s_open, __pyx_k_open, sizeof(__pyx_k_open), 0, 0, 1, 1},
6327 {&__pyx_n_s_open_file, __pyx_k_open_file, sizeof(__pyx_k_open_file), 0, 0, 1, 1},
6328 {&__pyx_n_s_pickle, __pyx_k_pickle, sizeof(__pyx_k_pickle), 0, 0, 1, 1},
6329 {&__pyx_n_s_pyx_PickleError, __pyx_k_pyx_PickleError, sizeof(__pyx_k_pyx_PickleError), 0, 0, 1, 1},
6330 {&__pyx_n_s_pyx_checksum, __pyx_k_pyx_checksum, sizeof(__pyx_k_pyx_checksum), 0, 0, 1, 1},
6331 {&__pyx_n_s_pyx_result, __pyx_k_pyx_result, sizeof(__pyx_k_pyx_result), 0, 0, 1, 1},
6332 {&__pyx_n_s_pyx_state, __pyx_k_pyx_state, sizeof(__pyx_k_pyx_state), 0, 0, 1, 1},
6333 {&__pyx_n_s_pyx_type, __pyx_k_pyx_type, sizeof(__pyx_k_pyx_type), 0, 0, 1, 1},
6334 {&__pyx_n_s_pyx_unpickle_MmReader, __pyx_k_pyx_unpickle_MmReader, sizeof(__pyx_k_pyx_unpickle_MmReader), 0, 0, 1, 1},
6335 {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
6336 {&__pyx_n_s_rb, __pyx_k_rb, sizeof(__pyx_k_rb), 0, 0, 1, 1},
6337 {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1},
6338 {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1},
6339 {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1},
6340 {&__pyx_n_s_seek, __pyx_k_seek, sizeof(__pyx_k_seek), 0, 0, 1, 1},
6341 {&__pyx_n_s_send, __pyx_k_send, sizeof(__pyx_k_send), 0, 0, 1, 1},
6342 {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1},
6343 {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1},
6344 {&__pyx_n_s_skip_headers, __pyx_k_skip_headers, sizeof(__pyx_k_skip_headers), 0, 0, 1, 1},
6345 {&__pyx_n_s_split, __pyx_k_split, sizeof(__pyx_k_split), 0, 0, 1, 1},
6346 {&__pyx_n_s_startswith, __pyx_k_startswith, sizeof(__pyx_k_startswith), 0, 0, 1, 1},
6347 {&__pyx_kp_s_stringsource, __pyx_k_stringsource, sizeof(__pyx_k_stringsource), 0, 0, 1, 0},
6348 {&__pyx_n_s_strip, __pyx_k_strip, sizeof(__pyx_k_strip), 0, 0, 1, 1},
6349 {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
6350 {&__pyx_n_s_throw, __pyx_k_throw, sizeof(__pyx_k_throw), 0, 0, 1, 1},
6351 {&__pyx_n_s_to_unicode, __pyx_k_to_unicode, sizeof(__pyx_k_to_unicode), 0, 0, 1, 1},
6352 {&__pyx_n_s_transposed, __pyx_k_transposed, sizeof(__pyx_k_transposed), 0, 0, 1, 1},
6353 {&__pyx_kp_s_unable_to_parse_line, __pyx_k_unable_to_parse_line, sizeof(__pyx_k_unable_to_parse_line), 0, 0, 1, 0},
6354 {&__pyx_n_s_update, __pyx_k_update, sizeof(__pyx_k_update), 0, 0, 1, 1},
6355 {&__pyx_n_s_utils, __pyx_k_utils, sizeof(__pyx_k_utils), 0, 0, 1, 1},
6356 {0, 0, 0, 0, 0, 0, 0}
6357 };
__Pyx_InitCachedBuiltins(void)6358 static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
6359 __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 59, __pyx_L1_error)
6360 __pyx_builtin_StopIteration = __Pyx_GetBuiltinName(__pyx_n_s_StopIteration); if (!__pyx_builtin_StopIteration) __PYX_ERR(0, 63, __pyx_L1_error)
6361 __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) __PYX_ERR(0, 67, __pyx_L1_error)
6362 __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 144, __pyx_L1_error)
6363 return 0;
6364 __pyx_L1_error:;
6365 return -1;
6366 }
6367
__Pyx_InitCachedConstants(void)6368 static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
6369 __Pyx_RefNannyDeclarations
6370 __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
6371
6372 /* "gensim/corpora/_mmreader.pyx":55
6373 * logger.info("initializing cython corpus reader from %s", input)
6374 * self.input, self.transposed = input, transposed
6375 * with utils.open_file(self.input) as lines: # <<<<<<<<<<<<<<
6376 * try:
6377 * header = utils.to_unicode(next(lines)).strip()
6378 */
6379 __pyx_tuple__2 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 55, __pyx_L1_error)
6380 __Pyx_GOTREF(__pyx_tuple__2);
6381 __Pyx_GIVEREF(__pyx_tuple__2);
6382
6383 /* "(tree fragment)":1
6384 * def __pyx_unpickle_MmReader(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<<
6385 * cdef object __pyx_PickleError
6386 * cdef object __pyx_result
6387 */
6388 __pyx_tuple__3 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(1, 1, __pyx_L1_error)
6389 __Pyx_GOTREF(__pyx_tuple__3);
6390 __Pyx_GIVEREF(__pyx_tuple__3);
6391 __pyx_codeobj__4 = (PyObject*)__Pyx_PyCode_New(3, 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_stringsource, __pyx_n_s_pyx_unpickle_MmReader, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__4)) __PYX_ERR(1, 1, __pyx_L1_error)
6392 __Pyx_RefNannyFinishContext();
6393 return 0;
6394 __pyx_L1_error:;
6395 __Pyx_RefNannyFinishContext();
6396 return -1;
6397 }
6398
__Pyx_InitGlobals(void)6399 static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
6400 if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
6401 __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error)
6402 __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error)
6403 __pyx_int_245759634 = PyInt_FromLong(245759634L); if (unlikely(!__pyx_int_245759634)) __PYX_ERR(0, 1, __pyx_L1_error)
6404 __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) __PYX_ERR(0, 1, __pyx_L1_error)
6405 return 0;
6406 __pyx_L1_error:;
6407 return -1;
6408 }
6409
6410 static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/
6411 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/
6412 static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/
6413 static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/
6414 static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/
6415 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/
6416 static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/
6417
__Pyx_modinit_global_init_code(void)6418 static int __Pyx_modinit_global_init_code(void) {
6419 __Pyx_RefNannyDeclarations
6420 __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
6421 /*--- Global init code ---*/
6422 __Pyx_RefNannyFinishContext();
6423 return 0;
6424 }
6425
__Pyx_modinit_variable_export_code(void)6426 static int __Pyx_modinit_variable_export_code(void) {
6427 __Pyx_RefNannyDeclarations
6428 __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
6429 /*--- Variable export code ---*/
6430 __Pyx_RefNannyFinishContext();
6431 return 0;
6432 }
6433
__Pyx_modinit_function_export_code(void)6434 static int __Pyx_modinit_function_export_code(void) {
6435 __Pyx_RefNannyDeclarations
6436 __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
6437 /*--- Function export code ---*/
6438 __Pyx_RefNannyFinishContext();
6439 return 0;
6440 }
6441
__Pyx_modinit_type_init_code(void)6442 static int __Pyx_modinit_type_init_code(void) {
6443 __Pyx_RefNannyDeclarations
6444 int __pyx_lineno = 0;
6445 const char *__pyx_filename = NULL;
6446 int __pyx_clineno = 0;
6447 __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
6448 /*--- Type init code ---*/
6449 if (PyType_Ready(&__pyx_type_6gensim_7corpora_9_mmreader_MmReader) < 0) __PYX_ERR(0, 15, __pyx_L1_error)
6450 #if PY_VERSION_HEX < 0x030800B1
6451 __pyx_type_6gensim_7corpora_9_mmreader_MmReader.tp_print = 0;
6452 #endif
6453 if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6gensim_7corpora_9_mmreader_MmReader.tp_dictoffset && __pyx_type_6gensim_7corpora_9_mmreader_MmReader.tp_getattro == PyObject_GenericGetAttr)) {
6454 __pyx_type_6gensim_7corpora_9_mmreader_MmReader.tp_getattro = __Pyx_PyObject_GenericGetAttr;
6455 }
6456 #if CYTHON_COMPILING_IN_CPYTHON
6457 {
6458 PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_6gensim_7corpora_9_mmreader_MmReader, "__init__"); if (unlikely(!wrapper)) __PYX_ERR(0, 15, __pyx_L1_error)
6459 if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
6460 __pyx_wrapperbase_6gensim_7corpora_9_mmreader_8MmReader___init__ = *((PyWrapperDescrObject *)wrapper)->d_base;
6461 __pyx_wrapperbase_6gensim_7corpora_9_mmreader_8MmReader___init__.doc = __pyx_doc_6gensim_7corpora_9_mmreader_8MmReader___init__;
6462 ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_6gensim_7corpora_9_mmreader_8MmReader___init__;
6463 }
6464 }
6465 #endif
6466 #if CYTHON_COMPILING_IN_CPYTHON
6467 {
6468 PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_6gensim_7corpora_9_mmreader_MmReader, "__len__"); if (unlikely(!wrapper)) __PYX_ERR(0, 15, __pyx_L1_error)
6469 if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
6470 __pyx_wrapperbase_6gensim_7corpora_9_mmreader_8MmReader_2__len__ = *((PyWrapperDescrObject *)wrapper)->d_base;
6471 __pyx_wrapperbase_6gensim_7corpora_9_mmreader_8MmReader_2__len__.doc = __pyx_doc_6gensim_7corpora_9_mmreader_8MmReader_2__len__;
6472 ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_6gensim_7corpora_9_mmreader_8MmReader_2__len__;
6473 }
6474 }
6475 #endif
6476 #if CYTHON_COMPILING_IN_CPYTHON
6477 {
6478 PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_6gensim_7corpora_9_mmreader_MmReader, "__iter__"); if (unlikely(!wrapper)) __PYX_ERR(0, 15, __pyx_L1_error)
6479 if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
6480 __pyx_wrapperbase_6gensim_7corpora_9_mmreader_8MmReader_8__iter__ = *((PyWrapperDescrObject *)wrapper)->d_base;
6481 __pyx_wrapperbase_6gensim_7corpora_9_mmreader_8MmReader_8__iter__.doc = __pyx_doc_6gensim_7corpora_9_mmreader_8MmReader_8__iter__;
6482 ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_6gensim_7corpora_9_mmreader_8MmReader_8__iter__;
6483 }
6484 }
6485 #endif
6486 if (PyObject_SetAttr(__pyx_m, __pyx_n_s_MmReader, (PyObject *)&__pyx_type_6gensim_7corpora_9_mmreader_MmReader) < 0) __PYX_ERR(0, 15, __pyx_L1_error)
6487 if (__Pyx_setup_reduce((PyObject*)&__pyx_type_6gensim_7corpora_9_mmreader_MmReader) < 0) __PYX_ERR(0, 15, __pyx_L1_error)
6488 __pyx_ptype_6gensim_7corpora_9_mmreader_MmReader = &__pyx_type_6gensim_7corpora_9_mmreader_MmReader;
6489 if (PyType_Ready(&__pyx_type_6gensim_7corpora_9_mmreader___pyx_scope_struct____init__) < 0) __PYX_ERR(0, 40, __pyx_L1_error)
6490 #if PY_VERSION_HEX < 0x030800B1
6491 __pyx_type_6gensim_7corpora_9_mmreader___pyx_scope_struct____init__.tp_print = 0;
6492 #endif
6493 if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6gensim_7corpora_9_mmreader___pyx_scope_struct____init__.tp_dictoffset && __pyx_type_6gensim_7corpora_9_mmreader___pyx_scope_struct____init__.tp_getattro == PyObject_GenericGetAttr)) {
6494 __pyx_type_6gensim_7corpora_9_mmreader___pyx_scope_struct____init__.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
6495 }
6496 __pyx_ptype_6gensim_7corpora_9_mmreader___pyx_scope_struct____init__ = &__pyx_type_6gensim_7corpora_9_mmreader___pyx_scope_struct____init__;
6497 if (PyType_Ready(&__pyx_type_6gensim_7corpora_9_mmreader___pyx_scope_struct_1_genexpr) < 0) __PYX_ERR(0, 70, __pyx_L1_error)
6498 #if PY_VERSION_HEX < 0x030800B1
6499 __pyx_type_6gensim_7corpora_9_mmreader___pyx_scope_struct_1_genexpr.tp_print = 0;
6500 #endif
6501 if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6gensim_7corpora_9_mmreader___pyx_scope_struct_1_genexpr.tp_dictoffset && __pyx_type_6gensim_7corpora_9_mmreader___pyx_scope_struct_1_genexpr.tp_getattro == PyObject_GenericGetAttr)) {
6502 __pyx_type_6gensim_7corpora_9_mmreader___pyx_scope_struct_1_genexpr.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
6503 }
6504 __pyx_ptype_6gensim_7corpora_9_mmreader___pyx_scope_struct_1_genexpr = &__pyx_type_6gensim_7corpora_9_mmreader___pyx_scope_struct_1_genexpr;
6505 if (PyType_Ready(&__pyx_type_6gensim_7corpora_9_mmreader___pyx_scope_struct_2___iter__) < 0) __PYX_ERR(0, 102, __pyx_L1_error)
6506 #if PY_VERSION_HEX < 0x030800B1
6507 __pyx_type_6gensim_7corpora_9_mmreader___pyx_scope_struct_2___iter__.tp_print = 0;
6508 #endif
6509 if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_6gensim_7corpora_9_mmreader___pyx_scope_struct_2___iter__.tp_dictoffset && __pyx_type_6gensim_7corpora_9_mmreader___pyx_scope_struct_2___iter__.tp_getattro == PyObject_GenericGetAttr)) {
6510 __pyx_type_6gensim_7corpora_9_mmreader___pyx_scope_struct_2___iter__.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
6511 }
6512 __pyx_ptype_6gensim_7corpora_9_mmreader___pyx_scope_struct_2___iter__ = &__pyx_type_6gensim_7corpora_9_mmreader___pyx_scope_struct_2___iter__;
6513 __Pyx_RefNannyFinishContext();
6514 return 0;
6515 __pyx_L1_error:;
6516 __Pyx_RefNannyFinishContext();
6517 return -1;
6518 }
6519
__Pyx_modinit_type_import_code(void)6520 static int __Pyx_modinit_type_import_code(void) {
6521 __Pyx_RefNannyDeclarations
6522 __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
6523 /*--- Type import code ---*/
6524 __Pyx_RefNannyFinishContext();
6525 return 0;
6526 }
6527
__Pyx_modinit_variable_import_code(void)6528 static int __Pyx_modinit_variable_import_code(void) {
6529 __Pyx_RefNannyDeclarations
6530 __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
6531 /*--- Variable import code ---*/
6532 __Pyx_RefNannyFinishContext();
6533 return 0;
6534 }
6535
__Pyx_modinit_function_import_code(void)6536 static int __Pyx_modinit_function_import_code(void) {
6537 __Pyx_RefNannyDeclarations
6538 __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
6539 /*--- Function import code ---*/
6540 __Pyx_RefNannyFinishContext();
6541 return 0;
6542 }
6543
6544
6545 #ifndef CYTHON_NO_PYINIT_EXPORT
6546 #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
6547 #elif PY_MAJOR_VERSION < 3
6548 #ifdef __cplusplus
6549 #define __Pyx_PyMODINIT_FUNC extern "C" void
6550 #else
6551 #define __Pyx_PyMODINIT_FUNC void
6552 #endif
6553 #else
6554 #ifdef __cplusplus
6555 #define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
6556 #else
6557 #define __Pyx_PyMODINIT_FUNC PyObject *
6558 #endif
6559 #endif
6560
6561
6562 #if PY_MAJOR_VERSION < 3
6563 __Pyx_PyMODINIT_FUNC init_mmreader(void) CYTHON_SMALL_CODE; /*proto*/
init_mmreader(void)6564 __Pyx_PyMODINIT_FUNC init_mmreader(void)
6565 #else
6566 __Pyx_PyMODINIT_FUNC PyInit__mmreader(void) CYTHON_SMALL_CODE; /*proto*/
6567 __Pyx_PyMODINIT_FUNC PyInit__mmreader(void)
6568 #if CYTHON_PEP489_MULTI_PHASE_INIT
6569 {
6570 return PyModuleDef_Init(&__pyx_moduledef);
6571 }
6572 static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
6573 #if PY_VERSION_HEX >= 0x030700A1
6574 static PY_INT64_T main_interpreter_id = -1;
6575 PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
6576 if (main_interpreter_id == -1) {
6577 main_interpreter_id = current_id;
6578 return (unlikely(current_id == -1)) ? -1 : 0;
6579 } else if (unlikely(main_interpreter_id != current_id))
6580 #else
6581 static PyInterpreterState *main_interpreter = NULL;
6582 PyInterpreterState *current_interpreter = PyThreadState_Get()->interp;
6583 if (!main_interpreter) {
6584 main_interpreter = current_interpreter;
6585 } else if (unlikely(main_interpreter != current_interpreter))
6586 #endif
6587 {
6588 PyErr_SetString(
6589 PyExc_ImportError,
6590 "Interpreter change detected - this module can only be loaded into one interpreter per process.");
6591 return -1;
6592 }
6593 return 0;
6594 }
6595 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) {
6596 PyObject *value = PyObject_GetAttrString(spec, from_name);
6597 int result = 0;
6598 if (likely(value)) {
6599 if (allow_none || value != Py_None) {
6600 result = PyDict_SetItemString(moddict, to_name, value);
6601 }
6602 Py_DECREF(value);
6603 } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
6604 PyErr_Clear();
6605 } else {
6606 result = -1;
6607 }
6608 return result;
6609 }
6610 static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
6611 PyObject *module = NULL, *moddict, *modname;
6612 if (__Pyx_check_single_interpreter())
6613 return NULL;
6614 if (__pyx_m)
6615 return __Pyx_NewRef(__pyx_m);
6616 modname = PyObject_GetAttrString(spec, "name");
6617 if (unlikely(!modname)) goto bad;
6618 module = PyModule_NewObject(modname);
6619 Py_DECREF(modname);
6620 if (unlikely(!module)) goto bad;
6621 moddict = PyModule_GetDict(module);
6622 if (unlikely(!moddict)) goto bad;
6623 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
6624 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
6625 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
6626 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
6627 return module;
6628 bad:
6629 Py_XDECREF(module);
6630 return NULL;
6631 }
6632
6633
6634 static CYTHON_SMALL_CODE int __pyx_pymod_exec__mmreader(PyObject *__pyx_pyinit_module)
6635 #endif
6636 #endif
6637 {
6638 PyObject *__pyx_t_1 = NULL;
6639 PyObject *__pyx_t_2 = NULL;
6640 PyObject *__pyx_t_3 = NULL;
6641 int __pyx_lineno = 0;
6642 const char *__pyx_filename = NULL;
6643 int __pyx_clineno = 0;
6644 __Pyx_RefNannyDeclarations
6645 #if CYTHON_PEP489_MULTI_PHASE_INIT
6646 if (__pyx_m) {
6647 if (__pyx_m == __pyx_pyinit_module) return 0;
6648 PyErr_SetString(PyExc_RuntimeError, "Module '_mmreader' has already been imported. Re-initialisation is not supported.");
6649 return -1;
6650 }
6651 #elif PY_MAJOR_VERSION >= 3
6652 if (__pyx_m) return __Pyx_NewRef(__pyx_m);
6653 #endif
6654 #if CYTHON_REFNANNY
6655 __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
6656 if (!__Pyx_RefNanny) {
6657 PyErr_Clear();
6658 __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
6659 if (!__Pyx_RefNanny)
6660 Py_FatalError("failed to import 'refnanny' module");
6661 }
6662 #endif
6663 __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit__mmreader(void)", 0);
6664 if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
6665 #ifdef __Pxy_PyFrame_Initialize_Offsets
6666 __Pxy_PyFrame_Initialize_Offsets();
6667 #endif
6668 __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
6669 __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
6670 __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
6671 #ifdef __Pyx_CyFunction_USED
6672 if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
6673 #endif
6674 #ifdef __Pyx_FusedFunction_USED
6675 if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
6676 #endif
6677 #ifdef __Pyx_Coroutine_USED
6678 if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
6679 #endif
6680 #ifdef __Pyx_Generator_USED
6681 if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
6682 #endif
6683 #ifdef __Pyx_AsyncGen_USED
6684 if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
6685 #endif
6686 #ifdef __Pyx_StopAsyncIteration_USED
6687 if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
6688 #endif
6689 /*--- Library function declarations ---*/
6690 /*--- Threads initialization code ---*/
6691 #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
6692 #ifdef WITH_THREAD /* Python build with threading support? */
6693 PyEval_InitThreads();
6694 #endif
6695 #endif
6696 /*--- Module creation code ---*/
6697 #if CYTHON_PEP489_MULTI_PHASE_INIT
6698 __pyx_m = __pyx_pyinit_module;
6699 Py_INCREF(__pyx_m);
6700 #else
6701 #if PY_MAJOR_VERSION < 3
6702 __pyx_m = Py_InitModule4("_mmreader", __pyx_methods, __pyx_k_Reader_for_corpus_in_the_Matrix, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
6703 #else
6704 __pyx_m = PyModule_Create(&__pyx_moduledef);
6705 #endif
6706 if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
6707 #endif
6708 __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
6709 Py_INCREF(__pyx_d);
6710 __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
6711 Py_INCREF(__pyx_b);
6712 __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
6713 Py_INCREF(__pyx_cython_runtime);
6714 if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
6715 /*--- Initialize various global constants etc. ---*/
6716 if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
6717 #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
6718 if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
6719 #endif
6720 if (__pyx_module_is_main_gensim__corpora___mmreader) {
6721 if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
6722 }
6723 #if PY_MAJOR_VERSION >= 3
6724 {
6725 PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
6726 if (!PyDict_GetItemString(modules, "gensim.corpora._mmreader")) {
6727 if (unlikely(PyDict_SetItemString(modules, "gensim.corpora._mmreader", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
6728 }
6729 }
6730 #endif
6731 /*--- Builtin init code ---*/
6732 if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
6733 /*--- Constants init code ---*/
6734 if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
6735 /*--- Global type/function init code ---*/
6736 (void)__Pyx_modinit_global_init_code();
6737 (void)__Pyx_modinit_variable_export_code();
6738 (void)__Pyx_modinit_function_export_code();
6739 if (unlikely(__Pyx_modinit_type_init_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
6740 (void)__Pyx_modinit_type_import_code();
6741 (void)__Pyx_modinit_variable_import_code();
6742 (void)__Pyx_modinit_function_import_code();
6743 /*--- Execution code ---*/
6744 #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
6745 if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
6746 #endif
6747
6748 /* "gensim/corpora/_mmreader.pyx":5
6749 *
6750 * """Reader for corpus in the Matrix Market format."""
6751 * import logging # <<<<<<<<<<<<<<
6752 *
6753 * cimport cython
6754 */
6755 __pyx_t_1 = __Pyx_Import(__pyx_n_s_logging, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5, __pyx_L1_error)
6756 __Pyx_GOTREF(__pyx_t_1);
6757 if (PyDict_SetItem(__pyx_d, __pyx_n_s_logging, __pyx_t_1) < 0) __PYX_ERR(0, 5, __pyx_L1_error)
6758 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6759
6760 /* "gensim/corpora/_mmreader.pyx":10
6761 * from libc.stdio cimport sscanf
6762 *
6763 * from gensim import utils # <<<<<<<<<<<<<<
6764 *
6765 * logger = logging.getLogger(__name__)
6766 */
6767 __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 10, __pyx_L1_error)
6768 __Pyx_GOTREF(__pyx_t_1);
6769 __Pyx_INCREF(__pyx_n_s_utils);
6770 __Pyx_GIVEREF(__pyx_n_s_utils);
6771 PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_utils);
6772 __pyx_t_2 = __Pyx_Import(__pyx_n_s_gensim, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 10, __pyx_L1_error)
6773 __Pyx_GOTREF(__pyx_t_2);
6774 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6775 __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_utils); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 10, __pyx_L1_error)
6776 __Pyx_GOTREF(__pyx_t_1);
6777 if (PyDict_SetItem(__pyx_d, __pyx_n_s_utils, __pyx_t_1) < 0) __PYX_ERR(0, 10, __pyx_L1_error)
6778 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6779 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6780
6781 /* "gensim/corpora/_mmreader.pyx":12
6782 * from gensim import utils
6783 *
6784 * logger = logging.getLogger(__name__) # <<<<<<<<<<<<<<
6785 *
6786 *
6787 */
6788 __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_logging); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 12, __pyx_L1_error)
6789 __Pyx_GOTREF(__pyx_t_2);
6790 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_getLogger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 12, __pyx_L1_error)
6791 __Pyx_GOTREF(__pyx_t_1);
6792 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6793 __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 12, __pyx_L1_error)
6794 __Pyx_GOTREF(__pyx_t_2);
6795 __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 12, __pyx_L1_error)
6796 __Pyx_GOTREF(__pyx_t_3);
6797 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6798 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6799 if (PyDict_SetItem(__pyx_d, __pyx_n_s_logger, __pyx_t_3) < 0) __PYX_ERR(0, 12, __pyx_L1_error)
6800 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6801
6802 /* "(tree fragment)":1
6803 * def __pyx_unpickle_MmReader(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<<
6804 * cdef object __pyx_PickleError
6805 * cdef object __pyx_result
6806 */
6807 __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_6gensim_7corpora_9_mmreader_1__pyx_unpickle_MmReader, NULL, __pyx_n_s_gensim_corpora__mmreader); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1, __pyx_L1_error)
6808 __Pyx_GOTREF(__pyx_t_3);
6809 if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_MmReader, __pyx_t_3) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
6810 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6811
6812 /* "gensim/corpora/_mmreader.pyx":1
6813 * # Copyright (C) 2018 Radim Rehurek <radimrehurek@seznam.cz> # <<<<<<<<<<<<<<
6814 * # cython: embedsignature=True
6815 *
6816 */
6817 __pyx_t_3 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1, __pyx_L1_error)
6818 __Pyx_GOTREF(__pyx_t_3);
6819 if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_3) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
6820 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6821
6822 /*--- Wrapped vars code ---*/
6823
6824 goto __pyx_L0;
6825 __pyx_L1_error:;
6826 __Pyx_XDECREF(__pyx_t_1);
6827 __Pyx_XDECREF(__pyx_t_2);
6828 __Pyx_XDECREF(__pyx_t_3);
6829 if (__pyx_m) {
6830 if (__pyx_d) {
6831 __Pyx_AddTraceback("init gensim.corpora._mmreader", __pyx_clineno, __pyx_lineno, __pyx_filename);
6832 }
6833 Py_CLEAR(__pyx_m);
6834 } else if (!PyErr_Occurred()) {
6835 PyErr_SetString(PyExc_ImportError, "init gensim.corpora._mmreader");
6836 }
6837 __pyx_L0:;
6838 __Pyx_RefNannyFinishContext();
6839 #if CYTHON_PEP489_MULTI_PHASE_INIT
6840 return (__pyx_m != NULL) ? 0 : -1;
6841 #elif PY_MAJOR_VERSION >= 3
6842 return __pyx_m;
6843 #else
6844 return;
6845 #endif
6846 }
6847
6848 /* --- Runtime support code --- */
6849 /* Refnanny */
6850 #if CYTHON_REFNANNY
__Pyx_RefNannyImportAPI(const char * modname)6851 static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
6852 PyObject *m = NULL, *p = NULL;
6853 void *r = NULL;
6854 m = PyImport_ImportModule(modname);
6855 if (!m) goto end;
6856 p = PyObject_GetAttrString(m, "RefNannyAPI");
6857 if (!p) goto end;
6858 r = PyLong_AsVoidPtr(p);
6859 end:
6860 Py_XDECREF(p);
6861 Py_XDECREF(m);
6862 return (__Pyx_RefNannyAPIStruct *)r;
6863 }
6864 #endif
6865
6866 /* PyObjectGetAttrStr */
6867 #if CYTHON_USE_TYPE_SLOTS
__Pyx_PyObject_GetAttrStr(PyObject * obj,PyObject * attr_name)6868 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
6869 PyTypeObject* tp = Py_TYPE(obj);
6870 if (likely(tp->tp_getattro))
6871 return tp->tp_getattro(obj, attr_name);
6872 #if PY_MAJOR_VERSION < 3
6873 if (likely(tp->tp_getattr))
6874 return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
6875 #endif
6876 return PyObject_GetAttr(obj, attr_name);
6877 }
6878 #endif
6879
6880 /* GetBuiltinName */
__Pyx_GetBuiltinName(PyObject * name)6881 static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
6882 PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
6883 if (unlikely(!result)) {
6884 PyErr_Format(PyExc_NameError,
6885 #if PY_MAJOR_VERSION >= 3
6886 "name '%U' is not defined", name);
6887 #else
6888 "name '%.200s' is not defined", PyString_AS_STRING(name));
6889 #endif
6890 }
6891 return result;
6892 }
6893
6894 /* RaiseDoubleKeywords */
__Pyx_RaiseDoubleKeywordsError(const char * func_name,PyObject * kw_name)6895 static void __Pyx_RaiseDoubleKeywordsError(
6896 const char* func_name,
6897 PyObject* kw_name)
6898 {
6899 PyErr_Format(PyExc_TypeError,
6900 #if PY_MAJOR_VERSION >= 3
6901 "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
6902 #else
6903 "%s() got multiple values for keyword argument '%s'", func_name,
6904 PyString_AsString(kw_name));
6905 #endif
6906 }
6907
6908 /* ParseKeywords */
__Pyx_ParseOptionalKeywords(PyObject * kwds,PyObject ** argnames[],PyObject * kwds2,PyObject * values[],Py_ssize_t num_pos_args,const char * function_name)6909 static int __Pyx_ParseOptionalKeywords(
6910 PyObject *kwds,
6911 PyObject **argnames[],
6912 PyObject *kwds2,
6913 PyObject *values[],
6914 Py_ssize_t num_pos_args,
6915 const char* function_name)
6916 {
6917 PyObject *key = 0, *value = 0;
6918 Py_ssize_t pos = 0;
6919 PyObject*** name;
6920 PyObject*** first_kw_arg = argnames + num_pos_args;
6921 while (PyDict_Next(kwds, &pos, &key, &value)) {
6922 name = first_kw_arg;
6923 while (*name && (**name != key)) name++;
6924 if (*name) {
6925 values[name-argnames] = value;
6926 continue;
6927 }
6928 name = first_kw_arg;
6929 #if PY_MAJOR_VERSION < 3
6930 if (likely(PyString_Check(key))) {
6931 while (*name) {
6932 if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
6933 && _PyString_Eq(**name, key)) {
6934 values[name-argnames] = value;
6935 break;
6936 }
6937 name++;
6938 }
6939 if (*name) continue;
6940 else {
6941 PyObject*** argname = argnames;
6942 while (argname != first_kw_arg) {
6943 if ((**argname == key) || (
6944 (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
6945 && _PyString_Eq(**argname, key))) {
6946 goto arg_passed_twice;
6947 }
6948 argname++;
6949 }
6950 }
6951 } else
6952 #endif
6953 if (likely(PyUnicode_Check(key))) {
6954 while (*name) {
6955 int cmp = (**name == key) ? 0 :
6956 #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
6957 (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
6958 #endif
6959 PyUnicode_Compare(**name, key);
6960 if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
6961 if (cmp == 0) {
6962 values[name-argnames] = value;
6963 break;
6964 }
6965 name++;
6966 }
6967 if (*name) continue;
6968 else {
6969 PyObject*** argname = argnames;
6970 while (argname != first_kw_arg) {
6971 int cmp = (**argname == key) ? 0 :
6972 #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
6973 (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
6974 #endif
6975 PyUnicode_Compare(**argname, key);
6976 if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
6977 if (cmp == 0) goto arg_passed_twice;
6978 argname++;
6979 }
6980 }
6981 } else
6982 goto invalid_keyword_type;
6983 if (kwds2) {
6984 if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
6985 } else {
6986 goto invalid_keyword;
6987 }
6988 }
6989 return 0;
6990 arg_passed_twice:
6991 __Pyx_RaiseDoubleKeywordsError(function_name, key);
6992 goto bad;
6993 invalid_keyword_type:
6994 PyErr_Format(PyExc_TypeError,
6995 "%.200s() keywords must be strings", function_name);
6996 goto bad;
6997 invalid_keyword:
6998 PyErr_Format(PyExc_TypeError,
6999 #if PY_MAJOR_VERSION < 3
7000 "%.200s() got an unexpected keyword argument '%.200s'",
7001 function_name, PyString_AsString(key));
7002 #else
7003 "%s() got an unexpected keyword argument '%U'",
7004 function_name, key);
7005 #endif
7006 bad:
7007 return -1;
7008 }
7009
7010 /* RaiseArgTupleInvalid */
__Pyx_RaiseArgtupleInvalid(const char * func_name,int exact,Py_ssize_t num_min,Py_ssize_t num_max,Py_ssize_t num_found)7011 static void __Pyx_RaiseArgtupleInvalid(
7012 const char* func_name,
7013 int exact,
7014 Py_ssize_t num_min,
7015 Py_ssize_t num_max,
7016 Py_ssize_t num_found)
7017 {
7018 Py_ssize_t num_expected;
7019 const char *more_or_less;
7020 if (num_found < num_min) {
7021 num_expected = num_min;
7022 more_or_less = "at least";
7023 } else {
7024 num_expected = num_max;
7025 more_or_less = "at most";
7026 }
7027 if (exact) {
7028 more_or_less = "exactly";
7029 }
7030 PyErr_Format(PyExc_TypeError,
7031 "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
7032 func_name, more_or_less, num_expected,
7033 (num_expected == 1) ? "" : "s", num_found);
7034 }
7035
7036 /* None */
__Pyx_RaiseClosureNameError(const char * varname)7037 static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname) {
7038 PyErr_Format(PyExc_NameError, "free variable '%s' referenced before assignment in enclosing scope", varname);
7039 }
7040
7041 /* PyFunctionFastCall */
7042 #if CYTHON_FAST_PYCALL
__Pyx_PyFunction_FastCallNoKw(PyCodeObject * co,PyObject ** args,Py_ssize_t na,PyObject * globals)7043 static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
7044 PyObject *globals) {
7045 PyFrameObject *f;
7046 PyThreadState *tstate = __Pyx_PyThreadState_Current;
7047 PyObject **fastlocals;
7048 Py_ssize_t i;
7049 PyObject *result;
7050 assert(globals != NULL);
7051 /* XXX Perhaps we should create a specialized
7052 PyFrame_New() that doesn't take locals, but does
7053 take builtins without sanity checking them.
7054 */
7055 assert(tstate != NULL);
7056 f = PyFrame_New(tstate, co, globals, NULL);
7057 if (f == NULL) {
7058 return NULL;
7059 }
7060 fastlocals = __Pyx_PyFrame_GetLocalsplus(f);
7061 for (i = 0; i < na; i++) {
7062 Py_INCREF(*args);
7063 fastlocals[i] = *args++;
7064 }
7065 result = PyEval_EvalFrameEx(f,0);
7066 ++tstate->recursion_depth;
7067 Py_DECREF(f);
7068 --tstate->recursion_depth;
7069 return result;
7070 }
7071 #if 1 || PY_VERSION_HEX < 0x030600B1
__Pyx_PyFunction_FastCallDict(PyObject * func,PyObject ** args,Py_ssize_t nargs,PyObject * kwargs)7072 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) {
7073 PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
7074 PyObject *globals = PyFunction_GET_GLOBALS(func);
7075 PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
7076 PyObject *closure;
7077 #if PY_MAJOR_VERSION >= 3
7078 PyObject *kwdefs;
7079 #endif
7080 PyObject *kwtuple, **k;
7081 PyObject **d;
7082 Py_ssize_t nd;
7083 Py_ssize_t nk;
7084 PyObject *result;
7085 assert(kwargs == NULL || PyDict_Check(kwargs));
7086 nk = kwargs ? PyDict_Size(kwargs) : 0;
7087 if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
7088 return NULL;
7089 }
7090 if (
7091 #if PY_MAJOR_VERSION >= 3
7092 co->co_kwonlyargcount == 0 &&
7093 #endif
7094 likely(kwargs == NULL || nk == 0) &&
7095 co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
7096 if (argdefs == NULL && co->co_argcount == nargs) {
7097 result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
7098 goto done;
7099 }
7100 else if (nargs == 0 && argdefs != NULL
7101 && co->co_argcount == Py_SIZE(argdefs)) {
7102 /* function called with no arguments, but all parameters have
7103 a default value: use default values as arguments .*/
7104 args = &PyTuple_GET_ITEM(argdefs, 0);
7105 result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
7106 goto done;
7107 }
7108 }
7109 if (kwargs != NULL) {
7110 Py_ssize_t pos, i;
7111 kwtuple = PyTuple_New(2 * nk);
7112 if (kwtuple == NULL) {
7113 result = NULL;
7114 goto done;
7115 }
7116 k = &PyTuple_GET_ITEM(kwtuple, 0);
7117 pos = i = 0;
7118 while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
7119 Py_INCREF(k[i]);
7120 Py_INCREF(k[i+1]);
7121 i += 2;
7122 }
7123 nk = i / 2;
7124 }
7125 else {
7126 kwtuple = NULL;
7127 k = NULL;
7128 }
7129 closure = PyFunction_GET_CLOSURE(func);
7130 #if PY_MAJOR_VERSION >= 3
7131 kwdefs = PyFunction_GET_KW_DEFAULTS(func);
7132 #endif
7133 if (argdefs != NULL) {
7134 d = &PyTuple_GET_ITEM(argdefs, 0);
7135 nd = Py_SIZE(argdefs);
7136 }
7137 else {
7138 d = NULL;
7139 nd = 0;
7140 }
7141 #if PY_MAJOR_VERSION >= 3
7142 result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
7143 args, (int)nargs,
7144 k, (int)nk,
7145 d, (int)nd, kwdefs, closure);
7146 #else
7147 result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
7148 args, (int)nargs,
7149 k, (int)nk,
7150 d, (int)nd, closure);
7151 #endif
7152 Py_XDECREF(kwtuple);
7153 done:
7154 Py_LeaveRecursiveCall();
7155 return result;
7156 }
7157 #endif
7158 #endif
7159
7160 /* PyObjectCall */
7161 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_Call(PyObject * func,PyObject * arg,PyObject * kw)7162 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
7163 PyObject *result;
7164 ternaryfunc call = func->ob_type->tp_call;
7165 if (unlikely(!call))
7166 return PyObject_Call(func, arg, kw);
7167 if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
7168 return NULL;
7169 result = (*call)(func, arg, kw);
7170 Py_LeaveRecursiveCall();
7171 if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
7172 PyErr_SetString(
7173 PyExc_SystemError,
7174 "NULL result without error in PyObject_Call");
7175 }
7176 return result;
7177 }
7178 #endif
7179
7180 /* PyObjectCallMethO */
7181 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_CallMethO(PyObject * func,PyObject * arg)7182 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
7183 PyObject *self, *result;
7184 PyCFunction cfunc;
7185 cfunc = PyCFunction_GET_FUNCTION(func);
7186 self = PyCFunction_GET_SELF(func);
7187 if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
7188 return NULL;
7189 result = cfunc(self, arg);
7190 Py_LeaveRecursiveCall();
7191 if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
7192 PyErr_SetString(
7193 PyExc_SystemError,
7194 "NULL result without error in PyObject_Call");
7195 }
7196 return result;
7197 }
7198 #endif
7199
7200 /* PyObjectCallNoArg */
7201 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_CallNoArg(PyObject * func)7202 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
7203 #if CYTHON_FAST_PYCALL
7204 if (PyFunction_Check(func)) {
7205 return __Pyx_PyFunction_FastCall(func, NULL, 0);
7206 }
7207 #endif
7208 #ifdef __Pyx_CyFunction_USED
7209 if (likely(PyCFunction_Check(func) || __Pyx_CyFunction_Check(func)))
7210 #else
7211 if (likely(PyCFunction_Check(func)))
7212 #endif
7213 {
7214 if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
7215 return __Pyx_PyObject_CallMethO(func, NULL);
7216 }
7217 }
7218 return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
7219 }
7220 #endif
7221
7222 /* PyCFunctionFastCall */
7223 #if CYTHON_FAST_PYCCALL
__Pyx_PyCFunction_FastCall(PyObject * func_obj,PyObject ** args,Py_ssize_t nargs)7224 static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
7225 PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
7226 PyCFunction meth = PyCFunction_GET_FUNCTION(func);
7227 PyObject *self = PyCFunction_GET_SELF(func);
7228 int flags = PyCFunction_GET_FLAGS(func);
7229 assert(PyCFunction_Check(func));
7230 assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)));
7231 assert(nargs >= 0);
7232 assert(nargs == 0 || args != NULL);
7233 /* _PyCFunction_FastCallDict() must not be called with an exception set,
7234 because it may clear it (directly or indirectly) and so the
7235 caller loses its exception */
7236 assert(!PyErr_Occurred());
7237 if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
7238 return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL);
7239 } else {
7240 return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs);
7241 }
7242 }
7243 #endif
7244
7245 /* PyObjectCallOneArg */
7246 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx__PyObject_CallOneArg(PyObject * func,PyObject * arg)7247 static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
7248 PyObject *result;
7249 PyObject *args = PyTuple_New(1);
7250 if (unlikely(!args)) return NULL;
7251 Py_INCREF(arg);
7252 PyTuple_SET_ITEM(args, 0, arg);
7253 result = __Pyx_PyObject_Call(func, args, NULL);
7254 Py_DECREF(args);
7255 return result;
7256 }
__Pyx_PyObject_CallOneArg(PyObject * func,PyObject * arg)7257 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
7258 #if CYTHON_FAST_PYCALL
7259 if (PyFunction_Check(func)) {
7260 return __Pyx_PyFunction_FastCall(func, &arg, 1);
7261 }
7262 #endif
7263 if (likely(PyCFunction_Check(func))) {
7264 if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
7265 return __Pyx_PyObject_CallMethO(func, arg);
7266 #if CYTHON_FAST_PYCCALL
7267 } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) {
7268 return __Pyx_PyCFunction_FastCall(func, &arg, 1);
7269 #endif
7270 }
7271 }
7272 return __Pyx__PyObject_CallOneArg(func, arg);
7273 }
7274 #else
__Pyx_PyObject_CallOneArg(PyObject * func,PyObject * arg)7275 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
7276 PyObject *result;
7277 PyObject *args = PyTuple_Pack(1, arg);
7278 if (unlikely(!args)) return NULL;
7279 result = __Pyx_PyObject_Call(func, args, NULL);
7280 Py_DECREF(args);
7281 return result;
7282 }
7283 #endif
7284
7285 /* PyDictVersioning */
7286 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
__Pyx_get_tp_dict_version(PyObject * obj)7287 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
7288 PyObject *dict = Py_TYPE(obj)->tp_dict;
7289 return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
7290 }
__Pyx_get_object_dict_version(PyObject * obj)7291 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
7292 PyObject **dictptr = NULL;
7293 Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
7294 if (offset) {
7295 #if CYTHON_COMPILING_IN_CPYTHON
7296 dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
7297 #else
7298 dictptr = _PyObject_GetDictPtr(obj);
7299 #endif
7300 }
7301 return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
7302 }
__Pyx_object_dict_version_matches(PyObject * obj,PY_UINT64_T tp_dict_version,PY_UINT64_T obj_dict_version)7303 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
7304 PyObject *dict = Py_TYPE(obj)->tp_dict;
7305 if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
7306 return 0;
7307 return obj_dict_version == __Pyx_get_object_dict_version(obj);
7308 }
7309 #endif
7310
7311 /* GetModuleGlobalName */
7312 #if CYTHON_USE_DICT_VERSIONS
__Pyx__GetModuleGlobalName(PyObject * name,PY_UINT64_T * dict_version,PyObject ** dict_cached_value)7313 static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value)
7314 #else
7315 static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
7316 #endif
7317 {
7318 PyObject *result;
7319 #if !CYTHON_AVOID_BORROWED_REFS
7320 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
7321 result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
7322 __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
7323 if (likely(result)) {
7324 return __Pyx_NewRef(result);
7325 } else if (unlikely(PyErr_Occurred())) {
7326 return NULL;
7327 }
7328 #else
7329 result = PyDict_GetItem(__pyx_d, name);
7330 __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
7331 if (likely(result)) {
7332 return __Pyx_NewRef(result);
7333 }
7334 #endif
7335 #else
7336 result = PyObject_GetItem(__pyx_d, name);
7337 __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
7338 if (likely(result)) {
7339 return __Pyx_NewRef(result);
7340 }
7341 PyErr_Clear();
7342 #endif
7343 return __Pyx_GetBuiltinName(name);
7344 }
7345
7346 /* PyObjectCall2Args */
__Pyx_PyObject_Call2Args(PyObject * function,PyObject * arg1,PyObject * arg2)7347 static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) {
7348 PyObject *args, *result = NULL;
7349 #if CYTHON_FAST_PYCALL
7350 if (PyFunction_Check(function)) {
7351 PyObject *args[2] = {arg1, arg2};
7352 return __Pyx_PyFunction_FastCall(function, args, 2);
7353 }
7354 #endif
7355 #if CYTHON_FAST_PYCCALL
7356 if (__Pyx_PyFastCFunction_Check(function)) {
7357 PyObject *args[2] = {arg1, arg2};
7358 return __Pyx_PyCFunction_FastCall(function, args, 2);
7359 }
7360 #endif
7361 args = PyTuple_New(2);
7362 if (unlikely(!args)) goto done;
7363 Py_INCREF(arg1);
7364 PyTuple_SET_ITEM(args, 0, arg1);
7365 Py_INCREF(arg2);
7366 PyTuple_SET_ITEM(args, 1, arg2);
7367 Py_INCREF(function);
7368 result = __Pyx_PyObject_Call(function, args, NULL);
7369 Py_DECREF(args);
7370 Py_DECREF(function);
7371 done:
7372 return result;
7373 }
7374
7375 /* PyErrFetchRestore */
7376 #if CYTHON_FAST_THREAD_STATE
__Pyx_ErrRestoreInState(PyThreadState * tstate,PyObject * type,PyObject * value,PyObject * tb)7377 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
7378 PyObject *tmp_type, *tmp_value, *tmp_tb;
7379 tmp_type = tstate->curexc_type;
7380 tmp_value = tstate->curexc_value;
7381 tmp_tb = tstate->curexc_traceback;
7382 tstate->curexc_type = type;
7383 tstate->curexc_value = value;
7384 tstate->curexc_traceback = tb;
7385 Py_XDECREF(tmp_type);
7386 Py_XDECREF(tmp_value);
7387 Py_XDECREF(tmp_tb);
7388 }
__Pyx_ErrFetchInState(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)7389 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
7390 *type = tstate->curexc_type;
7391 *value = tstate->curexc_value;
7392 *tb = tstate->curexc_traceback;
7393 tstate->curexc_type = 0;
7394 tstate->curexc_value = 0;
7395 tstate->curexc_traceback = 0;
7396 }
7397 #endif
7398
7399 /* IterNext */
__Pyx_PyIter_Next2Default(PyObject * defval)7400 static PyObject *__Pyx_PyIter_Next2Default(PyObject* defval) {
7401 PyObject* exc_type;
7402 __Pyx_PyThreadState_declare
7403 __Pyx_PyThreadState_assign
7404 exc_type = __Pyx_PyErr_Occurred();
7405 if (unlikely(exc_type)) {
7406 if (!defval || unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))
7407 return NULL;
7408 __Pyx_PyErr_Clear();
7409 Py_INCREF(defval);
7410 return defval;
7411 }
7412 if (defval) {
7413 Py_INCREF(defval);
7414 return defval;
7415 }
7416 __Pyx_PyErr_SetNone(PyExc_StopIteration);
7417 return NULL;
7418 }
__Pyx_PyIter_Next_ErrorNoIterator(PyObject * iterator)7419 static void __Pyx_PyIter_Next_ErrorNoIterator(PyObject *iterator) {
7420 PyErr_Format(PyExc_TypeError,
7421 "%.200s object is not an iterator", Py_TYPE(iterator)->tp_name);
7422 }
__Pyx_PyIter_Next2(PyObject * iterator,PyObject * defval)7423 static CYTHON_INLINE PyObject *__Pyx_PyIter_Next2(PyObject* iterator, PyObject* defval) {
7424 PyObject* next;
7425 iternextfunc iternext = Py_TYPE(iterator)->tp_iternext;
7426 if (likely(iternext)) {
7427 #if CYTHON_USE_TYPE_SLOTS
7428 next = iternext(iterator);
7429 if (likely(next))
7430 return next;
7431 #if PY_VERSION_HEX >= 0x02070000
7432 if (unlikely(iternext == &_PyObject_NextNotImplemented))
7433 return NULL;
7434 #endif
7435 #else
7436 next = PyIter_Next(iterator);
7437 if (likely(next))
7438 return next;
7439 #endif
7440 } else if (CYTHON_USE_TYPE_SLOTS || unlikely(!PyIter_Check(iterator))) {
7441 __Pyx_PyIter_Next_ErrorNoIterator(iterator);
7442 return NULL;
7443 }
7444 #if !CYTHON_USE_TYPE_SLOTS
7445 else {
7446 next = PyIter_Next(iterator);
7447 if (likely(next))
7448 return next;
7449 }
7450 #endif
7451 return __Pyx_PyIter_Next2Default(defval);
7452 }
7453
7454 /* RaiseException */
7455 #if PY_MAJOR_VERSION < 3
__Pyx_Raise(PyObject * type,PyObject * value,PyObject * tb,CYTHON_UNUSED PyObject * cause)7456 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
7457 CYTHON_UNUSED PyObject *cause) {
7458 __Pyx_PyThreadState_declare
7459 Py_XINCREF(type);
7460 if (!value || value == Py_None)
7461 value = NULL;
7462 else
7463 Py_INCREF(value);
7464 if (!tb || tb == Py_None)
7465 tb = NULL;
7466 else {
7467 Py_INCREF(tb);
7468 if (!PyTraceBack_Check(tb)) {
7469 PyErr_SetString(PyExc_TypeError,
7470 "raise: arg 3 must be a traceback or None");
7471 goto raise_error;
7472 }
7473 }
7474 if (PyType_Check(type)) {
7475 #if CYTHON_COMPILING_IN_PYPY
7476 if (!value) {
7477 Py_INCREF(Py_None);
7478 value = Py_None;
7479 }
7480 #endif
7481 PyErr_NormalizeException(&type, &value, &tb);
7482 } else {
7483 if (value) {
7484 PyErr_SetString(PyExc_TypeError,
7485 "instance exception may not have a separate value");
7486 goto raise_error;
7487 }
7488 value = type;
7489 type = (PyObject*) Py_TYPE(type);
7490 Py_INCREF(type);
7491 if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
7492 PyErr_SetString(PyExc_TypeError,
7493 "raise: exception class must be a subclass of BaseException");
7494 goto raise_error;
7495 }
7496 }
7497 __Pyx_PyThreadState_assign
7498 __Pyx_ErrRestore(type, value, tb);
7499 return;
7500 raise_error:
7501 Py_XDECREF(value);
7502 Py_XDECREF(type);
7503 Py_XDECREF(tb);
7504 return;
7505 }
7506 #else
__Pyx_Raise(PyObject * type,PyObject * value,PyObject * tb,PyObject * cause)7507 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
7508 PyObject* owned_instance = NULL;
7509 if (tb == Py_None) {
7510 tb = 0;
7511 } else if (tb && !PyTraceBack_Check(tb)) {
7512 PyErr_SetString(PyExc_TypeError,
7513 "raise: arg 3 must be a traceback or None");
7514 goto bad;
7515 }
7516 if (value == Py_None)
7517 value = 0;
7518 if (PyExceptionInstance_Check(type)) {
7519 if (value) {
7520 PyErr_SetString(PyExc_TypeError,
7521 "instance exception may not have a separate value");
7522 goto bad;
7523 }
7524 value = type;
7525 type = (PyObject*) Py_TYPE(value);
7526 } else if (PyExceptionClass_Check(type)) {
7527 PyObject *instance_class = NULL;
7528 if (value && PyExceptionInstance_Check(value)) {
7529 instance_class = (PyObject*) Py_TYPE(value);
7530 if (instance_class != type) {
7531 int is_subclass = PyObject_IsSubclass(instance_class, type);
7532 if (!is_subclass) {
7533 instance_class = NULL;
7534 } else if (unlikely(is_subclass == -1)) {
7535 goto bad;
7536 } else {
7537 type = instance_class;
7538 }
7539 }
7540 }
7541 if (!instance_class) {
7542 PyObject *args;
7543 if (!value)
7544 args = PyTuple_New(0);
7545 else if (PyTuple_Check(value)) {
7546 Py_INCREF(value);
7547 args = value;
7548 } else
7549 args = PyTuple_Pack(1, value);
7550 if (!args)
7551 goto bad;
7552 owned_instance = PyObject_Call(type, args, NULL);
7553 Py_DECREF(args);
7554 if (!owned_instance)
7555 goto bad;
7556 value = owned_instance;
7557 if (!PyExceptionInstance_Check(value)) {
7558 PyErr_Format(PyExc_TypeError,
7559 "calling %R should have returned an instance of "
7560 "BaseException, not %R",
7561 type, Py_TYPE(value));
7562 goto bad;
7563 }
7564 }
7565 } else {
7566 PyErr_SetString(PyExc_TypeError,
7567 "raise: exception class must be a subclass of BaseException");
7568 goto bad;
7569 }
7570 if (cause) {
7571 PyObject *fixed_cause;
7572 if (cause == Py_None) {
7573 fixed_cause = NULL;
7574 } else if (PyExceptionClass_Check(cause)) {
7575 fixed_cause = PyObject_CallObject(cause, NULL);
7576 if (fixed_cause == NULL)
7577 goto bad;
7578 } else if (PyExceptionInstance_Check(cause)) {
7579 fixed_cause = cause;
7580 Py_INCREF(fixed_cause);
7581 } else {
7582 PyErr_SetString(PyExc_TypeError,
7583 "exception causes must derive from "
7584 "BaseException");
7585 goto bad;
7586 }
7587 PyException_SetCause(value, fixed_cause);
7588 }
7589 PyErr_SetObject(type, value);
7590 if (tb) {
7591 #if CYTHON_COMPILING_IN_PYPY
7592 PyObject *tmp_type, *tmp_value, *tmp_tb;
7593 PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
7594 Py_INCREF(tb);
7595 PyErr_Restore(tmp_type, tmp_value, tb);
7596 Py_XDECREF(tmp_tb);
7597 #else
7598 PyThreadState *tstate = __Pyx_PyThreadState_Current;
7599 PyObject* tmp_tb = tstate->curexc_traceback;
7600 if (tb != tmp_tb) {
7601 Py_INCREF(tb);
7602 tstate->curexc_traceback = tb;
7603 Py_XDECREF(tmp_tb);
7604 }
7605 #endif
7606 }
7607 bad:
7608 Py_XDECREF(owned_instance);
7609 return;
7610 }
7611 #endif
7612
7613 /* GetTopmostException */
7614 #if CYTHON_USE_EXC_INFO_STACK
7615 static _PyErr_StackItem *
__Pyx_PyErr_GetTopmostException(PyThreadState * tstate)7616 __Pyx_PyErr_GetTopmostException(PyThreadState *tstate)
7617 {
7618 _PyErr_StackItem *exc_info = tstate->exc_info;
7619 while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) &&
7620 exc_info->previous_item != NULL)
7621 {
7622 exc_info = exc_info->previous_item;
7623 }
7624 return exc_info;
7625 }
7626 #endif
7627
7628 /* SaveResetException */
7629 #if CYTHON_FAST_THREAD_STATE
__Pyx__ExceptionSave(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)7630 static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
7631 #if CYTHON_USE_EXC_INFO_STACK
7632 _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
7633 *type = exc_info->exc_type;
7634 *value = exc_info->exc_value;
7635 *tb = exc_info->exc_traceback;
7636 #else
7637 *type = tstate->exc_type;
7638 *value = tstate->exc_value;
7639 *tb = tstate->exc_traceback;
7640 #endif
7641 Py_XINCREF(*type);
7642 Py_XINCREF(*value);
7643 Py_XINCREF(*tb);
7644 }
__Pyx__ExceptionReset(PyThreadState * tstate,PyObject * type,PyObject * value,PyObject * tb)7645 static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
7646 PyObject *tmp_type, *tmp_value, *tmp_tb;
7647 #if CYTHON_USE_EXC_INFO_STACK
7648 _PyErr_StackItem *exc_info = tstate->exc_info;
7649 tmp_type = exc_info->exc_type;
7650 tmp_value = exc_info->exc_value;
7651 tmp_tb = exc_info->exc_traceback;
7652 exc_info->exc_type = type;
7653 exc_info->exc_value = value;
7654 exc_info->exc_traceback = tb;
7655 #else
7656 tmp_type = tstate->exc_type;
7657 tmp_value = tstate->exc_value;
7658 tmp_tb = tstate->exc_traceback;
7659 tstate->exc_type = type;
7660 tstate->exc_value = value;
7661 tstate->exc_traceback = tb;
7662 #endif
7663 Py_XDECREF(tmp_type);
7664 Py_XDECREF(tmp_value);
7665 Py_XDECREF(tmp_tb);
7666 }
7667 #endif
7668
7669 /* PyErrExceptionMatches */
7670 #if CYTHON_FAST_THREAD_STATE
__Pyx_PyErr_ExceptionMatchesTuple(PyObject * exc_type,PyObject * tuple)7671 static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
7672 Py_ssize_t i, n;
7673 n = PyTuple_GET_SIZE(tuple);
7674 #if PY_MAJOR_VERSION >= 3
7675 for (i=0; i<n; i++) {
7676 if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
7677 }
7678 #endif
7679 for (i=0; i<n; i++) {
7680 if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
7681 }
7682 return 0;
7683 }
__Pyx_PyErr_ExceptionMatchesInState(PyThreadState * tstate,PyObject * err)7684 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
7685 PyObject *exc_type = tstate->curexc_type;
7686 if (exc_type == err) return 1;
7687 if (unlikely(!exc_type)) return 0;
7688 if (unlikely(PyTuple_Check(err)))
7689 return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
7690 return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
7691 }
7692 #endif
7693
7694 /* PyIntBinop */
7695 #if !CYTHON_COMPILING_IN_PYPY
__Pyx_PyInt_AddObjC(PyObject * op1,PyObject * op2,CYTHON_UNUSED long intval,int inplace,int zerodivision_check)7696 static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) {
7697 (void)inplace;
7698 (void)zerodivision_check;
7699 #if PY_MAJOR_VERSION < 3
7700 if (likely(PyInt_CheckExact(op1))) {
7701 const long b = intval;
7702 long x;
7703 long a = PyInt_AS_LONG(op1);
7704 x = (long)((unsigned long)a + b);
7705 if (likely((x^a) >= 0 || (x^b) >= 0))
7706 return PyInt_FromLong(x);
7707 return PyLong_Type.tp_as_number->nb_add(op1, op2);
7708 }
7709 #endif
7710 #if CYTHON_USE_PYLONG_INTERNALS
7711 if (likely(PyLong_CheckExact(op1))) {
7712 const long b = intval;
7713 long a, x;
7714 #ifdef HAVE_LONG_LONG
7715 const PY_LONG_LONG llb = intval;
7716 PY_LONG_LONG lla, llx;
7717 #endif
7718 const digit* digits = ((PyLongObject*)op1)->ob_digit;
7719 const Py_ssize_t size = Py_SIZE(op1);
7720 if (likely(__Pyx_sst_abs(size) <= 1)) {
7721 a = likely(size) ? digits[0] : 0;
7722 if (size == -1) a = -a;
7723 } else {
7724 switch (size) {
7725 case -2:
7726 if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
7727 a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
7728 break;
7729 #ifdef HAVE_LONG_LONG
7730 } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
7731 lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
7732 goto long_long;
7733 #endif
7734 }
7735 CYTHON_FALLTHROUGH;
7736 case 2:
7737 if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
7738 a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
7739 break;
7740 #ifdef HAVE_LONG_LONG
7741 } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
7742 lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
7743 goto long_long;
7744 #endif
7745 }
7746 CYTHON_FALLTHROUGH;
7747 case -3:
7748 if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
7749 a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
7750 break;
7751 #ifdef HAVE_LONG_LONG
7752 } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
7753 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]));
7754 goto long_long;
7755 #endif
7756 }
7757 CYTHON_FALLTHROUGH;
7758 case 3:
7759 if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
7760 a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
7761 break;
7762 #ifdef HAVE_LONG_LONG
7763 } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
7764 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]));
7765 goto long_long;
7766 #endif
7767 }
7768 CYTHON_FALLTHROUGH;
7769 case -4:
7770 if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
7771 a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
7772 break;
7773 #ifdef HAVE_LONG_LONG
7774 } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
7775 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]));
7776 goto long_long;
7777 #endif
7778 }
7779 CYTHON_FALLTHROUGH;
7780 case 4:
7781 if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
7782 a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
7783 break;
7784 #ifdef HAVE_LONG_LONG
7785 } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
7786 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]));
7787 goto long_long;
7788 #endif
7789 }
7790 CYTHON_FALLTHROUGH;
7791 default: return PyLong_Type.tp_as_number->nb_add(op1, op2);
7792 }
7793 }
7794 x = a + b;
7795 return PyLong_FromLong(x);
7796 #ifdef HAVE_LONG_LONG
7797 long_long:
7798 llx = lla + llb;
7799 return PyLong_FromLongLong(llx);
7800 #endif
7801
7802
7803 }
7804 #endif
7805 if (PyFloat_CheckExact(op1)) {
7806 const long b = intval;
7807 double a = PyFloat_AS_DOUBLE(op1);
7808 double result;
7809 PyFPE_START_PROTECT("add", return NULL)
7810 result = ((double)a) + (double)b;
7811 PyFPE_END_PROTECT(result)
7812 return PyFloat_FromDouble(result);
7813 }
7814 return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2);
7815 }
7816 #endif
7817
7818 /* RaiseTooManyValuesToUnpack */
__Pyx_RaiseTooManyValuesError(Py_ssize_t expected)7819 static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
7820 PyErr_Format(PyExc_ValueError,
7821 "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
7822 }
7823
7824 /* RaiseNeedMoreValuesToUnpack */
__Pyx_RaiseNeedMoreValuesError(Py_ssize_t index)7825 static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
7826 PyErr_Format(PyExc_ValueError,
7827 "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
7828 index, (index == 1) ? "" : "s");
7829 }
7830
7831 /* IterFinish */
__Pyx_IterFinish(void)7832 static CYTHON_INLINE int __Pyx_IterFinish(void) {
7833 #if CYTHON_FAST_THREAD_STATE
7834 PyThreadState *tstate = __Pyx_PyThreadState_Current;
7835 PyObject* exc_type = tstate->curexc_type;
7836 if (unlikely(exc_type)) {
7837 if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) {
7838 PyObject *exc_value, *exc_tb;
7839 exc_value = tstate->curexc_value;
7840 exc_tb = tstate->curexc_traceback;
7841 tstate->curexc_type = 0;
7842 tstate->curexc_value = 0;
7843 tstate->curexc_traceback = 0;
7844 Py_DECREF(exc_type);
7845 Py_XDECREF(exc_value);
7846 Py_XDECREF(exc_tb);
7847 return 0;
7848 } else {
7849 return -1;
7850 }
7851 }
7852 return 0;
7853 #else
7854 if (unlikely(PyErr_Occurred())) {
7855 if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
7856 PyErr_Clear();
7857 return 0;
7858 } else {
7859 return -1;
7860 }
7861 }
7862 return 0;
7863 #endif
7864 }
7865
7866 /* UnpackItemEndCheck */
__Pyx_IternextUnpackEndCheck(PyObject * retval,Py_ssize_t expected)7867 static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
7868 if (unlikely(retval)) {
7869 Py_DECREF(retval);
7870 __Pyx_RaiseTooManyValuesError(expected);
7871 return -1;
7872 } else {
7873 return __Pyx_IterFinish();
7874 }
7875 return 0;
7876 }
7877
7878 /* GetException */
7879 #if CYTHON_FAST_THREAD_STATE
__Pyx__GetException(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)7880 static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb)
7881 #else
7882 static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb)
7883 #endif
7884 {
7885 PyObject *local_type, *local_value, *local_tb;
7886 #if CYTHON_FAST_THREAD_STATE
7887 PyObject *tmp_type, *tmp_value, *tmp_tb;
7888 local_type = tstate->curexc_type;
7889 local_value = tstate->curexc_value;
7890 local_tb = tstate->curexc_traceback;
7891 tstate->curexc_type = 0;
7892 tstate->curexc_value = 0;
7893 tstate->curexc_traceback = 0;
7894 #else
7895 PyErr_Fetch(&local_type, &local_value, &local_tb);
7896 #endif
7897 PyErr_NormalizeException(&local_type, &local_value, &local_tb);
7898 #if CYTHON_FAST_THREAD_STATE
7899 if (unlikely(tstate->curexc_type))
7900 #else
7901 if (unlikely(PyErr_Occurred()))
7902 #endif
7903 goto bad;
7904 #if PY_MAJOR_VERSION >= 3
7905 if (local_tb) {
7906 if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
7907 goto bad;
7908 }
7909 #endif
7910 Py_XINCREF(local_tb);
7911 Py_XINCREF(local_type);
7912 Py_XINCREF(local_value);
7913 *type = local_type;
7914 *value = local_value;
7915 *tb = local_tb;
7916 #if CYTHON_FAST_THREAD_STATE
7917 #if CYTHON_USE_EXC_INFO_STACK
7918 {
7919 _PyErr_StackItem *exc_info = tstate->exc_info;
7920 tmp_type = exc_info->exc_type;
7921 tmp_value = exc_info->exc_value;
7922 tmp_tb = exc_info->exc_traceback;
7923 exc_info->exc_type = local_type;
7924 exc_info->exc_value = local_value;
7925 exc_info->exc_traceback = local_tb;
7926 }
7927 #else
7928 tmp_type = tstate->exc_type;
7929 tmp_value = tstate->exc_value;
7930 tmp_tb = tstate->exc_traceback;
7931 tstate->exc_type = local_type;
7932 tstate->exc_value = local_value;
7933 tstate->exc_traceback = local_tb;
7934 #endif
7935 Py_XDECREF(tmp_type);
7936 Py_XDECREF(tmp_value);
7937 Py_XDECREF(tmp_tb);
7938 #else
7939 PyErr_SetExcInfo(local_type, local_value, local_tb);
7940 #endif
7941 return 0;
7942 bad:
7943 *type = 0;
7944 *value = 0;
7945 *tb = 0;
7946 Py_XDECREF(local_type);
7947 Py_XDECREF(local_value);
7948 Py_XDECREF(local_tb);
7949 return -1;
7950 }
7951
7952 /* None */
__Pyx_RaiseUnboundLocalError(const char * varname)7953 static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) {
7954 PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname);
7955 }
7956
7957 /* PyIntCompare */
__Pyx_PyInt_EqObjC(PyObject * op1,PyObject * op2,CYTHON_UNUSED long intval,CYTHON_UNUSED long inplace)7958 static CYTHON_INLINE PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED long inplace) {
7959 if (op1 == op2) {
7960 Py_RETURN_TRUE;
7961 }
7962 #if PY_MAJOR_VERSION < 3
7963 if (likely(PyInt_CheckExact(op1))) {
7964 const long b = intval;
7965 long a = PyInt_AS_LONG(op1);
7966 if (a == b) Py_RETURN_TRUE; else Py_RETURN_FALSE;
7967 }
7968 #endif
7969 #if CYTHON_USE_PYLONG_INTERNALS
7970 if (likely(PyLong_CheckExact(op1))) {
7971 int unequal;
7972 unsigned long uintval;
7973 Py_ssize_t size = Py_SIZE(op1);
7974 const digit* digits = ((PyLongObject*)op1)->ob_digit;
7975 if (intval == 0) {
7976 if (size == 0) Py_RETURN_TRUE; else Py_RETURN_FALSE;
7977 } else if (intval < 0) {
7978 if (size >= 0)
7979 Py_RETURN_FALSE;
7980 intval = -intval;
7981 size = -size;
7982 } else {
7983 if (size <= 0)
7984 Py_RETURN_FALSE;
7985 }
7986 uintval = (unsigned long) intval;
7987 #if PyLong_SHIFT * 4 < SIZEOF_LONG*8
7988 if (uintval >> (PyLong_SHIFT * 4)) {
7989 unequal = (size != 5) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
7990 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[4] != ((uintval >> (4 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
7991 } else
7992 #endif
7993 #if PyLong_SHIFT * 3 < SIZEOF_LONG*8
7994 if (uintval >> (PyLong_SHIFT * 3)) {
7995 unequal = (size != 4) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
7996 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
7997 } else
7998 #endif
7999 #if PyLong_SHIFT * 2 < SIZEOF_LONG*8
8000 if (uintval >> (PyLong_SHIFT * 2)) {
8001 unequal = (size != 3) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
8002 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
8003 } else
8004 #endif
8005 #if PyLong_SHIFT * 1 < SIZEOF_LONG*8
8006 if (uintval >> (PyLong_SHIFT * 1)) {
8007 unequal = (size != 2) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
8008 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
8009 } else
8010 #endif
8011 unequal = (size != 1) || (((unsigned long) digits[0]) != (uintval & (unsigned long) PyLong_MASK));
8012 if (unequal == 0) Py_RETURN_TRUE; else Py_RETURN_FALSE;
8013 }
8014 #endif
8015 if (PyFloat_CheckExact(op1)) {
8016 const long b = intval;
8017 double a = PyFloat_AS_DOUBLE(op1);
8018 if ((double)a == (double)b) Py_RETURN_TRUE; else Py_RETURN_FALSE;
8019 }
8020 return (
8021 PyObject_RichCompare(op1, op2, Py_EQ));
8022 }
8023
8024 /* GetAttr */
__Pyx_GetAttr(PyObject * o,PyObject * n)8025 static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
8026 #if CYTHON_USE_TYPE_SLOTS
8027 #if PY_MAJOR_VERSION >= 3
8028 if (likely(PyUnicode_Check(n)))
8029 #else
8030 if (likely(PyString_Check(n)))
8031 #endif
8032 return __Pyx_PyObject_GetAttrStr(o, n);
8033 #endif
8034 return PyObject_GetAttr(o, n);
8035 }
8036
8037 /* GetAttr3 */
__Pyx_GetAttr3Default(PyObject * d)8038 static PyObject *__Pyx_GetAttr3Default(PyObject *d) {
8039 __Pyx_PyThreadState_declare
8040 __Pyx_PyThreadState_assign
8041 if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
8042 return NULL;
8043 __Pyx_PyErr_Clear();
8044 Py_INCREF(d);
8045 return d;
8046 }
__Pyx_GetAttr3(PyObject * o,PyObject * n,PyObject * d)8047 static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) {
8048 PyObject *r = __Pyx_GetAttr(o, n);
8049 return (likely(r)) ? r : __Pyx_GetAttr3Default(d);
8050 }
8051
8052 /* Import */
__Pyx_Import(PyObject * name,PyObject * from_list,int level)8053 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
8054 PyObject *empty_list = 0;
8055 PyObject *module = 0;
8056 PyObject *global_dict = 0;
8057 PyObject *empty_dict = 0;
8058 PyObject *list;
8059 #if PY_MAJOR_VERSION < 3
8060 PyObject *py_import;
8061 py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
8062 if (!py_import)
8063 goto bad;
8064 #endif
8065 if (from_list)
8066 list = from_list;
8067 else {
8068 empty_list = PyList_New(0);
8069 if (!empty_list)
8070 goto bad;
8071 list = empty_list;
8072 }
8073 global_dict = PyModule_GetDict(__pyx_m);
8074 if (!global_dict)
8075 goto bad;
8076 empty_dict = PyDict_New();
8077 if (!empty_dict)
8078 goto bad;
8079 {
8080 #if PY_MAJOR_VERSION >= 3
8081 if (level == -1) {
8082 if ((1) && (strchr(__Pyx_MODULE_NAME, '.'))) {
8083 module = PyImport_ImportModuleLevelObject(
8084 name, global_dict, empty_dict, list, 1);
8085 if (!module) {
8086 if (!PyErr_ExceptionMatches(PyExc_ImportError))
8087 goto bad;
8088 PyErr_Clear();
8089 }
8090 }
8091 level = 0;
8092 }
8093 #endif
8094 if (!module) {
8095 #if PY_MAJOR_VERSION < 3
8096 PyObject *py_level = PyInt_FromLong(level);
8097 if (!py_level)
8098 goto bad;
8099 module = PyObject_CallFunctionObjArgs(py_import,
8100 name, global_dict, empty_dict, list, py_level, (PyObject *)NULL);
8101 Py_DECREF(py_level);
8102 #else
8103 module = PyImport_ImportModuleLevelObject(
8104 name, global_dict, empty_dict, list, level);
8105 #endif
8106 }
8107 }
8108 bad:
8109 #if PY_MAJOR_VERSION < 3
8110 Py_XDECREF(py_import);
8111 #endif
8112 Py_XDECREF(empty_list);
8113 Py_XDECREF(empty_dict);
8114 return module;
8115 }
8116
8117 /* ImportFrom */
__Pyx_ImportFrom(PyObject * module,PyObject * name)8118 static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
8119 PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
8120 if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
8121 PyErr_Format(PyExc_ImportError,
8122 #if PY_MAJOR_VERSION < 3
8123 "cannot import name %.230s", PyString_AS_STRING(name));
8124 #else
8125 "cannot import name %S", name);
8126 #endif
8127 }
8128 return value;
8129 }
8130
8131 /* GetItemInt */
__Pyx_GetItemInt_Generic(PyObject * o,PyObject * j)8132 static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
8133 PyObject *r;
8134 if (!j) return NULL;
8135 r = PyObject_GetItem(o, j);
8136 Py_DECREF(j);
8137 return r;
8138 }
__Pyx_GetItemInt_List_Fast(PyObject * o,Py_ssize_t i,CYTHON_NCP_UNUSED int wraparound,CYTHON_NCP_UNUSED int boundscheck)8139 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
8140 CYTHON_NCP_UNUSED int wraparound,
8141 CYTHON_NCP_UNUSED int boundscheck) {
8142 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
8143 Py_ssize_t wrapped_i = i;
8144 if (wraparound & unlikely(i < 0)) {
8145 wrapped_i += PyList_GET_SIZE(o);
8146 }
8147 if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) {
8148 PyObject *r = PyList_GET_ITEM(o, wrapped_i);
8149 Py_INCREF(r);
8150 return r;
8151 }
8152 return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
8153 #else
8154 return PySequence_GetItem(o, i);
8155 #endif
8156 }
__Pyx_GetItemInt_Tuple_Fast(PyObject * o,Py_ssize_t i,CYTHON_NCP_UNUSED int wraparound,CYTHON_NCP_UNUSED int boundscheck)8157 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
8158 CYTHON_NCP_UNUSED int wraparound,
8159 CYTHON_NCP_UNUSED int boundscheck) {
8160 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
8161 Py_ssize_t wrapped_i = i;
8162 if (wraparound & unlikely(i < 0)) {
8163 wrapped_i += PyTuple_GET_SIZE(o);
8164 }
8165 if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) {
8166 PyObject *r = PyTuple_GET_ITEM(o, wrapped_i);
8167 Py_INCREF(r);
8168 return r;
8169 }
8170 return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
8171 #else
8172 return PySequence_GetItem(o, i);
8173 #endif
8174 }
__Pyx_GetItemInt_Fast(PyObject * o,Py_ssize_t i,int is_list,CYTHON_NCP_UNUSED int wraparound,CYTHON_NCP_UNUSED int boundscheck)8175 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
8176 CYTHON_NCP_UNUSED int wraparound,
8177 CYTHON_NCP_UNUSED int boundscheck) {
8178 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
8179 if (is_list || PyList_CheckExact(o)) {
8180 Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
8181 if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) {
8182 PyObject *r = PyList_GET_ITEM(o, n);
8183 Py_INCREF(r);
8184 return r;
8185 }
8186 }
8187 else if (PyTuple_CheckExact(o)) {
8188 Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
8189 if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) {
8190 PyObject *r = PyTuple_GET_ITEM(o, n);
8191 Py_INCREF(r);
8192 return r;
8193 }
8194 } else {
8195 PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
8196 if (likely(m && m->sq_item)) {
8197 if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
8198 Py_ssize_t l = m->sq_length(o);
8199 if (likely(l >= 0)) {
8200 i += l;
8201 } else {
8202 if (!PyErr_ExceptionMatches(PyExc_OverflowError))
8203 return NULL;
8204 PyErr_Clear();
8205 }
8206 }
8207 return m->sq_item(o, i);
8208 }
8209 }
8210 #else
8211 if (is_list || PySequence_Check(o)) {
8212 return PySequence_GetItem(o, i);
8213 }
8214 #endif
8215 return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
8216 }
8217
8218 /* HasAttr */
__Pyx_HasAttr(PyObject * o,PyObject * n)8219 static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) {
8220 PyObject *r;
8221 if (unlikely(!__Pyx_PyBaseString_Check(n))) {
8222 PyErr_SetString(PyExc_TypeError,
8223 "hasattr(): attribute name must be string");
8224 return -1;
8225 }
8226 r = __Pyx_GetAttr(o, n);
8227 if (unlikely(!r)) {
8228 PyErr_Clear();
8229 return 0;
8230 } else {
8231 Py_DECREF(r);
8232 return 1;
8233 }
8234 }
8235
8236 /* PyObject_GenericGetAttrNoDict */
8237 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
__Pyx_RaiseGenericGetAttributeError(PyTypeObject * tp,PyObject * attr_name)8238 static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
8239 PyErr_Format(PyExc_AttributeError,
8240 #if PY_MAJOR_VERSION >= 3
8241 "'%.50s' object has no attribute '%U'",
8242 tp->tp_name, attr_name);
8243 #else
8244 "'%.50s' object has no attribute '%.400s'",
8245 tp->tp_name, PyString_AS_STRING(attr_name));
8246 #endif
8247 return NULL;
8248 }
__Pyx_PyObject_GenericGetAttrNoDict(PyObject * obj,PyObject * attr_name)8249 static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
8250 PyObject *descr;
8251 PyTypeObject *tp = Py_TYPE(obj);
8252 if (unlikely(!PyString_Check(attr_name))) {
8253 return PyObject_GenericGetAttr(obj, attr_name);
8254 }
8255 assert(!tp->tp_dictoffset);
8256 descr = _PyType_Lookup(tp, attr_name);
8257 if (unlikely(!descr)) {
8258 return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
8259 }
8260 Py_INCREF(descr);
8261 #if PY_MAJOR_VERSION < 3
8262 if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
8263 #endif
8264 {
8265 descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
8266 if (unlikely(f)) {
8267 PyObject *res = f(descr, obj, (PyObject *)tp);
8268 Py_DECREF(descr);
8269 return res;
8270 }
8271 }
8272 return descr;
8273 }
8274 #endif
8275
8276 /* PyObject_GenericGetAttr */
8277 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
__Pyx_PyObject_GenericGetAttr(PyObject * obj,PyObject * attr_name)8278 static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) {
8279 if (unlikely(Py_TYPE(obj)->tp_dictoffset)) {
8280 return PyObject_GenericGetAttr(obj, attr_name);
8281 }
8282 return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name);
8283 }
8284 #endif
8285
8286 /* PyObjectGetAttrStrNoError */
__Pyx_PyObject_GetAttrStr_ClearAttributeError(void)8287 static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) {
8288 __Pyx_PyThreadState_declare
8289 __Pyx_PyThreadState_assign
8290 if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
8291 __Pyx_PyErr_Clear();
8292 }
__Pyx_PyObject_GetAttrStrNoError(PyObject * obj,PyObject * attr_name)8293 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) {
8294 PyObject *result;
8295 #if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS && PY_VERSION_HEX >= 0x030700B1
8296 PyTypeObject* tp = Py_TYPE(obj);
8297 if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) {
8298 return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1);
8299 }
8300 #endif
8301 result = __Pyx_PyObject_GetAttrStr(obj, attr_name);
8302 if (unlikely(!result)) {
8303 __Pyx_PyObject_GetAttrStr_ClearAttributeError();
8304 }
8305 return result;
8306 }
8307
8308 /* SetupReduce */
__Pyx_setup_reduce_is_named(PyObject * meth,PyObject * name)8309 static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) {
8310 int ret;
8311 PyObject *name_attr;
8312 name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name);
8313 if (likely(name_attr)) {
8314 ret = PyObject_RichCompareBool(name_attr, name, Py_EQ);
8315 } else {
8316 ret = -1;
8317 }
8318 if (unlikely(ret < 0)) {
8319 PyErr_Clear();
8320 ret = 0;
8321 }
8322 Py_XDECREF(name_attr);
8323 return ret;
8324 }
__Pyx_setup_reduce(PyObject * type_obj)8325 static int __Pyx_setup_reduce(PyObject* type_obj) {
8326 int ret = 0;
8327 PyObject *object_reduce = NULL;
8328 PyObject *object_reduce_ex = NULL;
8329 PyObject *reduce = NULL;
8330 PyObject *reduce_ex = NULL;
8331 PyObject *reduce_cython = NULL;
8332 PyObject *setstate = NULL;
8333 PyObject *setstate_cython = NULL;
8334 #if CYTHON_USE_PYTYPE_LOOKUP
8335 if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto __PYX_GOOD;
8336 #else
8337 if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto __PYX_GOOD;
8338 #endif
8339 #if CYTHON_USE_PYTYPE_LOOKUP
8340 object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
8341 #else
8342 object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
8343 #endif
8344 reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto __PYX_BAD;
8345 if (reduce_ex == object_reduce_ex) {
8346 #if CYTHON_USE_PYTYPE_LOOKUP
8347 object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
8348 #else
8349 object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
8350 #endif
8351 reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto __PYX_BAD;
8352 if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) {
8353 reduce_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_reduce_cython);
8354 if (likely(reduce_cython)) {
8355 ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
8356 ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
8357 } else if (reduce == object_reduce || PyErr_Occurred()) {
8358 goto __PYX_BAD;
8359 }
8360 setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate);
8361 if (!setstate) PyErr_Clear();
8362 if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) {
8363 setstate_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_setstate_cython);
8364 if (likely(setstate_cython)) {
8365 ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
8366 ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
8367 } else if (!setstate || PyErr_Occurred()) {
8368 goto __PYX_BAD;
8369 }
8370 }
8371 PyType_Modified((PyTypeObject*)type_obj);
8372 }
8373 }
8374 goto __PYX_GOOD;
8375 __PYX_BAD:
8376 if (!PyErr_Occurred())
8377 PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name);
8378 ret = -1;
8379 __PYX_GOOD:
8380 #if !CYTHON_USE_PYTYPE_LOOKUP
8381 Py_XDECREF(object_reduce);
8382 Py_XDECREF(object_reduce_ex);
8383 #endif
8384 Py_XDECREF(reduce);
8385 Py_XDECREF(reduce_ex);
8386 Py_XDECREF(reduce_cython);
8387 Py_XDECREF(setstate);
8388 Py_XDECREF(setstate_cython);
8389 return ret;
8390 }
8391
8392 /* CLineInTraceback */
8393 #ifndef CYTHON_CLINE_IN_TRACEBACK
__Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState * tstate,int c_line)8394 static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) {
8395 PyObject *use_cline;
8396 PyObject *ptype, *pvalue, *ptraceback;
8397 #if CYTHON_COMPILING_IN_CPYTHON
8398 PyObject **cython_runtime_dict;
8399 #endif
8400 if (unlikely(!__pyx_cython_runtime)) {
8401 return c_line;
8402 }
8403 __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
8404 #if CYTHON_COMPILING_IN_CPYTHON
8405 cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
8406 if (likely(cython_runtime_dict)) {
8407 __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
8408 use_cline, *cython_runtime_dict,
8409 __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback))
8410 } else
8411 #endif
8412 {
8413 PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
8414 if (use_cline_obj) {
8415 use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
8416 Py_DECREF(use_cline_obj);
8417 } else {
8418 PyErr_Clear();
8419 use_cline = NULL;
8420 }
8421 }
8422 if (!use_cline) {
8423 c_line = 0;
8424 PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
8425 }
8426 else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
8427 c_line = 0;
8428 }
8429 __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
8430 return c_line;
8431 }
8432 #endif
8433
8434 /* CodeObjectCache */
__pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry * entries,int count,int code_line)8435 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
8436 int start = 0, mid = 0, end = count - 1;
8437 if (end >= 0 && code_line > entries[end].code_line) {
8438 return count;
8439 }
8440 while (start < end) {
8441 mid = start + (end - start) / 2;
8442 if (code_line < entries[mid].code_line) {
8443 end = mid;
8444 } else if (code_line > entries[mid].code_line) {
8445 start = mid + 1;
8446 } else {
8447 return mid;
8448 }
8449 }
8450 if (code_line <= entries[mid].code_line) {
8451 return mid;
8452 } else {
8453 return mid + 1;
8454 }
8455 }
__pyx_find_code_object(int code_line)8456 static PyCodeObject *__pyx_find_code_object(int code_line) {
8457 PyCodeObject* code_object;
8458 int pos;
8459 if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
8460 return NULL;
8461 }
8462 pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
8463 if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
8464 return NULL;
8465 }
8466 code_object = __pyx_code_cache.entries[pos].code_object;
8467 Py_INCREF(code_object);
8468 return code_object;
8469 }
__pyx_insert_code_object(int code_line,PyCodeObject * code_object)8470 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
8471 int pos, i;
8472 __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
8473 if (unlikely(!code_line)) {
8474 return;
8475 }
8476 if (unlikely(!entries)) {
8477 entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
8478 if (likely(entries)) {
8479 __pyx_code_cache.entries = entries;
8480 __pyx_code_cache.max_count = 64;
8481 __pyx_code_cache.count = 1;
8482 entries[0].code_line = code_line;
8483 entries[0].code_object = code_object;
8484 Py_INCREF(code_object);
8485 }
8486 return;
8487 }
8488 pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
8489 if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
8490 PyCodeObject* tmp = entries[pos].code_object;
8491 entries[pos].code_object = code_object;
8492 Py_DECREF(tmp);
8493 return;
8494 }
8495 if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
8496 int new_max = __pyx_code_cache.max_count + 64;
8497 entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
8498 __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry));
8499 if (unlikely(!entries)) {
8500 return;
8501 }
8502 __pyx_code_cache.entries = entries;
8503 __pyx_code_cache.max_count = new_max;
8504 }
8505 for (i=__pyx_code_cache.count; i>pos; i--) {
8506 entries[i] = entries[i-1];
8507 }
8508 entries[pos].code_line = code_line;
8509 entries[pos].code_object = code_object;
8510 __pyx_code_cache.count++;
8511 Py_INCREF(code_object);
8512 }
8513
8514 /* AddTraceback */
8515 #include "compile.h"
8516 #include "frameobject.h"
8517 #include "traceback.h"
__Pyx_CreateCodeObjectForTraceback(const char * funcname,int c_line,int py_line,const char * filename)8518 static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
8519 const char *funcname, int c_line,
8520 int py_line, const char *filename) {
8521 PyCodeObject *py_code = 0;
8522 PyObject *py_srcfile = 0;
8523 PyObject *py_funcname = 0;
8524 #if PY_MAJOR_VERSION < 3
8525 py_srcfile = PyString_FromString(filename);
8526 #else
8527 py_srcfile = PyUnicode_FromString(filename);
8528 #endif
8529 if (!py_srcfile) goto bad;
8530 if (c_line) {
8531 #if PY_MAJOR_VERSION < 3
8532 py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
8533 #else
8534 py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
8535 #endif
8536 }
8537 else {
8538 #if PY_MAJOR_VERSION < 3
8539 py_funcname = PyString_FromString(funcname);
8540 #else
8541 py_funcname = PyUnicode_FromString(funcname);
8542 #endif
8543 }
8544 if (!py_funcname) goto bad;
8545 py_code = __Pyx_PyCode_New(
8546 0,
8547 0,
8548 0,
8549 0,
8550 0,
8551 __pyx_empty_bytes, /*PyObject *code,*/
8552 __pyx_empty_tuple, /*PyObject *consts,*/
8553 __pyx_empty_tuple, /*PyObject *names,*/
8554 __pyx_empty_tuple, /*PyObject *varnames,*/
8555 __pyx_empty_tuple, /*PyObject *freevars,*/
8556 __pyx_empty_tuple, /*PyObject *cellvars,*/
8557 py_srcfile, /*PyObject *filename,*/
8558 py_funcname, /*PyObject *name,*/
8559 py_line,
8560 __pyx_empty_bytes /*PyObject *lnotab*/
8561 );
8562 Py_DECREF(py_srcfile);
8563 Py_DECREF(py_funcname);
8564 return py_code;
8565 bad:
8566 Py_XDECREF(py_srcfile);
8567 Py_XDECREF(py_funcname);
8568 return NULL;
8569 }
__Pyx_AddTraceback(const char * funcname,int c_line,int py_line,const char * filename)8570 static void __Pyx_AddTraceback(const char *funcname, int c_line,
8571 int py_line, const char *filename) {
8572 PyCodeObject *py_code = 0;
8573 PyFrameObject *py_frame = 0;
8574 PyThreadState *tstate = __Pyx_PyThreadState_Current;
8575 if (c_line) {
8576 c_line = __Pyx_CLineForTraceback(tstate, c_line);
8577 }
8578 py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
8579 if (!py_code) {
8580 py_code = __Pyx_CreateCodeObjectForTraceback(
8581 funcname, c_line, py_line, filename);
8582 if (!py_code) goto bad;
8583 __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
8584 }
8585 py_frame = PyFrame_New(
8586 tstate, /*PyThreadState *tstate,*/
8587 py_code, /*PyCodeObject *code,*/
8588 __pyx_d, /*PyObject *globals,*/
8589 0 /*PyObject *locals*/
8590 );
8591 if (!py_frame) goto bad;
8592 __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
8593 PyTraceBack_Here(py_frame);
8594 bad:
8595 Py_XDECREF(py_code);
8596 Py_XDECREF(py_frame);
8597 }
8598
8599 /* CIntToPy */
__Pyx_PyInt_From_PY_LONG_LONG(PY_LONG_LONG value)8600 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_PY_LONG_LONG(PY_LONG_LONG value) {
8601 const PY_LONG_LONG neg_one = (PY_LONG_LONG) ((PY_LONG_LONG) 0 - (PY_LONG_LONG) 1), const_zero = (PY_LONG_LONG) 0;
8602 const int is_unsigned = neg_one > const_zero;
8603 if (is_unsigned) {
8604 if (sizeof(PY_LONG_LONG) < sizeof(long)) {
8605 return PyInt_FromLong((long) value);
8606 } else if (sizeof(PY_LONG_LONG) <= sizeof(unsigned long)) {
8607 return PyLong_FromUnsignedLong((unsigned long) value);
8608 #ifdef HAVE_LONG_LONG
8609 } else if (sizeof(PY_LONG_LONG) <= sizeof(unsigned PY_LONG_LONG)) {
8610 return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
8611 #endif
8612 }
8613 } else {
8614 if (sizeof(PY_LONG_LONG) <= sizeof(long)) {
8615 return PyInt_FromLong((long) value);
8616 #ifdef HAVE_LONG_LONG
8617 } else if (sizeof(PY_LONG_LONG) <= sizeof(PY_LONG_LONG)) {
8618 return PyLong_FromLongLong((PY_LONG_LONG) value);
8619 #endif
8620 }
8621 }
8622 {
8623 int one = 1; int little = (int)*(unsigned char *)&one;
8624 unsigned char *bytes = (unsigned char *)&value;
8625 return _PyLong_FromByteArray(bytes, sizeof(PY_LONG_LONG),
8626 little, !is_unsigned);
8627 }
8628 }
8629
8630 /* CIntFromPyVerify */
8631 #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
8632 __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
8633 #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
8634 __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
8635 #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
8636 {\
8637 func_type value = func_value;\
8638 if (sizeof(target_type) < sizeof(func_type)) {\
8639 if (unlikely(value != (func_type) (target_type) value)) {\
8640 func_type zero = 0;\
8641 if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
8642 return (target_type) -1;\
8643 if (is_unsigned && unlikely(value < zero))\
8644 goto raise_neg_overflow;\
8645 else\
8646 goto raise_overflow;\
8647 }\
8648 }\
8649 return (target_type) value;\
8650 }
8651
8652 /* CIntToPy */
__Pyx_PyInt_From_long(long value)8653 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
8654 const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0;
8655 const int is_unsigned = neg_one > const_zero;
8656 if (is_unsigned) {
8657 if (sizeof(long) < sizeof(long)) {
8658 return PyInt_FromLong((long) value);
8659 } else if (sizeof(long) <= sizeof(unsigned long)) {
8660 return PyLong_FromUnsignedLong((unsigned long) value);
8661 #ifdef HAVE_LONG_LONG
8662 } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
8663 return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
8664 #endif
8665 }
8666 } else {
8667 if (sizeof(long) <= sizeof(long)) {
8668 return PyInt_FromLong((long) value);
8669 #ifdef HAVE_LONG_LONG
8670 } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
8671 return PyLong_FromLongLong((PY_LONG_LONG) value);
8672 #endif
8673 }
8674 }
8675 {
8676 int one = 1; int little = (int)*(unsigned char *)&one;
8677 unsigned char *bytes = (unsigned char *)&value;
8678 return _PyLong_FromByteArray(bytes, sizeof(long),
8679 little, !is_unsigned);
8680 }
8681 }
8682
8683 /* CIntFromPy */
__Pyx_PyInt_As_PY_LONG_LONG(PyObject * x)8684 static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_As_PY_LONG_LONG(PyObject *x) {
8685 const PY_LONG_LONG neg_one = (PY_LONG_LONG) ((PY_LONG_LONG) 0 - (PY_LONG_LONG) 1), const_zero = (PY_LONG_LONG) 0;
8686 const int is_unsigned = neg_one > const_zero;
8687 #if PY_MAJOR_VERSION < 3
8688 if (likely(PyInt_Check(x))) {
8689 if (sizeof(PY_LONG_LONG) < sizeof(long)) {
8690 __PYX_VERIFY_RETURN_INT(PY_LONG_LONG, long, PyInt_AS_LONG(x))
8691 } else {
8692 long val = PyInt_AS_LONG(x);
8693 if (is_unsigned && unlikely(val < 0)) {
8694 goto raise_neg_overflow;
8695 }
8696 return (PY_LONG_LONG) val;
8697 }
8698 } else
8699 #endif
8700 if (likely(PyLong_Check(x))) {
8701 if (is_unsigned) {
8702 #if CYTHON_USE_PYLONG_INTERNALS
8703 const digit* digits = ((PyLongObject*)x)->ob_digit;
8704 switch (Py_SIZE(x)) {
8705 case 0: return (PY_LONG_LONG) 0;
8706 case 1: __PYX_VERIFY_RETURN_INT(PY_LONG_LONG, digit, digits[0])
8707 case 2:
8708 if (8 * sizeof(PY_LONG_LONG) > 1 * PyLong_SHIFT) {
8709 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
8710 __PYX_VERIFY_RETURN_INT(PY_LONG_LONG, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
8711 } else if (8 * sizeof(PY_LONG_LONG) >= 2 * PyLong_SHIFT) {
8712 return (PY_LONG_LONG) (((((PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[0]));
8713 }
8714 }
8715 break;
8716 case 3:
8717 if (8 * sizeof(PY_LONG_LONG) > 2 * PyLong_SHIFT) {
8718 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
8719 __PYX_VERIFY_RETURN_INT(PY_LONG_LONG, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
8720 } else if (8 * sizeof(PY_LONG_LONG) >= 3 * PyLong_SHIFT) {
8721 return (PY_LONG_LONG) (((((((PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[0]));
8722 }
8723 }
8724 break;
8725 case 4:
8726 if (8 * sizeof(PY_LONG_LONG) > 3 * PyLong_SHIFT) {
8727 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
8728 __PYX_VERIFY_RETURN_INT(PY_LONG_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])))
8729 } else if (8 * sizeof(PY_LONG_LONG) >= 4 * PyLong_SHIFT) {
8730 return (PY_LONG_LONG) (((((((((PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[0]));
8731 }
8732 }
8733 break;
8734 }
8735 #endif
8736 #if CYTHON_COMPILING_IN_CPYTHON
8737 if (unlikely(Py_SIZE(x) < 0)) {
8738 goto raise_neg_overflow;
8739 }
8740 #else
8741 {
8742 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
8743 if (unlikely(result < 0))
8744 return (PY_LONG_LONG) -1;
8745 if (unlikely(result == 1))
8746 goto raise_neg_overflow;
8747 }
8748 #endif
8749 if (sizeof(PY_LONG_LONG) <= sizeof(unsigned long)) {
8750 __PYX_VERIFY_RETURN_INT_EXC(PY_LONG_LONG, unsigned long, PyLong_AsUnsignedLong(x))
8751 #ifdef HAVE_LONG_LONG
8752 } else if (sizeof(PY_LONG_LONG) <= sizeof(unsigned PY_LONG_LONG)) {
8753 __PYX_VERIFY_RETURN_INT_EXC(PY_LONG_LONG, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
8754 #endif
8755 }
8756 } else {
8757 #if CYTHON_USE_PYLONG_INTERNALS
8758 const digit* digits = ((PyLongObject*)x)->ob_digit;
8759 switch (Py_SIZE(x)) {
8760 case 0: return (PY_LONG_LONG) 0;
8761 case -1: __PYX_VERIFY_RETURN_INT(PY_LONG_LONG, sdigit, (sdigit) (-(sdigit)digits[0]))
8762 case 1: __PYX_VERIFY_RETURN_INT(PY_LONG_LONG, digit, +digits[0])
8763 case -2:
8764 if (8 * sizeof(PY_LONG_LONG) - 1 > 1 * PyLong_SHIFT) {
8765 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
8766 __PYX_VERIFY_RETURN_INT(PY_LONG_LONG, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
8767 } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
8768 return (PY_LONG_LONG) (((PY_LONG_LONG)-1)*(((((PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[0])));
8769 }
8770 }
8771 break;
8772 case 2:
8773 if (8 * sizeof(PY_LONG_LONG) > 1 * PyLong_SHIFT) {
8774 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
8775 __PYX_VERIFY_RETURN_INT(PY_LONG_LONG, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
8776 } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
8777 return (PY_LONG_LONG) ((((((PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[0])));
8778 }
8779 }
8780 break;
8781 case -3:
8782 if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
8783 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
8784 __PYX_VERIFY_RETURN_INT(PY_LONG_LONG, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
8785 } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
8786 return (PY_LONG_LONG) (((PY_LONG_LONG)-1)*(((((((PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[0])));
8787 }
8788 }
8789 break;
8790 case 3:
8791 if (8 * sizeof(PY_LONG_LONG) > 2 * PyLong_SHIFT) {
8792 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
8793 __PYX_VERIFY_RETURN_INT(PY_LONG_LONG, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
8794 } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
8795 return (PY_LONG_LONG) ((((((((PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[0])));
8796 }
8797 }
8798 break;
8799 case -4:
8800 if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
8801 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
8802 __PYX_VERIFY_RETURN_INT(PY_LONG_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])))
8803 } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
8804 return (PY_LONG_LONG) (((PY_LONG_LONG)-1)*(((((((((PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[0])));
8805 }
8806 }
8807 break;
8808 case 4:
8809 if (8 * sizeof(PY_LONG_LONG) > 3 * PyLong_SHIFT) {
8810 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
8811 __PYX_VERIFY_RETURN_INT(PY_LONG_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])))
8812 } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
8813 return (PY_LONG_LONG) ((((((((((PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[0])));
8814 }
8815 }
8816 break;
8817 }
8818 #endif
8819 if (sizeof(PY_LONG_LONG) <= sizeof(long)) {
8820 __PYX_VERIFY_RETURN_INT_EXC(PY_LONG_LONG, long, PyLong_AsLong(x))
8821 #ifdef HAVE_LONG_LONG
8822 } else if (sizeof(PY_LONG_LONG) <= sizeof(PY_LONG_LONG)) {
8823 __PYX_VERIFY_RETURN_INT_EXC(PY_LONG_LONG, PY_LONG_LONG, PyLong_AsLongLong(x))
8824 #endif
8825 }
8826 }
8827 {
8828 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
8829 PyErr_SetString(PyExc_RuntimeError,
8830 "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
8831 #else
8832 PY_LONG_LONG val;
8833 PyObject *v = __Pyx_PyNumber_IntOrLong(x);
8834 #if PY_MAJOR_VERSION < 3
8835 if (likely(v) && !PyLong_Check(v)) {
8836 PyObject *tmp = v;
8837 v = PyNumber_Long(tmp);
8838 Py_DECREF(tmp);
8839 }
8840 #endif
8841 if (likely(v)) {
8842 int one = 1; int is_little = (int)*(unsigned char *)&one;
8843 unsigned char *bytes = (unsigned char *)&val;
8844 int ret = _PyLong_AsByteArray((PyLongObject *)v,
8845 bytes, sizeof(val),
8846 is_little, !is_unsigned);
8847 Py_DECREF(v);
8848 if (likely(!ret))
8849 return val;
8850 }
8851 #endif
8852 return (PY_LONG_LONG) -1;
8853 }
8854 } else {
8855 PY_LONG_LONG val;
8856 PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
8857 if (!tmp) return (PY_LONG_LONG) -1;
8858 val = __Pyx_PyInt_As_PY_LONG_LONG(tmp);
8859 Py_DECREF(tmp);
8860 return val;
8861 }
8862 raise_overflow:
8863 PyErr_SetString(PyExc_OverflowError,
8864 "value too large to convert to PY_LONG_LONG");
8865 return (PY_LONG_LONG) -1;
8866 raise_neg_overflow:
8867 PyErr_SetString(PyExc_OverflowError,
8868 "can't convert negative value to PY_LONG_LONG");
8869 return (PY_LONG_LONG) -1;
8870 }
8871
8872 /* CIntFromPy */
__Pyx_PyInt_As_long(PyObject * x)8873 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
8874 const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0;
8875 const int is_unsigned = neg_one > const_zero;
8876 #if PY_MAJOR_VERSION < 3
8877 if (likely(PyInt_Check(x))) {
8878 if (sizeof(long) < sizeof(long)) {
8879 __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
8880 } else {
8881 long val = PyInt_AS_LONG(x);
8882 if (is_unsigned && unlikely(val < 0)) {
8883 goto raise_neg_overflow;
8884 }
8885 return (long) val;
8886 }
8887 } else
8888 #endif
8889 if (likely(PyLong_Check(x))) {
8890 if (is_unsigned) {
8891 #if CYTHON_USE_PYLONG_INTERNALS
8892 const digit* digits = ((PyLongObject*)x)->ob_digit;
8893 switch (Py_SIZE(x)) {
8894 case 0: return (long) 0;
8895 case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
8896 case 2:
8897 if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
8898 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
8899 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
8900 } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
8901 return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
8902 }
8903 }
8904 break;
8905 case 3:
8906 if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
8907 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
8908 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
8909 } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
8910 return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
8911 }
8912 }
8913 break;
8914 case 4:
8915 if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
8916 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
8917 __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])))
8918 } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
8919 return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
8920 }
8921 }
8922 break;
8923 }
8924 #endif
8925 #if CYTHON_COMPILING_IN_CPYTHON
8926 if (unlikely(Py_SIZE(x) < 0)) {
8927 goto raise_neg_overflow;
8928 }
8929 #else
8930 {
8931 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
8932 if (unlikely(result < 0))
8933 return (long) -1;
8934 if (unlikely(result == 1))
8935 goto raise_neg_overflow;
8936 }
8937 #endif
8938 if (sizeof(long) <= sizeof(unsigned long)) {
8939 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
8940 #ifdef HAVE_LONG_LONG
8941 } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
8942 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
8943 #endif
8944 }
8945 } else {
8946 #if CYTHON_USE_PYLONG_INTERNALS
8947 const digit* digits = ((PyLongObject*)x)->ob_digit;
8948 switch (Py_SIZE(x)) {
8949 case 0: return (long) 0;
8950 case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
8951 case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
8952 case -2:
8953 if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
8954 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
8955 __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
8956 } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
8957 return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
8958 }
8959 }
8960 break;
8961 case 2:
8962 if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
8963 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
8964 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
8965 } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
8966 return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
8967 }
8968 }
8969 break;
8970 case -3:
8971 if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
8972 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
8973 __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
8974 } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
8975 return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
8976 }
8977 }
8978 break;
8979 case 3:
8980 if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
8981 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
8982 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
8983 } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
8984 return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
8985 }
8986 }
8987 break;
8988 case -4:
8989 if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
8990 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
8991 __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])))
8992 } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
8993 return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
8994 }
8995 }
8996 break;
8997 case 4:
8998 if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
8999 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
9000 __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])))
9001 } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
9002 return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
9003 }
9004 }
9005 break;
9006 }
9007 #endif
9008 if (sizeof(long) <= sizeof(long)) {
9009 __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
9010 #ifdef HAVE_LONG_LONG
9011 } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
9012 __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
9013 #endif
9014 }
9015 }
9016 {
9017 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
9018 PyErr_SetString(PyExc_RuntimeError,
9019 "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
9020 #else
9021 long val;
9022 PyObject *v = __Pyx_PyNumber_IntOrLong(x);
9023 #if PY_MAJOR_VERSION < 3
9024 if (likely(v) && !PyLong_Check(v)) {
9025 PyObject *tmp = v;
9026 v = PyNumber_Long(tmp);
9027 Py_DECREF(tmp);
9028 }
9029 #endif
9030 if (likely(v)) {
9031 int one = 1; int is_little = (int)*(unsigned char *)&one;
9032 unsigned char *bytes = (unsigned char *)&val;
9033 int ret = _PyLong_AsByteArray((PyLongObject *)v,
9034 bytes, sizeof(val),
9035 is_little, !is_unsigned);
9036 Py_DECREF(v);
9037 if (likely(!ret))
9038 return val;
9039 }
9040 #endif
9041 return (long) -1;
9042 }
9043 } else {
9044 long val;
9045 PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
9046 if (!tmp) return (long) -1;
9047 val = __Pyx_PyInt_As_long(tmp);
9048 Py_DECREF(tmp);
9049 return val;
9050 }
9051 raise_overflow:
9052 PyErr_SetString(PyExc_OverflowError,
9053 "value too large to convert to long");
9054 return (long) -1;
9055 raise_neg_overflow:
9056 PyErr_SetString(PyExc_OverflowError,
9057 "can't convert negative value to long");
9058 return (long) -1;
9059 }
9060
9061 /* CIntFromPy */
__Pyx_PyInt_As_int(PyObject * x)9062 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
9063 const int neg_one = (int) ((int) 0 - (int) 1), const_zero = (int) 0;
9064 const int is_unsigned = neg_one > const_zero;
9065 #if PY_MAJOR_VERSION < 3
9066 if (likely(PyInt_Check(x))) {
9067 if (sizeof(int) < sizeof(long)) {
9068 __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
9069 } else {
9070 long val = PyInt_AS_LONG(x);
9071 if (is_unsigned && unlikely(val < 0)) {
9072 goto raise_neg_overflow;
9073 }
9074 return (int) val;
9075 }
9076 } else
9077 #endif
9078 if (likely(PyLong_Check(x))) {
9079 if (is_unsigned) {
9080 #if CYTHON_USE_PYLONG_INTERNALS
9081 const digit* digits = ((PyLongObject*)x)->ob_digit;
9082 switch (Py_SIZE(x)) {
9083 case 0: return (int) 0;
9084 case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
9085 case 2:
9086 if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
9087 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
9088 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
9089 } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
9090 return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
9091 }
9092 }
9093 break;
9094 case 3:
9095 if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
9096 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
9097 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
9098 } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
9099 return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
9100 }
9101 }
9102 break;
9103 case 4:
9104 if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
9105 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
9106 __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])))
9107 } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
9108 return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
9109 }
9110 }
9111 break;
9112 }
9113 #endif
9114 #if CYTHON_COMPILING_IN_CPYTHON
9115 if (unlikely(Py_SIZE(x) < 0)) {
9116 goto raise_neg_overflow;
9117 }
9118 #else
9119 {
9120 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
9121 if (unlikely(result < 0))
9122 return (int) -1;
9123 if (unlikely(result == 1))
9124 goto raise_neg_overflow;
9125 }
9126 #endif
9127 if (sizeof(int) <= sizeof(unsigned long)) {
9128 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
9129 #ifdef HAVE_LONG_LONG
9130 } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
9131 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
9132 #endif
9133 }
9134 } else {
9135 #if CYTHON_USE_PYLONG_INTERNALS
9136 const digit* digits = ((PyLongObject*)x)->ob_digit;
9137 switch (Py_SIZE(x)) {
9138 case 0: return (int) 0;
9139 case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
9140 case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0])
9141 case -2:
9142 if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
9143 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
9144 __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
9145 } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
9146 return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
9147 }
9148 }
9149 break;
9150 case 2:
9151 if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
9152 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
9153 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
9154 } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
9155 return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
9156 }
9157 }
9158 break;
9159 case -3:
9160 if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
9161 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
9162 __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
9163 } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
9164 return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
9165 }
9166 }
9167 break;
9168 case 3:
9169 if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
9170 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
9171 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
9172 } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
9173 return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
9174 }
9175 }
9176 break;
9177 case -4:
9178 if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
9179 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
9180 __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])))
9181 } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
9182 return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
9183 }
9184 }
9185 break;
9186 case 4:
9187 if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
9188 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
9189 __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])))
9190 } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
9191 return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
9192 }
9193 }
9194 break;
9195 }
9196 #endif
9197 if (sizeof(int) <= sizeof(long)) {
9198 __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
9199 #ifdef HAVE_LONG_LONG
9200 } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
9201 __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
9202 #endif
9203 }
9204 }
9205 {
9206 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
9207 PyErr_SetString(PyExc_RuntimeError,
9208 "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
9209 #else
9210 int val;
9211 PyObject *v = __Pyx_PyNumber_IntOrLong(x);
9212 #if PY_MAJOR_VERSION < 3
9213 if (likely(v) && !PyLong_Check(v)) {
9214 PyObject *tmp = v;
9215 v = PyNumber_Long(tmp);
9216 Py_DECREF(tmp);
9217 }
9218 #endif
9219 if (likely(v)) {
9220 int one = 1; int is_little = (int)*(unsigned char *)&one;
9221 unsigned char *bytes = (unsigned char *)&val;
9222 int ret = _PyLong_AsByteArray((PyLongObject *)v,
9223 bytes, sizeof(val),
9224 is_little, !is_unsigned);
9225 Py_DECREF(v);
9226 if (likely(!ret))
9227 return val;
9228 }
9229 #endif
9230 return (int) -1;
9231 }
9232 } else {
9233 int val;
9234 PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
9235 if (!tmp) return (int) -1;
9236 val = __Pyx_PyInt_As_int(tmp);
9237 Py_DECREF(tmp);
9238 return val;
9239 }
9240 raise_overflow:
9241 PyErr_SetString(PyExc_OverflowError,
9242 "value too large to convert to int");
9243 return (int) -1;
9244 raise_neg_overflow:
9245 PyErr_SetString(PyExc_OverflowError,
9246 "can't convert negative value to int");
9247 return (int) -1;
9248 }
9249
9250 /* FastTypeChecks */
9251 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_InBases(PyTypeObject * a,PyTypeObject * b)9252 static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
9253 while (a) {
9254 a = a->tp_base;
9255 if (a == b)
9256 return 1;
9257 }
9258 return b == &PyBaseObject_Type;
9259 }
__Pyx_IsSubtype(PyTypeObject * a,PyTypeObject * b)9260 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
9261 PyObject *mro;
9262 if (a == b) return 1;
9263 mro = a->tp_mro;
9264 if (likely(mro)) {
9265 Py_ssize_t i, n;
9266 n = PyTuple_GET_SIZE(mro);
9267 for (i = 0; i < n; i++) {
9268 if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
9269 return 1;
9270 }
9271 return 0;
9272 }
9273 return __Pyx_InBases(a, b);
9274 }
9275 #if PY_MAJOR_VERSION == 2
__Pyx_inner_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)9276 static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
9277 PyObject *exception, *value, *tb;
9278 int res;
9279 __Pyx_PyThreadState_declare
9280 __Pyx_PyThreadState_assign
9281 __Pyx_ErrFetch(&exception, &value, &tb);
9282 res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
9283 if (unlikely(res == -1)) {
9284 PyErr_WriteUnraisable(err);
9285 res = 0;
9286 }
9287 if (!res) {
9288 res = PyObject_IsSubclass(err, exc_type2);
9289 if (unlikely(res == -1)) {
9290 PyErr_WriteUnraisable(err);
9291 res = 0;
9292 }
9293 }
9294 __Pyx_ErrRestore(exception, value, tb);
9295 return res;
9296 }
9297 #else
__Pyx_inner_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)9298 static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
9299 int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
9300 if (!res) {
9301 res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
9302 }
9303 return res;
9304 }
9305 #endif
__Pyx_PyErr_GivenExceptionMatchesTuple(PyObject * exc_type,PyObject * tuple)9306 static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
9307 Py_ssize_t i, n;
9308 assert(PyExceptionClass_Check(exc_type));
9309 n = PyTuple_GET_SIZE(tuple);
9310 #if PY_MAJOR_VERSION >= 3
9311 for (i=0; i<n; i++) {
9312 if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
9313 }
9314 #endif
9315 for (i=0; i<n; i++) {
9316 PyObject *t = PyTuple_GET_ITEM(tuple, i);
9317 #if PY_MAJOR_VERSION < 3
9318 if (likely(exc_type == t)) return 1;
9319 #endif
9320 if (likely(PyExceptionClass_Check(t))) {
9321 if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
9322 } else {
9323 }
9324 }
9325 return 0;
9326 }
__Pyx_PyErr_GivenExceptionMatches(PyObject * err,PyObject * exc_type)9327 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
9328 if (likely(err == exc_type)) return 1;
9329 if (likely(PyExceptionClass_Check(err))) {
9330 if (likely(PyExceptionClass_Check(exc_type))) {
9331 return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
9332 } else if (likely(PyTuple_Check(exc_type))) {
9333 return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
9334 } else {
9335 }
9336 }
9337 return PyErr_GivenExceptionMatches(err, exc_type);
9338 }
__Pyx_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)9339 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
9340 assert(PyExceptionClass_Check(exc_type1));
9341 assert(PyExceptionClass_Check(exc_type2));
9342 if (likely(err == exc_type1 || err == exc_type2)) return 1;
9343 if (likely(PyExceptionClass_Check(err))) {
9344 return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
9345 }
9346 return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
9347 }
9348 #endif
9349
9350 /* FetchCommonType */
__Pyx_FetchCommonType(PyTypeObject * type)9351 static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
9352 PyObject* fake_module;
9353 PyTypeObject* cached_type = NULL;
9354 fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI);
9355 if (!fake_module) return NULL;
9356 Py_INCREF(fake_module);
9357 cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name);
9358 if (cached_type) {
9359 if (!PyType_Check((PyObject*)cached_type)) {
9360 PyErr_Format(PyExc_TypeError,
9361 "Shared Cython type %.200s is not a type object",
9362 type->tp_name);
9363 goto bad;
9364 }
9365 if (cached_type->tp_basicsize != type->tp_basicsize) {
9366 PyErr_Format(PyExc_TypeError,
9367 "Shared Cython type %.200s has the wrong size, try recompiling",
9368 type->tp_name);
9369 goto bad;
9370 }
9371 } else {
9372 if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
9373 PyErr_Clear();
9374 if (PyType_Ready(type) < 0) goto bad;
9375 if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0)
9376 goto bad;
9377 Py_INCREF(type);
9378 cached_type = type;
9379 }
9380 done:
9381 Py_DECREF(fake_module);
9382 return cached_type;
9383 bad:
9384 Py_XDECREF(cached_type);
9385 cached_type = NULL;
9386 goto done;
9387 }
9388
9389 /* SwapException */
9390 #if CYTHON_FAST_THREAD_STATE
__Pyx__ExceptionSwap(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)9391 static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
9392 PyObject *tmp_type, *tmp_value, *tmp_tb;
9393 #if CYTHON_USE_EXC_INFO_STACK
9394 _PyErr_StackItem *exc_info = tstate->exc_info;
9395 tmp_type = exc_info->exc_type;
9396 tmp_value = exc_info->exc_value;
9397 tmp_tb = exc_info->exc_traceback;
9398 exc_info->exc_type = *type;
9399 exc_info->exc_value = *value;
9400 exc_info->exc_traceback = *tb;
9401 #else
9402 tmp_type = tstate->exc_type;
9403 tmp_value = tstate->exc_value;
9404 tmp_tb = tstate->exc_traceback;
9405 tstate->exc_type = *type;
9406 tstate->exc_value = *value;
9407 tstate->exc_traceback = *tb;
9408 #endif
9409 *type = tmp_type;
9410 *value = tmp_value;
9411 *tb = tmp_tb;
9412 }
9413 #else
__Pyx_ExceptionSwap(PyObject ** type,PyObject ** value,PyObject ** tb)9414 static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
9415 PyObject *tmp_type, *tmp_value, *tmp_tb;
9416 PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
9417 PyErr_SetExcInfo(*type, *value, *tb);
9418 *type = tmp_type;
9419 *value = tmp_value;
9420 *tb = tmp_tb;
9421 }
9422 #endif
9423
9424 /* PyObjectGetMethod */
__Pyx_PyObject_GetMethod(PyObject * obj,PyObject * name,PyObject ** method)9425 static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method) {
9426 PyObject *attr;
9427 #if CYTHON_UNPACK_METHODS && CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_PYTYPE_LOOKUP
9428 PyTypeObject *tp = Py_TYPE(obj);
9429 PyObject *descr;
9430 descrgetfunc f = NULL;
9431 PyObject **dictptr, *dict;
9432 int meth_found = 0;
9433 assert (*method == NULL);
9434 if (unlikely(tp->tp_getattro != PyObject_GenericGetAttr)) {
9435 attr = __Pyx_PyObject_GetAttrStr(obj, name);
9436 goto try_unpack;
9437 }
9438 if (unlikely(tp->tp_dict == NULL) && unlikely(PyType_Ready(tp) < 0)) {
9439 return 0;
9440 }
9441 descr = _PyType_Lookup(tp, name);
9442 if (likely(descr != NULL)) {
9443 Py_INCREF(descr);
9444 #if PY_MAJOR_VERSION >= 3
9445 #ifdef __Pyx_CyFunction_USED
9446 if (likely(PyFunction_Check(descr) || (Py_TYPE(descr) == &PyMethodDescr_Type) || __Pyx_CyFunction_Check(descr)))
9447 #else
9448 if (likely(PyFunction_Check(descr) || (Py_TYPE(descr) == &PyMethodDescr_Type)))
9449 #endif
9450 #else
9451 #ifdef __Pyx_CyFunction_USED
9452 if (likely(PyFunction_Check(descr) || __Pyx_CyFunction_Check(descr)))
9453 #else
9454 if (likely(PyFunction_Check(descr)))
9455 #endif
9456 #endif
9457 {
9458 meth_found = 1;
9459 } else {
9460 f = Py_TYPE(descr)->tp_descr_get;
9461 if (f != NULL && PyDescr_IsData(descr)) {
9462 attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
9463 Py_DECREF(descr);
9464 goto try_unpack;
9465 }
9466 }
9467 }
9468 dictptr = _PyObject_GetDictPtr(obj);
9469 if (dictptr != NULL && (dict = *dictptr) != NULL) {
9470 Py_INCREF(dict);
9471 attr = __Pyx_PyDict_GetItemStr(dict, name);
9472 if (attr != NULL) {
9473 Py_INCREF(attr);
9474 Py_DECREF(dict);
9475 Py_XDECREF(descr);
9476 goto try_unpack;
9477 }
9478 Py_DECREF(dict);
9479 }
9480 if (meth_found) {
9481 *method = descr;
9482 return 1;
9483 }
9484 if (f != NULL) {
9485 attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
9486 Py_DECREF(descr);
9487 goto try_unpack;
9488 }
9489 if (descr != NULL) {
9490 *method = descr;
9491 return 0;
9492 }
9493 PyErr_Format(PyExc_AttributeError,
9494 #if PY_MAJOR_VERSION >= 3
9495 "'%.50s' object has no attribute '%U'",
9496 tp->tp_name, name);
9497 #else
9498 "'%.50s' object has no attribute '%.400s'",
9499 tp->tp_name, PyString_AS_STRING(name));
9500 #endif
9501 return 0;
9502 #else
9503 attr = __Pyx_PyObject_GetAttrStr(obj, name);
9504 goto try_unpack;
9505 #endif
9506 try_unpack:
9507 #if CYTHON_UNPACK_METHODS
9508 if (likely(attr) && PyMethod_Check(attr) && likely(PyMethod_GET_SELF(attr) == obj)) {
9509 PyObject *function = PyMethod_GET_FUNCTION(attr);
9510 Py_INCREF(function);
9511 Py_DECREF(attr);
9512 *method = function;
9513 return 1;
9514 }
9515 #endif
9516 *method = attr;
9517 return 0;
9518 }
9519
9520 /* PyObjectCallMethod1 */
__Pyx__PyObject_CallMethod1(PyObject * method,PyObject * arg)9521 static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg) {
9522 PyObject *result = __Pyx_PyObject_CallOneArg(method, arg);
9523 Py_DECREF(method);
9524 return result;
9525 }
__Pyx_PyObject_CallMethod1(PyObject * obj,PyObject * method_name,PyObject * arg)9526 static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) {
9527 PyObject *method = NULL, *result;
9528 int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method);
9529 if (likely(is_method)) {
9530 result = __Pyx_PyObject_Call2Args(method, obj, arg);
9531 Py_DECREF(method);
9532 return result;
9533 }
9534 if (unlikely(!method)) return NULL;
9535 return __Pyx__PyObject_CallMethod1(method, arg);
9536 }
9537
9538 /* CoroutineBase */
9539 #include <structmember.h>
9540 #include <frameobject.h>
9541 #define __Pyx_Coroutine_Undelegate(gen) Py_CLEAR((gen)->yieldfrom)
__Pyx_PyGen__FetchStopIterationValue(CYTHON_UNUSED PyThreadState * __pyx_tstate,PyObject ** pvalue)9542 static int __Pyx_PyGen__FetchStopIterationValue(CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject **pvalue) {
9543 PyObject *et, *ev, *tb;
9544 PyObject *value = NULL;
9545 __Pyx_ErrFetch(&et, &ev, &tb);
9546 if (!et) {
9547 Py_XDECREF(tb);
9548 Py_XDECREF(ev);
9549 Py_INCREF(Py_None);
9550 *pvalue = Py_None;
9551 return 0;
9552 }
9553 if (likely(et == PyExc_StopIteration)) {
9554 if (!ev) {
9555 Py_INCREF(Py_None);
9556 value = Py_None;
9557 }
9558 #if PY_VERSION_HEX >= 0x030300A0
9559 else if (Py_TYPE(ev) == (PyTypeObject*)PyExc_StopIteration) {
9560 value = ((PyStopIterationObject *)ev)->value;
9561 Py_INCREF(value);
9562 Py_DECREF(ev);
9563 }
9564 #endif
9565 else if (unlikely(PyTuple_Check(ev))) {
9566 if (PyTuple_GET_SIZE(ev) >= 1) {
9567 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
9568 value = PyTuple_GET_ITEM(ev, 0);
9569 Py_INCREF(value);
9570 #else
9571 value = PySequence_ITEM(ev, 0);
9572 #endif
9573 } else {
9574 Py_INCREF(Py_None);
9575 value = Py_None;
9576 }
9577 Py_DECREF(ev);
9578 }
9579 else if (!__Pyx_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration)) {
9580 value = ev;
9581 }
9582 if (likely(value)) {
9583 Py_XDECREF(tb);
9584 Py_DECREF(et);
9585 *pvalue = value;
9586 return 0;
9587 }
9588 } else if (!__Pyx_PyErr_GivenExceptionMatches(et, PyExc_StopIteration)) {
9589 __Pyx_ErrRestore(et, ev, tb);
9590 return -1;
9591 }
9592 PyErr_NormalizeException(&et, &ev, &tb);
9593 if (unlikely(!PyObject_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration))) {
9594 __Pyx_ErrRestore(et, ev, tb);
9595 return -1;
9596 }
9597 Py_XDECREF(tb);
9598 Py_DECREF(et);
9599 #if PY_VERSION_HEX >= 0x030300A0
9600 value = ((PyStopIterationObject *)ev)->value;
9601 Py_INCREF(value);
9602 Py_DECREF(ev);
9603 #else
9604 {
9605 PyObject* args = __Pyx_PyObject_GetAttrStr(ev, __pyx_n_s_args);
9606 Py_DECREF(ev);
9607 if (likely(args)) {
9608 value = PySequence_GetItem(args, 0);
9609 Py_DECREF(args);
9610 }
9611 if (unlikely(!value)) {
9612 __Pyx_ErrRestore(NULL, NULL, NULL);
9613 Py_INCREF(Py_None);
9614 value = Py_None;
9615 }
9616 }
9617 #endif
9618 *pvalue = value;
9619 return 0;
9620 }
9621 static CYTHON_INLINE
__Pyx_Coroutine_ExceptionClear(__Pyx_ExcInfoStruct * exc_state)9622 void __Pyx_Coroutine_ExceptionClear(__Pyx_ExcInfoStruct *exc_state) {
9623 PyObject *t, *v, *tb;
9624 t = exc_state->exc_type;
9625 v = exc_state->exc_value;
9626 tb = exc_state->exc_traceback;
9627 exc_state->exc_type = NULL;
9628 exc_state->exc_value = NULL;
9629 exc_state->exc_traceback = NULL;
9630 Py_XDECREF(t);
9631 Py_XDECREF(v);
9632 Py_XDECREF(tb);
9633 }
9634 #define __Pyx_Coroutine_AlreadyRunningError(gen) (__Pyx__Coroutine_AlreadyRunningError(gen), (PyObject*)NULL)
__Pyx__Coroutine_AlreadyRunningError(CYTHON_UNUSED __pyx_CoroutineObject * gen)9635 static void __Pyx__Coroutine_AlreadyRunningError(CYTHON_UNUSED __pyx_CoroutineObject *gen) {
9636 const char *msg;
9637 if ((0)) {
9638 #ifdef __Pyx_Coroutine_USED
9639 } else if (__Pyx_Coroutine_Check((PyObject*)gen)) {
9640 msg = "coroutine already executing";
9641 #endif
9642 #ifdef __Pyx_AsyncGen_USED
9643 } else if (__Pyx_AsyncGen_CheckExact((PyObject*)gen)) {
9644 msg = "async generator already executing";
9645 #endif
9646 } else {
9647 msg = "generator already executing";
9648 }
9649 PyErr_SetString(PyExc_ValueError, msg);
9650 }
9651 #define __Pyx_Coroutine_NotStartedError(gen) (__Pyx__Coroutine_NotStartedError(gen), (PyObject*)NULL)
__Pyx__Coroutine_NotStartedError(CYTHON_UNUSED PyObject * gen)9652 static void __Pyx__Coroutine_NotStartedError(CYTHON_UNUSED PyObject *gen) {
9653 const char *msg;
9654 if ((0)) {
9655 #ifdef __Pyx_Coroutine_USED
9656 } else if (__Pyx_Coroutine_Check(gen)) {
9657 msg = "can't send non-None value to a just-started coroutine";
9658 #endif
9659 #ifdef __Pyx_AsyncGen_USED
9660 } else if (__Pyx_AsyncGen_CheckExact(gen)) {
9661 msg = "can't send non-None value to a just-started async generator";
9662 #endif
9663 } else {
9664 msg = "can't send non-None value to a just-started generator";
9665 }
9666 PyErr_SetString(PyExc_TypeError, msg);
9667 }
9668 #define __Pyx_Coroutine_AlreadyTerminatedError(gen, value, closing) (__Pyx__Coroutine_AlreadyTerminatedError(gen, value, closing), (PyObject*)NULL)
__Pyx__Coroutine_AlreadyTerminatedError(CYTHON_UNUSED PyObject * gen,PyObject * value,CYTHON_UNUSED int closing)9669 static void __Pyx__Coroutine_AlreadyTerminatedError(CYTHON_UNUSED PyObject *gen, PyObject *value, CYTHON_UNUSED int closing) {
9670 #ifdef __Pyx_Coroutine_USED
9671 if (!closing && __Pyx_Coroutine_Check(gen)) {
9672 PyErr_SetString(PyExc_RuntimeError, "cannot reuse already awaited coroutine");
9673 } else
9674 #endif
9675 if (value) {
9676 #ifdef __Pyx_AsyncGen_USED
9677 if (__Pyx_AsyncGen_CheckExact(gen))
9678 PyErr_SetNone(__Pyx_PyExc_StopAsyncIteration);
9679 else
9680 #endif
9681 PyErr_SetNone(PyExc_StopIteration);
9682 }
9683 }
9684 static
__Pyx_Coroutine_SendEx(__pyx_CoroutineObject * self,PyObject * value,int closing)9685 PyObject *__Pyx_Coroutine_SendEx(__pyx_CoroutineObject *self, PyObject *value, int closing) {
9686 __Pyx_PyThreadState_declare
9687 PyThreadState *tstate;
9688 __Pyx_ExcInfoStruct *exc_state;
9689 PyObject *retval;
9690 assert(!self->is_running);
9691 if (unlikely(self->resume_label == 0)) {
9692 if (unlikely(value && value != Py_None)) {
9693 return __Pyx_Coroutine_NotStartedError((PyObject*)self);
9694 }
9695 }
9696 if (unlikely(self->resume_label == -1)) {
9697 return __Pyx_Coroutine_AlreadyTerminatedError((PyObject*)self, value, closing);
9698 }
9699 #if CYTHON_FAST_THREAD_STATE
9700 __Pyx_PyThreadState_assign
9701 tstate = __pyx_tstate;
9702 #else
9703 tstate = __Pyx_PyThreadState_Current;
9704 #endif
9705 exc_state = &self->gi_exc_state;
9706 if (exc_state->exc_type) {
9707 #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON
9708 #else
9709 if (exc_state->exc_traceback) {
9710 PyTracebackObject *tb = (PyTracebackObject *) exc_state->exc_traceback;
9711 PyFrameObject *f = tb->tb_frame;
9712 Py_XINCREF(tstate->frame);
9713 assert(f->f_back == NULL);
9714 f->f_back = tstate->frame;
9715 }
9716 #endif
9717 }
9718 #if CYTHON_USE_EXC_INFO_STACK
9719 exc_state->previous_item = tstate->exc_info;
9720 tstate->exc_info = exc_state;
9721 #else
9722 if (exc_state->exc_type) {
9723 __Pyx_ExceptionSwap(&exc_state->exc_type, &exc_state->exc_value, &exc_state->exc_traceback);
9724 } else {
9725 __Pyx_Coroutine_ExceptionClear(exc_state);
9726 __Pyx_ExceptionSave(&exc_state->exc_type, &exc_state->exc_value, &exc_state->exc_traceback);
9727 }
9728 #endif
9729 self->is_running = 1;
9730 retval = self->body((PyObject *) self, tstate, value);
9731 self->is_running = 0;
9732 #if CYTHON_USE_EXC_INFO_STACK
9733 exc_state = &self->gi_exc_state;
9734 tstate->exc_info = exc_state->previous_item;
9735 exc_state->previous_item = NULL;
9736 __Pyx_Coroutine_ResetFrameBackpointer(exc_state);
9737 #endif
9738 return retval;
9739 }
__Pyx_Coroutine_ResetFrameBackpointer(__Pyx_ExcInfoStruct * exc_state)9740 static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__Pyx_ExcInfoStruct *exc_state) {
9741 PyObject *exc_tb = exc_state->exc_traceback;
9742 if (likely(exc_tb)) {
9743 #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON
9744 #else
9745 PyTracebackObject *tb = (PyTracebackObject *) exc_tb;
9746 PyFrameObject *f = tb->tb_frame;
9747 Py_CLEAR(f->f_back);
9748 #endif
9749 }
9750 }
9751 static CYTHON_INLINE
__Pyx_Coroutine_MethodReturn(CYTHON_UNUSED PyObject * gen,PyObject * retval)9752 PyObject *__Pyx_Coroutine_MethodReturn(CYTHON_UNUSED PyObject* gen, PyObject *retval) {
9753 if (unlikely(!retval)) {
9754 __Pyx_PyThreadState_declare
9755 __Pyx_PyThreadState_assign
9756 if (!__Pyx_PyErr_Occurred()) {
9757 PyObject *exc = PyExc_StopIteration;
9758 #ifdef __Pyx_AsyncGen_USED
9759 if (__Pyx_AsyncGen_CheckExact(gen))
9760 exc = __Pyx_PyExc_StopAsyncIteration;
9761 #endif
9762 __Pyx_PyErr_SetNone(exc);
9763 }
9764 }
9765 return retval;
9766 }
9767 static CYTHON_INLINE
__Pyx_Coroutine_FinishDelegation(__pyx_CoroutineObject * gen)9768 PyObject *__Pyx_Coroutine_FinishDelegation(__pyx_CoroutineObject *gen) {
9769 PyObject *ret;
9770 PyObject *val = NULL;
9771 __Pyx_Coroutine_Undelegate(gen);
9772 __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, &val);
9773 ret = __Pyx_Coroutine_SendEx(gen, val, 0);
9774 Py_XDECREF(val);
9775 return ret;
9776 }
__Pyx_Coroutine_Send(PyObject * self,PyObject * value)9777 static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value) {
9778 PyObject *retval;
9779 __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self;
9780 PyObject *yf = gen->yieldfrom;
9781 if (unlikely(gen->is_running))
9782 return __Pyx_Coroutine_AlreadyRunningError(gen);
9783 if (yf) {
9784 PyObject *ret;
9785 gen->is_running = 1;
9786 #ifdef __Pyx_Generator_USED
9787 if (__Pyx_Generator_CheckExact(yf)) {
9788 ret = __Pyx_Coroutine_Send(yf, value);
9789 } else
9790 #endif
9791 #ifdef __Pyx_Coroutine_USED
9792 if (__Pyx_Coroutine_Check(yf)) {
9793 ret = __Pyx_Coroutine_Send(yf, value);
9794 } else
9795 #endif
9796 #ifdef __Pyx_AsyncGen_USED
9797 if (__pyx_PyAsyncGenASend_CheckExact(yf)) {
9798 ret = __Pyx_async_gen_asend_send(yf, value);
9799 } else
9800 #endif
9801 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03030000 && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3)
9802 if (PyGen_CheckExact(yf)) {
9803 ret = _PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value);
9804 } else
9805 #endif
9806 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03050000 && defined(PyCoro_CheckExact) && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3)
9807 if (PyCoro_CheckExact(yf)) {
9808 ret = _PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value);
9809 } else
9810 #endif
9811 {
9812 if (value == Py_None)
9813 ret = Py_TYPE(yf)->tp_iternext(yf);
9814 else
9815 ret = __Pyx_PyObject_CallMethod1(yf, __pyx_n_s_send, value);
9816 }
9817 gen->is_running = 0;
9818 if (likely(ret)) {
9819 return ret;
9820 }
9821 retval = __Pyx_Coroutine_FinishDelegation(gen);
9822 } else {
9823 retval = __Pyx_Coroutine_SendEx(gen, value, 0);
9824 }
9825 return __Pyx_Coroutine_MethodReturn(self, retval);
9826 }
__Pyx_Coroutine_CloseIter(__pyx_CoroutineObject * gen,PyObject * yf)9827 static int __Pyx_Coroutine_CloseIter(__pyx_CoroutineObject *gen, PyObject *yf) {
9828 PyObject *retval = NULL;
9829 int err = 0;
9830 #ifdef __Pyx_Generator_USED
9831 if (__Pyx_Generator_CheckExact(yf)) {
9832 retval = __Pyx_Coroutine_Close(yf);
9833 if (!retval)
9834 return -1;
9835 } else
9836 #endif
9837 #ifdef __Pyx_Coroutine_USED
9838 if (__Pyx_Coroutine_Check(yf)) {
9839 retval = __Pyx_Coroutine_Close(yf);
9840 if (!retval)
9841 return -1;
9842 } else
9843 if (__Pyx_CoroutineAwait_CheckExact(yf)) {
9844 retval = __Pyx_CoroutineAwait_Close((__pyx_CoroutineAwaitObject*)yf, NULL);
9845 if (!retval)
9846 return -1;
9847 } else
9848 #endif
9849 #ifdef __Pyx_AsyncGen_USED
9850 if (__pyx_PyAsyncGenASend_CheckExact(yf)) {
9851 retval = __Pyx_async_gen_asend_close(yf, NULL);
9852 } else
9853 if (__pyx_PyAsyncGenAThrow_CheckExact(yf)) {
9854 retval = __Pyx_async_gen_athrow_close(yf, NULL);
9855 } else
9856 #endif
9857 {
9858 PyObject *meth;
9859 gen->is_running = 1;
9860 meth = __Pyx_PyObject_GetAttrStr(yf, __pyx_n_s_close);
9861 if (unlikely(!meth)) {
9862 if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
9863 PyErr_WriteUnraisable(yf);
9864 }
9865 PyErr_Clear();
9866 } else {
9867 retval = PyObject_CallFunction(meth, NULL);
9868 Py_DECREF(meth);
9869 if (!retval)
9870 err = -1;
9871 }
9872 gen->is_running = 0;
9873 }
9874 Py_XDECREF(retval);
9875 return err;
9876 }
__Pyx_Generator_Next(PyObject * self)9877 static PyObject *__Pyx_Generator_Next(PyObject *self) {
9878 __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self;
9879 PyObject *yf = gen->yieldfrom;
9880 if (unlikely(gen->is_running))
9881 return __Pyx_Coroutine_AlreadyRunningError(gen);
9882 if (yf) {
9883 PyObject *ret;
9884 gen->is_running = 1;
9885 #ifdef __Pyx_Generator_USED
9886 if (__Pyx_Generator_CheckExact(yf)) {
9887 ret = __Pyx_Generator_Next(yf);
9888 } else
9889 #endif
9890 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03030000 && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3)
9891 if (PyGen_CheckExact(yf)) {
9892 ret = _PyGen_Send((PyGenObject*)yf, NULL);
9893 } else
9894 #endif
9895 #ifdef __Pyx_Coroutine_USED
9896 if (__Pyx_Coroutine_Check(yf)) {
9897 ret = __Pyx_Coroutine_Send(yf, Py_None);
9898 } else
9899 #endif
9900 ret = Py_TYPE(yf)->tp_iternext(yf);
9901 gen->is_running = 0;
9902 if (likely(ret)) {
9903 return ret;
9904 }
9905 return __Pyx_Coroutine_FinishDelegation(gen);
9906 }
9907 return __Pyx_Coroutine_SendEx(gen, Py_None, 0);
9908 }
__Pyx_Coroutine_Close_Method(PyObject * self,CYTHON_UNUSED PyObject * arg)9909 static PyObject *__Pyx_Coroutine_Close_Method(PyObject *self, CYTHON_UNUSED PyObject *arg) {
9910 return __Pyx_Coroutine_Close(self);
9911 }
__Pyx_Coroutine_Close(PyObject * self)9912 static PyObject *__Pyx_Coroutine_Close(PyObject *self) {
9913 __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
9914 PyObject *retval, *raised_exception;
9915 PyObject *yf = gen->yieldfrom;
9916 int err = 0;
9917 if (unlikely(gen->is_running))
9918 return __Pyx_Coroutine_AlreadyRunningError(gen);
9919 if (yf) {
9920 Py_INCREF(yf);
9921 err = __Pyx_Coroutine_CloseIter(gen, yf);
9922 __Pyx_Coroutine_Undelegate(gen);
9923 Py_DECREF(yf);
9924 }
9925 if (err == 0)
9926 PyErr_SetNone(PyExc_GeneratorExit);
9927 retval = __Pyx_Coroutine_SendEx(gen, NULL, 1);
9928 if (unlikely(retval)) {
9929 const char *msg;
9930 Py_DECREF(retval);
9931 if ((0)) {
9932 #ifdef __Pyx_Coroutine_USED
9933 } else if (__Pyx_Coroutine_Check(self)) {
9934 msg = "coroutine ignored GeneratorExit";
9935 #endif
9936 #ifdef __Pyx_AsyncGen_USED
9937 } else if (__Pyx_AsyncGen_CheckExact(self)) {
9938 #if PY_VERSION_HEX < 0x03060000
9939 msg = "async generator ignored GeneratorExit - might require Python 3.6+ finalisation (PEP 525)";
9940 #else
9941 msg = "async generator ignored GeneratorExit";
9942 #endif
9943 #endif
9944 } else {
9945 msg = "generator ignored GeneratorExit";
9946 }
9947 PyErr_SetString(PyExc_RuntimeError, msg);
9948 return NULL;
9949 }
9950 raised_exception = PyErr_Occurred();
9951 if (likely(!raised_exception || __Pyx_PyErr_GivenExceptionMatches2(raised_exception, PyExc_GeneratorExit, PyExc_StopIteration))) {
9952 if (raised_exception) PyErr_Clear();
9953 Py_INCREF(Py_None);
9954 return Py_None;
9955 }
9956 return NULL;
9957 }
__Pyx__Coroutine_Throw(PyObject * self,PyObject * typ,PyObject * val,PyObject * tb,PyObject * args,int close_on_genexit)9958 static PyObject *__Pyx__Coroutine_Throw(PyObject *self, PyObject *typ, PyObject *val, PyObject *tb,
9959 PyObject *args, int close_on_genexit) {
9960 __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
9961 PyObject *yf = gen->yieldfrom;
9962 if (unlikely(gen->is_running))
9963 return __Pyx_Coroutine_AlreadyRunningError(gen);
9964 if (yf) {
9965 PyObject *ret;
9966 Py_INCREF(yf);
9967 if (__Pyx_PyErr_GivenExceptionMatches(typ, PyExc_GeneratorExit) && close_on_genexit) {
9968 int err = __Pyx_Coroutine_CloseIter(gen, yf);
9969 Py_DECREF(yf);
9970 __Pyx_Coroutine_Undelegate(gen);
9971 if (err < 0)
9972 return __Pyx_Coroutine_MethodReturn(self, __Pyx_Coroutine_SendEx(gen, NULL, 0));
9973 goto throw_here;
9974 }
9975 gen->is_running = 1;
9976 if (0
9977 #ifdef __Pyx_Generator_USED
9978 || __Pyx_Generator_CheckExact(yf)
9979 #endif
9980 #ifdef __Pyx_Coroutine_USED
9981 || __Pyx_Coroutine_Check(yf)
9982 #endif
9983 ) {
9984 ret = __Pyx__Coroutine_Throw(yf, typ, val, tb, args, close_on_genexit);
9985 #ifdef __Pyx_Coroutine_USED
9986 } else if (__Pyx_CoroutineAwait_CheckExact(yf)) {
9987 ret = __Pyx__Coroutine_Throw(((__pyx_CoroutineAwaitObject*)yf)->coroutine, typ, val, tb, args, close_on_genexit);
9988 #endif
9989 } else {
9990 PyObject *meth = __Pyx_PyObject_GetAttrStr(yf, __pyx_n_s_throw);
9991 if (unlikely(!meth)) {
9992 Py_DECREF(yf);
9993 if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
9994 gen->is_running = 0;
9995 return NULL;
9996 }
9997 PyErr_Clear();
9998 __Pyx_Coroutine_Undelegate(gen);
9999 gen->is_running = 0;
10000 goto throw_here;
10001 }
10002 if (likely(args)) {
10003 ret = PyObject_CallObject(meth, args);
10004 } else {
10005 ret = PyObject_CallFunctionObjArgs(meth, typ, val, tb, NULL);
10006 }
10007 Py_DECREF(meth);
10008 }
10009 gen->is_running = 0;
10010 Py_DECREF(yf);
10011 if (!ret) {
10012 ret = __Pyx_Coroutine_FinishDelegation(gen);
10013 }
10014 return __Pyx_Coroutine_MethodReturn(self, ret);
10015 }
10016 throw_here:
10017 __Pyx_Raise(typ, val, tb, NULL);
10018 return __Pyx_Coroutine_MethodReturn(self, __Pyx_Coroutine_SendEx(gen, NULL, 0));
10019 }
__Pyx_Coroutine_Throw(PyObject * self,PyObject * args)10020 static PyObject *__Pyx_Coroutine_Throw(PyObject *self, PyObject *args) {
10021 PyObject *typ;
10022 PyObject *val = NULL;
10023 PyObject *tb = NULL;
10024 if (!PyArg_UnpackTuple(args, (char *)"throw", 1, 3, &typ, &val, &tb))
10025 return NULL;
10026 return __Pyx__Coroutine_Throw(self, typ, val, tb, args, 1);
10027 }
__Pyx_Coroutine_traverse_excstate(__Pyx_ExcInfoStruct * exc_state,visitproc visit,void * arg)10028 static CYTHON_INLINE int __Pyx_Coroutine_traverse_excstate(__Pyx_ExcInfoStruct *exc_state, visitproc visit, void *arg) {
10029 Py_VISIT(exc_state->exc_type);
10030 Py_VISIT(exc_state->exc_value);
10031 Py_VISIT(exc_state->exc_traceback);
10032 return 0;
10033 }
__Pyx_Coroutine_traverse(__pyx_CoroutineObject * gen,visitproc visit,void * arg)10034 static int __Pyx_Coroutine_traverse(__pyx_CoroutineObject *gen, visitproc visit, void *arg) {
10035 Py_VISIT(gen->closure);
10036 Py_VISIT(gen->classobj);
10037 Py_VISIT(gen->yieldfrom);
10038 return __Pyx_Coroutine_traverse_excstate(&gen->gi_exc_state, visit, arg);
10039 }
__Pyx_Coroutine_clear(PyObject * self)10040 static int __Pyx_Coroutine_clear(PyObject *self) {
10041 __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
10042 Py_CLEAR(gen->closure);
10043 Py_CLEAR(gen->classobj);
10044 Py_CLEAR(gen->yieldfrom);
10045 __Pyx_Coroutine_ExceptionClear(&gen->gi_exc_state);
10046 #ifdef __Pyx_AsyncGen_USED
10047 if (__Pyx_AsyncGen_CheckExact(self)) {
10048 Py_CLEAR(((__pyx_PyAsyncGenObject*)gen)->ag_finalizer);
10049 }
10050 #endif
10051 Py_CLEAR(gen->gi_code);
10052 Py_CLEAR(gen->gi_name);
10053 Py_CLEAR(gen->gi_qualname);
10054 Py_CLEAR(gen->gi_modulename);
10055 return 0;
10056 }
__Pyx_Coroutine_dealloc(PyObject * self)10057 static void __Pyx_Coroutine_dealloc(PyObject *self) {
10058 __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
10059 PyObject_GC_UnTrack(gen);
10060 if (gen->gi_weakreflist != NULL)
10061 PyObject_ClearWeakRefs(self);
10062 if (gen->resume_label >= 0) {
10063 PyObject_GC_Track(self);
10064 #if PY_VERSION_HEX >= 0x030400a1 && CYTHON_USE_TP_FINALIZE
10065 if (PyObject_CallFinalizerFromDealloc(self))
10066 #else
10067 Py_TYPE(gen)->tp_del(self);
10068 if (self->ob_refcnt > 0)
10069 #endif
10070 {
10071 return;
10072 }
10073 PyObject_GC_UnTrack(self);
10074 }
10075 #ifdef __Pyx_AsyncGen_USED
10076 if (__Pyx_AsyncGen_CheckExact(self)) {
10077 /* We have to handle this case for asynchronous generators
10078 right here, because this code has to be between UNTRACK
10079 and GC_Del. */
10080 Py_CLEAR(((__pyx_PyAsyncGenObject*)self)->ag_finalizer);
10081 }
10082 #endif
10083 __Pyx_Coroutine_clear(self);
10084 PyObject_GC_Del(gen);
10085 }
__Pyx_Coroutine_del(PyObject * self)10086 static void __Pyx_Coroutine_del(PyObject *self) {
10087 PyObject *error_type, *error_value, *error_traceback;
10088 __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
10089 __Pyx_PyThreadState_declare
10090 if (gen->resume_label < 0) {
10091 return;
10092 }
10093 #if !CYTHON_USE_TP_FINALIZE
10094 assert(self->ob_refcnt == 0);
10095 self->ob_refcnt = 1;
10096 #endif
10097 __Pyx_PyThreadState_assign
10098 __Pyx_ErrFetch(&error_type, &error_value, &error_traceback);
10099 #ifdef __Pyx_AsyncGen_USED
10100 if (__Pyx_AsyncGen_CheckExact(self)) {
10101 __pyx_PyAsyncGenObject *agen = (__pyx_PyAsyncGenObject*)self;
10102 PyObject *finalizer = agen->ag_finalizer;
10103 if (finalizer && !agen->ag_closed) {
10104 PyObject *res = __Pyx_PyObject_CallOneArg(finalizer, self);
10105 if (unlikely(!res)) {
10106 PyErr_WriteUnraisable(self);
10107 } else {
10108 Py_DECREF(res);
10109 }
10110 __Pyx_ErrRestore(error_type, error_value, error_traceback);
10111 return;
10112 }
10113 }
10114 #endif
10115 if (unlikely(gen->resume_label == 0 && !error_value)) {
10116 #ifdef __Pyx_Coroutine_USED
10117 #ifdef __Pyx_Generator_USED
10118 if (!__Pyx_Generator_CheckExact(self))
10119 #endif
10120 {
10121 PyObject_GC_UnTrack(self);
10122 #if PY_MAJOR_VERSION >= 3 || defined(PyErr_WarnFormat)
10123 if (unlikely(PyErr_WarnFormat(PyExc_RuntimeWarning, 1, "coroutine '%.50S' was never awaited", gen->gi_qualname) < 0))
10124 PyErr_WriteUnraisable(self);
10125 #else
10126 {PyObject *msg;
10127 char *cmsg;
10128 #if CYTHON_COMPILING_IN_PYPY
10129 msg = NULL;
10130 cmsg = (char*) "coroutine was never awaited";
10131 #else
10132 char *cname;
10133 PyObject *qualname;
10134 qualname = gen->gi_qualname;
10135 cname = PyString_AS_STRING(qualname);
10136 msg = PyString_FromFormat("coroutine '%.50s' was never awaited", cname);
10137 if (unlikely(!msg)) {
10138 PyErr_Clear();
10139 cmsg = (char*) "coroutine was never awaited";
10140 } else {
10141 cmsg = PyString_AS_STRING(msg);
10142 }
10143 #endif
10144 if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, cmsg, 1) < 0))
10145 PyErr_WriteUnraisable(self);
10146 Py_XDECREF(msg);}
10147 #endif
10148 PyObject_GC_Track(self);
10149 }
10150 #endif
10151 } else {
10152 PyObject *res = __Pyx_Coroutine_Close(self);
10153 if (unlikely(!res)) {
10154 if (PyErr_Occurred())
10155 PyErr_WriteUnraisable(self);
10156 } else {
10157 Py_DECREF(res);
10158 }
10159 }
10160 __Pyx_ErrRestore(error_type, error_value, error_traceback);
10161 #if !CYTHON_USE_TP_FINALIZE
10162 assert(self->ob_refcnt > 0);
10163 if (--self->ob_refcnt == 0) {
10164 return;
10165 }
10166 {
10167 Py_ssize_t refcnt = self->ob_refcnt;
10168 _Py_NewReference(self);
10169 self->ob_refcnt = refcnt;
10170 }
10171 #if CYTHON_COMPILING_IN_CPYTHON
10172 assert(PyType_IS_GC(self->ob_type) &&
10173 _Py_AS_GC(self)->gc.gc_refs != _PyGC_REFS_UNTRACKED);
10174 _Py_DEC_REFTOTAL;
10175 #endif
10176 #ifdef COUNT_ALLOCS
10177 --Py_TYPE(self)->tp_frees;
10178 --Py_TYPE(self)->tp_allocs;
10179 #endif
10180 #endif
10181 }
10182 static PyObject *
__Pyx_Coroutine_get_name(__pyx_CoroutineObject * self,CYTHON_UNUSED void * context)10183 __Pyx_Coroutine_get_name(__pyx_CoroutineObject *self, CYTHON_UNUSED void *context)
10184 {
10185 PyObject *name = self->gi_name;
10186 if (unlikely(!name)) name = Py_None;
10187 Py_INCREF(name);
10188 return name;
10189 }
10190 static int
__Pyx_Coroutine_set_name(__pyx_CoroutineObject * self,PyObject * value,CYTHON_UNUSED void * context)10191 __Pyx_Coroutine_set_name(__pyx_CoroutineObject *self, PyObject *value, CYTHON_UNUSED void *context)
10192 {
10193 PyObject *tmp;
10194 #if PY_MAJOR_VERSION >= 3
10195 if (unlikely(value == NULL || !PyUnicode_Check(value)))
10196 #else
10197 if (unlikely(value == NULL || !PyString_Check(value)))
10198 #endif
10199 {
10200 PyErr_SetString(PyExc_TypeError,
10201 "__name__ must be set to a string object");
10202 return -1;
10203 }
10204 tmp = self->gi_name;
10205 Py_INCREF(value);
10206 self->gi_name = value;
10207 Py_XDECREF(tmp);
10208 return 0;
10209 }
10210 static PyObject *
__Pyx_Coroutine_get_qualname(__pyx_CoroutineObject * self,CYTHON_UNUSED void * context)10211 __Pyx_Coroutine_get_qualname(__pyx_CoroutineObject *self, CYTHON_UNUSED void *context)
10212 {
10213 PyObject *name = self->gi_qualname;
10214 if (unlikely(!name)) name = Py_None;
10215 Py_INCREF(name);
10216 return name;
10217 }
10218 static int
__Pyx_Coroutine_set_qualname(__pyx_CoroutineObject * self,PyObject * value,CYTHON_UNUSED void * context)10219 __Pyx_Coroutine_set_qualname(__pyx_CoroutineObject *self, PyObject *value, CYTHON_UNUSED void *context)
10220 {
10221 PyObject *tmp;
10222 #if PY_MAJOR_VERSION >= 3
10223 if (unlikely(value == NULL || !PyUnicode_Check(value)))
10224 #else
10225 if (unlikely(value == NULL || !PyString_Check(value)))
10226 #endif
10227 {
10228 PyErr_SetString(PyExc_TypeError,
10229 "__qualname__ must be set to a string object");
10230 return -1;
10231 }
10232 tmp = self->gi_qualname;
10233 Py_INCREF(value);
10234 self->gi_qualname = value;
10235 Py_XDECREF(tmp);
10236 return 0;
10237 }
__Pyx__Coroutine_New(PyTypeObject * type,__pyx_coroutine_body_t body,PyObject * code,PyObject * closure,PyObject * name,PyObject * qualname,PyObject * module_name)10238 static __pyx_CoroutineObject *__Pyx__Coroutine_New(
10239 PyTypeObject* type, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
10240 PyObject *name, PyObject *qualname, PyObject *module_name) {
10241 __pyx_CoroutineObject *gen = PyObject_GC_New(__pyx_CoroutineObject, type);
10242 if (unlikely(!gen))
10243 return NULL;
10244 return __Pyx__Coroutine_NewInit(gen, body, code, closure, name, qualname, module_name);
10245 }
__Pyx__Coroutine_NewInit(__pyx_CoroutineObject * gen,__pyx_coroutine_body_t body,PyObject * code,PyObject * closure,PyObject * name,PyObject * qualname,PyObject * module_name)10246 static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit(
10247 __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
10248 PyObject *name, PyObject *qualname, PyObject *module_name) {
10249 gen->body = body;
10250 gen->closure = closure;
10251 Py_XINCREF(closure);
10252 gen->is_running = 0;
10253 gen->resume_label = 0;
10254 gen->classobj = NULL;
10255 gen->yieldfrom = NULL;
10256 gen->gi_exc_state.exc_type = NULL;
10257 gen->gi_exc_state.exc_value = NULL;
10258 gen->gi_exc_state.exc_traceback = NULL;
10259 #if CYTHON_USE_EXC_INFO_STACK
10260 gen->gi_exc_state.previous_item = NULL;
10261 #endif
10262 gen->gi_weakreflist = NULL;
10263 Py_XINCREF(qualname);
10264 gen->gi_qualname = qualname;
10265 Py_XINCREF(name);
10266 gen->gi_name = name;
10267 Py_XINCREF(module_name);
10268 gen->gi_modulename = module_name;
10269 Py_XINCREF(code);
10270 gen->gi_code = code;
10271 PyObject_GC_Track(gen);
10272 return gen;
10273 }
10274
10275 /* PatchModuleWithCoroutine */
__Pyx_Coroutine_patch_module(PyObject * module,const char * py_code)10276 static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code) {
10277 #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
10278 int result;
10279 PyObject *globals, *result_obj;
10280 globals = PyDict_New(); if (unlikely(!globals)) goto ignore;
10281 result = PyDict_SetItemString(globals, "_cython_coroutine_type",
10282 #ifdef __Pyx_Coroutine_USED
10283 (PyObject*)__pyx_CoroutineType);
10284 #else
10285 Py_None);
10286 #endif
10287 if (unlikely(result < 0)) goto ignore;
10288 result = PyDict_SetItemString(globals, "_cython_generator_type",
10289 #ifdef __Pyx_Generator_USED
10290 (PyObject*)__pyx_GeneratorType);
10291 #else
10292 Py_None);
10293 #endif
10294 if (unlikely(result < 0)) goto ignore;
10295 if (unlikely(PyDict_SetItemString(globals, "_module", module) < 0)) goto ignore;
10296 if (unlikely(PyDict_SetItemString(globals, "__builtins__", __pyx_b) < 0)) goto ignore;
10297 result_obj = PyRun_String(py_code, Py_file_input, globals, globals);
10298 if (unlikely(!result_obj)) goto ignore;
10299 Py_DECREF(result_obj);
10300 Py_DECREF(globals);
10301 return module;
10302 ignore:
10303 Py_XDECREF(globals);
10304 PyErr_WriteUnraisable(module);
10305 if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, "Cython module failed to patch module with custom type", 1) < 0)) {
10306 Py_DECREF(module);
10307 module = NULL;
10308 }
10309 #else
10310 py_code++;
10311 #endif
10312 return module;
10313 }
10314
10315 /* PatchGeneratorABC */
10316 #ifndef CYTHON_REGISTER_ABCS
10317 #define CYTHON_REGISTER_ABCS 1
10318 #endif
10319 #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
10320 static PyObject* __Pyx_patch_abc_module(PyObject *module);
__Pyx_patch_abc_module(PyObject * module)10321 static PyObject* __Pyx_patch_abc_module(PyObject *module) {
10322 module = __Pyx_Coroutine_patch_module(
10323 module, ""
10324 "if _cython_generator_type is not None:\n"
10325 " try: Generator = _module.Generator\n"
10326 " except AttributeError: pass\n"
10327 " else: Generator.register(_cython_generator_type)\n"
10328 "if _cython_coroutine_type is not None:\n"
10329 " try: Coroutine = _module.Coroutine\n"
10330 " except AttributeError: pass\n"
10331 " else: Coroutine.register(_cython_coroutine_type)\n"
10332 );
10333 return module;
10334 }
10335 #endif
__Pyx_patch_abc(void)10336 static int __Pyx_patch_abc(void) {
10337 #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
10338 static int abc_patched = 0;
10339 if (CYTHON_REGISTER_ABCS && !abc_patched) {
10340 PyObject *module;
10341 module = PyImport_ImportModule((PY_MAJOR_VERSION >= 3) ? "collections.abc" : "collections");
10342 if (!module) {
10343 PyErr_WriteUnraisable(NULL);
10344 if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning,
10345 ((PY_MAJOR_VERSION >= 3) ?
10346 "Cython module failed to register with collections.abc module" :
10347 "Cython module failed to register with collections module"), 1) < 0)) {
10348 return -1;
10349 }
10350 } else {
10351 module = __Pyx_patch_abc_module(module);
10352 abc_patched = 1;
10353 if (unlikely(!module))
10354 return -1;
10355 Py_DECREF(module);
10356 }
10357 module = PyImport_ImportModule("backports_abc");
10358 if (module) {
10359 module = __Pyx_patch_abc_module(module);
10360 Py_XDECREF(module);
10361 }
10362 if (!module) {
10363 PyErr_Clear();
10364 }
10365 }
10366 #else
10367 if ((0)) __Pyx_Coroutine_patch_module(NULL, NULL);
10368 #endif
10369 return 0;
10370 }
10371
10372 /* Generator */
10373 static PyMethodDef __pyx_Generator_methods[] = {
10374 {"send", (PyCFunction) __Pyx_Coroutine_Send, METH_O,
10375 (char*) PyDoc_STR("send(arg) -> send 'arg' into generator,\nreturn next yielded value or raise StopIteration.")},
10376 {"throw", (PyCFunction) __Pyx_Coroutine_Throw, METH_VARARGS,
10377 (char*) PyDoc_STR("throw(typ[,val[,tb]]) -> raise exception in generator,\nreturn next yielded value or raise StopIteration.")},
10378 {"close", (PyCFunction) __Pyx_Coroutine_Close_Method, METH_NOARGS,
10379 (char*) PyDoc_STR("close() -> raise GeneratorExit inside generator.")},
10380 {0, 0, 0, 0}
10381 };
10382 static PyMemberDef __pyx_Generator_memberlist[] = {
10383 {(char *) "gi_running", T_BOOL, offsetof(__pyx_CoroutineObject, is_running), READONLY, NULL},
10384 {(char*) "gi_yieldfrom", T_OBJECT, offsetof(__pyx_CoroutineObject, yieldfrom), READONLY,
10385 (char*) PyDoc_STR("object being iterated by 'yield from', or None")},
10386 {(char*) "gi_code", T_OBJECT, offsetof(__pyx_CoroutineObject, gi_code), READONLY, NULL},
10387 {0, 0, 0, 0, 0}
10388 };
10389 static PyGetSetDef __pyx_Generator_getsets[] = {
10390 {(char *) "__name__", (getter)__Pyx_Coroutine_get_name, (setter)__Pyx_Coroutine_set_name,
10391 (char*) PyDoc_STR("name of the generator"), 0},
10392 {(char *) "__qualname__", (getter)__Pyx_Coroutine_get_qualname, (setter)__Pyx_Coroutine_set_qualname,
10393 (char*) PyDoc_STR("qualified name of the generator"), 0},
10394 {0, 0, 0, 0, 0}
10395 };
10396 static PyTypeObject __pyx_GeneratorType_type = {
10397 PyVarObject_HEAD_INIT(0, 0)
10398 "generator",
10399 sizeof(__pyx_CoroutineObject),
10400 0,
10401 (destructor) __Pyx_Coroutine_dealloc,
10402 0,
10403 0,
10404 0,
10405 0,
10406 0,
10407 0,
10408 0,
10409 0,
10410 0,
10411 0,
10412 0,
10413 0,
10414 0,
10415 0,
10416 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_HAVE_FINALIZE,
10417 0,
10418 (traverseproc) __Pyx_Coroutine_traverse,
10419 0,
10420 0,
10421 offsetof(__pyx_CoroutineObject, gi_weakreflist),
10422 0,
10423 (iternextfunc) __Pyx_Generator_Next,
10424 __pyx_Generator_methods,
10425 __pyx_Generator_memberlist,
10426 __pyx_Generator_getsets,
10427 0,
10428 0,
10429 0,
10430 0,
10431 0,
10432 0,
10433 0,
10434 0,
10435 0,
10436 0,
10437 0,
10438 0,
10439 0,
10440 0,
10441 0,
10442 #if CYTHON_USE_TP_FINALIZE
10443 0,
10444 #else
10445 __Pyx_Coroutine_del,
10446 #endif
10447 0,
10448 #if CYTHON_USE_TP_FINALIZE
10449 __Pyx_Coroutine_del,
10450 #elif PY_VERSION_HEX >= 0x030400a1
10451 0,
10452 #endif
10453 #if PY_VERSION_HEX >= 0x030800b1
10454 0,
10455 #endif
10456 #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
10457 0,
10458 #endif
10459 };
__pyx_Generator_init(void)10460 static int __pyx_Generator_init(void) {
10461 __pyx_GeneratorType_type.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
10462 __pyx_GeneratorType_type.tp_iter = PyObject_SelfIter;
10463 __pyx_GeneratorType = __Pyx_FetchCommonType(&__pyx_GeneratorType_type);
10464 if (unlikely(!__pyx_GeneratorType)) {
10465 return -1;
10466 }
10467 return 0;
10468 }
10469
10470 /* CheckBinaryVersion */
__Pyx_check_binary_version(void)10471 static int __Pyx_check_binary_version(void) {
10472 char ctversion[4], rtversion[4];
10473 PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
10474 PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
10475 if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
10476 char message[200];
10477 PyOS_snprintf(message, sizeof(message),
10478 "compiletime version %s of module '%.100s' "
10479 "does not match runtime version %s",
10480 ctversion, __Pyx_MODULE_NAME, rtversion);
10481 return PyErr_WarnEx(NULL, message, 1);
10482 }
10483 return 0;
10484 }
10485
10486 /* InitStrings */
__Pyx_InitStrings(__Pyx_StringTabEntry * t)10487 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
10488 while (t->p) {
10489 #if PY_MAJOR_VERSION < 3
10490 if (t->is_unicode) {
10491 *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
10492 } else if (t->intern) {
10493 *t->p = PyString_InternFromString(t->s);
10494 } else {
10495 *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
10496 }
10497 #else
10498 if (t->is_unicode | t->is_str) {
10499 if (t->intern) {
10500 *t->p = PyUnicode_InternFromString(t->s);
10501 } else if (t->encoding) {
10502 *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
10503 } else {
10504 *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
10505 }
10506 } else {
10507 *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
10508 }
10509 #endif
10510 if (!*t->p)
10511 return -1;
10512 if (PyObject_Hash(*t->p) == -1)
10513 return -1;
10514 ++t;
10515 }
10516 return 0;
10517 }
10518
__Pyx_PyUnicode_FromString(const char * c_str)10519 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
10520 return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
10521 }
__Pyx_PyObject_AsString(PyObject * o)10522 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
10523 Py_ssize_t ignore;
10524 return __Pyx_PyObject_AsStringAndSize(o, &ignore);
10525 }
10526 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
10527 #if !CYTHON_PEP393_ENABLED
__Pyx_PyUnicode_AsStringAndSize(PyObject * o,Py_ssize_t * length)10528 static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
10529 char* defenc_c;
10530 PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
10531 if (!defenc) return NULL;
10532 defenc_c = PyBytes_AS_STRING(defenc);
10533 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
10534 {
10535 char* end = defenc_c + PyBytes_GET_SIZE(defenc);
10536 char* c;
10537 for (c = defenc_c; c < end; c++) {
10538 if ((unsigned char) (*c) >= 128) {
10539 PyUnicode_AsASCIIString(o);
10540 return NULL;
10541 }
10542 }
10543 }
10544 #endif
10545 *length = PyBytes_GET_SIZE(defenc);
10546 return defenc_c;
10547 }
10548 #else
__Pyx_PyUnicode_AsStringAndSize(PyObject * o,Py_ssize_t * length)10549 static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
10550 if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
10551 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
10552 if (likely(PyUnicode_IS_ASCII(o))) {
10553 *length = PyUnicode_GET_LENGTH(o);
10554 return PyUnicode_AsUTF8(o);
10555 } else {
10556 PyUnicode_AsASCIIString(o);
10557 return NULL;
10558 }
10559 #else
10560 return PyUnicode_AsUTF8AndSize(o, length);
10561 #endif
10562 }
10563 #endif
10564 #endif
__Pyx_PyObject_AsStringAndSize(PyObject * o,Py_ssize_t * length)10565 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
10566 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
10567 if (
10568 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
10569 __Pyx_sys_getdefaultencoding_not_ascii &&
10570 #endif
10571 PyUnicode_Check(o)) {
10572 return __Pyx_PyUnicode_AsStringAndSize(o, length);
10573 } else
10574 #endif
10575 #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
10576 if (PyByteArray_Check(o)) {
10577 *length = PyByteArray_GET_SIZE(o);
10578 return PyByteArray_AS_STRING(o);
10579 } else
10580 #endif
10581 {
10582 char* result;
10583 int r = PyBytes_AsStringAndSize(o, &result, length);
10584 if (unlikely(r < 0)) {
10585 return NULL;
10586 } else {
10587 return result;
10588 }
10589 }
10590 }
__Pyx_PyObject_IsTrue(PyObject * x)10591 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
10592 int is_true = x == Py_True;
10593 if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
10594 else return PyObject_IsTrue(x);
10595 }
__Pyx_PyObject_IsTrueAndDecref(PyObject * x)10596 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
10597 int retval;
10598 if (unlikely(!x)) return -1;
10599 retval = __Pyx_PyObject_IsTrue(x);
10600 Py_DECREF(x);
10601 return retval;
10602 }
__Pyx_PyNumber_IntOrLongWrongResultType(PyObject * result,const char * type_name)10603 static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
10604 #if PY_MAJOR_VERSION >= 3
10605 if (PyLong_Check(result)) {
10606 if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
10607 "__int__ returned non-int (type %.200s). "
10608 "The ability to return an instance of a strict subclass of int "
10609 "is deprecated, and may be removed in a future version of Python.",
10610 Py_TYPE(result)->tp_name)) {
10611 Py_DECREF(result);
10612 return NULL;
10613 }
10614 return result;
10615 }
10616 #endif
10617 PyErr_Format(PyExc_TypeError,
10618 "__%.4s__ returned non-%.4s (type %.200s)",
10619 type_name, type_name, Py_TYPE(result)->tp_name);
10620 Py_DECREF(result);
10621 return NULL;
10622 }
__Pyx_PyNumber_IntOrLong(PyObject * x)10623 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
10624 #if CYTHON_USE_TYPE_SLOTS
10625 PyNumberMethods *m;
10626 #endif
10627 const char *name = NULL;
10628 PyObject *res = NULL;
10629 #if PY_MAJOR_VERSION < 3
10630 if (likely(PyInt_Check(x) || PyLong_Check(x)))
10631 #else
10632 if (likely(PyLong_Check(x)))
10633 #endif
10634 return __Pyx_NewRef(x);
10635 #if CYTHON_USE_TYPE_SLOTS
10636 m = Py_TYPE(x)->tp_as_number;
10637 #if PY_MAJOR_VERSION < 3
10638 if (m && m->nb_int) {
10639 name = "int";
10640 res = m->nb_int(x);
10641 }
10642 else if (m && m->nb_long) {
10643 name = "long";
10644 res = m->nb_long(x);
10645 }
10646 #else
10647 if (likely(m && m->nb_int)) {
10648 name = "int";
10649 res = m->nb_int(x);
10650 }
10651 #endif
10652 #else
10653 if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
10654 res = PyNumber_Int(x);
10655 }
10656 #endif
10657 if (likely(res)) {
10658 #if PY_MAJOR_VERSION < 3
10659 if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
10660 #else
10661 if (unlikely(!PyLong_CheckExact(res))) {
10662 #endif
10663 return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
10664 }
10665 }
10666 else if (!PyErr_Occurred()) {
10667 PyErr_SetString(PyExc_TypeError,
10668 "an integer is required");
10669 }
10670 return res;
10671 }
10672 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
10673 Py_ssize_t ival;
10674 PyObject *x;
10675 #if PY_MAJOR_VERSION < 3
10676 if (likely(PyInt_CheckExact(b))) {
10677 if (sizeof(Py_ssize_t) >= sizeof(long))
10678 return PyInt_AS_LONG(b);
10679 else
10680 return PyInt_AsSsize_t(b);
10681 }
10682 #endif
10683 if (likely(PyLong_CheckExact(b))) {
10684 #if CYTHON_USE_PYLONG_INTERNALS
10685 const digit* digits = ((PyLongObject*)b)->ob_digit;
10686 const Py_ssize_t size = Py_SIZE(b);
10687 if (likely(__Pyx_sst_abs(size) <= 1)) {
10688 ival = likely(size) ? digits[0] : 0;
10689 if (size == -1) ival = -ival;
10690 return ival;
10691 } else {
10692 switch (size) {
10693 case 2:
10694 if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
10695 return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
10696 }
10697 break;
10698 case -2:
10699 if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
10700 return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
10701 }
10702 break;
10703 case 3:
10704 if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
10705 return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
10706 }
10707 break;
10708 case -3:
10709 if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
10710 return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
10711 }
10712 break;
10713 case 4:
10714 if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
10715 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]));
10716 }
10717 break;
10718 case -4:
10719 if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
10720 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]));
10721 }
10722 break;
10723 }
10724 }
10725 #endif
10726 return PyLong_AsSsize_t(b);
10727 }
10728 x = PyNumber_Index(b);
10729 if (!x) return -1;
10730 ival = PyInt_AsSsize_t(x);
10731 Py_DECREF(x);
10732 return ival;
10733 }
10734 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
10735 return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
10736 }
10737 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
10738 return PyInt_FromSize_t(ival);
10739 }
10740
10741
10742 #endif /* Py_PYTHON_H */
10743