1 /* Generated by Cython 0.29.23 */
2 
3 #ifndef PY_SSIZE_T_CLEAN
4 #define PY_SSIZE_T_CLEAN
5 #endif /* PY_SSIZE_T_CLEAN */
6 #include "Python.h"
7 #ifndef Py_PYTHON_H
8     #error Python headers needed to compile C extensions, please install development version of Python.
9 #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
10     #error Cython requires Python 2.6+ or Python 3.3+.
11 #else
12 #define CYTHON_ABI "0_29_23"
13 #define CYTHON_HEX_VERSION 0x001D17F0
14 #define CYTHON_FUTURE_DIVISION 1
15 #include <stddef.h>
16 #ifndef offsetof
17   #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
18 #endif
19 #if !defined(WIN32) && !defined(MS_WINDOWS)
20   #ifndef __stdcall
21     #define __stdcall
22   #endif
23   #ifndef __cdecl
24     #define __cdecl
25   #endif
26   #ifndef __fastcall
27     #define __fastcall
28   #endif
29 #endif
30 #ifndef DL_IMPORT
31   #define DL_IMPORT(t) t
32 #endif
33 #ifndef DL_EXPORT
34   #define DL_EXPORT(t) t
35 #endif
36 #define __PYX_COMMA ,
37 #ifndef HAVE_LONG_LONG
38   #if PY_VERSION_HEX >= 0x02070000
39     #define HAVE_LONG_LONG
40   #endif
41 #endif
42 #ifndef PY_LONG_LONG
43   #define PY_LONG_LONG LONG_LONG
44 #endif
45 #ifndef Py_HUGE_VAL
46   #define Py_HUGE_VAL HUGE_VAL
47 #endif
48 #ifdef PYPY_VERSION
49   #define CYTHON_COMPILING_IN_PYPY 1
50   #define CYTHON_COMPILING_IN_PYSTON 0
51   #define CYTHON_COMPILING_IN_CPYTHON 0
52   #undef CYTHON_USE_TYPE_SLOTS
53   #define CYTHON_USE_TYPE_SLOTS 0
54   #undef CYTHON_USE_PYTYPE_LOOKUP
55   #define CYTHON_USE_PYTYPE_LOOKUP 0
56   #if PY_VERSION_HEX < 0x03050000
57     #undef CYTHON_USE_ASYNC_SLOTS
58     #define CYTHON_USE_ASYNC_SLOTS 0
59   #elif !defined(CYTHON_USE_ASYNC_SLOTS)
60     #define CYTHON_USE_ASYNC_SLOTS 1
61   #endif
62   #undef CYTHON_USE_PYLIST_INTERNALS
63   #define CYTHON_USE_PYLIST_INTERNALS 0
64   #undef CYTHON_USE_UNICODE_INTERNALS
65   #define CYTHON_USE_UNICODE_INTERNALS 0
66   #undef CYTHON_USE_UNICODE_WRITER
67   #define CYTHON_USE_UNICODE_WRITER 0
68   #undef CYTHON_USE_PYLONG_INTERNALS
69   #define CYTHON_USE_PYLONG_INTERNALS 0
70   #undef CYTHON_AVOID_BORROWED_REFS
71   #define CYTHON_AVOID_BORROWED_REFS 1
72   #undef CYTHON_ASSUME_SAFE_MACROS
73   #define CYTHON_ASSUME_SAFE_MACROS 0
74   #undef CYTHON_UNPACK_METHODS
75   #define CYTHON_UNPACK_METHODS 0
76   #undef CYTHON_FAST_THREAD_STATE
77   #define CYTHON_FAST_THREAD_STATE 0
78   #undef CYTHON_FAST_PYCALL
79   #define CYTHON_FAST_PYCALL 0
80   #undef CYTHON_PEP489_MULTI_PHASE_INIT
81   #define CYTHON_PEP489_MULTI_PHASE_INIT 0
82   #undef CYTHON_USE_TP_FINALIZE
83   #define CYTHON_USE_TP_FINALIZE 0
84   #undef CYTHON_USE_DICT_VERSIONS
85   #define CYTHON_USE_DICT_VERSIONS 0
86   #undef CYTHON_USE_EXC_INFO_STACK
87   #define CYTHON_USE_EXC_INFO_STACK 0
88 #elif defined(PYSTON_VERSION)
89   #define CYTHON_COMPILING_IN_PYPY 0
90   #define CYTHON_COMPILING_IN_PYSTON 1
91   #define CYTHON_COMPILING_IN_CPYTHON 0
92   #ifndef CYTHON_USE_TYPE_SLOTS
93     #define CYTHON_USE_TYPE_SLOTS 1
94   #endif
95   #undef CYTHON_USE_PYTYPE_LOOKUP
96   #define CYTHON_USE_PYTYPE_LOOKUP 0
97   #undef CYTHON_USE_ASYNC_SLOTS
98   #define CYTHON_USE_ASYNC_SLOTS 0
99   #undef CYTHON_USE_PYLIST_INTERNALS
100   #define CYTHON_USE_PYLIST_INTERNALS 0
101   #ifndef CYTHON_USE_UNICODE_INTERNALS
102     #define CYTHON_USE_UNICODE_INTERNALS 1
103   #endif
104   #undef CYTHON_USE_UNICODE_WRITER
105   #define CYTHON_USE_UNICODE_WRITER 0
106   #undef CYTHON_USE_PYLONG_INTERNALS
107   #define CYTHON_USE_PYLONG_INTERNALS 0
108   #ifndef CYTHON_AVOID_BORROWED_REFS
109     #define CYTHON_AVOID_BORROWED_REFS 0
110   #endif
111   #ifndef CYTHON_ASSUME_SAFE_MACROS
112     #define CYTHON_ASSUME_SAFE_MACROS 1
113   #endif
114   #ifndef CYTHON_UNPACK_METHODS
115     #define CYTHON_UNPACK_METHODS 1
116   #endif
117   #undef CYTHON_FAST_THREAD_STATE
118   #define CYTHON_FAST_THREAD_STATE 0
119   #undef CYTHON_FAST_PYCALL
120   #define CYTHON_FAST_PYCALL 0
121   #undef CYTHON_PEP489_MULTI_PHASE_INIT
122   #define CYTHON_PEP489_MULTI_PHASE_INIT 0
123   #undef CYTHON_USE_TP_FINALIZE
124   #define CYTHON_USE_TP_FINALIZE 0
125   #undef CYTHON_USE_DICT_VERSIONS
126   #define CYTHON_USE_DICT_VERSIONS 0
127   #undef CYTHON_USE_EXC_INFO_STACK
128   #define CYTHON_USE_EXC_INFO_STACK 0
129 #else
130   #define CYTHON_COMPILING_IN_PYPY 0
131   #define CYTHON_COMPILING_IN_PYSTON 0
132   #define CYTHON_COMPILING_IN_CPYTHON 1
133   #ifndef CYTHON_USE_TYPE_SLOTS
134     #define CYTHON_USE_TYPE_SLOTS 1
135   #endif
136   #if PY_VERSION_HEX < 0x02070000
137     #undef CYTHON_USE_PYTYPE_LOOKUP
138     #define CYTHON_USE_PYTYPE_LOOKUP 0
139   #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
140     #define CYTHON_USE_PYTYPE_LOOKUP 1
141   #endif
142   #if PY_MAJOR_VERSION < 3
143     #undef CYTHON_USE_ASYNC_SLOTS
144     #define CYTHON_USE_ASYNC_SLOTS 0
145   #elif !defined(CYTHON_USE_ASYNC_SLOTS)
146     #define CYTHON_USE_ASYNC_SLOTS 1
147   #endif
148   #if PY_VERSION_HEX < 0x02070000
149     #undef CYTHON_USE_PYLONG_INTERNALS
150     #define CYTHON_USE_PYLONG_INTERNALS 0
151   #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
152     #define CYTHON_USE_PYLONG_INTERNALS 1
153   #endif
154   #ifndef CYTHON_USE_PYLIST_INTERNALS
155     #define CYTHON_USE_PYLIST_INTERNALS 1
156   #endif
157   #ifndef CYTHON_USE_UNICODE_INTERNALS
158     #define CYTHON_USE_UNICODE_INTERNALS 1
159   #endif
160   #if PY_VERSION_HEX < 0x030300F0
161     #undef CYTHON_USE_UNICODE_WRITER
162     #define CYTHON_USE_UNICODE_WRITER 0
163   #elif !defined(CYTHON_USE_UNICODE_WRITER)
164     #define CYTHON_USE_UNICODE_WRITER 1
165   #endif
166   #ifndef CYTHON_AVOID_BORROWED_REFS
167     #define CYTHON_AVOID_BORROWED_REFS 0
168   #endif
169   #ifndef CYTHON_ASSUME_SAFE_MACROS
170     #define CYTHON_ASSUME_SAFE_MACROS 1
171   #endif
172   #ifndef CYTHON_UNPACK_METHODS
173     #define CYTHON_UNPACK_METHODS 1
174   #endif
175   #ifndef CYTHON_FAST_THREAD_STATE
176     #define CYTHON_FAST_THREAD_STATE 1
177   #endif
178   #ifndef CYTHON_FAST_PYCALL
179     #define CYTHON_FAST_PYCALL 1
180   #endif
181   #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
182     #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000)
183   #endif
184   #ifndef CYTHON_USE_TP_FINALIZE
185     #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
186   #endif
187   #ifndef CYTHON_USE_DICT_VERSIONS
188     #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1)
189   #endif
190   #ifndef CYTHON_USE_EXC_INFO_STACK
191     #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3)
192   #endif
193 #endif
194 #if !defined(CYTHON_FAST_PYCCALL)
195 #define CYTHON_FAST_PYCCALL  (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
196 #endif
197 #if CYTHON_USE_PYLONG_INTERNALS
198   #include "longintrepr.h"
199   #undef SHIFT
200   #undef BASE
201   #undef MASK
202   #ifdef SIZEOF_VOID_P
203     enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) };
204   #endif
205 #endif
206 #ifndef __has_attribute
207   #define __has_attribute(x) 0
208 #endif
209 #ifndef __has_cpp_attribute
210   #define __has_cpp_attribute(x) 0
211 #endif
212 #ifndef CYTHON_RESTRICT
213   #if defined(__GNUC__)
214     #define CYTHON_RESTRICT __restrict__
215   #elif defined(_MSC_VER) && _MSC_VER >= 1400
216     #define CYTHON_RESTRICT __restrict
217   #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
218     #define CYTHON_RESTRICT restrict
219   #else
220     #define CYTHON_RESTRICT
221   #endif
222 #endif
223 #ifndef CYTHON_UNUSED
224 # if defined(__GNUC__)
225 #   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
226 #     define CYTHON_UNUSED __attribute__ ((__unused__))
227 #   else
228 #     define CYTHON_UNUSED
229 #   endif
230 # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
231 #   define CYTHON_UNUSED __attribute__ ((__unused__))
232 # else
233 #   define CYTHON_UNUSED
234 # endif
235 #endif
236 #ifndef CYTHON_MAYBE_UNUSED_VAR
237 #  if defined(__cplusplus)
CYTHON_MAYBE_UNUSED_VAR(const T &)238      template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
239 #  else
240 #    define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
241 #  endif
242 #endif
243 #ifndef CYTHON_NCP_UNUSED
244 # if CYTHON_COMPILING_IN_CPYTHON
245 #  define CYTHON_NCP_UNUSED
246 # else
247 #  define CYTHON_NCP_UNUSED CYTHON_UNUSED
248 # endif
249 #endif
250 #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
251 #ifdef _MSC_VER
252     #ifndef _MSC_STDINT_H_
253         #if _MSC_VER < 1300
254            typedef unsigned char     uint8_t;
255            typedef unsigned int      uint32_t;
256         #else
257            typedef unsigned __int8   uint8_t;
258            typedef unsigned __int32  uint32_t;
259         #endif
260     #endif
261 #else
262    #include <stdint.h>
263 #endif
264 #ifndef CYTHON_FALLTHROUGH
265   #if defined(__cplusplus) && __cplusplus >= 201103L
266     #if __has_cpp_attribute(fallthrough)
267       #define CYTHON_FALLTHROUGH [[fallthrough]]
268     #elif __has_cpp_attribute(clang::fallthrough)
269       #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
270     #elif __has_cpp_attribute(gnu::fallthrough)
271       #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
272     #endif
273   #endif
274   #ifndef CYTHON_FALLTHROUGH
275     #if __has_attribute(fallthrough)
276       #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
277     #else
278       #define CYTHON_FALLTHROUGH
279     #endif
280   #endif
281   #if defined(__clang__ ) && defined(__apple_build_version__)
282     #if __apple_build_version__ < 7000000
283       #undef  CYTHON_FALLTHROUGH
284       #define CYTHON_FALLTHROUGH
285     #endif
286   #endif
287 #endif
288 
289 #ifndef CYTHON_INLINE
290   #if defined(__clang__)
291     #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
292   #elif defined(__GNUC__)
293     #define CYTHON_INLINE __inline__
294   #elif defined(_MSC_VER)
295     #define CYTHON_INLINE __inline
296   #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
297     #define CYTHON_INLINE inline
298   #else
299     #define CYTHON_INLINE
300   #endif
301 #endif
302 
303 #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
304   #define Py_OptimizeFlag 0
305 #endif
306 #define __PYX_BUILD_PY_SSIZE_T "n"
307 #define CYTHON_FORMAT_SSIZE_T "z"
308 #if PY_MAJOR_VERSION < 3
309   #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
310   #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
311           PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
312   #define __Pyx_DefaultClassType PyClass_Type
313 #else
314   #define __Pyx_BUILTIN_MODULE_NAME "builtins"
315 #if PY_VERSION_HEX >= 0x030800A4 && PY_VERSION_HEX < 0x030800B2
316   #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
317           PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
318 #else
319   #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
320           PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
321 #endif
322   #define __Pyx_DefaultClassType PyType_Type
323 #endif
324 #ifndef Py_TPFLAGS_CHECKTYPES
325   #define Py_TPFLAGS_CHECKTYPES 0
326 #endif
327 #ifndef Py_TPFLAGS_HAVE_INDEX
328   #define Py_TPFLAGS_HAVE_INDEX 0
329 #endif
330 #ifndef Py_TPFLAGS_HAVE_NEWBUFFER
331   #define Py_TPFLAGS_HAVE_NEWBUFFER 0
332 #endif
333 #ifndef Py_TPFLAGS_HAVE_FINALIZE
334   #define Py_TPFLAGS_HAVE_FINALIZE 0
335 #endif
336 #ifndef METH_STACKLESS
337   #define METH_STACKLESS 0
338 #endif
339 #if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
340   #ifndef METH_FASTCALL
341      #define METH_FASTCALL 0x80
342   #endif
343   typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
344   typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
345                                                           Py_ssize_t nargs, PyObject *kwnames);
346 #else
347   #define __Pyx_PyCFunctionFast _PyCFunctionFast
348   #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
349 #endif
350 #if CYTHON_FAST_PYCCALL
351 #define __Pyx_PyFastCFunction_Check(func)\
352     ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)))))
353 #else
354 #define __Pyx_PyFastCFunction_Check(func) 0
355 #endif
356 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
357   #define PyObject_Malloc(s)   PyMem_Malloc(s)
358   #define PyObject_Free(p)     PyMem_Free(p)
359   #define PyObject_Realloc(p)  PyMem_Realloc(p)
360 #endif
361 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1
362   #define PyMem_RawMalloc(n)           PyMem_Malloc(n)
363   #define PyMem_RawRealloc(p, n)       PyMem_Realloc(p, n)
364   #define PyMem_RawFree(p)             PyMem_Free(p)
365 #endif
366 #if CYTHON_COMPILING_IN_PYSTON
367   #define __Pyx_PyCode_HasFreeVars(co)  PyCode_HasFreeVars(co)
368   #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
369 #else
370   #define __Pyx_PyCode_HasFreeVars(co)  (PyCode_GetNumFree(co) > 0)
371   #define __Pyx_PyFrame_SetLineNumber(frame, lineno)  (frame)->f_lineno = (lineno)
372 #endif
373 #if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
374   #define __Pyx_PyThreadState_Current PyThreadState_GET()
375 #elif PY_VERSION_HEX >= 0x03060000
376   #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
377 #elif PY_VERSION_HEX >= 0x03000000
378   #define __Pyx_PyThreadState_Current PyThreadState_GET()
379 #else
380   #define __Pyx_PyThreadState_Current _PyThreadState_Current
381 #endif
382 #if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
383 #include "pythread.h"
384 #define Py_tss_NEEDS_INIT 0
385 typedef int Py_tss_t;
PyThread_tss_create(Py_tss_t * key)386 static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
387   *key = PyThread_create_key();
388   return 0;
389 }
PyThread_tss_alloc(void)390 static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
391   Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
392   *key = Py_tss_NEEDS_INIT;
393   return key;
394 }
PyThread_tss_free(Py_tss_t * key)395 static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
396   PyObject_Free(key);
397 }
PyThread_tss_is_created(Py_tss_t * key)398 static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
399   return *key != Py_tss_NEEDS_INIT;
400 }
PyThread_tss_delete(Py_tss_t * key)401 static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
402   PyThread_delete_key(*key);
403   *key = Py_tss_NEEDS_INIT;
404 }
PyThread_tss_set(Py_tss_t * key,void * value)405 static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
406   return PyThread_set_key_value(*key, value);
407 }
PyThread_tss_get(Py_tss_t * key)408 static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
409   return PyThread_get_key_value(*key);
410 }
411 #endif
412 #if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
413 #define __Pyx_PyDict_NewPresized(n)  ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
414 #else
415 #define __Pyx_PyDict_NewPresized(n)  PyDict_New()
416 #endif
417 #if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
418   #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
419   #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
420 #else
421   #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
422   #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)
423 #endif
424 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
425 #define __Pyx_PyDict_GetItemStr(dict, name)  _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
426 #else
427 #define __Pyx_PyDict_GetItemStr(dict, name)  PyDict_GetItem(dict, name)
428 #endif
429 #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
430   #define CYTHON_PEP393_ENABLED 1
431   #define __Pyx_PyUnicode_READY(op)       (likely(PyUnicode_IS_READY(op)) ?\
432                                               0 : _PyUnicode_Ready((PyObject *)(op)))
433   #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_LENGTH(u)
434   #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
435   #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u)   PyUnicode_MAX_CHAR_VALUE(u)
436   #define __Pyx_PyUnicode_KIND(u)         PyUnicode_KIND(u)
437   #define __Pyx_PyUnicode_DATA(u)         PyUnicode_DATA(u)
438   #define __Pyx_PyUnicode_READ(k, d, i)   PyUnicode_READ(k, d, i)
439   #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  PyUnicode_WRITE(k, d, i, ch)
440   #if defined(PyUnicode_IS_READY) && defined(PyUnicode_GET_SIZE)
441   #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
442   #else
443   #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != PyUnicode_GET_LENGTH(u))
444   #endif
445 #else
446   #define CYTHON_PEP393_ENABLED 0
447   #define PyUnicode_1BYTE_KIND  1
448   #define PyUnicode_2BYTE_KIND  2
449   #define PyUnicode_4BYTE_KIND  4
450   #define __Pyx_PyUnicode_READY(op)       (0)
451   #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_SIZE(u)
452   #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
453   #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u)   ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
454   #define __Pyx_PyUnicode_KIND(u)         (sizeof(Py_UNICODE))
455   #define __Pyx_PyUnicode_DATA(u)         ((void*)PyUnicode_AS_UNICODE(u))
456   #define __Pyx_PyUnicode_READ(k, d, i)   ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
457   #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
458   #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != PyUnicode_GET_SIZE(u))
459 #endif
460 #if CYTHON_COMPILING_IN_PYPY
461   #define __Pyx_PyUnicode_Concat(a, b)      PyNumber_Add(a, b)
462   #define __Pyx_PyUnicode_ConcatSafe(a, b)  PyNumber_Add(a, b)
463 #else
464   #define __Pyx_PyUnicode_Concat(a, b)      PyUnicode_Concat(a, b)
465   #define __Pyx_PyUnicode_ConcatSafe(a, b)  ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
466       PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
467 #endif
468 #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
469   #define PyUnicode_Contains(u, s)  PySequence_Contains(u, s)
470 #endif
471 #if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
472   #define PyByteArray_Check(obj)  PyObject_TypeCheck(obj, &PyByteArray_Type)
473 #endif
474 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
475   #define PyObject_Format(obj, fmt)  PyObject_CallMethod(obj, "__format__", "O", fmt)
476 #endif
477 #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))
478 #define __Pyx_PyUnicode_FormatSafe(a, b)  ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
479 #if PY_MAJOR_VERSION >= 3
480   #define __Pyx_PyString_Format(a, b)  PyUnicode_Format(a, b)
481 #else
482   #define __Pyx_PyString_Format(a, b)  PyString_Format(a, b)
483 #endif
484 #if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
485   #define PyObject_ASCII(o)            PyObject_Repr(o)
486 #endif
487 #if PY_MAJOR_VERSION >= 3
488   #define PyBaseString_Type            PyUnicode_Type
489   #define PyStringObject               PyUnicodeObject
490   #define PyString_Type                PyUnicode_Type
491   #define PyString_Check               PyUnicode_Check
492   #define PyString_CheckExact          PyUnicode_CheckExact
493 #ifndef PyObject_Unicode
494   #define PyObject_Unicode             PyObject_Str
495 #endif
496 #endif
497 #if PY_MAJOR_VERSION >= 3
498   #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
499   #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
500 #else
501   #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
502   #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
503 #endif
504 #ifndef PySet_CheckExact
505   #define PySet_CheckExact(obj)        (Py_TYPE(obj) == &PySet_Type)
506 #endif
507 #if PY_VERSION_HEX >= 0x030900A4
508   #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt)
509   #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size)
510 #else
511   #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt)
512   #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size)
513 #endif
514 #if CYTHON_ASSUME_SAFE_MACROS
515   #define __Pyx_PySequence_SIZE(seq)  Py_SIZE(seq)
516 #else
517   #define __Pyx_PySequence_SIZE(seq)  PySequence_Size(seq)
518 #endif
519 #if PY_MAJOR_VERSION >= 3
520   #define PyIntObject                  PyLongObject
521   #define PyInt_Type                   PyLong_Type
522   #define PyInt_Check(op)              PyLong_Check(op)
523   #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
524   #define PyInt_FromString             PyLong_FromString
525   #define PyInt_FromUnicode            PyLong_FromUnicode
526   #define PyInt_FromLong               PyLong_FromLong
527   #define PyInt_FromSize_t             PyLong_FromSize_t
528   #define PyInt_FromSsize_t            PyLong_FromSsize_t
529   #define PyInt_AsLong                 PyLong_AsLong
530   #define PyInt_AS_LONG                PyLong_AS_LONG
531   #define PyInt_AsSsize_t              PyLong_AsSsize_t
532   #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
533   #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
534   #define PyNumber_Int                 PyNumber_Long
535 #endif
536 #if PY_MAJOR_VERSION >= 3
537   #define PyBoolObject                 PyLongObject
538 #endif
539 #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
540   #ifndef PyUnicode_InternFromString
541     #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
542   #endif
543 #endif
544 #if PY_VERSION_HEX < 0x030200A4
545   typedef long Py_hash_t;
546   #define __Pyx_PyInt_FromHash_t PyInt_FromLong
547   #define __Pyx_PyInt_AsHash_t   PyInt_AsLong
548 #else
549   #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
550   #define __Pyx_PyInt_AsHash_t   PyInt_AsSsize_t
551 #endif
552 #if PY_MAJOR_VERSION >= 3
553   #define __Pyx_PyMethod_New(func, self, klass) ((self) ? ((void)(klass), PyMethod_New(func, self)) : __Pyx_NewRef(func))
554 #else
555   #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
556 #endif
557 #if CYTHON_USE_ASYNC_SLOTS
558   #if PY_VERSION_HEX >= 0x030500B1
559     #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
560     #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
561   #else
562     #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
563   #endif
564 #else
565   #define __Pyx_PyType_AsAsync(obj) NULL
566 #endif
567 #ifndef __Pyx_PyAsyncMethodsStruct
568     typedef struct {
569         unaryfunc am_await;
570         unaryfunc am_aiter;
571         unaryfunc am_anext;
572     } __Pyx_PyAsyncMethodsStruct;
573 #endif
574 
575 #if defined(WIN32) || defined(MS_WINDOWS)
576   #define _USE_MATH_DEFINES
577 #endif
578 #include <math.h>
579 #ifdef NAN
580 #define __PYX_NAN() ((float) NAN)
581 #else
__PYX_NAN()582 static CYTHON_INLINE float __PYX_NAN() {
583   float value;
584   memset(&value, 0xFF, sizeof(value));
585   return value;
586 }
587 #endif
588 #if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
589 #define __Pyx_truncl trunc
590 #else
591 #define __Pyx_truncl truncl
592 #endif
593 
594 #define __PYX_MARK_ERR_POS(f_index, lineno) \
595     { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; }
596 #define __PYX_ERR(f_index, lineno, Ln_error) \
597     { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; }
598 
599 #ifndef __PYX_EXTERN_C
600   #ifdef __cplusplus
601     #define __PYX_EXTERN_C extern "C"
602   #else
603     #define __PYX_EXTERN_C extern
604   #endif
605 #endif
606 
607 #define __PYX_HAVE__borg__chunker
608 #define __PYX_HAVE_API__borg__chunker
609 /* Early includes */
610 #include <string.h>
611 #include <stdlib.h>
612 #include "_chunker.c"
613 #ifdef _OPENMP
614 #include <omp.h>
615 #endif /* _OPENMP */
616 
617 #if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
618 #define CYTHON_WITHOUT_ASSERTIONS
619 #endif
620 
621 typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
622                 const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
623 
624 #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
625 #define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0
626 #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8)
627 #define __PYX_DEFAULT_STRING_ENCODING ""
628 #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
629 #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
630 #define __Pyx_uchar_cast(c) ((unsigned char)c)
631 #define __Pyx_long_cast(x) ((long)x)
632 #define __Pyx_fits_Py_ssize_t(v, type, is_signed)  (\
633     (sizeof(type) < sizeof(Py_ssize_t))  ||\
634     (sizeof(type) > sizeof(Py_ssize_t) &&\
635           likely(v < (type)PY_SSIZE_T_MAX ||\
636                  v == (type)PY_SSIZE_T_MAX)  &&\
637           (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
638                                 v == (type)PY_SSIZE_T_MIN)))  ||\
639     (sizeof(type) == sizeof(Py_ssize_t) &&\
640           (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
641                                v == (type)PY_SSIZE_T_MAX)))  )
__Pyx_is_valid_index(Py_ssize_t i,Py_ssize_t limit)642 static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
643     return (size_t) i < (size_t) limit;
644 }
645 #if defined (__cplusplus) && __cplusplus >= 201103L
646     #include <cstdlib>
647     #define __Pyx_sst_abs(value) std::abs(value)
648 #elif SIZEOF_INT >= SIZEOF_SIZE_T
649     #define __Pyx_sst_abs(value) abs(value)
650 #elif SIZEOF_LONG >= SIZEOF_SIZE_T
651     #define __Pyx_sst_abs(value) labs(value)
652 #elif defined (_MSC_VER)
653     #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
654 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
655     #define __Pyx_sst_abs(value) llabs(value)
656 #elif defined (__GNUC__)
657     #define __Pyx_sst_abs(value) __builtin_llabs(value)
658 #else
659     #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
660 #endif
661 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
662 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
663 #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
664 #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
665 #define __Pyx_PyBytes_FromString        PyBytes_FromString
666 #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
667 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
668 #if PY_MAJOR_VERSION < 3
669     #define __Pyx_PyStr_FromString        __Pyx_PyBytes_FromString
670     #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
671 #else
672     #define __Pyx_PyStr_FromString        __Pyx_PyUnicode_FromString
673     #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
674 #endif
675 #define __Pyx_PyBytes_AsWritableString(s)     ((char*) PyBytes_AS_STRING(s))
676 #define __Pyx_PyBytes_AsWritableSString(s)    ((signed char*) PyBytes_AS_STRING(s))
677 #define __Pyx_PyBytes_AsWritableUString(s)    ((unsigned char*) PyBytes_AS_STRING(s))
678 #define __Pyx_PyBytes_AsString(s)     ((const char*) PyBytes_AS_STRING(s))
679 #define __Pyx_PyBytes_AsSString(s)    ((const signed char*) PyBytes_AS_STRING(s))
680 #define __Pyx_PyBytes_AsUString(s)    ((const unsigned char*) PyBytes_AS_STRING(s))
681 #define __Pyx_PyObject_AsWritableString(s)    ((char*) __Pyx_PyObject_AsString(s))
682 #define __Pyx_PyObject_AsWritableSString(s)    ((signed char*) __Pyx_PyObject_AsString(s))
683 #define __Pyx_PyObject_AsWritableUString(s)    ((unsigned char*) __Pyx_PyObject_AsString(s))
684 #define __Pyx_PyObject_AsSString(s)    ((const signed char*) __Pyx_PyObject_AsString(s))
685 #define __Pyx_PyObject_AsUString(s)    ((const unsigned char*) __Pyx_PyObject_AsString(s))
686 #define __Pyx_PyObject_FromCString(s)  __Pyx_PyObject_FromString((const char*)s)
687 #define __Pyx_PyBytes_FromCString(s)   __Pyx_PyBytes_FromString((const char*)s)
688 #define __Pyx_PyByteArray_FromCString(s)   __Pyx_PyByteArray_FromString((const char*)s)
689 #define __Pyx_PyStr_FromCString(s)     __Pyx_PyStr_FromString((const char*)s)
690 #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
__Pyx_Py_UNICODE_strlen(const Py_UNICODE * u)691 static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
692     const Py_UNICODE *u_end = u;
693     while (*u_end++) ;
694     return (size_t)(u_end - u - 1);
695 }
696 #define __Pyx_PyUnicode_FromUnicode(u)       PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
697 #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
698 #define __Pyx_PyUnicode_AsUnicode            PyUnicode_AsUnicode
699 #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
700 #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
701 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
702 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
703 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
704 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
705 #define __Pyx_PySequence_Tuple(obj)\
706     (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
707 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
708 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
709 #if CYTHON_ASSUME_SAFE_MACROS
710 #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
711 #else
712 #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
713 #endif
714 #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
715 #if PY_MAJOR_VERSION >= 3
716 #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
717 #else
718 #define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
719 #endif
720 #define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
721 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
722 static int __Pyx_sys_getdefaultencoding_not_ascii;
__Pyx_init_sys_getdefaultencoding_params(void)723 static int __Pyx_init_sys_getdefaultencoding_params(void) {
724     PyObject* sys;
725     PyObject* default_encoding = NULL;
726     PyObject* ascii_chars_u = NULL;
727     PyObject* ascii_chars_b = NULL;
728     const char* default_encoding_c;
729     sys = PyImport_ImportModule("sys");
730     if (!sys) goto bad;
731     default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
732     Py_DECREF(sys);
733     if (!default_encoding) goto bad;
734     default_encoding_c = PyBytes_AsString(default_encoding);
735     if (!default_encoding_c) goto bad;
736     if (strcmp(default_encoding_c, "ascii") == 0) {
737         __Pyx_sys_getdefaultencoding_not_ascii = 0;
738     } else {
739         char ascii_chars[128];
740         int c;
741         for (c = 0; c < 128; c++) {
742             ascii_chars[c] = c;
743         }
744         __Pyx_sys_getdefaultencoding_not_ascii = 1;
745         ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
746         if (!ascii_chars_u) goto bad;
747         ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
748         if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
749             PyErr_Format(
750                 PyExc_ValueError,
751                 "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
752                 default_encoding_c);
753             goto bad;
754         }
755         Py_DECREF(ascii_chars_u);
756         Py_DECREF(ascii_chars_b);
757     }
758     Py_DECREF(default_encoding);
759     return 0;
760 bad:
761     Py_XDECREF(default_encoding);
762     Py_XDECREF(ascii_chars_u);
763     Py_XDECREF(ascii_chars_b);
764     return -1;
765 }
766 #endif
767 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
768 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
769 #else
770 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
771 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
772 static char* __PYX_DEFAULT_STRING_ENCODING;
__Pyx_init_sys_getdefaultencoding_params(void)773 static int __Pyx_init_sys_getdefaultencoding_params(void) {
774     PyObject* sys;
775     PyObject* default_encoding = NULL;
776     char* default_encoding_c;
777     sys = PyImport_ImportModule("sys");
778     if (!sys) goto bad;
779     default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
780     Py_DECREF(sys);
781     if (!default_encoding) goto bad;
782     default_encoding_c = PyBytes_AsString(default_encoding);
783     if (!default_encoding_c) goto bad;
784     __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1);
785     if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
786     strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
787     Py_DECREF(default_encoding);
788     return 0;
789 bad:
790     Py_XDECREF(default_encoding);
791     return -1;
792 }
793 #endif
794 #endif
795 
796 
797 /* Test for GCC > 2.95 */
798 #if defined(__GNUC__)     && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
799   #define likely(x)   __builtin_expect(!!(x), 1)
800   #define unlikely(x) __builtin_expect(!!(x), 0)
801 #else /* !__GNUC__ or GCC < 2.95 */
802   #define likely(x)   (x)
803   #define unlikely(x) (x)
804 #endif /* __GNUC__ */
__Pyx_pretend_to_initialize(void * ptr)805 static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
806 
807 static PyObject *__pyx_m = NULL;
808 static PyObject *__pyx_d;
809 static PyObject *__pyx_b;
810 static PyObject *__pyx_cython_runtime = NULL;
811 static PyObject *__pyx_empty_tuple;
812 static PyObject *__pyx_empty_bytes;
813 static PyObject *__pyx_empty_unicode;
814 static int __pyx_lineno;
815 static int __pyx_clineno = 0;
816 static const char * __pyx_cfilenm= __FILE__;
817 static const char *__pyx_filename;
818 
819 
820 static const char *__pyx_f[] = {
821   "stringsource",
822   "src/borg/chunker.pyx",
823 };
824 
825 /*--- Type declarations ---*/
826 struct __pyx_obj_4borg_7chunker_Chunker;
827 
828 /* "borg/chunker.pyx":20
829  *
830  *
831  * cdef class Chunker:             # <<<<<<<<<<<<<<
832  *     cdef _Chunker *chunker
833  *
834  */
835 struct __pyx_obj_4borg_7chunker_Chunker {
836   PyObject_HEAD
837   Chunker *chunker;
838 };
839 
840 
841 /* --- Runtime support code (head) --- */
842 /* Refnanny.proto */
843 #ifndef CYTHON_REFNANNY
844   #define CYTHON_REFNANNY 0
845 #endif
846 #if CYTHON_REFNANNY
847   typedef struct {
848     void (*INCREF)(void*, PyObject*, int);
849     void (*DECREF)(void*, PyObject*, int);
850     void (*GOTREF)(void*, PyObject*, int);
851     void (*GIVEREF)(void*, PyObject*, int);
852     void* (*SetupContext)(const char*, int, const char*);
853     void (*FinishContext)(void**);
854   } __Pyx_RefNannyAPIStruct;
855   static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
856   static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
857   #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
858 #ifdef WITH_THREAD
859   #define __Pyx_RefNannySetupContext(name, acquire_gil)\
860           if (acquire_gil) {\
861               PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
862               __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
863               PyGILState_Release(__pyx_gilstate_save);\
864           } else {\
865               __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
866           }
867 #else
868   #define __Pyx_RefNannySetupContext(name, acquire_gil)\
869           __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
870 #endif
871   #define __Pyx_RefNannyFinishContext()\
872           __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
873   #define __Pyx_INCREF(r)  __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
874   #define __Pyx_DECREF(r)  __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
875   #define __Pyx_GOTREF(r)  __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
876   #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
877   #define __Pyx_XINCREF(r)  do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
878   #define __Pyx_XDECREF(r)  do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
879   #define __Pyx_XGOTREF(r)  do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
880   #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
881 #else
882   #define __Pyx_RefNannyDeclarations
883   #define __Pyx_RefNannySetupContext(name, acquire_gil)
884   #define __Pyx_RefNannyFinishContext()
885   #define __Pyx_INCREF(r) Py_INCREF(r)
886   #define __Pyx_DECREF(r) Py_DECREF(r)
887   #define __Pyx_GOTREF(r)
888   #define __Pyx_GIVEREF(r)
889   #define __Pyx_XINCREF(r) Py_XINCREF(r)
890   #define __Pyx_XDECREF(r) Py_XDECREF(r)
891   #define __Pyx_XGOTREF(r)
892   #define __Pyx_XGIVEREF(r)
893 #endif
894 #define __Pyx_XDECREF_SET(r, v) do {\
895         PyObject *tmp = (PyObject *) r;\
896         r = v; __Pyx_XDECREF(tmp);\
897     } while (0)
898 #define __Pyx_DECREF_SET(r, v) do {\
899         PyObject *tmp = (PyObject *) r;\
900         r = v; __Pyx_DECREF(tmp);\
901     } while (0)
902 #define __Pyx_CLEAR(r)    do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
903 #define __Pyx_XCLEAR(r)   do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
904 
905 /* PyObjectGetAttrStr.proto */
906 #if CYTHON_USE_TYPE_SLOTS
907 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
908 #else
909 #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
910 #endif
911 
912 /* GetBuiltinName.proto */
913 static PyObject *__Pyx_GetBuiltinName(PyObject *name);
914 
915 /* RaiseArgTupleInvalid.proto */
916 static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
917     Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
918 
919 /* RaiseDoubleKeywords.proto */
920 static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
921 
922 /* ParseKeywords.proto */
923 static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
924     PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
925     const char* function_name);
926 
927 /* PyIntBinop.proto */
928 #if !CYTHON_COMPILING_IN_PYPY
929 static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
930 #else
931 #define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace, zerodivision_check)\
932     (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2))
933 #endif
934 
935 /* PyObjectCall.proto */
936 #if CYTHON_COMPILING_IN_CPYTHON
937 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
938 #else
939 #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
940 #endif
941 
942 /* PyThreadStateGet.proto */
943 #if CYTHON_FAST_THREAD_STATE
944 #define __Pyx_PyThreadState_declare  PyThreadState *__pyx_tstate;
945 #define __Pyx_PyThreadState_assign  __pyx_tstate = __Pyx_PyThreadState_Current;
946 #define __Pyx_PyErr_Occurred()  __pyx_tstate->curexc_type
947 #else
948 #define __Pyx_PyThreadState_declare
949 #define __Pyx_PyThreadState_assign
950 #define __Pyx_PyErr_Occurred()  PyErr_Occurred()
951 #endif
952 
953 /* PyErrFetchRestore.proto */
954 #if CYTHON_FAST_THREAD_STATE
955 #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
956 #define __Pyx_ErrRestoreWithState(type, value, tb)  __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
957 #define __Pyx_ErrFetchWithState(type, value, tb)    __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
958 #define __Pyx_ErrRestore(type, value, tb)  __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
959 #define __Pyx_ErrFetch(type, value, tb)    __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
960 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
961 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
962 #if CYTHON_COMPILING_IN_CPYTHON
963 #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
964 #else
965 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
966 #endif
967 #else
968 #define __Pyx_PyErr_Clear() PyErr_Clear()
969 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
970 #define __Pyx_ErrRestoreWithState(type, value, tb)  PyErr_Restore(type, value, tb)
971 #define __Pyx_ErrFetchWithState(type, value, tb)  PyErr_Fetch(type, value, tb)
972 #define __Pyx_ErrRestoreInState(tstate, type, value, tb)  PyErr_Restore(type, value, tb)
973 #define __Pyx_ErrFetchInState(tstate, type, value, tb)  PyErr_Fetch(type, value, tb)
974 #define __Pyx_ErrRestore(type, value, tb)  PyErr_Restore(type, value, tb)
975 #define __Pyx_ErrFetch(type, value, tb)  PyErr_Fetch(type, value, tb)
976 #endif
977 
978 /* RaiseException.proto */
979 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
980 
981 /* PyObject_GenericGetAttrNoDict.proto */
982 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
983 static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
984 #else
985 #define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
986 #endif
987 
988 /* PyObject_GenericGetAttr.proto */
989 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
990 static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name);
991 #else
992 #define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr
993 #endif
994 
995 /* PyErrExceptionMatches.proto */
996 #if CYTHON_FAST_THREAD_STATE
997 #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
998 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
999 #else
1000 #define __Pyx_PyErr_ExceptionMatches(err)  PyErr_ExceptionMatches(err)
1001 #endif
1002 
1003 /* PyObjectGetAttrStrNoError.proto */
1004 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name);
1005 
1006 /* SetupReduce.proto */
1007 static int __Pyx_setup_reduce(PyObject* type_obj);
1008 
1009 /* PyDictVersioning.proto */
1010 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
1011 #define __PYX_DICT_VERSION_INIT  ((PY_UINT64_T) -1)
1012 #define __PYX_GET_DICT_VERSION(dict)  (((PyDictObject*)(dict))->ma_version_tag)
1013 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
1014     (version_var) = __PYX_GET_DICT_VERSION(dict);\
1015     (cache_var) = (value);
1016 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
1017     static PY_UINT64_T __pyx_dict_version = 0;\
1018     static PyObject *__pyx_dict_cached_value = NULL;\
1019     if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
1020         (VAR) = __pyx_dict_cached_value;\
1021     } else {\
1022         (VAR) = __pyx_dict_cached_value = (LOOKUP);\
1023         __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
1024     }\
1025 }
1026 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj);
1027 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj);
1028 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version);
1029 #else
1030 #define __PYX_GET_DICT_VERSION(dict)  (0)
1031 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
1032 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP)  (VAR) = (LOOKUP);
1033 #endif
1034 
1035 /* CLineInTraceback.proto */
1036 #ifdef CYTHON_CLINE_IN_TRACEBACK
1037 #define __Pyx_CLineForTraceback(tstate, c_line)  (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
1038 #else
1039 static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
1040 #endif
1041 
1042 /* CodeObjectCache.proto */
1043 typedef struct {
1044     PyCodeObject* code_object;
1045     int code_line;
1046 } __Pyx_CodeObjectCacheEntry;
1047 struct __Pyx_CodeObjectCache {
1048     int count;
1049     int max_count;
1050     __Pyx_CodeObjectCacheEntry* entries;
1051 };
1052 static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
1053 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
1054 static PyCodeObject *__pyx_find_code_object(int code_line);
1055 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
1056 
1057 /* AddTraceback.proto */
1058 static void __Pyx_AddTraceback(const char *funcname, int c_line,
1059                                int py_line, const char *filename);
1060 
1061 /* GCCDiagnostics.proto */
1062 #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
1063 #define __Pyx_HAS_GCC_DIAGNOSTIC
1064 #endif
1065 
1066 /* CIntFromPy.proto */
1067 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
1068 
1069 /* CIntFromPy.proto */
1070 static CYTHON_INLINE unsigned long __Pyx_PyInt_As_unsigned_long(PyObject *);
1071 
1072 /* CIntFromPy.proto */
1073 static CYTHON_INLINE uint32_t __Pyx_PyInt_As_uint32_t(PyObject *);
1074 
1075 /* CIntFromPy.proto */
1076 static CYTHON_INLINE unsigned char __Pyx_PyInt_As_unsigned_char(PyObject *);
1077 
1078 /* CIntFromPy.proto */
1079 static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *);
1080 
1081 /* CIntToPy.proto */
1082 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
1083 
1084 /* CIntToPy.proto */
1085 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
1086 
1087 /* CIntToPy.proto */
1088 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_long(unsigned long value);
1089 
1090 /* CIntToPy.proto */
1091 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_uint32_t(uint32_t value);
1092 
1093 /* CIntFromPy.proto */
1094 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
1095 
1096 /* FastTypeChecks.proto */
1097 #if CYTHON_COMPILING_IN_CPYTHON
1098 #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
1099 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
1100 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
1101 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
1102 #else
1103 #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
1104 #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
1105 #define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
1106 #endif
1107 #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
1108 
1109 /* CheckBinaryVersion.proto */
1110 static int __Pyx_check_binary_version(void);
1111 
1112 /* InitStrings.proto */
1113 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
1114 
1115 
1116 /* Module declarations from 'libc.string' */
1117 
1118 /* Module declarations from 'libc.stdlib' */
1119 
1120 /* Module declarations from 'borg.chunker' */
1121 static PyTypeObject *__pyx_ptype_4borg_7chunker_Chunker = 0;
1122 #define __Pyx_MODULE_NAME "borg.chunker"
1123 extern int __pyx_module_is_main_borg__chunker;
1124 int __pyx_module_is_main_borg__chunker = 0;
1125 
1126 /* Implementation of 'borg.chunker' */
1127 static PyObject *__pyx_builtin_TypeError;
1128 static const char __pyx_k_fd[] = "fd";
1129 static const char __pyx_k_fh[] = "fh";
1130 static const char __pyx_k_add[] = "add";
1131 static const char __pyx_k_len[] = "len";
1132 static const char __pyx_k_sum[] = "sum";
1133 static const char __pyx_k_data[] = "data";
1134 static const char __pyx_k_main[] = "__main__";
1135 static const char __pyx_k_name[] = "__name__";
1136 static const char __pyx_k_seed[] = "seed";
1137 static const char __pyx_k_test[] = "__test__";
1138 static const char __pyx_k_table[] = "table";
1139 static const char __pyx_k_1_1_01[] = "1.1_01";
1140 static const char __pyx_k_reduce[] = "__reduce__";
1141 static const char __pyx_k_remove[] = "remove";
1142 static const char __pyx_k_Chunker[] = "Chunker";
1143 static const char __pyx_k_buzhash[] = "buzhash";
1144 static const char __pyx_k_getstate[] = "__getstate__";
1145 static const char __pyx_k_setstate[] = "__setstate__";
1146 static const char __pyx_k_TypeError[] = "TypeError";
1147 static const char __pyx_k_reduce_ex[] = "__reduce_ex__";
1148 static const char __pyx_k_API_VERSION[] = "API_VERSION";
1149 static const char __pyx_k_borg_chunker[] = "borg.chunker";
1150 static const char __pyx_k_chunk_max_exp[] = "chunk_max_exp";
1151 static const char __pyx_k_chunk_min_exp[] = "chunk_min_exp";
1152 static const char __pyx_k_reduce_cython[] = "__reduce_cython__";
1153 static const char __pyx_k_buzhash_update[] = "buzhash_update";
1154 static const char __pyx_k_hash_mask_bits[] = "hash_mask_bits";
1155 static const char __pyx_k_setstate_cython[] = "__setstate_cython__";
1156 static const char __pyx_k_hash_window_size[] = "hash_window_size";
1157 static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
1158 static const char __pyx_k_too_small_max_size[] = "too small max_size";
1159 static const char __pyx_k_src_borg_chunker_pyx[] = "src/borg/chunker.pyx";
1160 static const char __pyx_k_no_default___reduce___due_to_non[] = "no default __reduce__ due to non-trivial __cinit__";
1161 static PyObject *__pyx_kp_u_1_1_01;
1162 static PyObject *__pyx_n_s_API_VERSION;
1163 static PyObject *__pyx_n_s_Chunker;
1164 static PyObject *__pyx_n_s_TypeError;
1165 static PyObject *__pyx_n_s_add;
1166 static PyObject *__pyx_n_s_borg_chunker;
1167 static PyObject *__pyx_n_s_buzhash;
1168 static PyObject *__pyx_n_s_buzhash_update;
1169 static PyObject *__pyx_n_s_chunk_max_exp;
1170 static PyObject *__pyx_n_s_chunk_min_exp;
1171 static PyObject *__pyx_n_s_cline_in_traceback;
1172 static PyObject *__pyx_n_s_data;
1173 static PyObject *__pyx_n_s_fd;
1174 static PyObject *__pyx_n_s_fh;
1175 static PyObject *__pyx_n_s_getstate;
1176 static PyObject *__pyx_n_s_hash_mask_bits;
1177 static PyObject *__pyx_n_s_hash_window_size;
1178 static PyObject *__pyx_n_s_len;
1179 static PyObject *__pyx_n_s_main;
1180 static PyObject *__pyx_n_s_name;
1181 static PyObject *__pyx_kp_s_no_default___reduce___due_to_non;
1182 static PyObject *__pyx_n_s_reduce;
1183 static PyObject *__pyx_n_s_reduce_cython;
1184 static PyObject *__pyx_n_s_reduce_ex;
1185 static PyObject *__pyx_n_s_remove;
1186 static PyObject *__pyx_n_s_seed;
1187 static PyObject *__pyx_n_s_setstate;
1188 static PyObject *__pyx_n_s_setstate_cython;
1189 static PyObject *__pyx_kp_s_src_borg_chunker_pyx;
1190 static PyObject *__pyx_n_s_sum;
1191 static PyObject *__pyx_n_s_table;
1192 static PyObject *__pyx_n_s_test;
1193 static PyObject *__pyx_kp_u_too_small_max_size;
1194 static int __pyx_pf_4borg_7chunker_7Chunker___cinit__(struct __pyx_obj_4borg_7chunker_Chunker *__pyx_v_self, int __pyx_v_seed, int __pyx_v_chunk_min_exp, int __pyx_v_chunk_max_exp, int __pyx_v_hash_mask_bits, int __pyx_v_hash_window_size); /* proto */
1195 static PyObject *__pyx_pf_4borg_7chunker_7Chunker_2chunkify(struct __pyx_obj_4borg_7chunker_Chunker *__pyx_v_self, PyObject *__pyx_v_fd, PyObject *__pyx_v_fh); /* proto */
1196 static void __pyx_pf_4borg_7chunker_7Chunker_4__dealloc__(struct __pyx_obj_4borg_7chunker_Chunker *__pyx_v_self); /* proto */
1197 static PyObject *__pyx_pf_4borg_7chunker_7Chunker_6__iter__(struct __pyx_obj_4borg_7chunker_Chunker *__pyx_v_self); /* proto */
1198 static PyObject *__pyx_pf_4borg_7chunker_7Chunker_8__next__(struct __pyx_obj_4borg_7chunker_Chunker *__pyx_v_self); /* proto */
1199 static PyObject *__pyx_pf_4borg_7chunker_7Chunker_10__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4borg_7chunker_Chunker *__pyx_v_self); /* proto */
1200 static PyObject *__pyx_pf_4borg_7chunker_7Chunker_12__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4borg_7chunker_Chunker *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
1201 static PyObject *__pyx_pf_4borg_7chunker_buzhash(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_data, unsigned long __pyx_v_seed); /* proto */
1202 static PyObject *__pyx_pf_4borg_7chunker_2buzhash_update(CYTHON_UNUSED PyObject *__pyx_self, uint32_t __pyx_v_sum, unsigned char __pyx_v_remove, unsigned char __pyx_v_add, size_t __pyx_v_len, unsigned long __pyx_v_seed); /* proto */
1203 static PyObject *__pyx_tp_new_4borg_7chunker_Chunker(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
1204 static PyObject *__pyx_int_1;
1205 static PyObject *__pyx_int_4294967295;
1206 static PyObject *__pyx_int_neg_1;
1207 static PyObject *__pyx_tuple_;
1208 static PyObject *__pyx_tuple__2;
1209 static PyObject *__pyx_tuple__3;
1210 static PyObject *__pyx_tuple__5;
1211 static PyObject *__pyx_codeobj__4;
1212 static PyObject *__pyx_codeobj__6;
1213 /* Late includes */
1214 
1215 /* "borg/chunker.pyx":23
1216  *     cdef _Chunker *chunker
1217  *
1218  *     def __cinit__(self, int seed, int chunk_min_exp, int chunk_max_exp, int hash_mask_bits, int hash_window_size):             # <<<<<<<<<<<<<<
1219  *         min_size = 1 << chunk_min_exp
1220  *         max_size = 1 << chunk_max_exp
1221  */
1222 
1223 /* Python wrapper */
1224 static int __pyx_pw_4borg_7chunker_7Chunker_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_pw_4borg_7chunker_7Chunker_1__cinit__(PyObject * __pyx_v_self,PyObject * __pyx_args,PyObject * __pyx_kwds)1225 static int __pyx_pw_4borg_7chunker_7Chunker_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
1226   int __pyx_v_seed;
1227   int __pyx_v_chunk_min_exp;
1228   int __pyx_v_chunk_max_exp;
1229   int __pyx_v_hash_mask_bits;
1230   int __pyx_v_hash_window_size;
1231   int __pyx_lineno = 0;
1232   const char *__pyx_filename = NULL;
1233   int __pyx_clineno = 0;
1234   int __pyx_r;
1235   __Pyx_RefNannyDeclarations
1236   __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
1237   {
1238     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_seed,&__pyx_n_s_chunk_min_exp,&__pyx_n_s_chunk_max_exp,&__pyx_n_s_hash_mask_bits,&__pyx_n_s_hash_window_size,0};
1239     PyObject* values[5] = {0,0,0,0,0};
1240     if (unlikely(__pyx_kwds)) {
1241       Py_ssize_t kw_args;
1242       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
1243       switch (pos_args) {
1244         case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
1245         CYTHON_FALLTHROUGH;
1246         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
1247         CYTHON_FALLTHROUGH;
1248         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
1249         CYTHON_FALLTHROUGH;
1250         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
1251         CYTHON_FALLTHROUGH;
1252         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1253         CYTHON_FALLTHROUGH;
1254         case  0: break;
1255         default: goto __pyx_L5_argtuple_error;
1256       }
1257       kw_args = PyDict_Size(__pyx_kwds);
1258       switch (pos_args) {
1259         case  0:
1260         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_seed)) != 0)) kw_args--;
1261         else goto __pyx_L5_argtuple_error;
1262         CYTHON_FALLTHROUGH;
1263         case  1:
1264         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_chunk_min_exp)) != 0)) kw_args--;
1265         else {
1266           __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 5, 5, 1); __PYX_ERR(1, 23, __pyx_L3_error)
1267         }
1268         CYTHON_FALLTHROUGH;
1269         case  2:
1270         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_chunk_max_exp)) != 0)) kw_args--;
1271         else {
1272           __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 5, 5, 2); __PYX_ERR(1, 23, __pyx_L3_error)
1273         }
1274         CYTHON_FALLTHROUGH;
1275         case  3:
1276         if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_hash_mask_bits)) != 0)) kw_args--;
1277         else {
1278           __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 5, 5, 3); __PYX_ERR(1, 23, __pyx_L3_error)
1279         }
1280         CYTHON_FALLTHROUGH;
1281         case  4:
1282         if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_hash_window_size)) != 0)) kw_args--;
1283         else {
1284           __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 5, 5, 4); __PYX_ERR(1, 23, __pyx_L3_error)
1285         }
1286       }
1287       if (unlikely(kw_args > 0)) {
1288         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(1, 23, __pyx_L3_error)
1289       }
1290     } else if (PyTuple_GET_SIZE(__pyx_args) != 5) {
1291       goto __pyx_L5_argtuple_error;
1292     } else {
1293       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1294       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
1295       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
1296       values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
1297       values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
1298     }
1299     __pyx_v_seed = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_seed == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 23, __pyx_L3_error)
1300     __pyx_v_chunk_min_exp = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_chunk_min_exp == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 23, __pyx_L3_error)
1301     __pyx_v_chunk_max_exp = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_chunk_max_exp == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 23, __pyx_L3_error)
1302     __pyx_v_hash_mask_bits = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_hash_mask_bits == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 23, __pyx_L3_error)
1303     __pyx_v_hash_window_size = __Pyx_PyInt_As_int(values[4]); if (unlikely((__pyx_v_hash_window_size == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 23, __pyx_L3_error)
1304   }
1305   goto __pyx_L4_argument_unpacking_done;
1306   __pyx_L5_argtuple_error:;
1307   __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 23, __pyx_L3_error)
1308   __pyx_L3_error:;
1309   __Pyx_AddTraceback("borg.chunker.Chunker.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
1310   __Pyx_RefNannyFinishContext();
1311   return -1;
1312   __pyx_L4_argument_unpacking_done:;
1313   __pyx_r = __pyx_pf_4borg_7chunker_7Chunker___cinit__(((struct __pyx_obj_4borg_7chunker_Chunker *)__pyx_v_self), __pyx_v_seed, __pyx_v_chunk_min_exp, __pyx_v_chunk_max_exp, __pyx_v_hash_mask_bits, __pyx_v_hash_window_size);
1314 
1315   /* function exit code */
1316   __Pyx_RefNannyFinishContext();
1317   return __pyx_r;
1318 }
1319 
__pyx_pf_4borg_7chunker_7Chunker___cinit__(struct __pyx_obj_4borg_7chunker_Chunker * __pyx_v_self,int __pyx_v_seed,int __pyx_v_chunk_min_exp,int __pyx_v_chunk_max_exp,int __pyx_v_hash_mask_bits,int __pyx_v_hash_window_size)1320 static int __pyx_pf_4borg_7chunker_7Chunker___cinit__(struct __pyx_obj_4borg_7chunker_Chunker *__pyx_v_self, int __pyx_v_seed, int __pyx_v_chunk_min_exp, int __pyx_v_chunk_max_exp, int __pyx_v_hash_mask_bits, int __pyx_v_hash_window_size) {
1321   PyObject *__pyx_v_min_size = NULL;
1322   long __pyx_v_max_size;
1323   long __pyx_v_hash_mask;
1324   int __pyx_r;
1325   __Pyx_RefNannyDeclarations
1326   PyObject *__pyx_t_1 = NULL;
1327   PyObject *__pyx_t_2 = NULL;
1328   PyObject *__pyx_t_3 = NULL;
1329   int __pyx_t_4;
1330   int __pyx_t_5;
1331   uint32_t __pyx_t_6;
1332   int __pyx_lineno = 0;
1333   const char *__pyx_filename = NULL;
1334   int __pyx_clineno = 0;
1335   __Pyx_RefNannySetupContext("__cinit__", 0);
1336 
1337   /* "borg/chunker.pyx":24
1338  *
1339  *     def __cinit__(self, int seed, int chunk_min_exp, int chunk_max_exp, int hash_mask_bits, int hash_window_size):
1340  *         min_size = 1 << chunk_min_exp             # <<<<<<<<<<<<<<
1341  *         max_size = 1 << chunk_max_exp
1342  *         # see chunker_process, first while loop condition, first term must be able to get True:
1343  */
1344   __pyx_t_1 = __Pyx_PyInt_From_long((1 << __pyx_v_chunk_min_exp)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 24, __pyx_L1_error)
1345   __Pyx_GOTREF(__pyx_t_1);
1346   __pyx_v_min_size = __pyx_t_1;
1347   __pyx_t_1 = 0;
1348 
1349   /* "borg/chunker.pyx":25
1350  *     def __cinit__(self, int seed, int chunk_min_exp, int chunk_max_exp, int hash_mask_bits, int hash_window_size):
1351  *         min_size = 1 << chunk_min_exp
1352  *         max_size = 1 << chunk_max_exp             # <<<<<<<<<<<<<<
1353  *         # see chunker_process, first while loop condition, first term must be able to get True:
1354  *         assert hash_window_size + min_size + 1 <= max_size, "too small max_size"
1355  */
1356   __pyx_v_max_size = (1 << __pyx_v_chunk_max_exp);
1357 
1358   /* "borg/chunker.pyx":27
1359  *         max_size = 1 << chunk_max_exp
1360  *         # see chunker_process, first while loop condition, first term must be able to get True:
1361  *         assert hash_window_size + min_size + 1 <= max_size, "too small max_size"             # <<<<<<<<<<<<<<
1362  *         hash_mask = (1 << hash_mask_bits) - 1
1363  *         self.chunker = chunker_init(hash_window_size, hash_mask, min_size, max_size, seed & 0xffffffff)
1364  */
1365   #ifndef CYTHON_WITHOUT_ASSERTIONS
1366   if (unlikely(!Py_OptimizeFlag)) {
1367     __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_hash_window_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 27, __pyx_L1_error)
1368     __Pyx_GOTREF(__pyx_t_1);
1369     __pyx_t_2 = PyNumber_Add(__pyx_t_1, __pyx_v_min_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 27, __pyx_L1_error)
1370     __Pyx_GOTREF(__pyx_t_2);
1371     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1372     __pyx_t_1 = __Pyx_PyInt_AddObjC(__pyx_t_2, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 27, __pyx_L1_error)
1373     __Pyx_GOTREF(__pyx_t_1);
1374     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1375     __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v_max_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 27, __pyx_L1_error)
1376     __Pyx_GOTREF(__pyx_t_2);
1377     __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_LE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 27, __pyx_L1_error)
1378     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1379     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1380     __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(1, 27, __pyx_L1_error)
1381     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1382     if (unlikely(!__pyx_t_4)) {
1383       PyErr_SetObject(PyExc_AssertionError, __pyx_kp_u_too_small_max_size);
1384       __PYX_ERR(1, 27, __pyx_L1_error)
1385     }
1386   }
1387   #endif
1388 
1389   /* "borg/chunker.pyx":28
1390  *         # see chunker_process, first while loop condition, first term must be able to get True:
1391  *         assert hash_window_size + min_size + 1 <= max_size, "too small max_size"
1392  *         hash_mask = (1 << hash_mask_bits) - 1             # <<<<<<<<<<<<<<
1393  *         self.chunker = chunker_init(hash_window_size, hash_mask, min_size, max_size, seed & 0xffffffff)
1394  *
1395  */
1396   __pyx_v_hash_mask = ((1 << __pyx_v_hash_mask_bits) - 1);
1397 
1398   /* "borg/chunker.pyx":29
1399  *         assert hash_window_size + min_size + 1 <= max_size, "too small max_size"
1400  *         hash_mask = (1 << hash_mask_bits) - 1
1401  *         self.chunker = chunker_init(hash_window_size, hash_mask, min_size, max_size, seed & 0xffffffff)             # <<<<<<<<<<<<<<
1402  *
1403  *     def chunkify(self, fd, fh=-1):
1404  */
1405   __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_v_min_size); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 29, __pyx_L1_error)
1406   __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_seed); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 29, __pyx_L1_error)
1407   __Pyx_GOTREF(__pyx_t_3);
1408   __pyx_t_2 = PyNumber_And(__pyx_t_3, __pyx_int_4294967295); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 29, __pyx_L1_error)
1409   __Pyx_GOTREF(__pyx_t_2);
1410   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1411   __pyx_t_6 = __Pyx_PyInt_As_uint32_t(__pyx_t_2); if (unlikely((__pyx_t_6 == ((uint32_t)-1)) && PyErr_Occurred())) __PYX_ERR(1, 29, __pyx_L1_error)
1412   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1413   __pyx_v_self->chunker = chunker_init(__pyx_v_hash_window_size, __pyx_v_hash_mask, __pyx_t_5, __pyx_v_max_size, __pyx_t_6);
1414 
1415   /* "borg/chunker.pyx":23
1416  *     cdef _Chunker *chunker
1417  *
1418  *     def __cinit__(self, int seed, int chunk_min_exp, int chunk_max_exp, int hash_mask_bits, int hash_window_size):             # <<<<<<<<<<<<<<
1419  *         min_size = 1 << chunk_min_exp
1420  *         max_size = 1 << chunk_max_exp
1421  */
1422 
1423   /* function exit code */
1424   __pyx_r = 0;
1425   goto __pyx_L0;
1426   __pyx_L1_error:;
1427   __Pyx_XDECREF(__pyx_t_1);
1428   __Pyx_XDECREF(__pyx_t_2);
1429   __Pyx_XDECREF(__pyx_t_3);
1430   __Pyx_AddTraceback("borg.chunker.Chunker.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
1431   __pyx_r = -1;
1432   __pyx_L0:;
1433   __Pyx_XDECREF(__pyx_v_min_size);
1434   __Pyx_RefNannyFinishContext();
1435   return __pyx_r;
1436 }
1437 
1438 /* "borg/chunker.pyx":31
1439  *         self.chunker = chunker_init(hash_window_size, hash_mask, min_size, max_size, seed & 0xffffffff)
1440  *
1441  *     def chunkify(self, fd, fh=-1):             # <<<<<<<<<<<<<<
1442  *         """
1443  *         Cut a file into chunks.
1444  */
1445 
1446 /* Python wrapper */
1447 static PyObject *__pyx_pw_4borg_7chunker_7Chunker_3chunkify(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
1448 static char __pyx_doc_4borg_7chunker_7Chunker_2chunkify[] = "\n        Cut a file into chunks.\n\n        :param fd: Python file object\n        :param fh: OS-level file handle (if available),\n                   defaults to -1 which means not to use OS-level fd.\n        ";
__pyx_pw_4borg_7chunker_7Chunker_3chunkify(PyObject * __pyx_v_self,PyObject * __pyx_args,PyObject * __pyx_kwds)1449 static PyObject *__pyx_pw_4borg_7chunker_7Chunker_3chunkify(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
1450   PyObject *__pyx_v_fd = 0;
1451   PyObject *__pyx_v_fh = 0;
1452   int __pyx_lineno = 0;
1453   const char *__pyx_filename = NULL;
1454   int __pyx_clineno = 0;
1455   PyObject *__pyx_r = 0;
1456   __Pyx_RefNannyDeclarations
1457   __Pyx_RefNannySetupContext("chunkify (wrapper)", 0);
1458   {
1459     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_fd,&__pyx_n_s_fh,0};
1460     PyObject* values[2] = {0,0};
1461     values[1] = ((PyObject *)__pyx_int_neg_1);
1462     if (unlikely(__pyx_kwds)) {
1463       Py_ssize_t kw_args;
1464       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
1465       switch (pos_args) {
1466         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
1467         CYTHON_FALLTHROUGH;
1468         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1469         CYTHON_FALLTHROUGH;
1470         case  0: break;
1471         default: goto __pyx_L5_argtuple_error;
1472       }
1473       kw_args = PyDict_Size(__pyx_kwds);
1474       switch (pos_args) {
1475         case  0:
1476         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fd)) != 0)) kw_args--;
1477         else goto __pyx_L5_argtuple_error;
1478         CYTHON_FALLTHROUGH;
1479         case  1:
1480         if (kw_args > 0) {
1481           PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fh);
1482           if (value) { values[1] = value; kw_args--; }
1483         }
1484       }
1485       if (unlikely(kw_args > 0)) {
1486         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "chunkify") < 0)) __PYX_ERR(1, 31, __pyx_L3_error)
1487       }
1488     } else {
1489       switch (PyTuple_GET_SIZE(__pyx_args)) {
1490         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
1491         CYTHON_FALLTHROUGH;
1492         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1493         break;
1494         default: goto __pyx_L5_argtuple_error;
1495       }
1496     }
1497     __pyx_v_fd = values[0];
1498     __pyx_v_fh = values[1];
1499   }
1500   goto __pyx_L4_argument_unpacking_done;
1501   __pyx_L5_argtuple_error:;
1502   __Pyx_RaiseArgtupleInvalid("chunkify", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 31, __pyx_L3_error)
1503   __pyx_L3_error:;
1504   __Pyx_AddTraceback("borg.chunker.Chunker.chunkify", __pyx_clineno, __pyx_lineno, __pyx_filename);
1505   __Pyx_RefNannyFinishContext();
1506   return NULL;
1507   __pyx_L4_argument_unpacking_done:;
1508   __pyx_r = __pyx_pf_4borg_7chunker_7Chunker_2chunkify(((struct __pyx_obj_4borg_7chunker_Chunker *)__pyx_v_self), __pyx_v_fd, __pyx_v_fh);
1509 
1510   /* function exit code */
1511   __Pyx_RefNannyFinishContext();
1512   return __pyx_r;
1513 }
1514 
__pyx_pf_4borg_7chunker_7Chunker_2chunkify(struct __pyx_obj_4borg_7chunker_Chunker * __pyx_v_self,PyObject * __pyx_v_fd,PyObject * __pyx_v_fh)1515 static PyObject *__pyx_pf_4borg_7chunker_7Chunker_2chunkify(struct __pyx_obj_4borg_7chunker_Chunker *__pyx_v_self, PyObject *__pyx_v_fd, PyObject *__pyx_v_fh) {
1516   PyObject *__pyx_r = NULL;
1517   __Pyx_RefNannyDeclarations
1518   int __pyx_t_1;
1519   int __pyx_lineno = 0;
1520   const char *__pyx_filename = NULL;
1521   int __pyx_clineno = 0;
1522   __Pyx_RefNannySetupContext("chunkify", 0);
1523 
1524   /* "borg/chunker.pyx":39
1525  *                    defaults to -1 which means not to use OS-level fd.
1526  *         """
1527  *         chunker_set_fd(self.chunker, fd, fh)             # <<<<<<<<<<<<<<
1528  *         return self
1529  *
1530  */
1531   __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_fh); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 39, __pyx_L1_error)
1532   chunker_set_fd(__pyx_v_self->chunker, __pyx_v_fd, __pyx_t_1);
1533 
1534   /* "borg/chunker.pyx":40
1535  *         """
1536  *         chunker_set_fd(self.chunker, fd, fh)
1537  *         return self             # <<<<<<<<<<<<<<
1538  *
1539  *     def __dealloc__(self):
1540  */
1541   __Pyx_XDECREF(__pyx_r);
1542   __Pyx_INCREF(((PyObject *)__pyx_v_self));
1543   __pyx_r = ((PyObject *)__pyx_v_self);
1544   goto __pyx_L0;
1545 
1546   /* "borg/chunker.pyx":31
1547  *         self.chunker = chunker_init(hash_window_size, hash_mask, min_size, max_size, seed & 0xffffffff)
1548  *
1549  *     def chunkify(self, fd, fh=-1):             # <<<<<<<<<<<<<<
1550  *         """
1551  *         Cut a file into chunks.
1552  */
1553 
1554   /* function exit code */
1555   __pyx_L1_error:;
1556   __Pyx_AddTraceback("borg.chunker.Chunker.chunkify", __pyx_clineno, __pyx_lineno, __pyx_filename);
1557   __pyx_r = NULL;
1558   __pyx_L0:;
1559   __Pyx_XGIVEREF(__pyx_r);
1560   __Pyx_RefNannyFinishContext();
1561   return __pyx_r;
1562 }
1563 
1564 /* "borg/chunker.pyx":42
1565  *         return self
1566  *
1567  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
1568  *         if self.chunker:
1569  *             chunker_free(self.chunker)
1570  */
1571 
1572 /* Python wrapper */
1573 static void __pyx_pw_4borg_7chunker_7Chunker_5__dealloc__(PyObject *__pyx_v_self); /*proto*/
__pyx_pw_4borg_7chunker_7Chunker_5__dealloc__(PyObject * __pyx_v_self)1574 static void __pyx_pw_4borg_7chunker_7Chunker_5__dealloc__(PyObject *__pyx_v_self) {
1575   __Pyx_RefNannyDeclarations
1576   __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
1577   __pyx_pf_4borg_7chunker_7Chunker_4__dealloc__(((struct __pyx_obj_4borg_7chunker_Chunker *)__pyx_v_self));
1578 
1579   /* function exit code */
1580   __Pyx_RefNannyFinishContext();
1581 }
1582 
__pyx_pf_4borg_7chunker_7Chunker_4__dealloc__(struct __pyx_obj_4borg_7chunker_Chunker * __pyx_v_self)1583 static void __pyx_pf_4borg_7chunker_7Chunker_4__dealloc__(struct __pyx_obj_4borg_7chunker_Chunker *__pyx_v_self) {
1584   __Pyx_RefNannyDeclarations
1585   int __pyx_t_1;
1586   __Pyx_RefNannySetupContext("__dealloc__", 0);
1587 
1588   /* "borg/chunker.pyx":43
1589  *
1590  *     def __dealloc__(self):
1591  *         if self.chunker:             # <<<<<<<<<<<<<<
1592  *             chunker_free(self.chunker)
1593  *
1594  */
1595   __pyx_t_1 = (__pyx_v_self->chunker != 0);
1596   if (__pyx_t_1) {
1597 
1598     /* "borg/chunker.pyx":44
1599  *     def __dealloc__(self):
1600  *         if self.chunker:
1601  *             chunker_free(self.chunker)             # <<<<<<<<<<<<<<
1602  *
1603  *     def __iter__(self):
1604  */
1605     chunker_free(__pyx_v_self->chunker);
1606 
1607     /* "borg/chunker.pyx":43
1608  *
1609  *     def __dealloc__(self):
1610  *         if self.chunker:             # <<<<<<<<<<<<<<
1611  *             chunker_free(self.chunker)
1612  *
1613  */
1614   }
1615 
1616   /* "borg/chunker.pyx":42
1617  *         return self
1618  *
1619  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
1620  *         if self.chunker:
1621  *             chunker_free(self.chunker)
1622  */
1623 
1624   /* function exit code */
1625   __Pyx_RefNannyFinishContext();
1626 }
1627 
1628 /* "borg/chunker.pyx":46
1629  *             chunker_free(self.chunker)
1630  *
1631  *     def __iter__(self):             # <<<<<<<<<<<<<<
1632  *         return self
1633  *
1634  */
1635 
1636 /* Python wrapper */
1637 static PyObject *__pyx_pw_4borg_7chunker_7Chunker_7__iter__(PyObject *__pyx_v_self); /*proto*/
__pyx_pw_4borg_7chunker_7Chunker_7__iter__(PyObject * __pyx_v_self)1638 static PyObject *__pyx_pw_4borg_7chunker_7Chunker_7__iter__(PyObject *__pyx_v_self) {
1639   PyObject *__pyx_r = 0;
1640   __Pyx_RefNannyDeclarations
1641   __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
1642   __pyx_r = __pyx_pf_4borg_7chunker_7Chunker_6__iter__(((struct __pyx_obj_4borg_7chunker_Chunker *)__pyx_v_self));
1643 
1644   /* function exit code */
1645   __Pyx_RefNannyFinishContext();
1646   return __pyx_r;
1647 }
1648 
__pyx_pf_4borg_7chunker_7Chunker_6__iter__(struct __pyx_obj_4borg_7chunker_Chunker * __pyx_v_self)1649 static PyObject *__pyx_pf_4borg_7chunker_7Chunker_6__iter__(struct __pyx_obj_4borg_7chunker_Chunker *__pyx_v_self) {
1650   PyObject *__pyx_r = NULL;
1651   __Pyx_RefNannyDeclarations
1652   __Pyx_RefNannySetupContext("__iter__", 0);
1653 
1654   /* "borg/chunker.pyx":47
1655  *
1656  *     def __iter__(self):
1657  *         return self             # <<<<<<<<<<<<<<
1658  *
1659  *     def __next__(self):
1660  */
1661   __Pyx_XDECREF(__pyx_r);
1662   __Pyx_INCREF(((PyObject *)__pyx_v_self));
1663   __pyx_r = ((PyObject *)__pyx_v_self);
1664   goto __pyx_L0;
1665 
1666   /* "borg/chunker.pyx":46
1667  *             chunker_free(self.chunker)
1668  *
1669  *     def __iter__(self):             # <<<<<<<<<<<<<<
1670  *         return self
1671  *
1672  */
1673 
1674   /* function exit code */
1675   __pyx_L0:;
1676   __Pyx_XGIVEREF(__pyx_r);
1677   __Pyx_RefNannyFinishContext();
1678   return __pyx_r;
1679 }
1680 
1681 /* "borg/chunker.pyx":49
1682  *         return self
1683  *
1684  *     def __next__(self):             # <<<<<<<<<<<<<<
1685  *         return chunker_process(self.chunker)
1686  *
1687  */
1688 
1689 /* Python wrapper */
1690 static PyObject *__pyx_pw_4borg_7chunker_7Chunker_9__next__(PyObject *__pyx_v_self); /*proto*/
__pyx_pw_4borg_7chunker_7Chunker_9__next__(PyObject * __pyx_v_self)1691 static PyObject *__pyx_pw_4borg_7chunker_7Chunker_9__next__(PyObject *__pyx_v_self) {
1692   PyObject *__pyx_r = 0;
1693   __Pyx_RefNannyDeclarations
1694   __Pyx_RefNannySetupContext("__next__ (wrapper)", 0);
1695   __pyx_r = __pyx_pf_4borg_7chunker_7Chunker_8__next__(((struct __pyx_obj_4borg_7chunker_Chunker *)__pyx_v_self));
1696 
1697   /* function exit code */
1698   __Pyx_RefNannyFinishContext();
1699   return __pyx_r;
1700 }
1701 
__pyx_pf_4borg_7chunker_7Chunker_8__next__(struct __pyx_obj_4borg_7chunker_Chunker * __pyx_v_self)1702 static PyObject *__pyx_pf_4borg_7chunker_7Chunker_8__next__(struct __pyx_obj_4borg_7chunker_Chunker *__pyx_v_self) {
1703   PyObject *__pyx_r = NULL;
1704   __Pyx_RefNannyDeclarations
1705   PyObject *__pyx_t_1 = NULL;
1706   int __pyx_lineno = 0;
1707   const char *__pyx_filename = NULL;
1708   int __pyx_clineno = 0;
1709   __Pyx_RefNannySetupContext("__next__", 0);
1710 
1711   /* "borg/chunker.pyx":50
1712  *
1713  *     def __next__(self):
1714  *         return chunker_process(self.chunker)             # <<<<<<<<<<<<<<
1715  *
1716  *
1717  */
1718   __Pyx_XDECREF(__pyx_r);
1719   __pyx_t_1 = chunker_process(__pyx_v_self->chunker); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 50, __pyx_L1_error)
1720   __Pyx_GOTREF(__pyx_t_1);
1721   __pyx_r = __pyx_t_1;
1722   __pyx_t_1 = 0;
1723   goto __pyx_L0;
1724 
1725   /* "borg/chunker.pyx":49
1726  *         return self
1727  *
1728  *     def __next__(self):             # <<<<<<<<<<<<<<
1729  *         return chunker_process(self.chunker)
1730  *
1731  */
1732 
1733   /* function exit code */
1734   __pyx_L1_error:;
1735   __Pyx_XDECREF(__pyx_t_1);
1736   __Pyx_AddTraceback("borg.chunker.Chunker.__next__", __pyx_clineno, __pyx_lineno, __pyx_filename);
1737   __pyx_r = NULL;
1738   __pyx_L0:;
1739   __Pyx_XGIVEREF(__pyx_r);
1740   __Pyx_RefNannyFinishContext();
1741   return __pyx_r;
1742 }
1743 
1744 /* "(tree fragment)":1
1745  * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
1746  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
1747  * def __setstate_cython__(self, __pyx_state):
1748  */
1749 
1750 /* Python wrapper */
1751 static PyObject *__pyx_pw_4borg_7chunker_7Chunker_11__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pw_4borg_7chunker_7Chunker_11__reduce_cython__(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)1752 static PyObject *__pyx_pw_4borg_7chunker_7Chunker_11__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
1753   PyObject *__pyx_r = 0;
1754   __Pyx_RefNannyDeclarations
1755   __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
1756   __pyx_r = __pyx_pf_4borg_7chunker_7Chunker_10__reduce_cython__(((struct __pyx_obj_4borg_7chunker_Chunker *)__pyx_v_self));
1757 
1758   /* function exit code */
1759   __Pyx_RefNannyFinishContext();
1760   return __pyx_r;
1761 }
1762 
__pyx_pf_4borg_7chunker_7Chunker_10__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4borg_7chunker_Chunker * __pyx_v_self)1763 static PyObject *__pyx_pf_4borg_7chunker_7Chunker_10__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4borg_7chunker_Chunker *__pyx_v_self) {
1764   PyObject *__pyx_r = NULL;
1765   __Pyx_RefNannyDeclarations
1766   PyObject *__pyx_t_1 = NULL;
1767   int __pyx_lineno = 0;
1768   const char *__pyx_filename = NULL;
1769   int __pyx_clineno = 0;
1770   __Pyx_RefNannySetupContext("__reduce_cython__", 0);
1771 
1772   /* "(tree fragment)":2
1773  * def __reduce_cython__(self):
1774  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
1775  * def __setstate_cython__(self, __pyx_state):
1776  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
1777  */
1778   __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2, __pyx_L1_error)
1779   __Pyx_GOTREF(__pyx_t_1);
1780   __Pyx_Raise(__pyx_t_1, 0, 0, 0);
1781   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1782   __PYX_ERR(0, 2, __pyx_L1_error)
1783 
1784   /* "(tree fragment)":1
1785  * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
1786  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
1787  * def __setstate_cython__(self, __pyx_state):
1788  */
1789 
1790   /* function exit code */
1791   __pyx_L1_error:;
1792   __Pyx_XDECREF(__pyx_t_1);
1793   __Pyx_AddTraceback("borg.chunker.Chunker.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
1794   __pyx_r = NULL;
1795   __Pyx_XGIVEREF(__pyx_r);
1796   __Pyx_RefNannyFinishContext();
1797   return __pyx_r;
1798 }
1799 
1800 /* "(tree fragment)":3
1801  * def __reduce_cython__(self):
1802  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
1803  * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
1804  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
1805  */
1806 
1807 /* Python wrapper */
1808 static PyObject *__pyx_pw_4borg_7chunker_7Chunker_13__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
__pyx_pw_4borg_7chunker_7Chunker_13__setstate_cython__(PyObject * __pyx_v_self,PyObject * __pyx_v___pyx_state)1809 static PyObject *__pyx_pw_4borg_7chunker_7Chunker_13__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
1810   PyObject *__pyx_r = 0;
1811   __Pyx_RefNannyDeclarations
1812   __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
1813   __pyx_r = __pyx_pf_4borg_7chunker_7Chunker_12__setstate_cython__(((struct __pyx_obj_4borg_7chunker_Chunker *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
1814 
1815   /* function exit code */
1816   __Pyx_RefNannyFinishContext();
1817   return __pyx_r;
1818 }
1819 
__pyx_pf_4borg_7chunker_7Chunker_12__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4borg_7chunker_Chunker * __pyx_v_self,CYTHON_UNUSED PyObject * __pyx_v___pyx_state)1820 static PyObject *__pyx_pf_4borg_7chunker_7Chunker_12__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4borg_7chunker_Chunker *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
1821   PyObject *__pyx_r = NULL;
1822   __Pyx_RefNannyDeclarations
1823   PyObject *__pyx_t_1 = NULL;
1824   int __pyx_lineno = 0;
1825   const char *__pyx_filename = NULL;
1826   int __pyx_clineno = 0;
1827   __Pyx_RefNannySetupContext("__setstate_cython__", 0);
1828 
1829   /* "(tree fragment)":4
1830  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
1831  * def __setstate_cython__(self, __pyx_state):
1832  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
1833  */
1834   __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4, __pyx_L1_error)
1835   __Pyx_GOTREF(__pyx_t_1);
1836   __Pyx_Raise(__pyx_t_1, 0, 0, 0);
1837   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1838   __PYX_ERR(0, 4, __pyx_L1_error)
1839 
1840   /* "(tree fragment)":3
1841  * def __reduce_cython__(self):
1842  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
1843  * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
1844  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
1845  */
1846 
1847   /* function exit code */
1848   __pyx_L1_error:;
1849   __Pyx_XDECREF(__pyx_t_1);
1850   __Pyx_AddTraceback("borg.chunker.Chunker.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
1851   __pyx_r = NULL;
1852   __Pyx_XGIVEREF(__pyx_r);
1853   __Pyx_RefNannyFinishContext();
1854   return __pyx_r;
1855 }
1856 
1857 /* "borg/chunker.pyx":53
1858  *
1859  *
1860  * def buzhash(data, unsigned long seed):             # <<<<<<<<<<<<<<
1861  *     cdef uint32_t *table
1862  *     cdef uint32_t sum
1863  */
1864 
1865 /* Python wrapper */
1866 static PyObject *__pyx_pw_4borg_7chunker_1buzhash(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
1867 static PyMethodDef __pyx_mdef_4borg_7chunker_1buzhash = {"buzhash", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4borg_7chunker_1buzhash, METH_VARARGS|METH_KEYWORDS, 0};
__pyx_pw_4borg_7chunker_1buzhash(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)1868 static PyObject *__pyx_pw_4borg_7chunker_1buzhash(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
1869   PyObject *__pyx_v_data = 0;
1870   unsigned long __pyx_v_seed;
1871   int __pyx_lineno = 0;
1872   const char *__pyx_filename = NULL;
1873   int __pyx_clineno = 0;
1874   PyObject *__pyx_r = 0;
1875   __Pyx_RefNannyDeclarations
1876   __Pyx_RefNannySetupContext("buzhash (wrapper)", 0);
1877   {
1878     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_data,&__pyx_n_s_seed,0};
1879     PyObject* values[2] = {0,0};
1880     if (unlikely(__pyx_kwds)) {
1881       Py_ssize_t kw_args;
1882       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
1883       switch (pos_args) {
1884         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
1885         CYTHON_FALLTHROUGH;
1886         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1887         CYTHON_FALLTHROUGH;
1888         case  0: break;
1889         default: goto __pyx_L5_argtuple_error;
1890       }
1891       kw_args = PyDict_Size(__pyx_kwds);
1892       switch (pos_args) {
1893         case  0:
1894         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_data)) != 0)) kw_args--;
1895         else goto __pyx_L5_argtuple_error;
1896         CYTHON_FALLTHROUGH;
1897         case  1:
1898         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_seed)) != 0)) kw_args--;
1899         else {
1900           __Pyx_RaiseArgtupleInvalid("buzhash", 1, 2, 2, 1); __PYX_ERR(1, 53, __pyx_L3_error)
1901         }
1902       }
1903       if (unlikely(kw_args > 0)) {
1904         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "buzhash") < 0)) __PYX_ERR(1, 53, __pyx_L3_error)
1905       }
1906     } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
1907       goto __pyx_L5_argtuple_error;
1908     } else {
1909       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1910       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
1911     }
1912     __pyx_v_data = values[0];
1913     __pyx_v_seed = __Pyx_PyInt_As_unsigned_long(values[1]); if (unlikely((__pyx_v_seed == (unsigned long)-1) && PyErr_Occurred())) __PYX_ERR(1, 53, __pyx_L3_error)
1914   }
1915   goto __pyx_L4_argument_unpacking_done;
1916   __pyx_L5_argtuple_error:;
1917   __Pyx_RaiseArgtupleInvalid("buzhash", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 53, __pyx_L3_error)
1918   __pyx_L3_error:;
1919   __Pyx_AddTraceback("borg.chunker.buzhash", __pyx_clineno, __pyx_lineno, __pyx_filename);
1920   __Pyx_RefNannyFinishContext();
1921   return NULL;
1922   __pyx_L4_argument_unpacking_done:;
1923   __pyx_r = __pyx_pf_4borg_7chunker_buzhash(__pyx_self, __pyx_v_data, __pyx_v_seed);
1924 
1925   /* function exit code */
1926   __Pyx_RefNannyFinishContext();
1927   return __pyx_r;
1928 }
1929 
__pyx_pf_4borg_7chunker_buzhash(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v_data,unsigned long __pyx_v_seed)1930 static PyObject *__pyx_pf_4borg_7chunker_buzhash(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_data, unsigned long __pyx_v_seed) {
1931   uint32_t *__pyx_v_table;
1932   uint32_t __pyx_v_sum;
1933   PyObject *__pyx_r = NULL;
1934   __Pyx_RefNannyDeclarations
1935   PyObject *__pyx_t_1 = NULL;
1936   PyObject *__pyx_t_2 = NULL;
1937   uint32_t __pyx_t_3;
1938   unsigned char const *__pyx_t_4;
1939   Py_ssize_t __pyx_t_5;
1940   int __pyx_lineno = 0;
1941   const char *__pyx_filename = NULL;
1942   int __pyx_clineno = 0;
1943   __Pyx_RefNannySetupContext("buzhash", 0);
1944 
1945   /* "borg/chunker.pyx":56
1946  *     cdef uint32_t *table
1947  *     cdef uint32_t sum
1948  *     table = buzhash_init_table(seed & 0xffffffff)             # <<<<<<<<<<<<<<
1949  *     sum = c_buzhash(<const unsigned char *> data, len(data), table)
1950  *     free(table)
1951  */
1952   __pyx_t_1 = __Pyx_PyInt_From_unsigned_long(__pyx_v_seed); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 56, __pyx_L1_error)
1953   __Pyx_GOTREF(__pyx_t_1);
1954   __pyx_t_2 = PyNumber_And(__pyx_t_1, __pyx_int_4294967295); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 56, __pyx_L1_error)
1955   __Pyx_GOTREF(__pyx_t_2);
1956   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1957   __pyx_t_3 = __Pyx_PyInt_As_uint32_t(__pyx_t_2); if (unlikely((__pyx_t_3 == ((uint32_t)-1)) && PyErr_Occurred())) __PYX_ERR(1, 56, __pyx_L1_error)
1958   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1959   __pyx_v_table = buzhash_init_table(__pyx_t_3);
1960 
1961   /* "borg/chunker.pyx":57
1962  *     cdef uint32_t sum
1963  *     table = buzhash_init_table(seed & 0xffffffff)
1964  *     sum = c_buzhash(<const unsigned char *> data, len(data), table)             # <<<<<<<<<<<<<<
1965  *     free(table)
1966  *     return sum
1967  */
1968   __pyx_t_4 = __Pyx_PyObject_AsUString(__pyx_v_data); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) __PYX_ERR(1, 57, __pyx_L1_error)
1969   __pyx_t_5 = PyObject_Length(__pyx_v_data); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(1, 57, __pyx_L1_error)
1970   __pyx_v_sum = buzhash(((unsigned char const *)__pyx_t_4), __pyx_t_5, __pyx_v_table);
1971 
1972   /* "borg/chunker.pyx":58
1973  *     table = buzhash_init_table(seed & 0xffffffff)
1974  *     sum = c_buzhash(<const unsigned char *> data, len(data), table)
1975  *     free(table)             # <<<<<<<<<<<<<<
1976  *     return sum
1977  *
1978  */
1979   free(__pyx_v_table);
1980 
1981   /* "borg/chunker.pyx":59
1982  *     sum = c_buzhash(<const unsigned char *> data, len(data), table)
1983  *     free(table)
1984  *     return sum             # <<<<<<<<<<<<<<
1985  *
1986  *
1987  */
1988   __Pyx_XDECREF(__pyx_r);
1989   __pyx_t_2 = __Pyx_PyInt_From_uint32_t(__pyx_v_sum); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 59, __pyx_L1_error)
1990   __Pyx_GOTREF(__pyx_t_2);
1991   __pyx_r = __pyx_t_2;
1992   __pyx_t_2 = 0;
1993   goto __pyx_L0;
1994 
1995   /* "borg/chunker.pyx":53
1996  *
1997  *
1998  * def buzhash(data, unsigned long seed):             # <<<<<<<<<<<<<<
1999  *     cdef uint32_t *table
2000  *     cdef uint32_t sum
2001  */
2002 
2003   /* function exit code */
2004   __pyx_L1_error:;
2005   __Pyx_XDECREF(__pyx_t_1);
2006   __Pyx_XDECREF(__pyx_t_2);
2007   __Pyx_AddTraceback("borg.chunker.buzhash", __pyx_clineno, __pyx_lineno, __pyx_filename);
2008   __pyx_r = NULL;
2009   __pyx_L0:;
2010   __Pyx_XGIVEREF(__pyx_r);
2011   __Pyx_RefNannyFinishContext();
2012   return __pyx_r;
2013 }
2014 
2015 /* "borg/chunker.pyx":62
2016  *
2017  *
2018  * def buzhash_update(uint32_t sum, unsigned char remove, unsigned char add, size_t len, unsigned long seed):             # <<<<<<<<<<<<<<
2019  *     cdef uint32_t *table
2020  *     table = buzhash_init_table(seed & 0xffffffff)
2021  */
2022 
2023 /* Python wrapper */
2024 static PyObject *__pyx_pw_4borg_7chunker_3buzhash_update(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
2025 static PyMethodDef __pyx_mdef_4borg_7chunker_3buzhash_update = {"buzhash_update", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4borg_7chunker_3buzhash_update, METH_VARARGS|METH_KEYWORDS, 0};
__pyx_pw_4borg_7chunker_3buzhash_update(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)2026 static PyObject *__pyx_pw_4borg_7chunker_3buzhash_update(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
2027   uint32_t __pyx_v_sum;
2028   unsigned char __pyx_v_remove;
2029   unsigned char __pyx_v_add;
2030   size_t __pyx_v_len;
2031   unsigned long __pyx_v_seed;
2032   int __pyx_lineno = 0;
2033   const char *__pyx_filename = NULL;
2034   int __pyx_clineno = 0;
2035   PyObject *__pyx_r = 0;
2036   __Pyx_RefNannyDeclarations
2037   __Pyx_RefNannySetupContext("buzhash_update (wrapper)", 0);
2038   {
2039     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sum,&__pyx_n_s_remove,&__pyx_n_s_add,&__pyx_n_s_len,&__pyx_n_s_seed,0};
2040     PyObject* values[5] = {0,0,0,0,0};
2041     if (unlikely(__pyx_kwds)) {
2042       Py_ssize_t kw_args;
2043       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
2044       switch (pos_args) {
2045         case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
2046         CYTHON_FALLTHROUGH;
2047         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
2048         CYTHON_FALLTHROUGH;
2049         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
2050         CYTHON_FALLTHROUGH;
2051         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
2052         CYTHON_FALLTHROUGH;
2053         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2054         CYTHON_FALLTHROUGH;
2055         case  0: break;
2056         default: goto __pyx_L5_argtuple_error;
2057       }
2058       kw_args = PyDict_Size(__pyx_kwds);
2059       switch (pos_args) {
2060         case  0:
2061         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sum)) != 0)) kw_args--;
2062         else goto __pyx_L5_argtuple_error;
2063         CYTHON_FALLTHROUGH;
2064         case  1:
2065         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_remove)) != 0)) kw_args--;
2066         else {
2067           __Pyx_RaiseArgtupleInvalid("buzhash_update", 1, 5, 5, 1); __PYX_ERR(1, 62, __pyx_L3_error)
2068         }
2069         CYTHON_FALLTHROUGH;
2070         case  2:
2071         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_add)) != 0)) kw_args--;
2072         else {
2073           __Pyx_RaiseArgtupleInvalid("buzhash_update", 1, 5, 5, 2); __PYX_ERR(1, 62, __pyx_L3_error)
2074         }
2075         CYTHON_FALLTHROUGH;
2076         case  3:
2077         if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_len)) != 0)) kw_args--;
2078         else {
2079           __Pyx_RaiseArgtupleInvalid("buzhash_update", 1, 5, 5, 3); __PYX_ERR(1, 62, __pyx_L3_error)
2080         }
2081         CYTHON_FALLTHROUGH;
2082         case  4:
2083         if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_seed)) != 0)) kw_args--;
2084         else {
2085           __Pyx_RaiseArgtupleInvalid("buzhash_update", 1, 5, 5, 4); __PYX_ERR(1, 62, __pyx_L3_error)
2086         }
2087       }
2088       if (unlikely(kw_args > 0)) {
2089         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "buzhash_update") < 0)) __PYX_ERR(1, 62, __pyx_L3_error)
2090       }
2091     } else if (PyTuple_GET_SIZE(__pyx_args) != 5) {
2092       goto __pyx_L5_argtuple_error;
2093     } else {
2094       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2095       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
2096       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
2097       values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
2098       values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
2099     }
2100     __pyx_v_sum = __Pyx_PyInt_As_uint32_t(values[0]); if (unlikely((__pyx_v_sum == ((uint32_t)-1)) && PyErr_Occurred())) __PYX_ERR(1, 62, __pyx_L3_error)
2101     __pyx_v_remove = __Pyx_PyInt_As_unsigned_char(values[1]); if (unlikely((__pyx_v_remove == (unsigned char)-1) && PyErr_Occurred())) __PYX_ERR(1, 62, __pyx_L3_error)
2102     __pyx_v_add = __Pyx_PyInt_As_unsigned_char(values[2]); if (unlikely((__pyx_v_add == (unsigned char)-1) && PyErr_Occurred())) __PYX_ERR(1, 62, __pyx_L3_error)
2103     __pyx_v_len = __Pyx_PyInt_As_size_t(values[3]); if (unlikely((__pyx_v_len == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 62, __pyx_L3_error)
2104     __pyx_v_seed = __Pyx_PyInt_As_unsigned_long(values[4]); if (unlikely((__pyx_v_seed == (unsigned long)-1) && PyErr_Occurred())) __PYX_ERR(1, 62, __pyx_L3_error)
2105   }
2106   goto __pyx_L4_argument_unpacking_done;
2107   __pyx_L5_argtuple_error:;
2108   __Pyx_RaiseArgtupleInvalid("buzhash_update", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 62, __pyx_L3_error)
2109   __pyx_L3_error:;
2110   __Pyx_AddTraceback("borg.chunker.buzhash_update", __pyx_clineno, __pyx_lineno, __pyx_filename);
2111   __Pyx_RefNannyFinishContext();
2112   return NULL;
2113   __pyx_L4_argument_unpacking_done:;
2114   __pyx_r = __pyx_pf_4borg_7chunker_2buzhash_update(__pyx_self, __pyx_v_sum, __pyx_v_remove, __pyx_v_add, __pyx_v_len, __pyx_v_seed);
2115 
2116   /* function exit code */
2117   __Pyx_RefNannyFinishContext();
2118   return __pyx_r;
2119 }
2120 
__pyx_pf_4borg_7chunker_2buzhash_update(CYTHON_UNUSED PyObject * __pyx_self,uint32_t __pyx_v_sum,unsigned char __pyx_v_remove,unsigned char __pyx_v_add,size_t __pyx_v_len,unsigned long __pyx_v_seed)2121 static PyObject *__pyx_pf_4borg_7chunker_2buzhash_update(CYTHON_UNUSED PyObject *__pyx_self, uint32_t __pyx_v_sum, unsigned char __pyx_v_remove, unsigned char __pyx_v_add, size_t __pyx_v_len, unsigned long __pyx_v_seed) {
2122   uint32_t *__pyx_v_table;
2123   PyObject *__pyx_r = NULL;
2124   __Pyx_RefNannyDeclarations
2125   PyObject *__pyx_t_1 = NULL;
2126   PyObject *__pyx_t_2 = NULL;
2127   uint32_t __pyx_t_3;
2128   int __pyx_lineno = 0;
2129   const char *__pyx_filename = NULL;
2130   int __pyx_clineno = 0;
2131   __Pyx_RefNannySetupContext("buzhash_update", 0);
2132 
2133   /* "borg/chunker.pyx":64
2134  * def buzhash_update(uint32_t sum, unsigned char remove, unsigned char add, size_t len, unsigned long seed):
2135  *     cdef uint32_t *table
2136  *     table = buzhash_init_table(seed & 0xffffffff)             # <<<<<<<<<<<<<<
2137  *     sum = c_buzhash_update(sum, remove, add, len, table)
2138  *     free(table)
2139  */
2140   __pyx_t_1 = __Pyx_PyInt_From_unsigned_long(__pyx_v_seed); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 64, __pyx_L1_error)
2141   __Pyx_GOTREF(__pyx_t_1);
2142   __pyx_t_2 = PyNumber_And(__pyx_t_1, __pyx_int_4294967295); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 64, __pyx_L1_error)
2143   __Pyx_GOTREF(__pyx_t_2);
2144   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2145   __pyx_t_3 = __Pyx_PyInt_As_uint32_t(__pyx_t_2); if (unlikely((__pyx_t_3 == ((uint32_t)-1)) && PyErr_Occurred())) __PYX_ERR(1, 64, __pyx_L1_error)
2146   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2147   __pyx_v_table = buzhash_init_table(__pyx_t_3);
2148 
2149   /* "borg/chunker.pyx":65
2150  *     cdef uint32_t *table
2151  *     table = buzhash_init_table(seed & 0xffffffff)
2152  *     sum = c_buzhash_update(sum, remove, add, len, table)             # <<<<<<<<<<<<<<
2153  *     free(table)
2154  *     return sum
2155  */
2156   __pyx_v_sum = buzhash_update(__pyx_v_sum, __pyx_v_remove, __pyx_v_add, __pyx_v_len, __pyx_v_table);
2157 
2158   /* "borg/chunker.pyx":66
2159  *     table = buzhash_init_table(seed & 0xffffffff)
2160  *     sum = c_buzhash_update(sum, remove, add, len, table)
2161  *     free(table)             # <<<<<<<<<<<<<<
2162  *     return sum
2163  */
2164   free(__pyx_v_table);
2165 
2166   /* "borg/chunker.pyx":67
2167  *     sum = c_buzhash_update(sum, remove, add, len, table)
2168  *     free(table)
2169  *     return sum             # <<<<<<<<<<<<<<
2170  */
2171   __Pyx_XDECREF(__pyx_r);
2172   __pyx_t_2 = __Pyx_PyInt_From_uint32_t(__pyx_v_sum); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 67, __pyx_L1_error)
2173   __Pyx_GOTREF(__pyx_t_2);
2174   __pyx_r = __pyx_t_2;
2175   __pyx_t_2 = 0;
2176   goto __pyx_L0;
2177 
2178   /* "borg/chunker.pyx":62
2179  *
2180  *
2181  * def buzhash_update(uint32_t sum, unsigned char remove, unsigned char add, size_t len, unsigned long seed):             # <<<<<<<<<<<<<<
2182  *     cdef uint32_t *table
2183  *     table = buzhash_init_table(seed & 0xffffffff)
2184  */
2185 
2186   /* function exit code */
2187   __pyx_L1_error:;
2188   __Pyx_XDECREF(__pyx_t_1);
2189   __Pyx_XDECREF(__pyx_t_2);
2190   __Pyx_AddTraceback("borg.chunker.buzhash_update", __pyx_clineno, __pyx_lineno, __pyx_filename);
2191   __pyx_r = NULL;
2192   __pyx_L0:;
2193   __Pyx_XGIVEREF(__pyx_r);
2194   __Pyx_RefNannyFinishContext();
2195   return __pyx_r;
2196 }
2197 
__pyx_tp_new_4borg_7chunker_Chunker(PyTypeObject * t,PyObject * a,PyObject * k)2198 static PyObject *__pyx_tp_new_4borg_7chunker_Chunker(PyTypeObject *t, PyObject *a, PyObject *k) {
2199   PyObject *o;
2200   if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
2201     o = (*t->tp_alloc)(t, 0);
2202   } else {
2203     o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
2204   }
2205   if (unlikely(!o)) return 0;
2206   if (unlikely(__pyx_pw_4borg_7chunker_7Chunker_1__cinit__(o, a, k) < 0)) goto bad;
2207   return o;
2208   bad:
2209   Py_DECREF(o); o = 0;
2210   return NULL;
2211 }
2212 
__pyx_tp_dealloc_4borg_7chunker_Chunker(PyObject * o)2213 static void __pyx_tp_dealloc_4borg_7chunker_Chunker(PyObject *o) {
2214   #if CYTHON_USE_TP_FINALIZE
2215   if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) {
2216     if (PyObject_CallFinalizerFromDealloc(o)) return;
2217   }
2218   #endif
2219   {
2220     PyObject *etype, *eval, *etb;
2221     PyErr_Fetch(&etype, &eval, &etb);
2222     __Pyx_SET_REFCNT(o, Py_REFCNT(o) + 1);
2223     __pyx_pw_4borg_7chunker_7Chunker_5__dealloc__(o);
2224     __Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1);
2225     PyErr_Restore(etype, eval, etb);
2226   }
2227   (*Py_TYPE(o)->tp_free)(o);
2228 }
2229 
__pyx_specialmethod___pyx_pw_4borg_7chunker_7Chunker_9__next__(PyObject * self,CYTHON_UNUSED PyObject * arg)2230 static PyObject *__pyx_specialmethod___pyx_pw_4borg_7chunker_7Chunker_9__next__(PyObject *self, CYTHON_UNUSED PyObject *arg) {return __pyx_pw_4borg_7chunker_7Chunker_9__next__(self);}
2231 
2232 static PyMethodDef __pyx_methods_4borg_7chunker_Chunker[] = {
2233   {"chunkify", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4borg_7chunker_7Chunker_3chunkify, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4borg_7chunker_7Chunker_2chunkify},
2234   {"__next__", (PyCFunction)__pyx_specialmethod___pyx_pw_4borg_7chunker_7Chunker_9__next__, METH_NOARGS|METH_COEXIST, 0},
2235   {"__reduce_cython__", (PyCFunction)__pyx_pw_4borg_7chunker_7Chunker_11__reduce_cython__, METH_NOARGS, 0},
2236   {"__setstate_cython__", (PyCFunction)__pyx_pw_4borg_7chunker_7Chunker_13__setstate_cython__, METH_O, 0},
2237   {0, 0, 0, 0}
2238 };
2239 
2240 static PyTypeObject __pyx_type_4borg_7chunker_Chunker = {
2241   PyVarObject_HEAD_INIT(0, 0)
2242   "borg.chunker.Chunker", /*tp_name*/
2243   sizeof(struct __pyx_obj_4borg_7chunker_Chunker), /*tp_basicsize*/
2244   0, /*tp_itemsize*/
2245   __pyx_tp_dealloc_4borg_7chunker_Chunker, /*tp_dealloc*/
2246   #if PY_VERSION_HEX < 0x030800b4
2247   0, /*tp_print*/
2248   #endif
2249   #if PY_VERSION_HEX >= 0x030800b4
2250   0, /*tp_vectorcall_offset*/
2251   #endif
2252   0, /*tp_getattr*/
2253   0, /*tp_setattr*/
2254   #if PY_MAJOR_VERSION < 3
2255   0, /*tp_compare*/
2256   #endif
2257   #if PY_MAJOR_VERSION >= 3
2258   0, /*tp_as_async*/
2259   #endif
2260   0, /*tp_repr*/
2261   0, /*tp_as_number*/
2262   0, /*tp_as_sequence*/
2263   0, /*tp_as_mapping*/
2264   0, /*tp_hash*/
2265   0, /*tp_call*/
2266   0, /*tp_str*/
2267   0, /*tp_getattro*/
2268   0, /*tp_setattro*/
2269   0, /*tp_as_buffer*/
2270   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
2271   0, /*tp_doc*/
2272   0, /*tp_traverse*/
2273   0, /*tp_clear*/
2274   0, /*tp_richcompare*/
2275   0, /*tp_weaklistoffset*/
2276   __pyx_pw_4borg_7chunker_7Chunker_7__iter__, /*tp_iter*/
2277   __pyx_pw_4borg_7chunker_7Chunker_9__next__, /*tp_iternext*/
2278   __pyx_methods_4borg_7chunker_Chunker, /*tp_methods*/
2279   0, /*tp_members*/
2280   0, /*tp_getset*/
2281   0, /*tp_base*/
2282   0, /*tp_dict*/
2283   0, /*tp_descr_get*/
2284   0, /*tp_descr_set*/
2285   0, /*tp_dictoffset*/
2286   0, /*tp_init*/
2287   0, /*tp_alloc*/
2288   __pyx_tp_new_4borg_7chunker_Chunker, /*tp_new*/
2289   0, /*tp_free*/
2290   0, /*tp_is_gc*/
2291   0, /*tp_bases*/
2292   0, /*tp_mro*/
2293   0, /*tp_cache*/
2294   0, /*tp_subclasses*/
2295   0, /*tp_weaklist*/
2296   0, /*tp_del*/
2297   0, /*tp_version_tag*/
2298   #if PY_VERSION_HEX >= 0x030400a1
2299   0, /*tp_finalize*/
2300   #endif
2301   #if PY_VERSION_HEX >= 0x030800b1
2302   0, /*tp_vectorcall*/
2303   #endif
2304   #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
2305   0, /*tp_print*/
2306   #endif
2307 };
2308 
2309 static PyMethodDef __pyx_methods[] = {
2310   {0, 0, 0, 0}
2311 };
2312 
2313 #if PY_MAJOR_VERSION >= 3
2314 #if CYTHON_PEP489_MULTI_PHASE_INIT
2315 static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
2316 static int __pyx_pymod_exec_chunker(PyObject* module); /*proto*/
2317 static PyModuleDef_Slot __pyx_moduledef_slots[] = {
2318   {Py_mod_create, (void*)__pyx_pymod_create},
2319   {Py_mod_exec, (void*)__pyx_pymod_exec_chunker},
2320   {0, NULL}
2321 };
2322 #endif
2323 
2324 static struct PyModuleDef __pyx_moduledef = {
2325     PyModuleDef_HEAD_INIT,
2326     "chunker",
2327     0, /* m_doc */
2328   #if CYTHON_PEP489_MULTI_PHASE_INIT
2329     0, /* m_size */
2330   #else
2331     -1, /* m_size */
2332   #endif
2333     __pyx_methods /* m_methods */,
2334   #if CYTHON_PEP489_MULTI_PHASE_INIT
2335     __pyx_moduledef_slots, /* m_slots */
2336   #else
2337     NULL, /* m_reload */
2338   #endif
2339     NULL, /* m_traverse */
2340     NULL, /* m_clear */
2341     NULL /* m_free */
2342 };
2343 #endif
2344 #ifndef CYTHON_SMALL_CODE
2345 #if defined(__clang__)
2346     #define CYTHON_SMALL_CODE
2347 #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
2348     #define CYTHON_SMALL_CODE __attribute__((cold))
2349 #else
2350     #define CYTHON_SMALL_CODE
2351 #endif
2352 #endif
2353 
2354 static __Pyx_StringTabEntry __pyx_string_tab[] = {
2355   {&__pyx_kp_u_1_1_01, __pyx_k_1_1_01, sizeof(__pyx_k_1_1_01), 0, 1, 0, 0},
2356   {&__pyx_n_s_API_VERSION, __pyx_k_API_VERSION, sizeof(__pyx_k_API_VERSION), 0, 0, 1, 1},
2357   {&__pyx_n_s_Chunker, __pyx_k_Chunker, sizeof(__pyx_k_Chunker), 0, 0, 1, 1},
2358   {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1},
2359   {&__pyx_n_s_add, __pyx_k_add, sizeof(__pyx_k_add), 0, 0, 1, 1},
2360   {&__pyx_n_s_borg_chunker, __pyx_k_borg_chunker, sizeof(__pyx_k_borg_chunker), 0, 0, 1, 1},
2361   {&__pyx_n_s_buzhash, __pyx_k_buzhash, sizeof(__pyx_k_buzhash), 0, 0, 1, 1},
2362   {&__pyx_n_s_buzhash_update, __pyx_k_buzhash_update, sizeof(__pyx_k_buzhash_update), 0, 0, 1, 1},
2363   {&__pyx_n_s_chunk_max_exp, __pyx_k_chunk_max_exp, sizeof(__pyx_k_chunk_max_exp), 0, 0, 1, 1},
2364   {&__pyx_n_s_chunk_min_exp, __pyx_k_chunk_min_exp, sizeof(__pyx_k_chunk_min_exp), 0, 0, 1, 1},
2365   {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
2366   {&__pyx_n_s_data, __pyx_k_data, sizeof(__pyx_k_data), 0, 0, 1, 1},
2367   {&__pyx_n_s_fd, __pyx_k_fd, sizeof(__pyx_k_fd), 0, 0, 1, 1},
2368   {&__pyx_n_s_fh, __pyx_k_fh, sizeof(__pyx_k_fh), 0, 0, 1, 1},
2369   {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1},
2370   {&__pyx_n_s_hash_mask_bits, __pyx_k_hash_mask_bits, sizeof(__pyx_k_hash_mask_bits), 0, 0, 1, 1},
2371   {&__pyx_n_s_hash_window_size, __pyx_k_hash_window_size, sizeof(__pyx_k_hash_window_size), 0, 0, 1, 1},
2372   {&__pyx_n_s_len, __pyx_k_len, sizeof(__pyx_k_len), 0, 0, 1, 1},
2373   {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
2374   {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
2375   {&__pyx_kp_s_no_default___reduce___due_to_non, __pyx_k_no_default___reduce___due_to_non, sizeof(__pyx_k_no_default___reduce___due_to_non), 0, 0, 1, 0},
2376   {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1},
2377   {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1},
2378   {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1},
2379   {&__pyx_n_s_remove, __pyx_k_remove, sizeof(__pyx_k_remove), 0, 0, 1, 1},
2380   {&__pyx_n_s_seed, __pyx_k_seed, sizeof(__pyx_k_seed), 0, 0, 1, 1},
2381   {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1},
2382   {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1},
2383   {&__pyx_kp_s_src_borg_chunker_pyx, __pyx_k_src_borg_chunker_pyx, sizeof(__pyx_k_src_borg_chunker_pyx), 0, 0, 1, 0},
2384   {&__pyx_n_s_sum, __pyx_k_sum, sizeof(__pyx_k_sum), 0, 0, 1, 1},
2385   {&__pyx_n_s_table, __pyx_k_table, sizeof(__pyx_k_table), 0, 0, 1, 1},
2386   {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
2387   {&__pyx_kp_u_too_small_max_size, __pyx_k_too_small_max_size, sizeof(__pyx_k_too_small_max_size), 0, 1, 0, 0},
2388   {0, 0, 0, 0, 0, 0, 0}
2389 };
__Pyx_InitCachedBuiltins(void)2390 static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
2391   __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(0, 2, __pyx_L1_error)
2392   return 0;
2393   __pyx_L1_error:;
2394   return -1;
2395 }
2396 
__Pyx_InitCachedConstants(void)2397 static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
2398   __Pyx_RefNannyDeclarations
2399   __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
2400 
2401   /* "(tree fragment)":2
2402  * def __reduce_cython__(self):
2403  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
2404  * def __setstate_cython__(self, __pyx_state):
2405  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
2406  */
2407   __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 2, __pyx_L1_error)
2408   __Pyx_GOTREF(__pyx_tuple_);
2409   __Pyx_GIVEREF(__pyx_tuple_);
2410 
2411   /* "(tree fragment)":4
2412  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
2413  * def __setstate_cython__(self, __pyx_state):
2414  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
2415  */
2416   __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 4, __pyx_L1_error)
2417   __Pyx_GOTREF(__pyx_tuple__2);
2418   __Pyx_GIVEREF(__pyx_tuple__2);
2419 
2420   /* "borg/chunker.pyx":53
2421  *
2422  *
2423  * def buzhash(data, unsigned long seed):             # <<<<<<<<<<<<<<
2424  *     cdef uint32_t *table
2425  *     cdef uint32_t sum
2426  */
2427   __pyx_tuple__3 = PyTuple_Pack(4, __pyx_n_s_data, __pyx_n_s_seed, __pyx_n_s_table, __pyx_n_s_sum); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(1, 53, __pyx_L1_error)
2428   __Pyx_GOTREF(__pyx_tuple__3);
2429   __Pyx_GIVEREF(__pyx_tuple__3);
2430   __pyx_codeobj__4 = (PyObject*)__Pyx_PyCode_New(2, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__3, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_borg_chunker_pyx, __pyx_n_s_buzhash, 53, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__4)) __PYX_ERR(1, 53, __pyx_L1_error)
2431 
2432   /* "borg/chunker.pyx":62
2433  *
2434  *
2435  * def buzhash_update(uint32_t sum, unsigned char remove, unsigned char add, size_t len, unsigned long seed):             # <<<<<<<<<<<<<<
2436  *     cdef uint32_t *table
2437  *     table = buzhash_init_table(seed & 0xffffffff)
2438  */
2439   __pyx_tuple__5 = PyTuple_Pack(6, __pyx_n_s_sum, __pyx_n_s_remove, __pyx_n_s_add, __pyx_n_s_len, __pyx_n_s_seed, __pyx_n_s_table); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(1, 62, __pyx_L1_error)
2440   __Pyx_GOTREF(__pyx_tuple__5);
2441   __Pyx_GIVEREF(__pyx_tuple__5);
2442   __pyx_codeobj__6 = (PyObject*)__Pyx_PyCode_New(5, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__5, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_borg_chunker_pyx, __pyx_n_s_buzhash_update, 62, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__6)) __PYX_ERR(1, 62, __pyx_L1_error)
2443   __Pyx_RefNannyFinishContext();
2444   return 0;
2445   __pyx_L1_error:;
2446   __Pyx_RefNannyFinishContext();
2447   return -1;
2448 }
2449 
__Pyx_InitGlobals(void)2450 static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
2451   if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(1, 1, __pyx_L1_error);
2452   __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(1, 1, __pyx_L1_error)
2453   __pyx_int_4294967295 = PyInt_FromString((char *)"4294967295", 0, 0); if (unlikely(!__pyx_int_4294967295)) __PYX_ERR(1, 1, __pyx_L1_error)
2454   __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) __PYX_ERR(1, 1, __pyx_L1_error)
2455   return 0;
2456   __pyx_L1_error:;
2457   return -1;
2458 }
2459 
2460 static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/
2461 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/
2462 static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/
2463 static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/
2464 static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/
2465 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/
2466 static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/
2467 
__Pyx_modinit_global_init_code(void)2468 static int __Pyx_modinit_global_init_code(void) {
2469   __Pyx_RefNannyDeclarations
2470   __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
2471   /*--- Global init code ---*/
2472   __Pyx_RefNannyFinishContext();
2473   return 0;
2474 }
2475 
__Pyx_modinit_variable_export_code(void)2476 static int __Pyx_modinit_variable_export_code(void) {
2477   __Pyx_RefNannyDeclarations
2478   __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
2479   /*--- Variable export code ---*/
2480   __Pyx_RefNannyFinishContext();
2481   return 0;
2482 }
2483 
__Pyx_modinit_function_export_code(void)2484 static int __Pyx_modinit_function_export_code(void) {
2485   __Pyx_RefNannyDeclarations
2486   __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
2487   /*--- Function export code ---*/
2488   __Pyx_RefNannyFinishContext();
2489   return 0;
2490 }
2491 
__Pyx_modinit_type_init_code(void)2492 static int __Pyx_modinit_type_init_code(void) {
2493   __Pyx_RefNannyDeclarations
2494   int __pyx_lineno = 0;
2495   const char *__pyx_filename = NULL;
2496   int __pyx_clineno = 0;
2497   __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
2498   /*--- Type init code ---*/
2499   if (PyType_Ready(&__pyx_type_4borg_7chunker_Chunker) < 0) __PYX_ERR(1, 20, __pyx_L1_error)
2500   #if PY_VERSION_HEX < 0x030800B1
2501   __pyx_type_4borg_7chunker_Chunker.tp_print = 0;
2502   #endif
2503   if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4borg_7chunker_Chunker.tp_dictoffset && __pyx_type_4borg_7chunker_Chunker.tp_getattro == PyObject_GenericGetAttr)) {
2504     __pyx_type_4borg_7chunker_Chunker.tp_getattro = __Pyx_PyObject_GenericGetAttr;
2505   }
2506   if (PyObject_SetAttr(__pyx_m, __pyx_n_s_Chunker, (PyObject *)&__pyx_type_4borg_7chunker_Chunker) < 0) __PYX_ERR(1, 20, __pyx_L1_error)
2507   if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4borg_7chunker_Chunker) < 0) __PYX_ERR(1, 20, __pyx_L1_error)
2508   __pyx_ptype_4borg_7chunker_Chunker = &__pyx_type_4borg_7chunker_Chunker;
2509   __Pyx_RefNannyFinishContext();
2510   return 0;
2511   __pyx_L1_error:;
2512   __Pyx_RefNannyFinishContext();
2513   return -1;
2514 }
2515 
__Pyx_modinit_type_import_code(void)2516 static int __Pyx_modinit_type_import_code(void) {
2517   __Pyx_RefNannyDeclarations
2518   __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
2519   /*--- Type import code ---*/
2520   __Pyx_RefNannyFinishContext();
2521   return 0;
2522 }
2523 
__Pyx_modinit_variable_import_code(void)2524 static int __Pyx_modinit_variable_import_code(void) {
2525   __Pyx_RefNannyDeclarations
2526   __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
2527   /*--- Variable import code ---*/
2528   __Pyx_RefNannyFinishContext();
2529   return 0;
2530 }
2531 
__Pyx_modinit_function_import_code(void)2532 static int __Pyx_modinit_function_import_code(void) {
2533   __Pyx_RefNannyDeclarations
2534   __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
2535   /*--- Function import code ---*/
2536   __Pyx_RefNannyFinishContext();
2537   return 0;
2538 }
2539 
2540 
2541 #ifndef CYTHON_NO_PYINIT_EXPORT
2542 #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
2543 #elif PY_MAJOR_VERSION < 3
2544 #ifdef __cplusplus
2545 #define __Pyx_PyMODINIT_FUNC extern "C" void
2546 #else
2547 #define __Pyx_PyMODINIT_FUNC void
2548 #endif
2549 #else
2550 #ifdef __cplusplus
2551 #define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
2552 #else
2553 #define __Pyx_PyMODINIT_FUNC PyObject *
2554 #endif
2555 #endif
2556 
2557 
2558 #if PY_MAJOR_VERSION < 3
2559 __Pyx_PyMODINIT_FUNC initchunker(void) CYTHON_SMALL_CODE; /*proto*/
initchunker(void)2560 __Pyx_PyMODINIT_FUNC initchunker(void)
2561 #else
2562 __Pyx_PyMODINIT_FUNC PyInit_chunker(void) CYTHON_SMALL_CODE; /*proto*/
2563 __Pyx_PyMODINIT_FUNC PyInit_chunker(void)
2564 #if CYTHON_PEP489_MULTI_PHASE_INIT
2565 {
2566   return PyModuleDef_Init(&__pyx_moduledef);
2567 }
2568 static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
2569     #if PY_VERSION_HEX >= 0x030700A1
2570     static PY_INT64_T main_interpreter_id = -1;
2571     PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
2572     if (main_interpreter_id == -1) {
2573         main_interpreter_id = current_id;
2574         return (unlikely(current_id == -1)) ? -1 : 0;
2575     } else if (unlikely(main_interpreter_id != current_id))
2576     #else
2577     static PyInterpreterState *main_interpreter = NULL;
2578     PyInterpreterState *current_interpreter = PyThreadState_Get()->interp;
2579     if (!main_interpreter) {
2580         main_interpreter = current_interpreter;
2581     } else if (unlikely(main_interpreter != current_interpreter))
2582     #endif
2583     {
2584         PyErr_SetString(
2585             PyExc_ImportError,
2586             "Interpreter change detected - this module can only be loaded into one interpreter per process.");
2587         return -1;
2588     }
2589     return 0;
2590 }
2591 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) {
2592     PyObject *value = PyObject_GetAttrString(spec, from_name);
2593     int result = 0;
2594     if (likely(value)) {
2595         if (allow_none || value != Py_None) {
2596             result = PyDict_SetItemString(moddict, to_name, value);
2597         }
2598         Py_DECREF(value);
2599     } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
2600         PyErr_Clear();
2601     } else {
2602         result = -1;
2603     }
2604     return result;
2605 }
2606 static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
2607     PyObject *module = NULL, *moddict, *modname;
2608     if (__Pyx_check_single_interpreter())
2609         return NULL;
2610     if (__pyx_m)
2611         return __Pyx_NewRef(__pyx_m);
2612     modname = PyObject_GetAttrString(spec, "name");
2613     if (unlikely(!modname)) goto bad;
2614     module = PyModule_NewObject(modname);
2615     Py_DECREF(modname);
2616     if (unlikely(!module)) goto bad;
2617     moddict = PyModule_GetDict(module);
2618     if (unlikely(!moddict)) goto bad;
2619     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
2620     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
2621     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
2622     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
2623     return module;
2624 bad:
2625     Py_XDECREF(module);
2626     return NULL;
2627 }
2628 
2629 
2630 static CYTHON_SMALL_CODE int __pyx_pymod_exec_chunker(PyObject *__pyx_pyinit_module)
2631 #endif
2632 #endif
2633 {
2634   PyObject *__pyx_t_1 = NULL;
2635   int __pyx_lineno = 0;
2636   const char *__pyx_filename = NULL;
2637   int __pyx_clineno = 0;
2638   __Pyx_RefNannyDeclarations
2639   #if CYTHON_PEP489_MULTI_PHASE_INIT
2640   if (__pyx_m) {
2641     if (__pyx_m == __pyx_pyinit_module) return 0;
2642     PyErr_SetString(PyExc_RuntimeError, "Module 'chunker' has already been imported. Re-initialisation is not supported.");
2643     return -1;
2644   }
2645   #elif PY_MAJOR_VERSION >= 3
2646   if (__pyx_m) return __Pyx_NewRef(__pyx_m);
2647   #endif
2648   #if CYTHON_REFNANNY
2649 __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
2650 if (!__Pyx_RefNanny) {
2651   PyErr_Clear();
2652   __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
2653   if (!__Pyx_RefNanny)
2654       Py_FatalError("failed to import 'refnanny' module");
2655 }
2656 #endif
2657   __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_chunker(void)", 0);
2658   if (__Pyx_check_binary_version() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
2659   #ifdef __Pxy_PyFrame_Initialize_Offsets
2660   __Pxy_PyFrame_Initialize_Offsets();
2661   #endif
2662   __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(1, 1, __pyx_L1_error)
2663   __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(1, 1, __pyx_L1_error)
2664   __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(1, 1, __pyx_L1_error)
2665   #ifdef __Pyx_CyFunction_USED
2666   if (__pyx_CyFunction_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
2667   #endif
2668   #ifdef __Pyx_FusedFunction_USED
2669   if (__pyx_FusedFunction_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
2670   #endif
2671   #ifdef __Pyx_Coroutine_USED
2672   if (__pyx_Coroutine_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
2673   #endif
2674   #ifdef __Pyx_Generator_USED
2675   if (__pyx_Generator_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
2676   #endif
2677   #ifdef __Pyx_AsyncGen_USED
2678   if (__pyx_AsyncGen_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
2679   #endif
2680   #ifdef __Pyx_StopAsyncIteration_USED
2681   if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
2682   #endif
2683   /*--- Library function declarations ---*/
2684   /*--- Threads initialization code ---*/
2685   #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
2686   #ifdef WITH_THREAD /* Python build with threading support? */
2687   PyEval_InitThreads();
2688   #endif
2689   #endif
2690   /*--- Module creation code ---*/
2691   #if CYTHON_PEP489_MULTI_PHASE_INIT
2692   __pyx_m = __pyx_pyinit_module;
2693   Py_INCREF(__pyx_m);
2694   #else
2695   #if PY_MAJOR_VERSION < 3
2696   __pyx_m = Py_InitModule4("chunker", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
2697   #else
2698   __pyx_m = PyModule_Create(&__pyx_moduledef);
2699   #endif
2700   if (unlikely(!__pyx_m)) __PYX_ERR(1, 1, __pyx_L1_error)
2701   #endif
2702   __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(1, 1, __pyx_L1_error)
2703   Py_INCREF(__pyx_d);
2704   __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(1, 1, __pyx_L1_error)
2705   Py_INCREF(__pyx_b);
2706   __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(1, 1, __pyx_L1_error)
2707   Py_INCREF(__pyx_cython_runtime);
2708   if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(1, 1, __pyx_L1_error);
2709   /*--- Initialize various global constants etc. ---*/
2710   if (__Pyx_InitGlobals() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
2711   #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
2712   if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
2713   #endif
2714   if (__pyx_module_is_main_borg__chunker) {
2715     if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
2716   }
2717   #if PY_MAJOR_VERSION >= 3
2718   {
2719     PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(1, 1, __pyx_L1_error)
2720     if (!PyDict_GetItemString(modules, "borg.chunker")) {
2721       if (unlikely(PyDict_SetItemString(modules, "borg.chunker", __pyx_m) < 0)) __PYX_ERR(1, 1, __pyx_L1_error)
2722     }
2723   }
2724   #endif
2725   /*--- Builtin init code ---*/
2726   if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
2727   /*--- Constants init code ---*/
2728   if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
2729   /*--- Global type/function init code ---*/
2730   (void)__Pyx_modinit_global_init_code();
2731   (void)__Pyx_modinit_variable_export_code();
2732   (void)__Pyx_modinit_function_export_code();
2733   if (unlikely(__Pyx_modinit_type_init_code() < 0)) __PYX_ERR(1, 1, __pyx_L1_error)
2734   (void)__Pyx_modinit_type_import_code();
2735   (void)__Pyx_modinit_variable_import_code();
2736   (void)__Pyx_modinit_function_import_code();
2737   /*--- Execution code ---*/
2738   #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
2739   if (__Pyx_patch_abc() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
2740   #endif
2741 
2742   /* "borg/chunker.pyx":3
2743  * # cython: language_level=3
2744  *
2745  * API_VERSION = '1.1_01'             # <<<<<<<<<<<<<<
2746  *
2747  * from libc.stdlib cimport free
2748  */
2749   if (PyDict_SetItem(__pyx_d, __pyx_n_s_API_VERSION, __pyx_kp_u_1_1_01) < 0) __PYX_ERR(1, 3, __pyx_L1_error)
2750 
2751   /* "borg/chunker.pyx":53
2752  *
2753  *
2754  * def buzhash(data, unsigned long seed):             # <<<<<<<<<<<<<<
2755  *     cdef uint32_t *table
2756  *     cdef uint32_t sum
2757  */
2758   __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4borg_7chunker_1buzhash, NULL, __pyx_n_s_borg_chunker); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 53, __pyx_L1_error)
2759   __Pyx_GOTREF(__pyx_t_1);
2760   if (PyDict_SetItem(__pyx_d, __pyx_n_s_buzhash, __pyx_t_1) < 0) __PYX_ERR(1, 53, __pyx_L1_error)
2761   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2762 
2763   /* "borg/chunker.pyx":62
2764  *
2765  *
2766  * def buzhash_update(uint32_t sum, unsigned char remove, unsigned char add, size_t len, unsigned long seed):             # <<<<<<<<<<<<<<
2767  *     cdef uint32_t *table
2768  *     table = buzhash_init_table(seed & 0xffffffff)
2769  */
2770   __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4borg_7chunker_3buzhash_update, NULL, __pyx_n_s_borg_chunker); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 62, __pyx_L1_error)
2771   __Pyx_GOTREF(__pyx_t_1);
2772   if (PyDict_SetItem(__pyx_d, __pyx_n_s_buzhash_update, __pyx_t_1) < 0) __PYX_ERR(1, 62, __pyx_L1_error)
2773   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2774 
2775   /* "borg/chunker.pyx":1
2776  * # cython: language_level=3             # <<<<<<<<<<<<<<
2777  *
2778  * API_VERSION = '1.1_01'
2779  */
2780   __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1, __pyx_L1_error)
2781   __Pyx_GOTREF(__pyx_t_1);
2782   if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
2783   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2784 
2785   /*--- Wrapped vars code ---*/
2786 
2787   goto __pyx_L0;
2788   __pyx_L1_error:;
2789   __Pyx_XDECREF(__pyx_t_1);
2790   if (__pyx_m) {
2791     if (__pyx_d) {
2792       __Pyx_AddTraceback("init borg.chunker", __pyx_clineno, __pyx_lineno, __pyx_filename);
2793     }
2794     Py_CLEAR(__pyx_m);
2795   } else if (!PyErr_Occurred()) {
2796     PyErr_SetString(PyExc_ImportError, "init borg.chunker");
2797   }
2798   __pyx_L0:;
2799   __Pyx_RefNannyFinishContext();
2800   #if CYTHON_PEP489_MULTI_PHASE_INIT
2801   return (__pyx_m != NULL) ? 0 : -1;
2802   #elif PY_MAJOR_VERSION >= 3
2803   return __pyx_m;
2804   #else
2805   return;
2806   #endif
2807 }
2808 
2809 /* --- Runtime support code --- */
2810 /* Refnanny */
2811 #if CYTHON_REFNANNY
__Pyx_RefNannyImportAPI(const char * modname)2812 static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
2813     PyObject *m = NULL, *p = NULL;
2814     void *r = NULL;
2815     m = PyImport_ImportModule(modname);
2816     if (!m) goto end;
2817     p = PyObject_GetAttrString(m, "RefNannyAPI");
2818     if (!p) goto end;
2819     r = PyLong_AsVoidPtr(p);
2820 end:
2821     Py_XDECREF(p);
2822     Py_XDECREF(m);
2823     return (__Pyx_RefNannyAPIStruct *)r;
2824 }
2825 #endif
2826 
2827 /* PyObjectGetAttrStr */
2828 #if CYTHON_USE_TYPE_SLOTS
__Pyx_PyObject_GetAttrStr(PyObject * obj,PyObject * attr_name)2829 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
2830     PyTypeObject* tp = Py_TYPE(obj);
2831     if (likely(tp->tp_getattro))
2832         return tp->tp_getattro(obj, attr_name);
2833 #if PY_MAJOR_VERSION < 3
2834     if (likely(tp->tp_getattr))
2835         return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
2836 #endif
2837     return PyObject_GetAttr(obj, attr_name);
2838 }
2839 #endif
2840 
2841 /* GetBuiltinName */
__Pyx_GetBuiltinName(PyObject * name)2842 static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
2843     PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
2844     if (unlikely(!result)) {
2845         PyErr_Format(PyExc_NameError,
2846 #if PY_MAJOR_VERSION >= 3
2847             "name '%U' is not defined", name);
2848 #else
2849             "name '%.200s' is not defined", PyString_AS_STRING(name));
2850 #endif
2851     }
2852     return result;
2853 }
2854 
2855 /* RaiseArgTupleInvalid */
__Pyx_RaiseArgtupleInvalid(const char * func_name,int exact,Py_ssize_t num_min,Py_ssize_t num_max,Py_ssize_t num_found)2856 static void __Pyx_RaiseArgtupleInvalid(
2857     const char* func_name,
2858     int exact,
2859     Py_ssize_t num_min,
2860     Py_ssize_t num_max,
2861     Py_ssize_t num_found)
2862 {
2863     Py_ssize_t num_expected;
2864     const char *more_or_less;
2865     if (num_found < num_min) {
2866         num_expected = num_min;
2867         more_or_less = "at least";
2868     } else {
2869         num_expected = num_max;
2870         more_or_less = "at most";
2871     }
2872     if (exact) {
2873         more_or_less = "exactly";
2874     }
2875     PyErr_Format(PyExc_TypeError,
2876                  "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
2877                  func_name, more_or_less, num_expected,
2878                  (num_expected == 1) ? "" : "s", num_found);
2879 }
2880 
2881 /* RaiseDoubleKeywords */
__Pyx_RaiseDoubleKeywordsError(const char * func_name,PyObject * kw_name)2882 static void __Pyx_RaiseDoubleKeywordsError(
2883     const char* func_name,
2884     PyObject* kw_name)
2885 {
2886     PyErr_Format(PyExc_TypeError,
2887         #if PY_MAJOR_VERSION >= 3
2888         "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
2889         #else
2890         "%s() got multiple values for keyword argument '%s'", func_name,
2891         PyString_AsString(kw_name));
2892         #endif
2893 }
2894 
2895 /* ParseKeywords */
__Pyx_ParseOptionalKeywords(PyObject * kwds,PyObject ** argnames[],PyObject * kwds2,PyObject * values[],Py_ssize_t num_pos_args,const char * function_name)2896 static int __Pyx_ParseOptionalKeywords(
2897     PyObject *kwds,
2898     PyObject **argnames[],
2899     PyObject *kwds2,
2900     PyObject *values[],
2901     Py_ssize_t num_pos_args,
2902     const char* function_name)
2903 {
2904     PyObject *key = 0, *value = 0;
2905     Py_ssize_t pos = 0;
2906     PyObject*** name;
2907     PyObject*** first_kw_arg = argnames + num_pos_args;
2908     while (PyDict_Next(kwds, &pos, &key, &value)) {
2909         name = first_kw_arg;
2910         while (*name && (**name != key)) name++;
2911         if (*name) {
2912             values[name-argnames] = value;
2913             continue;
2914         }
2915         name = first_kw_arg;
2916         #if PY_MAJOR_VERSION < 3
2917         if (likely(PyString_Check(key))) {
2918             while (*name) {
2919                 if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
2920                         && _PyString_Eq(**name, key)) {
2921                     values[name-argnames] = value;
2922                     break;
2923                 }
2924                 name++;
2925             }
2926             if (*name) continue;
2927             else {
2928                 PyObject*** argname = argnames;
2929                 while (argname != first_kw_arg) {
2930                     if ((**argname == key) || (
2931                             (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
2932                              && _PyString_Eq(**argname, key))) {
2933                         goto arg_passed_twice;
2934                     }
2935                     argname++;
2936                 }
2937             }
2938         } else
2939         #endif
2940         if (likely(PyUnicode_Check(key))) {
2941             while (*name) {
2942                 int cmp = (**name == key) ? 0 :
2943                 #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
2944                     (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
2945                 #endif
2946                     PyUnicode_Compare(**name, key);
2947                 if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
2948                 if (cmp == 0) {
2949                     values[name-argnames] = value;
2950                     break;
2951                 }
2952                 name++;
2953             }
2954             if (*name) continue;
2955             else {
2956                 PyObject*** argname = argnames;
2957                 while (argname != first_kw_arg) {
2958                     int cmp = (**argname == key) ? 0 :
2959                     #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
2960                         (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
2961                     #endif
2962                         PyUnicode_Compare(**argname, key);
2963                     if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
2964                     if (cmp == 0) goto arg_passed_twice;
2965                     argname++;
2966                 }
2967             }
2968         } else
2969             goto invalid_keyword_type;
2970         if (kwds2) {
2971             if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
2972         } else {
2973             goto invalid_keyword;
2974         }
2975     }
2976     return 0;
2977 arg_passed_twice:
2978     __Pyx_RaiseDoubleKeywordsError(function_name, key);
2979     goto bad;
2980 invalid_keyword_type:
2981     PyErr_Format(PyExc_TypeError,
2982         "%.200s() keywords must be strings", function_name);
2983     goto bad;
2984 invalid_keyword:
2985     PyErr_Format(PyExc_TypeError,
2986     #if PY_MAJOR_VERSION < 3
2987         "%.200s() got an unexpected keyword argument '%.200s'",
2988         function_name, PyString_AsString(key));
2989     #else
2990         "%s() got an unexpected keyword argument '%U'",
2991         function_name, key);
2992     #endif
2993 bad:
2994     return -1;
2995 }
2996 
2997 /* PyIntBinop */
2998 #if !CYTHON_COMPILING_IN_PYPY
__Pyx_PyInt_AddObjC(PyObject * op1,PyObject * op2,CYTHON_UNUSED long intval,int inplace,int zerodivision_check)2999 static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) {
3000     (void)inplace;
3001     (void)zerodivision_check;
3002     #if PY_MAJOR_VERSION < 3
3003     if (likely(PyInt_CheckExact(op1))) {
3004         const long b = intval;
3005         long x;
3006         long a = PyInt_AS_LONG(op1);
3007             x = (long)((unsigned long)a + b);
3008             if (likely((x^a) >= 0 || (x^b) >= 0))
3009                 return PyInt_FromLong(x);
3010             return PyLong_Type.tp_as_number->nb_add(op1, op2);
3011     }
3012     #endif
3013     #if CYTHON_USE_PYLONG_INTERNALS
3014     if (likely(PyLong_CheckExact(op1))) {
3015         const long b = intval;
3016         long a, x;
3017 #ifdef HAVE_LONG_LONG
3018         const PY_LONG_LONG llb = intval;
3019         PY_LONG_LONG lla, llx;
3020 #endif
3021         const digit* digits = ((PyLongObject*)op1)->ob_digit;
3022         const Py_ssize_t size = Py_SIZE(op1);
3023         if (likely(__Pyx_sst_abs(size) <= 1)) {
3024             a = likely(size) ? digits[0] : 0;
3025             if (size == -1) a = -a;
3026         } else {
3027             switch (size) {
3028                 case -2:
3029                     if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
3030                         a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
3031                         break;
3032 #ifdef HAVE_LONG_LONG
3033                     } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
3034                         lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
3035                         goto long_long;
3036 #endif
3037                     }
3038                     CYTHON_FALLTHROUGH;
3039                 case 2:
3040                     if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
3041                         a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
3042                         break;
3043 #ifdef HAVE_LONG_LONG
3044                     } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
3045                         lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
3046                         goto long_long;
3047 #endif
3048                     }
3049                     CYTHON_FALLTHROUGH;
3050                 case -3:
3051                     if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
3052                         a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
3053                         break;
3054 #ifdef HAVE_LONG_LONG
3055                     } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
3056                         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]));
3057                         goto long_long;
3058 #endif
3059                     }
3060                     CYTHON_FALLTHROUGH;
3061                 case 3:
3062                     if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
3063                         a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
3064                         break;
3065 #ifdef HAVE_LONG_LONG
3066                     } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
3067                         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]));
3068                         goto long_long;
3069 #endif
3070                     }
3071                     CYTHON_FALLTHROUGH;
3072                 case -4:
3073                     if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
3074                         a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
3075                         break;
3076 #ifdef HAVE_LONG_LONG
3077                     } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
3078                         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]));
3079                         goto long_long;
3080 #endif
3081                     }
3082                     CYTHON_FALLTHROUGH;
3083                 case 4:
3084                     if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
3085                         a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
3086                         break;
3087 #ifdef HAVE_LONG_LONG
3088                     } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
3089                         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]));
3090                         goto long_long;
3091 #endif
3092                     }
3093                     CYTHON_FALLTHROUGH;
3094                 default: return PyLong_Type.tp_as_number->nb_add(op1, op2);
3095             }
3096         }
3097                 x = a + b;
3098             return PyLong_FromLong(x);
3099 #ifdef HAVE_LONG_LONG
3100         long_long:
3101                 llx = lla + llb;
3102             return PyLong_FromLongLong(llx);
3103 #endif
3104 
3105 
3106     }
3107     #endif
3108     if (PyFloat_CheckExact(op1)) {
3109         const long b = intval;
3110         double a = PyFloat_AS_DOUBLE(op1);
3111             double result;
3112             PyFPE_START_PROTECT("add", return NULL)
3113             result = ((double)a) + (double)b;
3114             PyFPE_END_PROTECT(result)
3115             return PyFloat_FromDouble(result);
3116     }
3117     return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2);
3118 }
3119 #endif
3120 
3121 /* PyObjectCall */
3122 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_Call(PyObject * func,PyObject * arg,PyObject * kw)3123 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
3124     PyObject *result;
3125     ternaryfunc call = func->ob_type->tp_call;
3126     if (unlikely(!call))
3127         return PyObject_Call(func, arg, kw);
3128     if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
3129         return NULL;
3130     result = (*call)(func, arg, kw);
3131     Py_LeaveRecursiveCall();
3132     if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
3133         PyErr_SetString(
3134             PyExc_SystemError,
3135             "NULL result without error in PyObject_Call");
3136     }
3137     return result;
3138 }
3139 #endif
3140 
3141 /* PyErrFetchRestore */
3142 #if CYTHON_FAST_THREAD_STATE
__Pyx_ErrRestoreInState(PyThreadState * tstate,PyObject * type,PyObject * value,PyObject * tb)3143 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
3144     PyObject *tmp_type, *tmp_value, *tmp_tb;
3145     tmp_type = tstate->curexc_type;
3146     tmp_value = tstate->curexc_value;
3147     tmp_tb = tstate->curexc_traceback;
3148     tstate->curexc_type = type;
3149     tstate->curexc_value = value;
3150     tstate->curexc_traceback = tb;
3151     Py_XDECREF(tmp_type);
3152     Py_XDECREF(tmp_value);
3153     Py_XDECREF(tmp_tb);
3154 }
__Pyx_ErrFetchInState(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)3155 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
3156     *type = tstate->curexc_type;
3157     *value = tstate->curexc_value;
3158     *tb = tstate->curexc_traceback;
3159     tstate->curexc_type = 0;
3160     tstate->curexc_value = 0;
3161     tstate->curexc_traceback = 0;
3162 }
3163 #endif
3164 
3165 /* RaiseException */
3166 #if PY_MAJOR_VERSION < 3
__Pyx_Raise(PyObject * type,PyObject * value,PyObject * tb,CYTHON_UNUSED PyObject * cause)3167 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
3168                         CYTHON_UNUSED PyObject *cause) {
3169     __Pyx_PyThreadState_declare
3170     Py_XINCREF(type);
3171     if (!value || value == Py_None)
3172         value = NULL;
3173     else
3174         Py_INCREF(value);
3175     if (!tb || tb == Py_None)
3176         tb = NULL;
3177     else {
3178         Py_INCREF(tb);
3179         if (!PyTraceBack_Check(tb)) {
3180             PyErr_SetString(PyExc_TypeError,
3181                 "raise: arg 3 must be a traceback or None");
3182             goto raise_error;
3183         }
3184     }
3185     if (PyType_Check(type)) {
3186 #if CYTHON_COMPILING_IN_PYPY
3187         if (!value) {
3188             Py_INCREF(Py_None);
3189             value = Py_None;
3190         }
3191 #endif
3192         PyErr_NormalizeException(&type, &value, &tb);
3193     } else {
3194         if (value) {
3195             PyErr_SetString(PyExc_TypeError,
3196                 "instance exception may not have a separate value");
3197             goto raise_error;
3198         }
3199         value = type;
3200         type = (PyObject*) Py_TYPE(type);
3201         Py_INCREF(type);
3202         if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
3203             PyErr_SetString(PyExc_TypeError,
3204                 "raise: exception class must be a subclass of BaseException");
3205             goto raise_error;
3206         }
3207     }
3208     __Pyx_PyThreadState_assign
3209     __Pyx_ErrRestore(type, value, tb);
3210     return;
3211 raise_error:
3212     Py_XDECREF(value);
3213     Py_XDECREF(type);
3214     Py_XDECREF(tb);
3215     return;
3216 }
3217 #else
__Pyx_Raise(PyObject * type,PyObject * value,PyObject * tb,PyObject * cause)3218 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
3219     PyObject* owned_instance = NULL;
3220     if (tb == Py_None) {
3221         tb = 0;
3222     } else if (tb && !PyTraceBack_Check(tb)) {
3223         PyErr_SetString(PyExc_TypeError,
3224             "raise: arg 3 must be a traceback or None");
3225         goto bad;
3226     }
3227     if (value == Py_None)
3228         value = 0;
3229     if (PyExceptionInstance_Check(type)) {
3230         if (value) {
3231             PyErr_SetString(PyExc_TypeError,
3232                 "instance exception may not have a separate value");
3233             goto bad;
3234         }
3235         value = type;
3236         type = (PyObject*) Py_TYPE(value);
3237     } else if (PyExceptionClass_Check(type)) {
3238         PyObject *instance_class = NULL;
3239         if (value && PyExceptionInstance_Check(value)) {
3240             instance_class = (PyObject*) Py_TYPE(value);
3241             if (instance_class != type) {
3242                 int is_subclass = PyObject_IsSubclass(instance_class, type);
3243                 if (!is_subclass) {
3244                     instance_class = NULL;
3245                 } else if (unlikely(is_subclass == -1)) {
3246                     goto bad;
3247                 } else {
3248                     type = instance_class;
3249                 }
3250             }
3251         }
3252         if (!instance_class) {
3253             PyObject *args;
3254             if (!value)
3255                 args = PyTuple_New(0);
3256             else if (PyTuple_Check(value)) {
3257                 Py_INCREF(value);
3258                 args = value;
3259             } else
3260                 args = PyTuple_Pack(1, value);
3261             if (!args)
3262                 goto bad;
3263             owned_instance = PyObject_Call(type, args, NULL);
3264             Py_DECREF(args);
3265             if (!owned_instance)
3266                 goto bad;
3267             value = owned_instance;
3268             if (!PyExceptionInstance_Check(value)) {
3269                 PyErr_Format(PyExc_TypeError,
3270                              "calling %R should have returned an instance of "
3271                              "BaseException, not %R",
3272                              type, Py_TYPE(value));
3273                 goto bad;
3274             }
3275         }
3276     } else {
3277         PyErr_SetString(PyExc_TypeError,
3278             "raise: exception class must be a subclass of BaseException");
3279         goto bad;
3280     }
3281     if (cause) {
3282         PyObject *fixed_cause;
3283         if (cause == Py_None) {
3284             fixed_cause = NULL;
3285         } else if (PyExceptionClass_Check(cause)) {
3286             fixed_cause = PyObject_CallObject(cause, NULL);
3287             if (fixed_cause == NULL)
3288                 goto bad;
3289         } else if (PyExceptionInstance_Check(cause)) {
3290             fixed_cause = cause;
3291             Py_INCREF(fixed_cause);
3292         } else {
3293             PyErr_SetString(PyExc_TypeError,
3294                             "exception causes must derive from "
3295                             "BaseException");
3296             goto bad;
3297         }
3298         PyException_SetCause(value, fixed_cause);
3299     }
3300     PyErr_SetObject(type, value);
3301     if (tb) {
3302 #if CYTHON_COMPILING_IN_PYPY
3303         PyObject *tmp_type, *tmp_value, *tmp_tb;
3304         PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
3305         Py_INCREF(tb);
3306         PyErr_Restore(tmp_type, tmp_value, tb);
3307         Py_XDECREF(tmp_tb);
3308 #else
3309         PyThreadState *tstate = __Pyx_PyThreadState_Current;
3310         PyObject* tmp_tb = tstate->curexc_traceback;
3311         if (tb != tmp_tb) {
3312             Py_INCREF(tb);
3313             tstate->curexc_traceback = tb;
3314             Py_XDECREF(tmp_tb);
3315         }
3316 #endif
3317     }
3318 bad:
3319     Py_XDECREF(owned_instance);
3320     return;
3321 }
3322 #endif
3323 
3324 /* PyObject_GenericGetAttrNoDict */
3325 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
__Pyx_RaiseGenericGetAttributeError(PyTypeObject * tp,PyObject * attr_name)3326 static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
3327     PyErr_Format(PyExc_AttributeError,
3328 #if PY_MAJOR_VERSION >= 3
3329                  "'%.50s' object has no attribute '%U'",
3330                  tp->tp_name, attr_name);
3331 #else
3332                  "'%.50s' object has no attribute '%.400s'",
3333                  tp->tp_name, PyString_AS_STRING(attr_name));
3334 #endif
3335     return NULL;
3336 }
__Pyx_PyObject_GenericGetAttrNoDict(PyObject * obj,PyObject * attr_name)3337 static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
3338     PyObject *descr;
3339     PyTypeObject *tp = Py_TYPE(obj);
3340     if (unlikely(!PyString_Check(attr_name))) {
3341         return PyObject_GenericGetAttr(obj, attr_name);
3342     }
3343     assert(!tp->tp_dictoffset);
3344     descr = _PyType_Lookup(tp, attr_name);
3345     if (unlikely(!descr)) {
3346         return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
3347     }
3348     Py_INCREF(descr);
3349     #if PY_MAJOR_VERSION < 3
3350     if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
3351     #endif
3352     {
3353         descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
3354         if (unlikely(f)) {
3355             PyObject *res = f(descr, obj, (PyObject *)tp);
3356             Py_DECREF(descr);
3357             return res;
3358         }
3359     }
3360     return descr;
3361 }
3362 #endif
3363 
3364 /* PyObject_GenericGetAttr */
3365 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
__Pyx_PyObject_GenericGetAttr(PyObject * obj,PyObject * attr_name)3366 static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) {
3367     if (unlikely(Py_TYPE(obj)->tp_dictoffset)) {
3368         return PyObject_GenericGetAttr(obj, attr_name);
3369     }
3370     return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name);
3371 }
3372 #endif
3373 
3374 /* PyErrExceptionMatches */
3375 #if CYTHON_FAST_THREAD_STATE
__Pyx_PyErr_ExceptionMatchesTuple(PyObject * exc_type,PyObject * tuple)3376 static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
3377     Py_ssize_t i, n;
3378     n = PyTuple_GET_SIZE(tuple);
3379 #if PY_MAJOR_VERSION >= 3
3380     for (i=0; i<n; i++) {
3381         if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
3382     }
3383 #endif
3384     for (i=0; i<n; i++) {
3385         if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
3386     }
3387     return 0;
3388 }
__Pyx_PyErr_ExceptionMatchesInState(PyThreadState * tstate,PyObject * err)3389 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
3390     PyObject *exc_type = tstate->curexc_type;
3391     if (exc_type == err) return 1;
3392     if (unlikely(!exc_type)) return 0;
3393     if (unlikely(PyTuple_Check(err)))
3394         return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
3395     return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
3396 }
3397 #endif
3398 
3399 /* PyObjectGetAttrStrNoError */
__Pyx_PyObject_GetAttrStr_ClearAttributeError(void)3400 static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) {
3401     __Pyx_PyThreadState_declare
3402     __Pyx_PyThreadState_assign
3403     if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
3404         __Pyx_PyErr_Clear();
3405 }
__Pyx_PyObject_GetAttrStrNoError(PyObject * obj,PyObject * attr_name)3406 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) {
3407     PyObject *result;
3408 #if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS && PY_VERSION_HEX >= 0x030700B1
3409     PyTypeObject* tp = Py_TYPE(obj);
3410     if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) {
3411         return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1);
3412     }
3413 #endif
3414     result = __Pyx_PyObject_GetAttrStr(obj, attr_name);
3415     if (unlikely(!result)) {
3416         __Pyx_PyObject_GetAttrStr_ClearAttributeError();
3417     }
3418     return result;
3419 }
3420 
3421 /* SetupReduce */
__Pyx_setup_reduce_is_named(PyObject * meth,PyObject * name)3422 static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) {
3423   int ret;
3424   PyObject *name_attr;
3425   name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name);
3426   if (likely(name_attr)) {
3427       ret = PyObject_RichCompareBool(name_attr, name, Py_EQ);
3428   } else {
3429       ret = -1;
3430   }
3431   if (unlikely(ret < 0)) {
3432       PyErr_Clear();
3433       ret = 0;
3434   }
3435   Py_XDECREF(name_attr);
3436   return ret;
3437 }
__Pyx_setup_reduce(PyObject * type_obj)3438 static int __Pyx_setup_reduce(PyObject* type_obj) {
3439     int ret = 0;
3440     PyObject *object_reduce = NULL;
3441     PyObject *object_reduce_ex = NULL;
3442     PyObject *reduce = NULL;
3443     PyObject *reduce_ex = NULL;
3444     PyObject *reduce_cython = NULL;
3445     PyObject *setstate = NULL;
3446     PyObject *setstate_cython = NULL;
3447 #if CYTHON_USE_PYTYPE_LOOKUP
3448     if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto __PYX_GOOD;
3449 #else
3450     if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto __PYX_GOOD;
3451 #endif
3452 #if CYTHON_USE_PYTYPE_LOOKUP
3453     object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
3454 #else
3455     object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
3456 #endif
3457     reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto __PYX_BAD;
3458     if (reduce_ex == object_reduce_ex) {
3459 #if CYTHON_USE_PYTYPE_LOOKUP
3460         object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
3461 #else
3462         object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
3463 #endif
3464         reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto __PYX_BAD;
3465         if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) {
3466             reduce_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_reduce_cython);
3467             if (likely(reduce_cython)) {
3468                 ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
3469                 ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
3470             } else if (reduce == object_reduce || PyErr_Occurred()) {
3471                 goto __PYX_BAD;
3472             }
3473             setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate);
3474             if (!setstate) PyErr_Clear();
3475             if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) {
3476                 setstate_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_setstate_cython);
3477                 if (likely(setstate_cython)) {
3478                     ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
3479                     ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
3480                 } else if (!setstate || PyErr_Occurred()) {
3481                     goto __PYX_BAD;
3482                 }
3483             }
3484             PyType_Modified((PyTypeObject*)type_obj);
3485         }
3486     }
3487     goto __PYX_GOOD;
3488 __PYX_BAD:
3489     if (!PyErr_Occurred())
3490         PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name);
3491     ret = -1;
3492 __PYX_GOOD:
3493 #if !CYTHON_USE_PYTYPE_LOOKUP
3494     Py_XDECREF(object_reduce);
3495     Py_XDECREF(object_reduce_ex);
3496 #endif
3497     Py_XDECREF(reduce);
3498     Py_XDECREF(reduce_ex);
3499     Py_XDECREF(reduce_cython);
3500     Py_XDECREF(setstate);
3501     Py_XDECREF(setstate_cython);
3502     return ret;
3503 }
3504 
3505 /* PyDictVersioning */
3506 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
__Pyx_get_tp_dict_version(PyObject * obj)3507 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
3508     PyObject *dict = Py_TYPE(obj)->tp_dict;
3509     return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
3510 }
__Pyx_get_object_dict_version(PyObject * obj)3511 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
3512     PyObject **dictptr = NULL;
3513     Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
3514     if (offset) {
3515 #if CYTHON_COMPILING_IN_CPYTHON
3516         dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
3517 #else
3518         dictptr = _PyObject_GetDictPtr(obj);
3519 #endif
3520     }
3521     return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
3522 }
__Pyx_object_dict_version_matches(PyObject * obj,PY_UINT64_T tp_dict_version,PY_UINT64_T obj_dict_version)3523 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
3524     PyObject *dict = Py_TYPE(obj)->tp_dict;
3525     if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
3526         return 0;
3527     return obj_dict_version == __Pyx_get_object_dict_version(obj);
3528 }
3529 #endif
3530 
3531 /* CLineInTraceback */
3532 #ifndef CYTHON_CLINE_IN_TRACEBACK
__Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState * tstate,int c_line)3533 static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) {
3534     PyObject *use_cline;
3535     PyObject *ptype, *pvalue, *ptraceback;
3536 #if CYTHON_COMPILING_IN_CPYTHON
3537     PyObject **cython_runtime_dict;
3538 #endif
3539     if (unlikely(!__pyx_cython_runtime)) {
3540         return c_line;
3541     }
3542     __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
3543 #if CYTHON_COMPILING_IN_CPYTHON
3544     cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
3545     if (likely(cython_runtime_dict)) {
3546         __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
3547             use_cline, *cython_runtime_dict,
3548             __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback))
3549     } else
3550 #endif
3551     {
3552       PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
3553       if (use_cline_obj) {
3554         use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
3555         Py_DECREF(use_cline_obj);
3556       } else {
3557         PyErr_Clear();
3558         use_cline = NULL;
3559       }
3560     }
3561     if (!use_cline) {
3562         c_line = 0;
3563         PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
3564     }
3565     else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
3566         c_line = 0;
3567     }
3568     __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
3569     return c_line;
3570 }
3571 #endif
3572 
3573 /* CodeObjectCache */
__pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry * entries,int count,int code_line)3574 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
3575     int start = 0, mid = 0, end = count - 1;
3576     if (end >= 0 && code_line > entries[end].code_line) {
3577         return count;
3578     }
3579     while (start < end) {
3580         mid = start + (end - start) / 2;
3581         if (code_line < entries[mid].code_line) {
3582             end = mid;
3583         } else if (code_line > entries[mid].code_line) {
3584              start = mid + 1;
3585         } else {
3586             return mid;
3587         }
3588     }
3589     if (code_line <= entries[mid].code_line) {
3590         return mid;
3591     } else {
3592         return mid + 1;
3593     }
3594 }
__pyx_find_code_object(int code_line)3595 static PyCodeObject *__pyx_find_code_object(int code_line) {
3596     PyCodeObject* code_object;
3597     int pos;
3598     if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
3599         return NULL;
3600     }
3601     pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
3602     if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
3603         return NULL;
3604     }
3605     code_object = __pyx_code_cache.entries[pos].code_object;
3606     Py_INCREF(code_object);
3607     return code_object;
3608 }
__pyx_insert_code_object(int code_line,PyCodeObject * code_object)3609 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
3610     int pos, i;
3611     __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
3612     if (unlikely(!code_line)) {
3613         return;
3614     }
3615     if (unlikely(!entries)) {
3616         entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
3617         if (likely(entries)) {
3618             __pyx_code_cache.entries = entries;
3619             __pyx_code_cache.max_count = 64;
3620             __pyx_code_cache.count = 1;
3621             entries[0].code_line = code_line;
3622             entries[0].code_object = code_object;
3623             Py_INCREF(code_object);
3624         }
3625         return;
3626     }
3627     pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
3628     if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
3629         PyCodeObject* tmp = entries[pos].code_object;
3630         entries[pos].code_object = code_object;
3631         Py_DECREF(tmp);
3632         return;
3633     }
3634     if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
3635         int new_max = __pyx_code_cache.max_count + 64;
3636         entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
3637             __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry));
3638         if (unlikely(!entries)) {
3639             return;
3640         }
3641         __pyx_code_cache.entries = entries;
3642         __pyx_code_cache.max_count = new_max;
3643     }
3644     for (i=__pyx_code_cache.count; i>pos; i--) {
3645         entries[i] = entries[i-1];
3646     }
3647     entries[pos].code_line = code_line;
3648     entries[pos].code_object = code_object;
3649     __pyx_code_cache.count++;
3650     Py_INCREF(code_object);
3651 }
3652 
3653 /* AddTraceback */
3654 #include "compile.h"
3655 #include "frameobject.h"
3656 #include "traceback.h"
__Pyx_CreateCodeObjectForTraceback(const char * funcname,int c_line,int py_line,const char * filename)3657 static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
3658             const char *funcname, int c_line,
3659             int py_line, const char *filename) {
3660     PyCodeObject *py_code = 0;
3661     PyObject *py_srcfile = 0;
3662     PyObject *py_funcname = 0;
3663     #if PY_MAJOR_VERSION < 3
3664     py_srcfile = PyString_FromString(filename);
3665     #else
3666     py_srcfile = PyUnicode_FromString(filename);
3667     #endif
3668     if (!py_srcfile) goto bad;
3669     if (c_line) {
3670         #if PY_MAJOR_VERSION < 3
3671         py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
3672         #else
3673         py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
3674         #endif
3675     }
3676     else {
3677         #if PY_MAJOR_VERSION < 3
3678         py_funcname = PyString_FromString(funcname);
3679         #else
3680         py_funcname = PyUnicode_FromString(funcname);
3681         #endif
3682     }
3683     if (!py_funcname) goto bad;
3684     py_code = __Pyx_PyCode_New(
3685         0,
3686         0,
3687         0,
3688         0,
3689         0,
3690         __pyx_empty_bytes, /*PyObject *code,*/
3691         __pyx_empty_tuple, /*PyObject *consts,*/
3692         __pyx_empty_tuple, /*PyObject *names,*/
3693         __pyx_empty_tuple, /*PyObject *varnames,*/
3694         __pyx_empty_tuple, /*PyObject *freevars,*/
3695         __pyx_empty_tuple, /*PyObject *cellvars,*/
3696         py_srcfile,   /*PyObject *filename,*/
3697         py_funcname,  /*PyObject *name,*/
3698         py_line,
3699         __pyx_empty_bytes  /*PyObject *lnotab*/
3700     );
3701     Py_DECREF(py_srcfile);
3702     Py_DECREF(py_funcname);
3703     return py_code;
3704 bad:
3705     Py_XDECREF(py_srcfile);
3706     Py_XDECREF(py_funcname);
3707     return NULL;
3708 }
__Pyx_AddTraceback(const char * funcname,int c_line,int py_line,const char * filename)3709 static void __Pyx_AddTraceback(const char *funcname, int c_line,
3710                                int py_line, const char *filename) {
3711     PyCodeObject *py_code = 0;
3712     PyFrameObject *py_frame = 0;
3713     PyThreadState *tstate = __Pyx_PyThreadState_Current;
3714     if (c_line) {
3715         c_line = __Pyx_CLineForTraceback(tstate, c_line);
3716     }
3717     py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
3718     if (!py_code) {
3719         py_code = __Pyx_CreateCodeObjectForTraceback(
3720             funcname, c_line, py_line, filename);
3721         if (!py_code) goto bad;
3722         __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
3723     }
3724     py_frame = PyFrame_New(
3725         tstate,            /*PyThreadState *tstate,*/
3726         py_code,           /*PyCodeObject *code,*/
3727         __pyx_d,    /*PyObject *globals,*/
3728         0                  /*PyObject *locals*/
3729     );
3730     if (!py_frame) goto bad;
3731     __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
3732     PyTraceBack_Here(py_frame);
3733 bad:
3734     Py_XDECREF(py_code);
3735     Py_XDECREF(py_frame);
3736 }
3737 
3738 /* CIntFromPyVerify */
3739 #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
3740     __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
3741 #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
3742     __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
3743 #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
3744     {\
3745         func_type value = func_value;\
3746         if (sizeof(target_type) < sizeof(func_type)) {\
3747             if (unlikely(value != (func_type) (target_type) value)) {\
3748                 func_type zero = 0;\
3749                 if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
3750                     return (target_type) -1;\
3751                 if (is_unsigned && unlikely(value < zero))\
3752                     goto raise_neg_overflow;\
3753                 else\
3754                     goto raise_overflow;\
3755             }\
3756         }\
3757         return (target_type) value;\
3758     }
3759 
3760 /* CIntFromPy */
__Pyx_PyInt_As_int(PyObject * x)3761 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
3762 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
3763 #pragma GCC diagnostic push
3764 #pragma GCC diagnostic ignored "-Wconversion"
3765 #endif
3766     const int neg_one = (int) -1, const_zero = (int) 0;
3767 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
3768 #pragma GCC diagnostic pop
3769 #endif
3770     const int is_unsigned = neg_one > const_zero;
3771 #if PY_MAJOR_VERSION < 3
3772     if (likely(PyInt_Check(x))) {
3773         if (sizeof(int) < sizeof(long)) {
3774             __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
3775         } else {
3776             long val = PyInt_AS_LONG(x);
3777             if (is_unsigned && unlikely(val < 0)) {
3778                 goto raise_neg_overflow;
3779             }
3780             return (int) val;
3781         }
3782     } else
3783 #endif
3784     if (likely(PyLong_Check(x))) {
3785         if (is_unsigned) {
3786 #if CYTHON_USE_PYLONG_INTERNALS
3787             const digit* digits = ((PyLongObject*)x)->ob_digit;
3788             switch (Py_SIZE(x)) {
3789                 case  0: return (int) 0;
3790                 case  1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
3791                 case 2:
3792                     if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
3793                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
3794                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3795                         } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
3796                             return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
3797                         }
3798                     }
3799                     break;
3800                 case 3:
3801                     if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
3802                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
3803                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3804                         } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
3805                             return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
3806                         }
3807                     }
3808                     break;
3809                 case 4:
3810                     if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
3811                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
3812                             __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])))
3813                         } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
3814                             return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
3815                         }
3816                     }
3817                     break;
3818             }
3819 #endif
3820 #if CYTHON_COMPILING_IN_CPYTHON
3821             if (unlikely(Py_SIZE(x) < 0)) {
3822                 goto raise_neg_overflow;
3823             }
3824 #else
3825             {
3826                 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
3827                 if (unlikely(result < 0))
3828                     return (int) -1;
3829                 if (unlikely(result == 1))
3830                     goto raise_neg_overflow;
3831             }
3832 #endif
3833             if (sizeof(int) <= sizeof(unsigned long)) {
3834                 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
3835 #ifdef HAVE_LONG_LONG
3836             } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
3837                 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
3838 #endif
3839             }
3840         } else {
3841 #if CYTHON_USE_PYLONG_INTERNALS
3842             const digit* digits = ((PyLongObject*)x)->ob_digit;
3843             switch (Py_SIZE(x)) {
3844                 case  0: return (int) 0;
3845                 case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
3846                 case  1: __PYX_VERIFY_RETURN_INT(int,  digit, +digits[0])
3847                 case -2:
3848                     if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
3849                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
3850                             __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3851                         } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
3852                             return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
3853                         }
3854                     }
3855                     break;
3856                 case 2:
3857                     if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
3858                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
3859                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3860                         } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
3861                             return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
3862                         }
3863                     }
3864                     break;
3865                 case -3:
3866                     if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
3867                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
3868                             __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3869                         } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
3870                             return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
3871                         }
3872                     }
3873                     break;
3874                 case 3:
3875                     if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
3876                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
3877                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3878                         } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
3879                             return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
3880                         }
3881                     }
3882                     break;
3883                 case -4:
3884                     if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
3885                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
3886                             __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])))
3887                         } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
3888                             return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
3889                         }
3890                     }
3891                     break;
3892                 case 4:
3893                     if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
3894                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
3895                             __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])))
3896                         } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
3897                             return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
3898                         }
3899                     }
3900                     break;
3901             }
3902 #endif
3903             if (sizeof(int) <= sizeof(long)) {
3904                 __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
3905 #ifdef HAVE_LONG_LONG
3906             } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
3907                 __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
3908 #endif
3909             }
3910         }
3911         {
3912 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
3913             PyErr_SetString(PyExc_RuntimeError,
3914                             "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
3915 #else
3916             int val;
3917             PyObject *v = __Pyx_PyNumber_IntOrLong(x);
3918  #if PY_MAJOR_VERSION < 3
3919             if (likely(v) && !PyLong_Check(v)) {
3920                 PyObject *tmp = v;
3921                 v = PyNumber_Long(tmp);
3922                 Py_DECREF(tmp);
3923             }
3924  #endif
3925             if (likely(v)) {
3926                 int one = 1; int is_little = (int)*(unsigned char *)&one;
3927                 unsigned char *bytes = (unsigned char *)&val;
3928                 int ret = _PyLong_AsByteArray((PyLongObject *)v,
3929                                               bytes, sizeof(val),
3930                                               is_little, !is_unsigned);
3931                 Py_DECREF(v);
3932                 if (likely(!ret))
3933                     return val;
3934             }
3935 #endif
3936             return (int) -1;
3937         }
3938     } else {
3939         int val;
3940         PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
3941         if (!tmp) return (int) -1;
3942         val = __Pyx_PyInt_As_int(tmp);
3943         Py_DECREF(tmp);
3944         return val;
3945     }
3946 raise_overflow:
3947     PyErr_SetString(PyExc_OverflowError,
3948         "value too large to convert to int");
3949     return (int) -1;
3950 raise_neg_overflow:
3951     PyErr_SetString(PyExc_OverflowError,
3952         "can't convert negative value to int");
3953     return (int) -1;
3954 }
3955 
3956 /* CIntFromPy */
__Pyx_PyInt_As_unsigned_long(PyObject * x)3957 static CYTHON_INLINE unsigned long __Pyx_PyInt_As_unsigned_long(PyObject *x) {
3958 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
3959 #pragma GCC diagnostic push
3960 #pragma GCC diagnostic ignored "-Wconversion"
3961 #endif
3962     const unsigned long neg_one = (unsigned long) -1, const_zero = (unsigned long) 0;
3963 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
3964 #pragma GCC diagnostic pop
3965 #endif
3966     const int is_unsigned = neg_one > const_zero;
3967 #if PY_MAJOR_VERSION < 3
3968     if (likely(PyInt_Check(x))) {
3969         if (sizeof(unsigned long) < sizeof(long)) {
3970             __PYX_VERIFY_RETURN_INT(unsigned long, long, PyInt_AS_LONG(x))
3971         } else {
3972             long val = PyInt_AS_LONG(x);
3973             if (is_unsigned && unlikely(val < 0)) {
3974                 goto raise_neg_overflow;
3975             }
3976             return (unsigned long) val;
3977         }
3978     } else
3979 #endif
3980     if (likely(PyLong_Check(x))) {
3981         if (is_unsigned) {
3982 #if CYTHON_USE_PYLONG_INTERNALS
3983             const digit* digits = ((PyLongObject*)x)->ob_digit;
3984             switch (Py_SIZE(x)) {
3985                 case  0: return (unsigned long) 0;
3986                 case  1: __PYX_VERIFY_RETURN_INT(unsigned long, digit, digits[0])
3987                 case 2:
3988                     if (8 * sizeof(unsigned long) > 1 * PyLong_SHIFT) {
3989                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
3990                             __PYX_VERIFY_RETURN_INT(unsigned long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3991                         } else if (8 * sizeof(unsigned long) >= 2 * PyLong_SHIFT) {
3992                             return (unsigned long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
3993                         }
3994                     }
3995                     break;
3996                 case 3:
3997                     if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
3998                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
3999                             __PYX_VERIFY_RETURN_INT(unsigned long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4000                         } else if (8 * sizeof(unsigned long) >= 3 * PyLong_SHIFT) {
4001                             return (unsigned long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
4002                         }
4003                     }
4004                     break;
4005                 case 4:
4006                     if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
4007                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
4008                             __PYX_VERIFY_RETURN_INT(unsigned 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])))
4009                         } else if (8 * sizeof(unsigned long) >= 4 * PyLong_SHIFT) {
4010                             return (unsigned long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
4011                         }
4012                     }
4013                     break;
4014             }
4015 #endif
4016 #if CYTHON_COMPILING_IN_CPYTHON
4017             if (unlikely(Py_SIZE(x) < 0)) {
4018                 goto raise_neg_overflow;
4019             }
4020 #else
4021             {
4022                 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
4023                 if (unlikely(result < 0))
4024                     return (unsigned long) -1;
4025                 if (unlikely(result == 1))
4026                     goto raise_neg_overflow;
4027             }
4028 #endif
4029             if (sizeof(unsigned long) <= sizeof(unsigned long)) {
4030                 __PYX_VERIFY_RETURN_INT_EXC(unsigned long, unsigned long, PyLong_AsUnsignedLong(x))
4031 #ifdef HAVE_LONG_LONG
4032             } else if (sizeof(unsigned long) <= sizeof(unsigned PY_LONG_LONG)) {
4033                 __PYX_VERIFY_RETURN_INT_EXC(unsigned long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
4034 #endif
4035             }
4036         } else {
4037 #if CYTHON_USE_PYLONG_INTERNALS
4038             const digit* digits = ((PyLongObject*)x)->ob_digit;
4039             switch (Py_SIZE(x)) {
4040                 case  0: return (unsigned long) 0;
4041                 case -1: __PYX_VERIFY_RETURN_INT(unsigned long, sdigit, (sdigit) (-(sdigit)digits[0]))
4042                 case  1: __PYX_VERIFY_RETURN_INT(unsigned long,  digit, +digits[0])
4043                 case -2:
4044                     if (8 * sizeof(unsigned long) - 1 > 1 * PyLong_SHIFT) {
4045                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
4046                             __PYX_VERIFY_RETURN_INT(unsigned long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4047                         } else if (8 * sizeof(unsigned long) - 1 > 2 * PyLong_SHIFT) {
4048                             return (unsigned long) (((unsigned long)-1)*(((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])));
4049                         }
4050                     }
4051                     break;
4052                 case 2:
4053                     if (8 * sizeof(unsigned long) > 1 * PyLong_SHIFT) {
4054                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
4055                             __PYX_VERIFY_RETURN_INT(unsigned long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4056                         } else if (8 * sizeof(unsigned long) - 1 > 2 * PyLong_SHIFT) {
4057                             return (unsigned long) ((((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])));
4058                         }
4059                     }
4060                     break;
4061                 case -3:
4062                     if (8 * sizeof(unsigned long) - 1 > 2 * PyLong_SHIFT) {
4063                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
4064                             __PYX_VERIFY_RETURN_INT(unsigned long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4065                         } else if (8 * sizeof(unsigned long) - 1 > 3 * PyLong_SHIFT) {
4066                             return (unsigned long) (((unsigned long)-1)*(((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])));
4067                         }
4068                     }
4069                     break;
4070                 case 3:
4071                     if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
4072                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
4073                             __PYX_VERIFY_RETURN_INT(unsigned long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4074                         } else if (8 * sizeof(unsigned long) - 1 > 3 * PyLong_SHIFT) {
4075                             return (unsigned long) ((((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])));
4076                         }
4077                     }
4078                     break;
4079                 case -4:
4080                     if (8 * sizeof(unsigned long) - 1 > 3 * PyLong_SHIFT) {
4081                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
4082                             __PYX_VERIFY_RETURN_INT(unsigned 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])))
4083                         } else if (8 * sizeof(unsigned long) - 1 > 4 * PyLong_SHIFT) {
4084                             return (unsigned long) (((unsigned long)-1)*(((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])));
4085                         }
4086                     }
4087                     break;
4088                 case 4:
4089                     if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
4090                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
4091                             __PYX_VERIFY_RETURN_INT(unsigned 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])))
4092                         } else if (8 * sizeof(unsigned long) - 1 > 4 * PyLong_SHIFT) {
4093                             return (unsigned long) ((((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])));
4094                         }
4095                     }
4096                     break;
4097             }
4098 #endif
4099             if (sizeof(unsigned long) <= sizeof(long)) {
4100                 __PYX_VERIFY_RETURN_INT_EXC(unsigned long, long, PyLong_AsLong(x))
4101 #ifdef HAVE_LONG_LONG
4102             } else if (sizeof(unsigned long) <= sizeof(PY_LONG_LONG)) {
4103                 __PYX_VERIFY_RETURN_INT_EXC(unsigned long, PY_LONG_LONG, PyLong_AsLongLong(x))
4104 #endif
4105             }
4106         }
4107         {
4108 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
4109             PyErr_SetString(PyExc_RuntimeError,
4110                             "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
4111 #else
4112             unsigned long val;
4113             PyObject *v = __Pyx_PyNumber_IntOrLong(x);
4114  #if PY_MAJOR_VERSION < 3
4115             if (likely(v) && !PyLong_Check(v)) {
4116                 PyObject *tmp = v;
4117                 v = PyNumber_Long(tmp);
4118                 Py_DECREF(tmp);
4119             }
4120  #endif
4121             if (likely(v)) {
4122                 int one = 1; int is_little = (int)*(unsigned char *)&one;
4123                 unsigned char *bytes = (unsigned char *)&val;
4124                 int ret = _PyLong_AsByteArray((PyLongObject *)v,
4125                                               bytes, sizeof(val),
4126                                               is_little, !is_unsigned);
4127                 Py_DECREF(v);
4128                 if (likely(!ret))
4129                     return val;
4130             }
4131 #endif
4132             return (unsigned long) -1;
4133         }
4134     } else {
4135         unsigned long val;
4136         PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
4137         if (!tmp) return (unsigned long) -1;
4138         val = __Pyx_PyInt_As_unsigned_long(tmp);
4139         Py_DECREF(tmp);
4140         return val;
4141     }
4142 raise_overflow:
4143     PyErr_SetString(PyExc_OverflowError,
4144         "value too large to convert to unsigned long");
4145     return (unsigned long) -1;
4146 raise_neg_overflow:
4147     PyErr_SetString(PyExc_OverflowError,
4148         "can't convert negative value to unsigned long");
4149     return (unsigned long) -1;
4150 }
4151 
4152 /* CIntFromPy */
__Pyx_PyInt_As_uint32_t(PyObject * x)4153 static CYTHON_INLINE uint32_t __Pyx_PyInt_As_uint32_t(PyObject *x) {
4154 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
4155 #pragma GCC diagnostic push
4156 #pragma GCC diagnostic ignored "-Wconversion"
4157 #endif
4158     const uint32_t neg_one = (uint32_t) -1, const_zero = (uint32_t) 0;
4159 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
4160 #pragma GCC diagnostic pop
4161 #endif
4162     const int is_unsigned = neg_one > const_zero;
4163 #if PY_MAJOR_VERSION < 3
4164     if (likely(PyInt_Check(x))) {
4165         if (sizeof(uint32_t) < sizeof(long)) {
4166             __PYX_VERIFY_RETURN_INT(uint32_t, long, PyInt_AS_LONG(x))
4167         } else {
4168             long val = PyInt_AS_LONG(x);
4169             if (is_unsigned && unlikely(val < 0)) {
4170                 goto raise_neg_overflow;
4171             }
4172             return (uint32_t) val;
4173         }
4174     } else
4175 #endif
4176     if (likely(PyLong_Check(x))) {
4177         if (is_unsigned) {
4178 #if CYTHON_USE_PYLONG_INTERNALS
4179             const digit* digits = ((PyLongObject*)x)->ob_digit;
4180             switch (Py_SIZE(x)) {
4181                 case  0: return (uint32_t) 0;
4182                 case  1: __PYX_VERIFY_RETURN_INT(uint32_t, digit, digits[0])
4183                 case 2:
4184                     if (8 * sizeof(uint32_t) > 1 * PyLong_SHIFT) {
4185                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
4186                             __PYX_VERIFY_RETURN_INT(uint32_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4187                         } else if (8 * sizeof(uint32_t) >= 2 * PyLong_SHIFT) {
4188                             return (uint32_t) (((((uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0]));
4189                         }
4190                     }
4191                     break;
4192                 case 3:
4193                     if (8 * sizeof(uint32_t) > 2 * PyLong_SHIFT) {
4194                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
4195                             __PYX_VERIFY_RETURN_INT(uint32_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4196                         } else if (8 * sizeof(uint32_t) >= 3 * PyLong_SHIFT) {
4197                             return (uint32_t) (((((((uint32_t)digits[2]) << PyLong_SHIFT) | (uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0]));
4198                         }
4199                     }
4200                     break;
4201                 case 4:
4202                     if (8 * sizeof(uint32_t) > 3 * PyLong_SHIFT) {
4203                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
4204                             __PYX_VERIFY_RETURN_INT(uint32_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4205                         } else if (8 * sizeof(uint32_t) >= 4 * PyLong_SHIFT) {
4206                             return (uint32_t) (((((((((uint32_t)digits[3]) << PyLong_SHIFT) | (uint32_t)digits[2]) << PyLong_SHIFT) | (uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0]));
4207                         }
4208                     }
4209                     break;
4210             }
4211 #endif
4212 #if CYTHON_COMPILING_IN_CPYTHON
4213             if (unlikely(Py_SIZE(x) < 0)) {
4214                 goto raise_neg_overflow;
4215             }
4216 #else
4217             {
4218                 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
4219                 if (unlikely(result < 0))
4220                     return (uint32_t) -1;
4221                 if (unlikely(result == 1))
4222                     goto raise_neg_overflow;
4223             }
4224 #endif
4225             if (sizeof(uint32_t) <= sizeof(unsigned long)) {
4226                 __PYX_VERIFY_RETURN_INT_EXC(uint32_t, unsigned long, PyLong_AsUnsignedLong(x))
4227 #ifdef HAVE_LONG_LONG
4228             } else if (sizeof(uint32_t) <= sizeof(unsigned PY_LONG_LONG)) {
4229                 __PYX_VERIFY_RETURN_INT_EXC(uint32_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
4230 #endif
4231             }
4232         } else {
4233 #if CYTHON_USE_PYLONG_INTERNALS
4234             const digit* digits = ((PyLongObject*)x)->ob_digit;
4235             switch (Py_SIZE(x)) {
4236                 case  0: return (uint32_t) 0;
4237                 case -1: __PYX_VERIFY_RETURN_INT(uint32_t, sdigit, (sdigit) (-(sdigit)digits[0]))
4238                 case  1: __PYX_VERIFY_RETURN_INT(uint32_t,  digit, +digits[0])
4239                 case -2:
4240                     if (8 * sizeof(uint32_t) - 1 > 1 * PyLong_SHIFT) {
4241                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
4242                             __PYX_VERIFY_RETURN_INT(uint32_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4243                         } else if (8 * sizeof(uint32_t) - 1 > 2 * PyLong_SHIFT) {
4244                             return (uint32_t) (((uint32_t)-1)*(((((uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0])));
4245                         }
4246                     }
4247                     break;
4248                 case 2:
4249                     if (8 * sizeof(uint32_t) > 1 * PyLong_SHIFT) {
4250                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
4251                             __PYX_VERIFY_RETURN_INT(uint32_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4252                         } else if (8 * sizeof(uint32_t) - 1 > 2 * PyLong_SHIFT) {
4253                             return (uint32_t) ((((((uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0])));
4254                         }
4255                     }
4256                     break;
4257                 case -3:
4258                     if (8 * sizeof(uint32_t) - 1 > 2 * PyLong_SHIFT) {
4259                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
4260                             __PYX_VERIFY_RETURN_INT(uint32_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4261                         } else if (8 * sizeof(uint32_t) - 1 > 3 * PyLong_SHIFT) {
4262                             return (uint32_t) (((uint32_t)-1)*(((((((uint32_t)digits[2]) << PyLong_SHIFT) | (uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0])));
4263                         }
4264                     }
4265                     break;
4266                 case 3:
4267                     if (8 * sizeof(uint32_t) > 2 * PyLong_SHIFT) {
4268                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
4269                             __PYX_VERIFY_RETURN_INT(uint32_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4270                         } else if (8 * sizeof(uint32_t) - 1 > 3 * PyLong_SHIFT) {
4271                             return (uint32_t) ((((((((uint32_t)digits[2]) << PyLong_SHIFT) | (uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0])));
4272                         }
4273                     }
4274                     break;
4275                 case -4:
4276                     if (8 * sizeof(uint32_t) - 1 > 3 * PyLong_SHIFT) {
4277                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
4278                             __PYX_VERIFY_RETURN_INT(uint32_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4279                         } else if (8 * sizeof(uint32_t) - 1 > 4 * PyLong_SHIFT) {
4280                             return (uint32_t) (((uint32_t)-1)*(((((((((uint32_t)digits[3]) << PyLong_SHIFT) | (uint32_t)digits[2]) << PyLong_SHIFT) | (uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0])));
4281                         }
4282                     }
4283                     break;
4284                 case 4:
4285                     if (8 * sizeof(uint32_t) > 3 * PyLong_SHIFT) {
4286                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
4287                             __PYX_VERIFY_RETURN_INT(uint32_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4288                         } else if (8 * sizeof(uint32_t) - 1 > 4 * PyLong_SHIFT) {
4289                             return (uint32_t) ((((((((((uint32_t)digits[3]) << PyLong_SHIFT) | (uint32_t)digits[2]) << PyLong_SHIFT) | (uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0])));
4290                         }
4291                     }
4292                     break;
4293             }
4294 #endif
4295             if (sizeof(uint32_t) <= sizeof(long)) {
4296                 __PYX_VERIFY_RETURN_INT_EXC(uint32_t, long, PyLong_AsLong(x))
4297 #ifdef HAVE_LONG_LONG
4298             } else if (sizeof(uint32_t) <= sizeof(PY_LONG_LONG)) {
4299                 __PYX_VERIFY_RETURN_INT_EXC(uint32_t, PY_LONG_LONG, PyLong_AsLongLong(x))
4300 #endif
4301             }
4302         }
4303         {
4304 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
4305             PyErr_SetString(PyExc_RuntimeError,
4306                             "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
4307 #else
4308             uint32_t val;
4309             PyObject *v = __Pyx_PyNumber_IntOrLong(x);
4310  #if PY_MAJOR_VERSION < 3
4311             if (likely(v) && !PyLong_Check(v)) {
4312                 PyObject *tmp = v;
4313                 v = PyNumber_Long(tmp);
4314                 Py_DECREF(tmp);
4315             }
4316  #endif
4317             if (likely(v)) {
4318                 int one = 1; int is_little = (int)*(unsigned char *)&one;
4319                 unsigned char *bytes = (unsigned char *)&val;
4320                 int ret = _PyLong_AsByteArray((PyLongObject *)v,
4321                                               bytes, sizeof(val),
4322                                               is_little, !is_unsigned);
4323                 Py_DECREF(v);
4324                 if (likely(!ret))
4325                     return val;
4326             }
4327 #endif
4328             return (uint32_t) -1;
4329         }
4330     } else {
4331         uint32_t val;
4332         PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
4333         if (!tmp) return (uint32_t) -1;
4334         val = __Pyx_PyInt_As_uint32_t(tmp);
4335         Py_DECREF(tmp);
4336         return val;
4337     }
4338 raise_overflow:
4339     PyErr_SetString(PyExc_OverflowError,
4340         "value too large to convert to uint32_t");
4341     return (uint32_t) -1;
4342 raise_neg_overflow:
4343     PyErr_SetString(PyExc_OverflowError,
4344         "can't convert negative value to uint32_t");
4345     return (uint32_t) -1;
4346 }
4347 
4348 /* CIntFromPy */
__Pyx_PyInt_As_unsigned_char(PyObject * x)4349 static CYTHON_INLINE unsigned char __Pyx_PyInt_As_unsigned_char(PyObject *x) {
4350 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
4351 #pragma GCC diagnostic push
4352 #pragma GCC diagnostic ignored "-Wconversion"
4353 #endif
4354     const unsigned char neg_one = (unsigned char) -1, const_zero = (unsigned char) 0;
4355 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
4356 #pragma GCC diagnostic pop
4357 #endif
4358     const int is_unsigned = neg_one > const_zero;
4359 #if PY_MAJOR_VERSION < 3
4360     if (likely(PyInt_Check(x))) {
4361         if (sizeof(unsigned char) < sizeof(long)) {
4362             __PYX_VERIFY_RETURN_INT(unsigned char, long, PyInt_AS_LONG(x))
4363         } else {
4364             long val = PyInt_AS_LONG(x);
4365             if (is_unsigned && unlikely(val < 0)) {
4366                 goto raise_neg_overflow;
4367             }
4368             return (unsigned char) val;
4369         }
4370     } else
4371 #endif
4372     if (likely(PyLong_Check(x))) {
4373         if (is_unsigned) {
4374 #if CYTHON_USE_PYLONG_INTERNALS
4375             const digit* digits = ((PyLongObject*)x)->ob_digit;
4376             switch (Py_SIZE(x)) {
4377                 case  0: return (unsigned char) 0;
4378                 case  1: __PYX_VERIFY_RETURN_INT(unsigned char, digit, digits[0])
4379                 case 2:
4380                     if (8 * sizeof(unsigned char) > 1 * PyLong_SHIFT) {
4381                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
4382                             __PYX_VERIFY_RETURN_INT(unsigned char, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4383                         } else if (8 * sizeof(unsigned char) >= 2 * PyLong_SHIFT) {
4384                             return (unsigned char) (((((unsigned char)digits[1]) << PyLong_SHIFT) | (unsigned char)digits[0]));
4385                         }
4386                     }
4387                     break;
4388                 case 3:
4389                     if (8 * sizeof(unsigned char) > 2 * PyLong_SHIFT) {
4390                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
4391                             __PYX_VERIFY_RETURN_INT(unsigned char, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4392                         } else if (8 * sizeof(unsigned char) >= 3 * PyLong_SHIFT) {
4393                             return (unsigned char) (((((((unsigned char)digits[2]) << PyLong_SHIFT) | (unsigned char)digits[1]) << PyLong_SHIFT) | (unsigned char)digits[0]));
4394                         }
4395                     }
4396                     break;
4397                 case 4:
4398                     if (8 * sizeof(unsigned char) > 3 * PyLong_SHIFT) {
4399                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
4400                             __PYX_VERIFY_RETURN_INT(unsigned char, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4401                         } else if (8 * sizeof(unsigned char) >= 4 * PyLong_SHIFT) {
4402                             return (unsigned char) (((((((((unsigned char)digits[3]) << PyLong_SHIFT) | (unsigned char)digits[2]) << PyLong_SHIFT) | (unsigned char)digits[1]) << PyLong_SHIFT) | (unsigned char)digits[0]));
4403                         }
4404                     }
4405                     break;
4406             }
4407 #endif
4408 #if CYTHON_COMPILING_IN_CPYTHON
4409             if (unlikely(Py_SIZE(x) < 0)) {
4410                 goto raise_neg_overflow;
4411             }
4412 #else
4413             {
4414                 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
4415                 if (unlikely(result < 0))
4416                     return (unsigned char) -1;
4417                 if (unlikely(result == 1))
4418                     goto raise_neg_overflow;
4419             }
4420 #endif
4421             if (sizeof(unsigned char) <= sizeof(unsigned long)) {
4422                 __PYX_VERIFY_RETURN_INT_EXC(unsigned char, unsigned long, PyLong_AsUnsignedLong(x))
4423 #ifdef HAVE_LONG_LONG
4424             } else if (sizeof(unsigned char) <= sizeof(unsigned PY_LONG_LONG)) {
4425                 __PYX_VERIFY_RETURN_INT_EXC(unsigned char, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
4426 #endif
4427             }
4428         } else {
4429 #if CYTHON_USE_PYLONG_INTERNALS
4430             const digit* digits = ((PyLongObject*)x)->ob_digit;
4431             switch (Py_SIZE(x)) {
4432                 case  0: return (unsigned char) 0;
4433                 case -1: __PYX_VERIFY_RETURN_INT(unsigned char, sdigit, (sdigit) (-(sdigit)digits[0]))
4434                 case  1: __PYX_VERIFY_RETURN_INT(unsigned char,  digit, +digits[0])
4435                 case -2:
4436                     if (8 * sizeof(unsigned char) - 1 > 1 * PyLong_SHIFT) {
4437                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
4438                             __PYX_VERIFY_RETURN_INT(unsigned char, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4439                         } else if (8 * sizeof(unsigned char) - 1 > 2 * PyLong_SHIFT) {
4440                             return (unsigned char) (((unsigned char)-1)*(((((unsigned char)digits[1]) << PyLong_SHIFT) | (unsigned char)digits[0])));
4441                         }
4442                     }
4443                     break;
4444                 case 2:
4445                     if (8 * sizeof(unsigned char) > 1 * PyLong_SHIFT) {
4446                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
4447                             __PYX_VERIFY_RETURN_INT(unsigned char, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4448                         } else if (8 * sizeof(unsigned char) - 1 > 2 * PyLong_SHIFT) {
4449                             return (unsigned char) ((((((unsigned char)digits[1]) << PyLong_SHIFT) | (unsigned char)digits[0])));
4450                         }
4451                     }
4452                     break;
4453                 case -3:
4454                     if (8 * sizeof(unsigned char) - 1 > 2 * PyLong_SHIFT) {
4455                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
4456                             __PYX_VERIFY_RETURN_INT(unsigned char, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4457                         } else if (8 * sizeof(unsigned char) - 1 > 3 * PyLong_SHIFT) {
4458                             return (unsigned char) (((unsigned char)-1)*(((((((unsigned char)digits[2]) << PyLong_SHIFT) | (unsigned char)digits[1]) << PyLong_SHIFT) | (unsigned char)digits[0])));
4459                         }
4460                     }
4461                     break;
4462                 case 3:
4463                     if (8 * sizeof(unsigned char) > 2 * PyLong_SHIFT) {
4464                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
4465                             __PYX_VERIFY_RETURN_INT(unsigned char, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4466                         } else if (8 * sizeof(unsigned char) - 1 > 3 * PyLong_SHIFT) {
4467                             return (unsigned char) ((((((((unsigned char)digits[2]) << PyLong_SHIFT) | (unsigned char)digits[1]) << PyLong_SHIFT) | (unsigned char)digits[0])));
4468                         }
4469                     }
4470                     break;
4471                 case -4:
4472                     if (8 * sizeof(unsigned char) - 1 > 3 * PyLong_SHIFT) {
4473                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
4474                             __PYX_VERIFY_RETURN_INT(unsigned char, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4475                         } else if (8 * sizeof(unsigned char) - 1 > 4 * PyLong_SHIFT) {
4476                             return (unsigned char) (((unsigned char)-1)*(((((((((unsigned char)digits[3]) << PyLong_SHIFT) | (unsigned char)digits[2]) << PyLong_SHIFT) | (unsigned char)digits[1]) << PyLong_SHIFT) | (unsigned char)digits[0])));
4477                         }
4478                     }
4479                     break;
4480                 case 4:
4481                     if (8 * sizeof(unsigned char) > 3 * PyLong_SHIFT) {
4482                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
4483                             __PYX_VERIFY_RETURN_INT(unsigned char, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4484                         } else if (8 * sizeof(unsigned char) - 1 > 4 * PyLong_SHIFT) {
4485                             return (unsigned char) ((((((((((unsigned char)digits[3]) << PyLong_SHIFT) | (unsigned char)digits[2]) << PyLong_SHIFT) | (unsigned char)digits[1]) << PyLong_SHIFT) | (unsigned char)digits[0])));
4486                         }
4487                     }
4488                     break;
4489             }
4490 #endif
4491             if (sizeof(unsigned char) <= sizeof(long)) {
4492                 __PYX_VERIFY_RETURN_INT_EXC(unsigned char, long, PyLong_AsLong(x))
4493 #ifdef HAVE_LONG_LONG
4494             } else if (sizeof(unsigned char) <= sizeof(PY_LONG_LONG)) {
4495                 __PYX_VERIFY_RETURN_INT_EXC(unsigned char, PY_LONG_LONG, PyLong_AsLongLong(x))
4496 #endif
4497             }
4498         }
4499         {
4500 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
4501             PyErr_SetString(PyExc_RuntimeError,
4502                             "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
4503 #else
4504             unsigned char val;
4505             PyObject *v = __Pyx_PyNumber_IntOrLong(x);
4506  #if PY_MAJOR_VERSION < 3
4507             if (likely(v) && !PyLong_Check(v)) {
4508                 PyObject *tmp = v;
4509                 v = PyNumber_Long(tmp);
4510                 Py_DECREF(tmp);
4511             }
4512  #endif
4513             if (likely(v)) {
4514                 int one = 1; int is_little = (int)*(unsigned char *)&one;
4515                 unsigned char *bytes = (unsigned char *)&val;
4516                 int ret = _PyLong_AsByteArray((PyLongObject *)v,
4517                                               bytes, sizeof(val),
4518                                               is_little, !is_unsigned);
4519                 Py_DECREF(v);
4520                 if (likely(!ret))
4521                     return val;
4522             }
4523 #endif
4524             return (unsigned char) -1;
4525         }
4526     } else {
4527         unsigned char val;
4528         PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
4529         if (!tmp) return (unsigned char) -1;
4530         val = __Pyx_PyInt_As_unsigned_char(tmp);
4531         Py_DECREF(tmp);
4532         return val;
4533     }
4534 raise_overflow:
4535     PyErr_SetString(PyExc_OverflowError,
4536         "value too large to convert to unsigned char");
4537     return (unsigned char) -1;
4538 raise_neg_overflow:
4539     PyErr_SetString(PyExc_OverflowError,
4540         "can't convert negative value to unsigned char");
4541     return (unsigned char) -1;
4542 }
4543 
4544 /* CIntFromPy */
__Pyx_PyInt_As_size_t(PyObject * x)4545 static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *x) {
4546 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
4547 #pragma GCC diagnostic push
4548 #pragma GCC diagnostic ignored "-Wconversion"
4549 #endif
4550     const size_t neg_one = (size_t) -1, const_zero = (size_t) 0;
4551 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
4552 #pragma GCC diagnostic pop
4553 #endif
4554     const int is_unsigned = neg_one > const_zero;
4555 #if PY_MAJOR_VERSION < 3
4556     if (likely(PyInt_Check(x))) {
4557         if (sizeof(size_t) < sizeof(long)) {
4558             __PYX_VERIFY_RETURN_INT(size_t, long, PyInt_AS_LONG(x))
4559         } else {
4560             long val = PyInt_AS_LONG(x);
4561             if (is_unsigned && unlikely(val < 0)) {
4562                 goto raise_neg_overflow;
4563             }
4564             return (size_t) val;
4565         }
4566     } else
4567 #endif
4568     if (likely(PyLong_Check(x))) {
4569         if (is_unsigned) {
4570 #if CYTHON_USE_PYLONG_INTERNALS
4571             const digit* digits = ((PyLongObject*)x)->ob_digit;
4572             switch (Py_SIZE(x)) {
4573                 case  0: return (size_t) 0;
4574                 case  1: __PYX_VERIFY_RETURN_INT(size_t, digit, digits[0])
4575                 case 2:
4576                     if (8 * sizeof(size_t) > 1 * PyLong_SHIFT) {
4577                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
4578                             __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4579                         } else if (8 * sizeof(size_t) >= 2 * PyLong_SHIFT) {
4580                             return (size_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
4581                         }
4582                     }
4583                     break;
4584                 case 3:
4585                     if (8 * sizeof(size_t) > 2 * PyLong_SHIFT) {
4586                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
4587                             __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4588                         } else if (8 * sizeof(size_t) >= 3 * PyLong_SHIFT) {
4589                             return (size_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
4590                         }
4591                     }
4592                     break;
4593                 case 4:
4594                     if (8 * sizeof(size_t) > 3 * PyLong_SHIFT) {
4595                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
4596                             __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4597                         } else if (8 * sizeof(size_t) >= 4 * PyLong_SHIFT) {
4598                             return (size_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
4599                         }
4600                     }
4601                     break;
4602             }
4603 #endif
4604 #if CYTHON_COMPILING_IN_CPYTHON
4605             if (unlikely(Py_SIZE(x) < 0)) {
4606                 goto raise_neg_overflow;
4607             }
4608 #else
4609             {
4610                 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
4611                 if (unlikely(result < 0))
4612                     return (size_t) -1;
4613                 if (unlikely(result == 1))
4614                     goto raise_neg_overflow;
4615             }
4616 #endif
4617             if (sizeof(size_t) <= sizeof(unsigned long)) {
4618                 __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned long, PyLong_AsUnsignedLong(x))
4619 #ifdef HAVE_LONG_LONG
4620             } else if (sizeof(size_t) <= sizeof(unsigned PY_LONG_LONG)) {
4621                 __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
4622 #endif
4623             }
4624         } else {
4625 #if CYTHON_USE_PYLONG_INTERNALS
4626             const digit* digits = ((PyLongObject*)x)->ob_digit;
4627             switch (Py_SIZE(x)) {
4628                 case  0: return (size_t) 0;
4629                 case -1: __PYX_VERIFY_RETURN_INT(size_t, sdigit, (sdigit) (-(sdigit)digits[0]))
4630                 case  1: __PYX_VERIFY_RETURN_INT(size_t,  digit, +digits[0])
4631                 case -2:
4632                     if (8 * sizeof(size_t) - 1 > 1 * PyLong_SHIFT) {
4633                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
4634                             __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4635                         } else if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
4636                             return (size_t) (((size_t)-1)*(((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
4637                         }
4638                     }
4639                     break;
4640                 case 2:
4641                     if (8 * sizeof(size_t) > 1 * PyLong_SHIFT) {
4642                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
4643                             __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4644                         } else if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
4645                             return (size_t) ((((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
4646                         }
4647                     }
4648                     break;
4649                 case -3:
4650                     if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
4651                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
4652                             __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4653                         } else if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
4654                             return (size_t) (((size_t)-1)*(((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
4655                         }
4656                     }
4657                     break;
4658                 case 3:
4659                     if (8 * sizeof(size_t) > 2 * PyLong_SHIFT) {
4660                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
4661                             __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4662                         } else if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
4663                             return (size_t) ((((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
4664                         }
4665                     }
4666                     break;
4667                 case -4:
4668                     if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
4669                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
4670                             __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4671                         } else if (8 * sizeof(size_t) - 1 > 4 * PyLong_SHIFT) {
4672                             return (size_t) (((size_t)-1)*(((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
4673                         }
4674                     }
4675                     break;
4676                 case 4:
4677                     if (8 * sizeof(size_t) > 3 * PyLong_SHIFT) {
4678                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
4679                             __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4680                         } else if (8 * sizeof(size_t) - 1 > 4 * PyLong_SHIFT) {
4681                             return (size_t) ((((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
4682                         }
4683                     }
4684                     break;
4685             }
4686 #endif
4687             if (sizeof(size_t) <= sizeof(long)) {
4688                 __PYX_VERIFY_RETURN_INT_EXC(size_t, long, PyLong_AsLong(x))
4689 #ifdef HAVE_LONG_LONG
4690             } else if (sizeof(size_t) <= sizeof(PY_LONG_LONG)) {
4691                 __PYX_VERIFY_RETURN_INT_EXC(size_t, PY_LONG_LONG, PyLong_AsLongLong(x))
4692 #endif
4693             }
4694         }
4695         {
4696 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
4697             PyErr_SetString(PyExc_RuntimeError,
4698                             "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
4699 #else
4700             size_t val;
4701             PyObject *v = __Pyx_PyNumber_IntOrLong(x);
4702  #if PY_MAJOR_VERSION < 3
4703             if (likely(v) && !PyLong_Check(v)) {
4704                 PyObject *tmp = v;
4705                 v = PyNumber_Long(tmp);
4706                 Py_DECREF(tmp);
4707             }
4708  #endif
4709             if (likely(v)) {
4710                 int one = 1; int is_little = (int)*(unsigned char *)&one;
4711                 unsigned char *bytes = (unsigned char *)&val;
4712                 int ret = _PyLong_AsByteArray((PyLongObject *)v,
4713                                               bytes, sizeof(val),
4714                                               is_little, !is_unsigned);
4715                 Py_DECREF(v);
4716                 if (likely(!ret))
4717                     return val;
4718             }
4719 #endif
4720             return (size_t) -1;
4721         }
4722     } else {
4723         size_t val;
4724         PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
4725         if (!tmp) return (size_t) -1;
4726         val = __Pyx_PyInt_As_size_t(tmp);
4727         Py_DECREF(tmp);
4728         return val;
4729     }
4730 raise_overflow:
4731     PyErr_SetString(PyExc_OverflowError,
4732         "value too large to convert to size_t");
4733     return (size_t) -1;
4734 raise_neg_overflow:
4735     PyErr_SetString(PyExc_OverflowError,
4736         "can't convert negative value to size_t");
4737     return (size_t) -1;
4738 }
4739 
4740 /* CIntToPy */
__Pyx_PyInt_From_long(long value)4741 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
4742 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
4743 #pragma GCC diagnostic push
4744 #pragma GCC diagnostic ignored "-Wconversion"
4745 #endif
4746     const long neg_one = (long) -1, const_zero = (long) 0;
4747 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
4748 #pragma GCC diagnostic pop
4749 #endif
4750     const int is_unsigned = neg_one > const_zero;
4751     if (is_unsigned) {
4752         if (sizeof(long) < sizeof(long)) {
4753             return PyInt_FromLong((long) value);
4754         } else if (sizeof(long) <= sizeof(unsigned long)) {
4755             return PyLong_FromUnsignedLong((unsigned long) value);
4756 #ifdef HAVE_LONG_LONG
4757         } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
4758             return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
4759 #endif
4760         }
4761     } else {
4762         if (sizeof(long) <= sizeof(long)) {
4763             return PyInt_FromLong((long) value);
4764 #ifdef HAVE_LONG_LONG
4765         } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
4766             return PyLong_FromLongLong((PY_LONG_LONG) value);
4767 #endif
4768         }
4769     }
4770     {
4771         int one = 1; int little = (int)*(unsigned char *)&one;
4772         unsigned char *bytes = (unsigned char *)&value;
4773         return _PyLong_FromByteArray(bytes, sizeof(long),
4774                                      little, !is_unsigned);
4775     }
4776 }
4777 
4778 /* CIntToPy */
__Pyx_PyInt_From_int(int value)4779 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
4780 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
4781 #pragma GCC diagnostic push
4782 #pragma GCC diagnostic ignored "-Wconversion"
4783 #endif
4784     const int neg_one = (int) -1, const_zero = (int) 0;
4785 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
4786 #pragma GCC diagnostic pop
4787 #endif
4788     const int is_unsigned = neg_one > const_zero;
4789     if (is_unsigned) {
4790         if (sizeof(int) < sizeof(long)) {
4791             return PyInt_FromLong((long) value);
4792         } else if (sizeof(int) <= sizeof(unsigned long)) {
4793             return PyLong_FromUnsignedLong((unsigned long) value);
4794 #ifdef HAVE_LONG_LONG
4795         } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
4796             return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
4797 #endif
4798         }
4799     } else {
4800         if (sizeof(int) <= sizeof(long)) {
4801             return PyInt_FromLong((long) value);
4802 #ifdef HAVE_LONG_LONG
4803         } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
4804             return PyLong_FromLongLong((PY_LONG_LONG) value);
4805 #endif
4806         }
4807     }
4808     {
4809         int one = 1; int little = (int)*(unsigned char *)&one;
4810         unsigned char *bytes = (unsigned char *)&value;
4811         return _PyLong_FromByteArray(bytes, sizeof(int),
4812                                      little, !is_unsigned);
4813     }
4814 }
4815 
4816 /* CIntToPy */
__Pyx_PyInt_From_unsigned_long(unsigned long value)4817 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_long(unsigned long value) {
4818 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
4819 #pragma GCC diagnostic push
4820 #pragma GCC diagnostic ignored "-Wconversion"
4821 #endif
4822     const unsigned long neg_one = (unsigned long) -1, const_zero = (unsigned long) 0;
4823 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
4824 #pragma GCC diagnostic pop
4825 #endif
4826     const int is_unsigned = neg_one > const_zero;
4827     if (is_unsigned) {
4828         if (sizeof(unsigned long) < sizeof(long)) {
4829             return PyInt_FromLong((long) value);
4830         } else if (sizeof(unsigned long) <= sizeof(unsigned long)) {
4831             return PyLong_FromUnsignedLong((unsigned long) value);
4832 #ifdef HAVE_LONG_LONG
4833         } else if (sizeof(unsigned long) <= sizeof(unsigned PY_LONG_LONG)) {
4834             return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
4835 #endif
4836         }
4837     } else {
4838         if (sizeof(unsigned long) <= sizeof(long)) {
4839             return PyInt_FromLong((long) value);
4840 #ifdef HAVE_LONG_LONG
4841         } else if (sizeof(unsigned long) <= sizeof(PY_LONG_LONG)) {
4842             return PyLong_FromLongLong((PY_LONG_LONG) value);
4843 #endif
4844         }
4845     }
4846     {
4847         int one = 1; int little = (int)*(unsigned char *)&one;
4848         unsigned char *bytes = (unsigned char *)&value;
4849         return _PyLong_FromByteArray(bytes, sizeof(unsigned long),
4850                                      little, !is_unsigned);
4851     }
4852 }
4853 
4854 /* CIntToPy */
__Pyx_PyInt_From_uint32_t(uint32_t value)4855 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_uint32_t(uint32_t value) {
4856 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
4857 #pragma GCC diagnostic push
4858 #pragma GCC diagnostic ignored "-Wconversion"
4859 #endif
4860     const uint32_t neg_one = (uint32_t) -1, const_zero = (uint32_t) 0;
4861 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
4862 #pragma GCC diagnostic pop
4863 #endif
4864     const int is_unsigned = neg_one > const_zero;
4865     if (is_unsigned) {
4866         if (sizeof(uint32_t) < sizeof(long)) {
4867             return PyInt_FromLong((long) value);
4868         } else if (sizeof(uint32_t) <= sizeof(unsigned long)) {
4869             return PyLong_FromUnsignedLong((unsigned long) value);
4870 #ifdef HAVE_LONG_LONG
4871         } else if (sizeof(uint32_t) <= sizeof(unsigned PY_LONG_LONG)) {
4872             return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
4873 #endif
4874         }
4875     } else {
4876         if (sizeof(uint32_t) <= sizeof(long)) {
4877             return PyInt_FromLong((long) value);
4878 #ifdef HAVE_LONG_LONG
4879         } else if (sizeof(uint32_t) <= sizeof(PY_LONG_LONG)) {
4880             return PyLong_FromLongLong((PY_LONG_LONG) value);
4881 #endif
4882         }
4883     }
4884     {
4885         int one = 1; int little = (int)*(unsigned char *)&one;
4886         unsigned char *bytes = (unsigned char *)&value;
4887         return _PyLong_FromByteArray(bytes, sizeof(uint32_t),
4888                                      little, !is_unsigned);
4889     }
4890 }
4891 
4892 /* CIntFromPy */
__Pyx_PyInt_As_long(PyObject * x)4893 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
4894 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
4895 #pragma GCC diagnostic push
4896 #pragma GCC diagnostic ignored "-Wconversion"
4897 #endif
4898     const long neg_one = (long) -1, const_zero = (long) 0;
4899 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
4900 #pragma GCC diagnostic pop
4901 #endif
4902     const int is_unsigned = neg_one > const_zero;
4903 #if PY_MAJOR_VERSION < 3
4904     if (likely(PyInt_Check(x))) {
4905         if (sizeof(long) < sizeof(long)) {
4906             __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
4907         } else {
4908             long val = PyInt_AS_LONG(x);
4909             if (is_unsigned && unlikely(val < 0)) {
4910                 goto raise_neg_overflow;
4911             }
4912             return (long) val;
4913         }
4914     } else
4915 #endif
4916     if (likely(PyLong_Check(x))) {
4917         if (is_unsigned) {
4918 #if CYTHON_USE_PYLONG_INTERNALS
4919             const digit* digits = ((PyLongObject*)x)->ob_digit;
4920             switch (Py_SIZE(x)) {
4921                 case  0: return (long) 0;
4922                 case  1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
4923                 case 2:
4924                     if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
4925                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
4926                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4927                         } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
4928                             return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
4929                         }
4930                     }
4931                     break;
4932                 case 3:
4933                     if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
4934                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
4935                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4936                         } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
4937                             return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
4938                         }
4939                     }
4940                     break;
4941                 case 4:
4942                     if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
4943                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
4944                             __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])))
4945                         } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
4946                             return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
4947                         }
4948                     }
4949                     break;
4950             }
4951 #endif
4952 #if CYTHON_COMPILING_IN_CPYTHON
4953             if (unlikely(Py_SIZE(x) < 0)) {
4954                 goto raise_neg_overflow;
4955             }
4956 #else
4957             {
4958                 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
4959                 if (unlikely(result < 0))
4960                     return (long) -1;
4961                 if (unlikely(result == 1))
4962                     goto raise_neg_overflow;
4963             }
4964 #endif
4965             if (sizeof(long) <= sizeof(unsigned long)) {
4966                 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
4967 #ifdef HAVE_LONG_LONG
4968             } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
4969                 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
4970 #endif
4971             }
4972         } else {
4973 #if CYTHON_USE_PYLONG_INTERNALS
4974             const digit* digits = ((PyLongObject*)x)->ob_digit;
4975             switch (Py_SIZE(x)) {
4976                 case  0: return (long) 0;
4977                 case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
4978                 case  1: __PYX_VERIFY_RETURN_INT(long,  digit, +digits[0])
4979                 case -2:
4980                     if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
4981                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
4982                             __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4983                         } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
4984                             return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
4985                         }
4986                     }
4987                     break;
4988                 case 2:
4989                     if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
4990                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
4991                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4992                         } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
4993                             return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
4994                         }
4995                     }
4996                     break;
4997                 case -3:
4998                     if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
4999                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
5000                             __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
5001                         } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
5002                             return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
5003                         }
5004                     }
5005                     break;
5006                 case 3:
5007                     if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
5008                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
5009                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
5010                         } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
5011                             return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
5012                         }
5013                     }
5014                     break;
5015                 case -4:
5016                     if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
5017                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
5018                             __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])))
5019                         } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
5020                             return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
5021                         }
5022                     }
5023                     break;
5024                 case 4:
5025                     if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
5026                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
5027                             __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])))
5028                         } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
5029                             return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
5030                         }
5031                     }
5032                     break;
5033             }
5034 #endif
5035             if (sizeof(long) <= sizeof(long)) {
5036                 __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
5037 #ifdef HAVE_LONG_LONG
5038             } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
5039                 __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
5040 #endif
5041             }
5042         }
5043         {
5044 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
5045             PyErr_SetString(PyExc_RuntimeError,
5046                             "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
5047 #else
5048             long val;
5049             PyObject *v = __Pyx_PyNumber_IntOrLong(x);
5050  #if PY_MAJOR_VERSION < 3
5051             if (likely(v) && !PyLong_Check(v)) {
5052                 PyObject *tmp = v;
5053                 v = PyNumber_Long(tmp);
5054                 Py_DECREF(tmp);
5055             }
5056  #endif
5057             if (likely(v)) {
5058                 int one = 1; int is_little = (int)*(unsigned char *)&one;
5059                 unsigned char *bytes = (unsigned char *)&val;
5060                 int ret = _PyLong_AsByteArray((PyLongObject *)v,
5061                                               bytes, sizeof(val),
5062                                               is_little, !is_unsigned);
5063                 Py_DECREF(v);
5064                 if (likely(!ret))
5065                     return val;
5066             }
5067 #endif
5068             return (long) -1;
5069         }
5070     } else {
5071         long val;
5072         PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
5073         if (!tmp) return (long) -1;
5074         val = __Pyx_PyInt_As_long(tmp);
5075         Py_DECREF(tmp);
5076         return val;
5077     }
5078 raise_overflow:
5079     PyErr_SetString(PyExc_OverflowError,
5080         "value too large to convert to long");
5081     return (long) -1;
5082 raise_neg_overflow:
5083     PyErr_SetString(PyExc_OverflowError,
5084         "can't convert negative value to long");
5085     return (long) -1;
5086 }
5087 
5088 /* FastTypeChecks */
5089 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_InBases(PyTypeObject * a,PyTypeObject * b)5090 static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
5091     while (a) {
5092         a = a->tp_base;
5093         if (a == b)
5094             return 1;
5095     }
5096     return b == &PyBaseObject_Type;
5097 }
__Pyx_IsSubtype(PyTypeObject * a,PyTypeObject * b)5098 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
5099     PyObject *mro;
5100     if (a == b) return 1;
5101     mro = a->tp_mro;
5102     if (likely(mro)) {
5103         Py_ssize_t i, n;
5104         n = PyTuple_GET_SIZE(mro);
5105         for (i = 0; i < n; i++) {
5106             if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
5107                 return 1;
5108         }
5109         return 0;
5110     }
5111     return __Pyx_InBases(a, b);
5112 }
5113 #if PY_MAJOR_VERSION == 2
__Pyx_inner_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)5114 static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
5115     PyObject *exception, *value, *tb;
5116     int res;
5117     __Pyx_PyThreadState_declare
5118     __Pyx_PyThreadState_assign
5119     __Pyx_ErrFetch(&exception, &value, &tb);
5120     res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
5121     if (unlikely(res == -1)) {
5122         PyErr_WriteUnraisable(err);
5123         res = 0;
5124     }
5125     if (!res) {
5126         res = PyObject_IsSubclass(err, exc_type2);
5127         if (unlikely(res == -1)) {
5128             PyErr_WriteUnraisable(err);
5129             res = 0;
5130         }
5131     }
5132     __Pyx_ErrRestore(exception, value, tb);
5133     return res;
5134 }
5135 #else
__Pyx_inner_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)5136 static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
5137     int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
5138     if (!res) {
5139         res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
5140     }
5141     return res;
5142 }
5143 #endif
__Pyx_PyErr_GivenExceptionMatchesTuple(PyObject * exc_type,PyObject * tuple)5144 static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
5145     Py_ssize_t i, n;
5146     assert(PyExceptionClass_Check(exc_type));
5147     n = PyTuple_GET_SIZE(tuple);
5148 #if PY_MAJOR_VERSION >= 3
5149     for (i=0; i<n; i++) {
5150         if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
5151     }
5152 #endif
5153     for (i=0; i<n; i++) {
5154         PyObject *t = PyTuple_GET_ITEM(tuple, i);
5155         #if PY_MAJOR_VERSION < 3
5156         if (likely(exc_type == t)) return 1;
5157         #endif
5158         if (likely(PyExceptionClass_Check(t))) {
5159             if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
5160         } else {
5161         }
5162     }
5163     return 0;
5164 }
__Pyx_PyErr_GivenExceptionMatches(PyObject * err,PyObject * exc_type)5165 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
5166     if (likely(err == exc_type)) return 1;
5167     if (likely(PyExceptionClass_Check(err))) {
5168         if (likely(PyExceptionClass_Check(exc_type))) {
5169             return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
5170         } else if (likely(PyTuple_Check(exc_type))) {
5171             return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
5172         } else {
5173         }
5174     }
5175     return PyErr_GivenExceptionMatches(err, exc_type);
5176 }
__Pyx_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)5177 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
5178     assert(PyExceptionClass_Check(exc_type1));
5179     assert(PyExceptionClass_Check(exc_type2));
5180     if (likely(err == exc_type1 || err == exc_type2)) return 1;
5181     if (likely(PyExceptionClass_Check(err))) {
5182         return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
5183     }
5184     return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
5185 }
5186 #endif
5187 
5188 /* CheckBinaryVersion */
__Pyx_check_binary_version(void)5189 static int __Pyx_check_binary_version(void) {
5190     char ctversion[4], rtversion[4];
5191     PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
5192     PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
5193     if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
5194         char message[200];
5195         PyOS_snprintf(message, sizeof(message),
5196                       "compiletime version %s of module '%.100s' "
5197                       "does not match runtime version %s",
5198                       ctversion, __Pyx_MODULE_NAME, rtversion);
5199         return PyErr_WarnEx(NULL, message, 1);
5200     }
5201     return 0;
5202 }
5203 
5204 /* InitStrings */
__Pyx_InitStrings(__Pyx_StringTabEntry * t)5205 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
5206     while (t->p) {
5207         #if PY_MAJOR_VERSION < 3
5208         if (t->is_unicode) {
5209             *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
5210         } else if (t->intern) {
5211             *t->p = PyString_InternFromString(t->s);
5212         } else {
5213             *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
5214         }
5215         #else
5216         if (t->is_unicode | t->is_str) {
5217             if (t->intern) {
5218                 *t->p = PyUnicode_InternFromString(t->s);
5219             } else if (t->encoding) {
5220                 *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
5221             } else {
5222                 *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
5223             }
5224         } else {
5225             *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
5226         }
5227         #endif
5228         if (!*t->p)
5229             return -1;
5230         if (PyObject_Hash(*t->p) == -1)
5231             return -1;
5232         ++t;
5233     }
5234     return 0;
5235 }
5236 
__Pyx_PyUnicode_FromString(const char * c_str)5237 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
5238     return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
5239 }
__Pyx_PyObject_AsString(PyObject * o)5240 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
5241     Py_ssize_t ignore;
5242     return __Pyx_PyObject_AsStringAndSize(o, &ignore);
5243 }
5244 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
5245 #if !CYTHON_PEP393_ENABLED
__Pyx_PyUnicode_AsStringAndSize(PyObject * o,Py_ssize_t * length)5246 static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
5247     char* defenc_c;
5248     PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
5249     if (!defenc) return NULL;
5250     defenc_c = PyBytes_AS_STRING(defenc);
5251 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
5252     {
5253         char* end = defenc_c + PyBytes_GET_SIZE(defenc);
5254         char* c;
5255         for (c = defenc_c; c < end; c++) {
5256             if ((unsigned char) (*c) >= 128) {
5257                 PyUnicode_AsASCIIString(o);
5258                 return NULL;
5259             }
5260         }
5261     }
5262 #endif
5263     *length = PyBytes_GET_SIZE(defenc);
5264     return defenc_c;
5265 }
5266 #else
__Pyx_PyUnicode_AsStringAndSize(PyObject * o,Py_ssize_t * length)5267 static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
5268     if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
5269 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
5270     if (likely(PyUnicode_IS_ASCII(o))) {
5271         *length = PyUnicode_GET_LENGTH(o);
5272         return PyUnicode_AsUTF8(o);
5273     } else {
5274         PyUnicode_AsASCIIString(o);
5275         return NULL;
5276     }
5277 #else
5278     return PyUnicode_AsUTF8AndSize(o, length);
5279 #endif
5280 }
5281 #endif
5282 #endif
__Pyx_PyObject_AsStringAndSize(PyObject * o,Py_ssize_t * length)5283 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
5284 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
5285     if (
5286 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
5287             __Pyx_sys_getdefaultencoding_not_ascii &&
5288 #endif
5289             PyUnicode_Check(o)) {
5290         return __Pyx_PyUnicode_AsStringAndSize(o, length);
5291     } else
5292 #endif
5293 #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
5294     if (PyByteArray_Check(o)) {
5295         *length = PyByteArray_GET_SIZE(o);
5296         return PyByteArray_AS_STRING(o);
5297     } else
5298 #endif
5299     {
5300         char* result;
5301         int r = PyBytes_AsStringAndSize(o, &result, length);
5302         if (unlikely(r < 0)) {
5303             return NULL;
5304         } else {
5305             return result;
5306         }
5307     }
5308 }
__Pyx_PyObject_IsTrue(PyObject * x)5309 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
5310    int is_true = x == Py_True;
5311    if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
5312    else return PyObject_IsTrue(x);
5313 }
__Pyx_PyObject_IsTrueAndDecref(PyObject * x)5314 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
5315     int retval;
5316     if (unlikely(!x)) return -1;
5317     retval = __Pyx_PyObject_IsTrue(x);
5318     Py_DECREF(x);
5319     return retval;
5320 }
__Pyx_PyNumber_IntOrLongWrongResultType(PyObject * result,const char * type_name)5321 static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
5322 #if PY_MAJOR_VERSION >= 3
5323     if (PyLong_Check(result)) {
5324         if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
5325                 "__int__ returned non-int (type %.200s).  "
5326                 "The ability to return an instance of a strict subclass of int "
5327                 "is deprecated, and may be removed in a future version of Python.",
5328                 Py_TYPE(result)->tp_name)) {
5329             Py_DECREF(result);
5330             return NULL;
5331         }
5332         return result;
5333     }
5334 #endif
5335     PyErr_Format(PyExc_TypeError,
5336                  "__%.4s__ returned non-%.4s (type %.200s)",
5337                  type_name, type_name, Py_TYPE(result)->tp_name);
5338     Py_DECREF(result);
5339     return NULL;
5340 }
__Pyx_PyNumber_IntOrLong(PyObject * x)5341 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
5342 #if CYTHON_USE_TYPE_SLOTS
5343   PyNumberMethods *m;
5344 #endif
5345   const char *name = NULL;
5346   PyObject *res = NULL;
5347 #if PY_MAJOR_VERSION < 3
5348   if (likely(PyInt_Check(x) || PyLong_Check(x)))
5349 #else
5350   if (likely(PyLong_Check(x)))
5351 #endif
5352     return __Pyx_NewRef(x);
5353 #if CYTHON_USE_TYPE_SLOTS
5354   m = Py_TYPE(x)->tp_as_number;
5355   #if PY_MAJOR_VERSION < 3
5356   if (m && m->nb_int) {
5357     name = "int";
5358     res = m->nb_int(x);
5359   }
5360   else if (m && m->nb_long) {
5361     name = "long";
5362     res = m->nb_long(x);
5363   }
5364   #else
5365   if (likely(m && m->nb_int)) {
5366     name = "int";
5367     res = m->nb_int(x);
5368   }
5369   #endif
5370 #else
5371   if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
5372     res = PyNumber_Int(x);
5373   }
5374 #endif
5375   if (likely(res)) {
5376 #if PY_MAJOR_VERSION < 3
5377     if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
5378 #else
5379     if (unlikely(!PyLong_CheckExact(res))) {
5380 #endif
5381         return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
5382     }
5383   }
5384   else if (!PyErr_Occurred()) {
5385     PyErr_SetString(PyExc_TypeError,
5386                     "an integer is required");
5387   }
5388   return res;
5389 }
5390 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
5391   Py_ssize_t ival;
5392   PyObject *x;
5393 #if PY_MAJOR_VERSION < 3
5394   if (likely(PyInt_CheckExact(b))) {
5395     if (sizeof(Py_ssize_t) >= sizeof(long))
5396         return PyInt_AS_LONG(b);
5397     else
5398         return PyInt_AsSsize_t(b);
5399   }
5400 #endif
5401   if (likely(PyLong_CheckExact(b))) {
5402     #if CYTHON_USE_PYLONG_INTERNALS
5403     const digit* digits = ((PyLongObject*)b)->ob_digit;
5404     const Py_ssize_t size = Py_SIZE(b);
5405     if (likely(__Pyx_sst_abs(size) <= 1)) {
5406         ival = likely(size) ? digits[0] : 0;
5407         if (size == -1) ival = -ival;
5408         return ival;
5409     } else {
5410       switch (size) {
5411          case 2:
5412            if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
5413              return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
5414            }
5415            break;
5416          case -2:
5417            if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
5418              return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
5419            }
5420            break;
5421          case 3:
5422            if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
5423              return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
5424            }
5425            break;
5426          case -3:
5427            if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
5428              return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
5429            }
5430            break;
5431          case 4:
5432            if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
5433              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]));
5434            }
5435            break;
5436          case -4:
5437            if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
5438              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]));
5439            }
5440            break;
5441       }
5442     }
5443     #endif
5444     return PyLong_AsSsize_t(b);
5445   }
5446   x = PyNumber_Index(b);
5447   if (!x) return -1;
5448   ival = PyInt_AsSsize_t(x);
5449   Py_DECREF(x);
5450   return ival;
5451 }
5452 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
5453   return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
5454 }
5455 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
5456     return PyInt_FromSize_t(ival);
5457 }
5458 
5459 
5460 #endif /* Py_PYTHON_H */
5461