1 /* Generated by Cython 0.29.21 */
2 
3 #define PY_SSIZE_T_CLEAN
4 #include "Python.h"
5 #ifndef Py_PYTHON_H
6     #error Python headers needed to compile C extensions, please install development version of Python.
7 #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
8     #error Cython requires Python 2.6+ or Python 3.3+.
9 #else
10 #define CYTHON_ABI "0_29_21"
11 #define CYTHON_HEX_VERSION 0x001D15F0
12 #define CYTHON_FUTURE_DIVISION 1
13 #include <stddef.h>
14 #ifndef offsetof
15   #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
16 #endif
17 #if !defined(WIN32) && !defined(MS_WINDOWS)
18   #ifndef __stdcall
19     #define __stdcall
20   #endif
21   #ifndef __cdecl
22     #define __cdecl
23   #endif
24   #ifndef __fastcall
25     #define __fastcall
26   #endif
27 #endif
28 #ifndef DL_IMPORT
29   #define DL_IMPORT(t) t
30 #endif
31 #ifndef DL_EXPORT
32   #define DL_EXPORT(t) t
33 #endif
34 #define __PYX_COMMA ,
35 #ifndef HAVE_LONG_LONG
36   #if PY_VERSION_HEX >= 0x02070000
37     #define HAVE_LONG_LONG
38   #endif
39 #endif
40 #ifndef PY_LONG_LONG
41   #define PY_LONG_LONG LONG_LONG
42 #endif
43 #ifndef Py_HUGE_VAL
44   #define Py_HUGE_VAL HUGE_VAL
45 #endif
46 #ifdef PYPY_VERSION
47   #define CYTHON_COMPILING_IN_PYPY 1
48   #define CYTHON_COMPILING_IN_PYSTON 0
49   #define CYTHON_COMPILING_IN_CPYTHON 0
50   #undef CYTHON_USE_TYPE_SLOTS
51   #define CYTHON_USE_TYPE_SLOTS 0
52   #undef CYTHON_USE_PYTYPE_LOOKUP
53   #define CYTHON_USE_PYTYPE_LOOKUP 0
54   #if PY_VERSION_HEX < 0x03050000
55     #undef CYTHON_USE_ASYNC_SLOTS
56     #define CYTHON_USE_ASYNC_SLOTS 0
57   #elif !defined(CYTHON_USE_ASYNC_SLOTS)
58     #define CYTHON_USE_ASYNC_SLOTS 1
59   #endif
60   #undef CYTHON_USE_PYLIST_INTERNALS
61   #define CYTHON_USE_PYLIST_INTERNALS 0
62   #undef CYTHON_USE_UNICODE_INTERNALS
63   #define CYTHON_USE_UNICODE_INTERNALS 0
64   #undef CYTHON_USE_UNICODE_WRITER
65   #define CYTHON_USE_UNICODE_WRITER 0
66   #undef CYTHON_USE_PYLONG_INTERNALS
67   #define CYTHON_USE_PYLONG_INTERNALS 0
68   #undef CYTHON_AVOID_BORROWED_REFS
69   #define CYTHON_AVOID_BORROWED_REFS 1
70   #undef CYTHON_ASSUME_SAFE_MACROS
71   #define CYTHON_ASSUME_SAFE_MACROS 0
72   #undef CYTHON_UNPACK_METHODS
73   #define CYTHON_UNPACK_METHODS 0
74   #undef CYTHON_FAST_THREAD_STATE
75   #define CYTHON_FAST_THREAD_STATE 0
76   #undef CYTHON_FAST_PYCALL
77   #define CYTHON_FAST_PYCALL 0
78   #undef CYTHON_PEP489_MULTI_PHASE_INIT
79   #define CYTHON_PEP489_MULTI_PHASE_INIT 0
80   #undef CYTHON_USE_TP_FINALIZE
81   #define CYTHON_USE_TP_FINALIZE 0
82   #undef CYTHON_USE_DICT_VERSIONS
83   #define CYTHON_USE_DICT_VERSIONS 0
84   #undef CYTHON_USE_EXC_INFO_STACK
85   #define CYTHON_USE_EXC_INFO_STACK 0
86 #elif defined(PYSTON_VERSION)
87   #define CYTHON_COMPILING_IN_PYPY 0
88   #define CYTHON_COMPILING_IN_PYSTON 1
89   #define CYTHON_COMPILING_IN_CPYTHON 0
90   #ifndef CYTHON_USE_TYPE_SLOTS
91     #define CYTHON_USE_TYPE_SLOTS 1
92   #endif
93   #undef CYTHON_USE_PYTYPE_LOOKUP
94   #define CYTHON_USE_PYTYPE_LOOKUP 0
95   #undef CYTHON_USE_ASYNC_SLOTS
96   #define CYTHON_USE_ASYNC_SLOTS 0
97   #undef CYTHON_USE_PYLIST_INTERNALS
98   #define CYTHON_USE_PYLIST_INTERNALS 0
99   #ifndef CYTHON_USE_UNICODE_INTERNALS
100     #define CYTHON_USE_UNICODE_INTERNALS 1
101   #endif
102   #undef CYTHON_USE_UNICODE_WRITER
103   #define CYTHON_USE_UNICODE_WRITER 0
104   #undef CYTHON_USE_PYLONG_INTERNALS
105   #define CYTHON_USE_PYLONG_INTERNALS 0
106   #ifndef CYTHON_AVOID_BORROWED_REFS
107     #define CYTHON_AVOID_BORROWED_REFS 0
108   #endif
109   #ifndef CYTHON_ASSUME_SAFE_MACROS
110     #define CYTHON_ASSUME_SAFE_MACROS 1
111   #endif
112   #ifndef CYTHON_UNPACK_METHODS
113     #define CYTHON_UNPACK_METHODS 1
114   #endif
115   #undef CYTHON_FAST_THREAD_STATE
116   #define CYTHON_FAST_THREAD_STATE 0
117   #undef CYTHON_FAST_PYCALL
118   #define CYTHON_FAST_PYCALL 0
119   #undef CYTHON_PEP489_MULTI_PHASE_INIT
120   #define CYTHON_PEP489_MULTI_PHASE_INIT 0
121   #undef CYTHON_USE_TP_FINALIZE
122   #define CYTHON_USE_TP_FINALIZE 0
123   #undef CYTHON_USE_DICT_VERSIONS
124   #define CYTHON_USE_DICT_VERSIONS 0
125   #undef CYTHON_USE_EXC_INFO_STACK
126   #define CYTHON_USE_EXC_INFO_STACK 0
127 #else
128   #define CYTHON_COMPILING_IN_PYPY 0
129   #define CYTHON_COMPILING_IN_PYSTON 0
130   #define CYTHON_COMPILING_IN_CPYTHON 1
131   #ifndef CYTHON_USE_TYPE_SLOTS
132     #define CYTHON_USE_TYPE_SLOTS 1
133   #endif
134   #if PY_VERSION_HEX < 0x02070000
135     #undef CYTHON_USE_PYTYPE_LOOKUP
136     #define CYTHON_USE_PYTYPE_LOOKUP 0
137   #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
138     #define CYTHON_USE_PYTYPE_LOOKUP 1
139   #endif
140   #if PY_MAJOR_VERSION < 3
141     #undef CYTHON_USE_ASYNC_SLOTS
142     #define CYTHON_USE_ASYNC_SLOTS 0
143   #elif !defined(CYTHON_USE_ASYNC_SLOTS)
144     #define CYTHON_USE_ASYNC_SLOTS 1
145   #endif
146   #if PY_VERSION_HEX < 0x02070000
147     #undef CYTHON_USE_PYLONG_INTERNALS
148     #define CYTHON_USE_PYLONG_INTERNALS 0
149   #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
150     #define CYTHON_USE_PYLONG_INTERNALS 1
151   #endif
152   #ifndef CYTHON_USE_PYLIST_INTERNALS
153     #define CYTHON_USE_PYLIST_INTERNALS 1
154   #endif
155   #ifndef CYTHON_USE_UNICODE_INTERNALS
156     #define CYTHON_USE_UNICODE_INTERNALS 1
157   #endif
158   #if PY_VERSION_HEX < 0x030300F0
159     #undef CYTHON_USE_UNICODE_WRITER
160     #define CYTHON_USE_UNICODE_WRITER 0
161   #elif !defined(CYTHON_USE_UNICODE_WRITER)
162     #define CYTHON_USE_UNICODE_WRITER 1
163   #endif
164   #ifndef CYTHON_AVOID_BORROWED_REFS
165     #define CYTHON_AVOID_BORROWED_REFS 0
166   #endif
167   #ifndef CYTHON_ASSUME_SAFE_MACROS
168     #define CYTHON_ASSUME_SAFE_MACROS 1
169   #endif
170   #ifndef CYTHON_UNPACK_METHODS
171     #define CYTHON_UNPACK_METHODS 1
172   #endif
173   #ifndef CYTHON_FAST_THREAD_STATE
174     #define CYTHON_FAST_THREAD_STATE 1
175   #endif
176   #ifndef CYTHON_FAST_PYCALL
177     #define CYTHON_FAST_PYCALL 1
178   #endif
179   #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
180     #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000)
181   #endif
182   #ifndef CYTHON_USE_TP_FINALIZE
183     #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
184   #endif
185   #ifndef CYTHON_USE_DICT_VERSIONS
186     #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1)
187   #endif
188   #ifndef CYTHON_USE_EXC_INFO_STACK
189     #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3)
190   #endif
191 #endif
192 #if !defined(CYTHON_FAST_PYCCALL)
193 #define CYTHON_FAST_PYCCALL  (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
194 #endif
195 #if CYTHON_USE_PYLONG_INTERNALS
196   #include "longintrepr.h"
197   #undef SHIFT
198   #undef BASE
199   #undef MASK
200   #ifdef SIZEOF_VOID_P
201     enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) };
202   #endif
203 #endif
204 #ifndef __has_attribute
205   #define __has_attribute(x) 0
206 #endif
207 #ifndef __has_cpp_attribute
208   #define __has_cpp_attribute(x) 0
209 #endif
210 #ifndef CYTHON_RESTRICT
211   #if defined(__GNUC__)
212     #define CYTHON_RESTRICT __restrict__
213   #elif defined(_MSC_VER) && _MSC_VER >= 1400
214     #define CYTHON_RESTRICT __restrict
215   #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
216     #define CYTHON_RESTRICT restrict
217   #else
218     #define CYTHON_RESTRICT
219   #endif
220 #endif
221 #ifndef CYTHON_UNUSED
222 # if defined(__GNUC__)
223 #   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
224 #     define CYTHON_UNUSED __attribute__ ((__unused__))
225 #   else
226 #     define CYTHON_UNUSED
227 #   endif
228 # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
229 #   define CYTHON_UNUSED __attribute__ ((__unused__))
230 # else
231 #   define CYTHON_UNUSED
232 # endif
233 #endif
234 #ifndef CYTHON_MAYBE_UNUSED_VAR
235 #  if defined(__cplusplus)
CYTHON_MAYBE_UNUSED_VAR(const T &)236      template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
237 #  else
238 #    define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
239 #  endif
240 #endif
241 #ifndef CYTHON_NCP_UNUSED
242 # if CYTHON_COMPILING_IN_CPYTHON
243 #  define CYTHON_NCP_UNUSED
244 # else
245 #  define CYTHON_NCP_UNUSED CYTHON_UNUSED
246 # endif
247 #endif
248 #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
249 #ifdef _MSC_VER
250     #ifndef _MSC_STDINT_H_
251         #if _MSC_VER < 1300
252            typedef unsigned char     uint8_t;
253            typedef unsigned int      uint32_t;
254         #else
255            typedef unsigned __int8   uint8_t;
256            typedef unsigned __int32  uint32_t;
257         #endif
258     #endif
259 #else
260    #include <stdint.h>
261 #endif
262 #ifndef CYTHON_FALLTHROUGH
263   #if defined(__cplusplus) && __cplusplus >= 201103L
264     #if __has_cpp_attribute(fallthrough)
265       #define CYTHON_FALLTHROUGH [[fallthrough]]
266     #elif __has_cpp_attribute(clang::fallthrough)
267       #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
268     #elif __has_cpp_attribute(gnu::fallthrough)
269       #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
270     #endif
271   #endif
272   #ifndef CYTHON_FALLTHROUGH
273     #if __has_attribute(fallthrough)
274       #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
275     #else
276       #define CYTHON_FALLTHROUGH
277     #endif
278   #endif
279   #if defined(__clang__ ) && defined(__apple_build_version__)
280     #if __apple_build_version__ < 7000000
281       #undef  CYTHON_FALLTHROUGH
282       #define CYTHON_FALLTHROUGH
283     #endif
284   #endif
285 #endif
286 
287 #ifndef CYTHON_INLINE
288   #if defined(__clang__)
289     #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
290   #elif defined(__GNUC__)
291     #define CYTHON_INLINE __inline__
292   #elif defined(_MSC_VER)
293     #define CYTHON_INLINE __inline
294   #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
295     #define CYTHON_INLINE inline
296   #else
297     #define CYTHON_INLINE
298   #endif
299 #endif
300 
301 #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
302   #define Py_OptimizeFlag 0
303 #endif
304 #define __PYX_BUILD_PY_SSIZE_T "n"
305 #define CYTHON_FORMAT_SSIZE_T "z"
306 #if PY_MAJOR_VERSION < 3
307   #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
308   #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
309           PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
310   #define __Pyx_DefaultClassType PyClass_Type
311 #else
312   #define __Pyx_BUILTIN_MODULE_NAME "builtins"
313 #if PY_VERSION_HEX >= 0x030800A4 && PY_VERSION_HEX < 0x030800B2
314   #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
315           PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
316 #else
317   #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
318           PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
319 #endif
320   #define __Pyx_DefaultClassType PyType_Type
321 #endif
322 #ifndef Py_TPFLAGS_CHECKTYPES
323   #define Py_TPFLAGS_CHECKTYPES 0
324 #endif
325 #ifndef Py_TPFLAGS_HAVE_INDEX
326   #define Py_TPFLAGS_HAVE_INDEX 0
327 #endif
328 #ifndef Py_TPFLAGS_HAVE_NEWBUFFER
329   #define Py_TPFLAGS_HAVE_NEWBUFFER 0
330 #endif
331 #ifndef Py_TPFLAGS_HAVE_FINALIZE
332   #define Py_TPFLAGS_HAVE_FINALIZE 0
333 #endif
334 #ifndef METH_STACKLESS
335   #define METH_STACKLESS 0
336 #endif
337 #if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
338   #ifndef METH_FASTCALL
339      #define METH_FASTCALL 0x80
340   #endif
341   typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
342   typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
343                                                           Py_ssize_t nargs, PyObject *kwnames);
344 #else
345   #define __Pyx_PyCFunctionFast _PyCFunctionFast
346   #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
347 #endif
348 #if CYTHON_FAST_PYCCALL
349 #define __Pyx_PyFastCFunction_Check(func)\
350     ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)))))
351 #else
352 #define __Pyx_PyFastCFunction_Check(func) 0
353 #endif
354 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
355   #define PyObject_Malloc(s)   PyMem_Malloc(s)
356   #define PyObject_Free(p)     PyMem_Free(p)
357   #define PyObject_Realloc(p)  PyMem_Realloc(p)
358 #endif
359 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1
360   #define PyMem_RawMalloc(n)           PyMem_Malloc(n)
361   #define PyMem_RawRealloc(p, n)       PyMem_Realloc(p, n)
362   #define PyMem_RawFree(p)             PyMem_Free(p)
363 #endif
364 #if CYTHON_COMPILING_IN_PYSTON
365   #define __Pyx_PyCode_HasFreeVars(co)  PyCode_HasFreeVars(co)
366   #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
367 #else
368   #define __Pyx_PyCode_HasFreeVars(co)  (PyCode_GetNumFree(co) > 0)
369   #define __Pyx_PyFrame_SetLineNumber(frame, lineno)  (frame)->f_lineno = (lineno)
370 #endif
371 #if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
372   #define __Pyx_PyThreadState_Current PyThreadState_GET()
373 #elif PY_VERSION_HEX >= 0x03060000
374   #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
375 #elif PY_VERSION_HEX >= 0x03000000
376   #define __Pyx_PyThreadState_Current PyThreadState_GET()
377 #else
378   #define __Pyx_PyThreadState_Current _PyThreadState_Current
379 #endif
380 #if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
381 #include "pythread.h"
382 #define Py_tss_NEEDS_INIT 0
383 typedef int Py_tss_t;
PyThread_tss_create(Py_tss_t * key)384 static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
385   *key = PyThread_create_key();
386   return 0;
387 }
PyThread_tss_alloc(void)388 static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
389   Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
390   *key = Py_tss_NEEDS_INIT;
391   return key;
392 }
PyThread_tss_free(Py_tss_t * key)393 static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
394   PyObject_Free(key);
395 }
PyThread_tss_is_created(Py_tss_t * key)396 static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
397   return *key != Py_tss_NEEDS_INIT;
398 }
PyThread_tss_delete(Py_tss_t * key)399 static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
400   PyThread_delete_key(*key);
401   *key = Py_tss_NEEDS_INIT;
402 }
PyThread_tss_set(Py_tss_t * key,void * value)403 static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
404   return PyThread_set_key_value(*key, value);
405 }
PyThread_tss_get(Py_tss_t * key)406 static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
407   return PyThread_get_key_value(*key);
408 }
409 #endif
410 #if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
411 #define __Pyx_PyDict_NewPresized(n)  ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
412 #else
413 #define __Pyx_PyDict_NewPresized(n)  PyDict_New()
414 #endif
415 #if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
416   #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
417   #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
418 #else
419   #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
420   #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)
421 #endif
422 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
423 #define __Pyx_PyDict_GetItemStr(dict, name)  _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
424 #else
425 #define __Pyx_PyDict_GetItemStr(dict, name)  PyDict_GetItem(dict, name)
426 #endif
427 #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
428   #define CYTHON_PEP393_ENABLED 1
429   #define __Pyx_PyUnicode_READY(op)       (likely(PyUnicode_IS_READY(op)) ?\
430                                               0 : _PyUnicode_Ready((PyObject *)(op)))
431   #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_LENGTH(u)
432   #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
433   #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u)   PyUnicode_MAX_CHAR_VALUE(u)
434   #define __Pyx_PyUnicode_KIND(u)         PyUnicode_KIND(u)
435   #define __Pyx_PyUnicode_DATA(u)         PyUnicode_DATA(u)
436   #define __Pyx_PyUnicode_READ(k, d, i)   PyUnicode_READ(k, d, i)
437   #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  PyUnicode_WRITE(k, d, i, ch)
438   #if defined(PyUnicode_IS_READY) && defined(PyUnicode_GET_SIZE)
439   #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
440   #else
441   #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != PyUnicode_GET_LENGTH(u))
442   #endif
443 #else
444   #define CYTHON_PEP393_ENABLED 0
445   #define PyUnicode_1BYTE_KIND  1
446   #define PyUnicode_2BYTE_KIND  2
447   #define PyUnicode_4BYTE_KIND  4
448   #define __Pyx_PyUnicode_READY(op)       (0)
449   #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_SIZE(u)
450   #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
451   #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u)   ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
452   #define __Pyx_PyUnicode_KIND(u)         (sizeof(Py_UNICODE))
453   #define __Pyx_PyUnicode_DATA(u)         ((void*)PyUnicode_AS_UNICODE(u))
454   #define __Pyx_PyUnicode_READ(k, d, i)   ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
455   #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
456   #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != PyUnicode_GET_SIZE(u))
457 #endif
458 #if CYTHON_COMPILING_IN_PYPY
459   #define __Pyx_PyUnicode_Concat(a, b)      PyNumber_Add(a, b)
460   #define __Pyx_PyUnicode_ConcatSafe(a, b)  PyNumber_Add(a, b)
461 #else
462   #define __Pyx_PyUnicode_Concat(a, b)      PyUnicode_Concat(a, b)
463   #define __Pyx_PyUnicode_ConcatSafe(a, b)  ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
464       PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
465 #endif
466 #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
467   #define PyUnicode_Contains(u, s)  PySequence_Contains(u, s)
468 #endif
469 #if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
470   #define PyByteArray_Check(obj)  PyObject_TypeCheck(obj, &PyByteArray_Type)
471 #endif
472 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
473   #define PyObject_Format(obj, fmt)  PyObject_CallMethod(obj, "__format__", "O", fmt)
474 #endif
475 #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))
476 #define __Pyx_PyUnicode_FormatSafe(a, b)  ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
477 #if PY_MAJOR_VERSION >= 3
478   #define __Pyx_PyString_Format(a, b)  PyUnicode_Format(a, b)
479 #else
480   #define __Pyx_PyString_Format(a, b)  PyString_Format(a, b)
481 #endif
482 #if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
483   #define PyObject_ASCII(o)            PyObject_Repr(o)
484 #endif
485 #if PY_MAJOR_VERSION >= 3
486   #define PyBaseString_Type            PyUnicode_Type
487   #define PyStringObject               PyUnicodeObject
488   #define PyString_Type                PyUnicode_Type
489   #define PyString_Check               PyUnicode_Check
490   #define PyString_CheckExact          PyUnicode_CheckExact
491 #ifndef PyObject_Unicode
492   #define PyObject_Unicode             PyObject_Str
493 #endif
494 #endif
495 #if PY_MAJOR_VERSION >= 3
496   #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
497   #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
498 #else
499   #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
500   #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
501 #endif
502 #ifndef PySet_CheckExact
503   #define PySet_CheckExact(obj)        (Py_TYPE(obj) == &PySet_Type)
504 #endif
505 #if PY_VERSION_HEX >= 0x030900A4
506   #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt)
507   #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size)
508 #else
509   #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt)
510   #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size)
511 #endif
512 #if CYTHON_ASSUME_SAFE_MACROS
513   #define __Pyx_PySequence_SIZE(seq)  Py_SIZE(seq)
514 #else
515   #define __Pyx_PySequence_SIZE(seq)  PySequence_Size(seq)
516 #endif
517 #if PY_MAJOR_VERSION >= 3
518   #define PyIntObject                  PyLongObject
519   #define PyInt_Type                   PyLong_Type
520   #define PyInt_Check(op)              PyLong_Check(op)
521   #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
522   #define PyInt_FromString             PyLong_FromString
523   #define PyInt_FromUnicode            PyLong_FromUnicode
524   #define PyInt_FromLong               PyLong_FromLong
525   #define PyInt_FromSize_t             PyLong_FromSize_t
526   #define PyInt_FromSsize_t            PyLong_FromSsize_t
527   #define PyInt_AsLong                 PyLong_AsLong
528   #define PyInt_AS_LONG                PyLong_AS_LONG
529   #define PyInt_AsSsize_t              PyLong_AsSsize_t
530   #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
531   #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
532   #define PyNumber_Int                 PyNumber_Long
533 #endif
534 #if PY_MAJOR_VERSION >= 3
535   #define PyBoolObject                 PyLongObject
536 #endif
537 #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
538   #ifndef PyUnicode_InternFromString
539     #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
540   #endif
541 #endif
542 #if PY_VERSION_HEX < 0x030200A4
543   typedef long Py_hash_t;
544   #define __Pyx_PyInt_FromHash_t PyInt_FromLong
545   #define __Pyx_PyInt_AsHash_t   PyInt_AsLong
546 #else
547   #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
548   #define __Pyx_PyInt_AsHash_t   PyInt_AsSsize_t
549 #endif
550 #if PY_MAJOR_VERSION >= 3
551   #define __Pyx_PyMethod_New(func, self, klass) ((self) ? ((void)(klass), PyMethod_New(func, self)) : __Pyx_NewRef(func))
552 #else
553   #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
554 #endif
555 #if CYTHON_USE_ASYNC_SLOTS
556   #if PY_VERSION_HEX >= 0x030500B1
557     #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
558     #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
559   #else
560     #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
561   #endif
562 #else
563   #define __Pyx_PyType_AsAsync(obj) NULL
564 #endif
565 #ifndef __Pyx_PyAsyncMethodsStruct
566     typedef struct {
567         unaryfunc am_await;
568         unaryfunc am_aiter;
569         unaryfunc am_anext;
570     } __Pyx_PyAsyncMethodsStruct;
571 #endif
572 
573 #if defined(WIN32) || defined(MS_WINDOWS)
574   #define _USE_MATH_DEFINES
575 #endif
576 #include <math.h>
577 #ifdef NAN
578 #define __PYX_NAN() ((float) NAN)
579 #else
__PYX_NAN()580 static CYTHON_INLINE float __PYX_NAN() {
581   float value;
582   memset(&value, 0xFF, sizeof(value));
583   return value;
584 }
585 #endif
586 #if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
587 #define __Pyx_truncl trunc
588 #else
589 #define __Pyx_truncl truncl
590 #endif
591 
592 #define __PYX_MARK_ERR_POS(f_index, lineno) \
593     { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; }
594 #define __PYX_ERR(f_index, lineno, Ln_error) \
595     { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; }
596 
597 #ifndef __PYX_EXTERN_C
598   #ifdef __cplusplus
599     #define __PYX_EXTERN_C extern "C"
600   #else
601     #define __PYX_EXTERN_C extern
602   #endif
603 #endif
604 
605 #define __PYX_HAVE__aiohttp___websocket
606 #define __PYX_HAVE_API__aiohttp___websocket
607 /* Early includes */
608 #include <string.h>
609 #include <stdio.h>
610 #include "pythread.h"
611 #include <stdint.h>
612 #ifdef _OPENMP
613 #include <omp.h>
614 #endif /* _OPENMP */
615 
616 #if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
617 #define CYTHON_WITHOUT_ASSERTIONS
618 #endif
619 
620 typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
621                 const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
622 
623 #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
624 #define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0
625 #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8)
626 #define __PYX_DEFAULT_STRING_ENCODING ""
627 #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
628 #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
629 #define __Pyx_uchar_cast(c) ((unsigned char)c)
630 #define __Pyx_long_cast(x) ((long)x)
631 #define __Pyx_fits_Py_ssize_t(v, type, is_signed)  (\
632     (sizeof(type) < sizeof(Py_ssize_t))  ||\
633     (sizeof(type) > sizeof(Py_ssize_t) &&\
634           likely(v < (type)PY_SSIZE_T_MAX ||\
635                  v == (type)PY_SSIZE_T_MAX)  &&\
636           (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
637                                 v == (type)PY_SSIZE_T_MIN)))  ||\
638     (sizeof(type) == sizeof(Py_ssize_t) &&\
639           (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
640                                v == (type)PY_SSIZE_T_MAX)))  )
__Pyx_is_valid_index(Py_ssize_t i,Py_ssize_t limit)641 static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
642     return (size_t) i < (size_t) limit;
643 }
644 #if defined (__cplusplus) && __cplusplus >= 201103L
645     #include <cstdlib>
646     #define __Pyx_sst_abs(value) std::abs(value)
647 #elif SIZEOF_INT >= SIZEOF_SIZE_T
648     #define __Pyx_sst_abs(value) abs(value)
649 #elif SIZEOF_LONG >= SIZEOF_SIZE_T
650     #define __Pyx_sst_abs(value) labs(value)
651 #elif defined (_MSC_VER)
652     #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
653 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
654     #define __Pyx_sst_abs(value) llabs(value)
655 #elif defined (__GNUC__)
656     #define __Pyx_sst_abs(value) __builtin_llabs(value)
657 #else
658     #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
659 #endif
660 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
661 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
662 #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
663 #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
664 #define __Pyx_PyBytes_FromString        PyBytes_FromString
665 #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
666 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
667 #if PY_MAJOR_VERSION < 3
668     #define __Pyx_PyStr_FromString        __Pyx_PyBytes_FromString
669     #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
670 #else
671     #define __Pyx_PyStr_FromString        __Pyx_PyUnicode_FromString
672     #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
673 #endif
674 #define __Pyx_PyBytes_AsWritableString(s)     ((char*) PyBytes_AS_STRING(s))
675 #define __Pyx_PyBytes_AsWritableSString(s)    ((signed char*) PyBytes_AS_STRING(s))
676 #define __Pyx_PyBytes_AsWritableUString(s)    ((unsigned char*) PyBytes_AS_STRING(s))
677 #define __Pyx_PyBytes_AsString(s)     ((const char*) PyBytes_AS_STRING(s))
678 #define __Pyx_PyBytes_AsSString(s)    ((const signed char*) PyBytes_AS_STRING(s))
679 #define __Pyx_PyBytes_AsUString(s)    ((const unsigned char*) PyBytes_AS_STRING(s))
680 #define __Pyx_PyObject_AsWritableString(s)    ((char*) __Pyx_PyObject_AsString(s))
681 #define __Pyx_PyObject_AsWritableSString(s)    ((signed char*) __Pyx_PyObject_AsString(s))
682 #define __Pyx_PyObject_AsWritableUString(s)    ((unsigned char*) __Pyx_PyObject_AsString(s))
683 #define __Pyx_PyObject_AsSString(s)    ((const signed char*) __Pyx_PyObject_AsString(s))
684 #define __Pyx_PyObject_AsUString(s)    ((const unsigned char*) __Pyx_PyObject_AsString(s))
685 #define __Pyx_PyObject_FromCString(s)  __Pyx_PyObject_FromString((const char*)s)
686 #define __Pyx_PyBytes_FromCString(s)   __Pyx_PyBytes_FromString((const char*)s)
687 #define __Pyx_PyByteArray_FromCString(s)   __Pyx_PyByteArray_FromString((const char*)s)
688 #define __Pyx_PyStr_FromCString(s)     __Pyx_PyStr_FromString((const char*)s)
689 #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
__Pyx_Py_UNICODE_strlen(const Py_UNICODE * u)690 static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
691     const Py_UNICODE *u_end = u;
692     while (*u_end++) ;
693     return (size_t)(u_end - u - 1);
694 }
695 #define __Pyx_PyUnicode_FromUnicode(u)       PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
696 #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
697 #define __Pyx_PyUnicode_AsUnicode            PyUnicode_AsUnicode
698 #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
699 #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
700 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
701 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
702 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
703 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
704 #define __Pyx_PySequence_Tuple(obj)\
705     (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
706 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
707 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
708 #if CYTHON_ASSUME_SAFE_MACROS
709 #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
710 #else
711 #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
712 #endif
713 #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
714 #if PY_MAJOR_VERSION >= 3
715 #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
716 #else
717 #define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
718 #endif
719 #define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
720 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
721 static int __Pyx_sys_getdefaultencoding_not_ascii;
__Pyx_init_sys_getdefaultencoding_params(void)722 static int __Pyx_init_sys_getdefaultencoding_params(void) {
723     PyObject* sys;
724     PyObject* default_encoding = NULL;
725     PyObject* ascii_chars_u = NULL;
726     PyObject* ascii_chars_b = NULL;
727     const char* default_encoding_c;
728     sys = PyImport_ImportModule("sys");
729     if (!sys) goto bad;
730     default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
731     Py_DECREF(sys);
732     if (!default_encoding) goto bad;
733     default_encoding_c = PyBytes_AsString(default_encoding);
734     if (!default_encoding_c) goto bad;
735     if (strcmp(default_encoding_c, "ascii") == 0) {
736         __Pyx_sys_getdefaultencoding_not_ascii = 0;
737     } else {
738         char ascii_chars[128];
739         int c;
740         for (c = 0; c < 128; c++) {
741             ascii_chars[c] = c;
742         }
743         __Pyx_sys_getdefaultencoding_not_ascii = 1;
744         ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
745         if (!ascii_chars_u) goto bad;
746         ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
747         if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
748             PyErr_Format(
749                 PyExc_ValueError,
750                 "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
751                 default_encoding_c);
752             goto bad;
753         }
754         Py_DECREF(ascii_chars_u);
755         Py_DECREF(ascii_chars_b);
756     }
757     Py_DECREF(default_encoding);
758     return 0;
759 bad:
760     Py_XDECREF(default_encoding);
761     Py_XDECREF(ascii_chars_u);
762     Py_XDECREF(ascii_chars_b);
763     return -1;
764 }
765 #endif
766 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
767 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
768 #else
769 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
770 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
771 static char* __PYX_DEFAULT_STRING_ENCODING;
__Pyx_init_sys_getdefaultencoding_params(void)772 static int __Pyx_init_sys_getdefaultencoding_params(void) {
773     PyObject* sys;
774     PyObject* default_encoding = NULL;
775     char* default_encoding_c;
776     sys = PyImport_ImportModule("sys");
777     if (!sys) goto bad;
778     default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
779     Py_DECREF(sys);
780     if (!default_encoding) goto bad;
781     default_encoding_c = PyBytes_AsString(default_encoding);
782     if (!default_encoding_c) goto bad;
783     __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1);
784     if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
785     strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
786     Py_DECREF(default_encoding);
787     return 0;
788 bad:
789     Py_XDECREF(default_encoding);
790     return -1;
791 }
792 #endif
793 #endif
794 
795 
796 /* Test for GCC > 2.95 */
797 #if defined(__GNUC__)     && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
798   #define likely(x)   __builtin_expect(!!(x), 1)
799   #define unlikely(x) __builtin_expect(!!(x), 0)
800 #else /* !__GNUC__ or GCC < 2.95 */
801   #define likely(x)   (x)
802   #define unlikely(x) (x)
803 #endif /* __GNUC__ */
__Pyx_pretend_to_initialize(void * ptr)804 static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
805 
806 static PyObject *__pyx_m = NULL;
807 static PyObject *__pyx_d;
808 static PyObject *__pyx_b;
809 static PyObject *__pyx_cython_runtime = NULL;
810 static PyObject *__pyx_empty_tuple;
811 static PyObject *__pyx_empty_bytes;
812 static PyObject *__pyx_empty_unicode;
813 static int __pyx_lineno;
814 static int __pyx_clineno = 0;
815 static const char * __pyx_cfilenm= __FILE__;
816 static const char *__pyx_filename;
817 
818 
819 static const char *__pyx_f[] = {
820   "aiohttp/_websocket.pyx",
821   "type.pxd",
822   "bool.pxd",
823   "complex.pxd",
824 };
825 
826 /*--- Type declarations ---*/
827 
828 /* --- Runtime support code (head) --- */
829 /* Refnanny.proto */
830 #ifndef CYTHON_REFNANNY
831   #define CYTHON_REFNANNY 0
832 #endif
833 #if CYTHON_REFNANNY
834   typedef struct {
835     void (*INCREF)(void*, PyObject*, int);
836     void (*DECREF)(void*, PyObject*, int);
837     void (*GOTREF)(void*, PyObject*, int);
838     void (*GIVEREF)(void*, PyObject*, int);
839     void* (*SetupContext)(const char*, int, const char*);
840     void (*FinishContext)(void**);
841   } __Pyx_RefNannyAPIStruct;
842   static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
843   static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
844   #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
845 #ifdef WITH_THREAD
846   #define __Pyx_RefNannySetupContext(name, acquire_gil)\
847           if (acquire_gil) {\
848               PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
849               __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
850               PyGILState_Release(__pyx_gilstate_save);\
851           } else {\
852               __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
853           }
854 #else
855   #define __Pyx_RefNannySetupContext(name, acquire_gil)\
856           __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
857 #endif
858   #define __Pyx_RefNannyFinishContext()\
859           __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
860   #define __Pyx_INCREF(r)  __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
861   #define __Pyx_DECREF(r)  __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
862   #define __Pyx_GOTREF(r)  __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
863   #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
864   #define __Pyx_XINCREF(r)  do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
865   #define __Pyx_XDECREF(r)  do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
866   #define __Pyx_XGOTREF(r)  do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
867   #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
868 #else
869   #define __Pyx_RefNannyDeclarations
870   #define __Pyx_RefNannySetupContext(name, acquire_gil)
871   #define __Pyx_RefNannyFinishContext()
872   #define __Pyx_INCREF(r) Py_INCREF(r)
873   #define __Pyx_DECREF(r) Py_DECREF(r)
874   #define __Pyx_GOTREF(r)
875   #define __Pyx_GIVEREF(r)
876   #define __Pyx_XINCREF(r) Py_XINCREF(r)
877   #define __Pyx_XDECREF(r) Py_XDECREF(r)
878   #define __Pyx_XGOTREF(r)
879   #define __Pyx_XGIVEREF(r)
880 #endif
881 #define __Pyx_XDECREF_SET(r, v) do {\
882         PyObject *tmp = (PyObject *) r;\
883         r = v; __Pyx_XDECREF(tmp);\
884     } while (0)
885 #define __Pyx_DECREF_SET(r, v) do {\
886         PyObject *tmp = (PyObject *) r;\
887         r = v; __Pyx_DECREF(tmp);\
888     } while (0)
889 #define __Pyx_CLEAR(r)    do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
890 #define __Pyx_XCLEAR(r)   do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
891 
892 /* PyObjectGetAttrStr.proto */
893 #if CYTHON_USE_TYPE_SLOTS
894 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
895 #else
896 #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
897 #endif
898 
899 /* GetBuiltinName.proto */
900 static PyObject *__Pyx_GetBuiltinName(PyObject *name);
901 
902 /* RaiseArgTupleInvalid.proto */
903 static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
904     Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
905 
906 /* RaiseDoubleKeywords.proto */
907 static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
908 
909 /* ParseKeywords.proto */
910 static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
911     PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
912     const char* function_name);
913 
914 /* PyCFunctionFastCall.proto */
915 #if CYTHON_FAST_PYCCALL
916 static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
917 #else
918 #define __Pyx_PyCFunction_FastCall(func, args, nargs)  (assert(0), NULL)
919 #endif
920 
921 /* PyFunctionFastCall.proto */
922 #if CYTHON_FAST_PYCALL
923 #define __Pyx_PyFunction_FastCall(func, args, nargs)\
924     __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
925 #if 1 || PY_VERSION_HEX < 0x030600B1
926 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs);
927 #else
928 #define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
929 #endif
930 #define __Pyx_BUILD_ASSERT_EXPR(cond)\
931     (sizeof(char [1 - 2*!(cond)]) - 1)
932 #ifndef Py_MEMBER_SIZE
933 #define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
934 #endif
935   static size_t __pyx_pyframe_localsplus_offset = 0;
936   #include "frameobject.h"
937   #define __Pxy_PyFrame_Initialize_Offsets()\
938     ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\
939      (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus)))
940   #define __Pyx_PyFrame_GetLocalsplus(frame)\
941     (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset))
942 #endif
943 
944 /* PyObjectCall.proto */
945 #if CYTHON_COMPILING_IN_CPYTHON
946 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
947 #else
948 #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
949 #endif
950 
951 /* PyObjectCallMethO.proto */
952 #if CYTHON_COMPILING_IN_CPYTHON
953 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
954 #endif
955 
956 /* PyObjectCallOneArg.proto */
957 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
958 
959 /* TypeImport.proto */
960 #ifndef __PYX_HAVE_RT_ImportType_proto
961 #define __PYX_HAVE_RT_ImportType_proto
962 enum __Pyx_ImportType_CheckSize {
963    __Pyx_ImportType_CheckSize_Error = 0,
964    __Pyx_ImportType_CheckSize_Warn = 1,
965    __Pyx_ImportType_CheckSize_Ignore = 2
966 };
967 static PyTypeObject *__Pyx_ImportType(PyObject* module, const char *module_name, const char *class_name, size_t size, enum __Pyx_ImportType_CheckSize check_size);
968 #endif
969 
970 /* PyDictVersioning.proto */
971 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
972 #define __PYX_DICT_VERSION_INIT  ((PY_UINT64_T) -1)
973 #define __PYX_GET_DICT_VERSION(dict)  (((PyDictObject*)(dict))->ma_version_tag)
974 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
975     (version_var) = __PYX_GET_DICT_VERSION(dict);\
976     (cache_var) = (value);
977 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
978     static PY_UINT64_T __pyx_dict_version = 0;\
979     static PyObject *__pyx_dict_cached_value = NULL;\
980     if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
981         (VAR) = __pyx_dict_cached_value;\
982     } else {\
983         (VAR) = __pyx_dict_cached_value = (LOOKUP);\
984         __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
985     }\
986 }
987 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj);
988 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj);
989 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version);
990 #else
991 #define __PYX_GET_DICT_VERSION(dict)  (0)
992 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
993 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP)  (VAR) = (LOOKUP);
994 #endif
995 
996 /* PyThreadStateGet.proto */
997 #if CYTHON_FAST_THREAD_STATE
998 #define __Pyx_PyThreadState_declare  PyThreadState *__pyx_tstate;
999 #define __Pyx_PyThreadState_assign  __pyx_tstate = __Pyx_PyThreadState_Current;
1000 #define __Pyx_PyErr_Occurred()  __pyx_tstate->curexc_type
1001 #else
1002 #define __Pyx_PyThreadState_declare
1003 #define __Pyx_PyThreadState_assign
1004 #define __Pyx_PyErr_Occurred()  PyErr_Occurred()
1005 #endif
1006 
1007 /* PyErrFetchRestore.proto */
1008 #if CYTHON_FAST_THREAD_STATE
1009 #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
1010 #define __Pyx_ErrRestoreWithState(type, value, tb)  __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
1011 #define __Pyx_ErrFetchWithState(type, value, tb)    __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
1012 #define __Pyx_ErrRestore(type, value, tb)  __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
1013 #define __Pyx_ErrFetch(type, value, tb)    __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
1014 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
1015 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1016 #if CYTHON_COMPILING_IN_CPYTHON
1017 #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
1018 #else
1019 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
1020 #endif
1021 #else
1022 #define __Pyx_PyErr_Clear() PyErr_Clear()
1023 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
1024 #define __Pyx_ErrRestoreWithState(type, value, tb)  PyErr_Restore(type, value, tb)
1025 #define __Pyx_ErrFetchWithState(type, value, tb)  PyErr_Fetch(type, value, tb)
1026 #define __Pyx_ErrRestoreInState(tstate, type, value, tb)  PyErr_Restore(type, value, tb)
1027 #define __Pyx_ErrFetchInState(tstate, type, value, tb)  PyErr_Fetch(type, value, tb)
1028 #define __Pyx_ErrRestore(type, value, tb)  PyErr_Restore(type, value, tb)
1029 #define __Pyx_ErrFetch(type, value, tb)  PyErr_Fetch(type, value, tb)
1030 #endif
1031 
1032 /* CLineInTraceback.proto */
1033 #ifdef CYTHON_CLINE_IN_TRACEBACK
1034 #define __Pyx_CLineForTraceback(tstate, c_line)  (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
1035 #else
1036 static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
1037 #endif
1038 
1039 /* CodeObjectCache.proto */
1040 typedef struct {
1041     PyCodeObject* code_object;
1042     int code_line;
1043 } __Pyx_CodeObjectCacheEntry;
1044 struct __Pyx_CodeObjectCache {
1045     int count;
1046     int max_count;
1047     __Pyx_CodeObjectCacheEntry* entries;
1048 };
1049 static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
1050 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
1051 static PyCodeObject *__pyx_find_code_object(int code_line);
1052 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
1053 
1054 /* AddTraceback.proto */
1055 static void __Pyx_AddTraceback(const char *funcname, int c_line,
1056                                int py_line, const char *filename);
1057 
1058 /* CIntToPy.proto */
1059 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
1060 
1061 /* CIntFromPy.proto */
1062 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
1063 
1064 /* CIntFromPy.proto */
1065 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
1066 
1067 /* FastTypeChecks.proto */
1068 #if CYTHON_COMPILING_IN_CPYTHON
1069 #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
1070 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
1071 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
1072 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
1073 #else
1074 #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
1075 #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
1076 #define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
1077 #endif
1078 #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
1079 
1080 /* CheckBinaryVersion.proto */
1081 static int __Pyx_check_binary_version(void);
1082 
1083 /* InitStrings.proto */
1084 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
1085 
1086 
1087 /* Module declarations from 'cpython.version' */
1088 
1089 /* Module declarations from '__builtin__' */
1090 
1091 /* Module declarations from 'cpython.type' */
1092 static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0;
1093 
1094 /* Module declarations from 'libc.string' */
1095 
1096 /* Module declarations from 'libc.stdio' */
1097 
1098 /* Module declarations from 'cpython.object' */
1099 
1100 /* Module declarations from 'cpython.ref' */
1101 
1102 /* Module declarations from 'cpython.exc' */
1103 
1104 /* Module declarations from 'cpython.module' */
1105 
1106 /* Module declarations from 'cpython.mem' */
1107 
1108 /* Module declarations from 'cpython.tuple' */
1109 
1110 /* Module declarations from 'cpython.list' */
1111 
1112 /* Module declarations from 'cpython.sequence' */
1113 
1114 /* Module declarations from 'cpython.mapping' */
1115 
1116 /* Module declarations from 'cpython.iterator' */
1117 
1118 /* Module declarations from 'cpython.number' */
1119 
1120 /* Module declarations from 'cpython.int' */
1121 
1122 /* Module declarations from '__builtin__' */
1123 
1124 /* Module declarations from 'cpython.bool' */
1125 static PyTypeObject *__pyx_ptype_7cpython_4bool_bool = 0;
1126 
1127 /* Module declarations from 'cpython.long' */
1128 
1129 /* Module declarations from 'cpython.float' */
1130 
1131 /* Module declarations from '__builtin__' */
1132 
1133 /* Module declarations from 'cpython.complex' */
1134 static PyTypeObject *__pyx_ptype_7cpython_7complex_complex = 0;
1135 
1136 /* Module declarations from 'cpython.string' */
1137 
1138 /* Module declarations from 'cpython.unicode' */
1139 
1140 /* Module declarations from 'cpython.dict' */
1141 
1142 /* Module declarations from 'cpython.instance' */
1143 
1144 /* Module declarations from 'cpython.function' */
1145 
1146 /* Module declarations from 'cpython.method' */
1147 
1148 /* Module declarations from 'cpython.weakref' */
1149 
1150 /* Module declarations from 'cpython.getargs' */
1151 
1152 /* Module declarations from 'cpython.pythread' */
1153 
1154 /* Module declarations from 'cpython.pystate' */
1155 
1156 /* Module declarations from 'cpython.cobject' */
1157 
1158 /* Module declarations from 'cpython.oldbuffer' */
1159 
1160 /* Module declarations from 'cpython.set' */
1161 
1162 /* Module declarations from 'cpython.buffer' */
1163 
1164 /* Module declarations from 'cpython.bytes' */
1165 
1166 /* Module declarations from 'cpython.pycapsule' */
1167 
1168 /* Module declarations from 'cpython' */
1169 
1170 /* Module declarations from 'libc.stdint' */
1171 
1172 /* Module declarations from 'aiohttp._websocket' */
1173 #define __Pyx_MODULE_NAME "aiohttp._websocket"
1174 extern int __pyx_module_is_main_aiohttp___websocket;
1175 int __pyx_module_is_main_aiohttp___websocket = 0;
1176 
1177 /* Implementation of 'aiohttp._websocket' */
1178 static PyObject *__pyx_builtin_range;
1179 static const char __pyx_k_i[] = "i";
1180 static const char __pyx_k_data[] = "data";
1181 static const char __pyx_k_main[] = "__main__";
1182 static const char __pyx_k_mask[] = "mask";
1183 static const char __pyx_k_name[] = "__name__";
1184 static const char __pyx_k_test[] = "__test__";
1185 static const char __pyx_k_range[] = "range";
1186 static const char __pyx_k_in_buf[] = "in_buf";
1187 static const char __pyx_k_data_len[] = "data_len";
1188 static const char __pyx_k_mask_buf[] = "mask_buf";
1189 static const char __pyx_k_uint32_msk[] = "uint32_msk";
1190 static const char __pyx_k_uint64_msk[] = "uint64_msk";
1191 static const char __pyx_k_aiohttp__websocket[] = "aiohttp._websocket";
1192 static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
1193 static const char __pyx_k_websocket_mask_cython[] = "_websocket_mask_cython";
1194 static const char __pyx_k_aiohttp__websocket_pyx[] = "aiohttp/_websocket.pyx";
1195 static PyObject *__pyx_n_s_aiohttp__websocket;
1196 static PyObject *__pyx_kp_s_aiohttp__websocket_pyx;
1197 static PyObject *__pyx_n_s_cline_in_traceback;
1198 static PyObject *__pyx_n_s_data;
1199 static PyObject *__pyx_n_s_data_len;
1200 static PyObject *__pyx_n_s_i;
1201 static PyObject *__pyx_n_s_in_buf;
1202 static PyObject *__pyx_n_s_main;
1203 static PyObject *__pyx_n_s_mask;
1204 static PyObject *__pyx_n_s_mask_buf;
1205 static PyObject *__pyx_n_s_name;
1206 static PyObject *__pyx_n_s_range;
1207 static PyObject *__pyx_n_s_test;
1208 static PyObject *__pyx_n_s_uint32_msk;
1209 static PyObject *__pyx_n_s_uint64_msk;
1210 static PyObject *__pyx_n_s_websocket_mask_cython;
1211 static PyObject *__pyx_pf_7aiohttp_10_websocket__websocket_mask_cython(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_mask, PyObject *__pyx_v_data); /* proto */
1212 static PyObject *__pyx_tuple_;
1213 static PyObject *__pyx_codeobj__2;
1214 /* Late includes */
1215 
1216 /* "aiohttp/_websocket.pyx":11
1217  *
1218  *
1219  * def _websocket_mask_cython(object mask, object data):             # <<<<<<<<<<<<<<
1220  *     """Note, this function mutates its `data` argument
1221  *     """
1222  */
1223 
1224 /* Python wrapper */
1225 static PyObject *__pyx_pw_7aiohttp_10_websocket_1_websocket_mask_cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
1226 static char __pyx_doc_7aiohttp_10_websocket__websocket_mask_cython[] = "Note, this function mutates its `data` argument\n    ";
1227 static PyMethodDef __pyx_mdef_7aiohttp_10_websocket_1_websocket_mask_cython = {"_websocket_mask_cython", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7aiohttp_10_websocket_1_websocket_mask_cython, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7aiohttp_10_websocket__websocket_mask_cython};
__pyx_pw_7aiohttp_10_websocket_1_websocket_mask_cython(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)1228 static PyObject *__pyx_pw_7aiohttp_10_websocket_1_websocket_mask_cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
1229   PyObject *__pyx_v_mask = 0;
1230   PyObject *__pyx_v_data = 0;
1231   int __pyx_lineno = 0;
1232   const char *__pyx_filename = NULL;
1233   int __pyx_clineno = 0;
1234   PyObject *__pyx_r = 0;
1235   __Pyx_RefNannyDeclarations
1236   __Pyx_RefNannySetupContext("_websocket_mask_cython (wrapper)", 0);
1237   {
1238     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_mask,&__pyx_n_s_data,0};
1239     PyObject* values[2] = {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  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
1245         CYTHON_FALLTHROUGH;
1246         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1247         CYTHON_FALLTHROUGH;
1248         case  0: break;
1249         default: goto __pyx_L5_argtuple_error;
1250       }
1251       kw_args = PyDict_Size(__pyx_kwds);
1252       switch (pos_args) {
1253         case  0:
1254         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_mask)) != 0)) kw_args--;
1255         else goto __pyx_L5_argtuple_error;
1256         CYTHON_FALLTHROUGH;
1257         case  1:
1258         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_data)) != 0)) kw_args--;
1259         else {
1260           __Pyx_RaiseArgtupleInvalid("_websocket_mask_cython", 1, 2, 2, 1); __PYX_ERR(0, 11, __pyx_L3_error)
1261         }
1262       }
1263       if (unlikely(kw_args > 0)) {
1264         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_websocket_mask_cython") < 0)) __PYX_ERR(0, 11, __pyx_L3_error)
1265       }
1266     } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
1267       goto __pyx_L5_argtuple_error;
1268     } else {
1269       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1270       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
1271     }
1272     __pyx_v_mask = values[0];
1273     __pyx_v_data = values[1];
1274   }
1275   goto __pyx_L4_argument_unpacking_done;
1276   __pyx_L5_argtuple_error:;
1277   __Pyx_RaiseArgtupleInvalid("_websocket_mask_cython", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 11, __pyx_L3_error)
1278   __pyx_L3_error:;
1279   __Pyx_AddTraceback("aiohttp._websocket._websocket_mask_cython", __pyx_clineno, __pyx_lineno, __pyx_filename);
1280   __Pyx_RefNannyFinishContext();
1281   return NULL;
1282   __pyx_L4_argument_unpacking_done:;
1283   __pyx_r = __pyx_pf_7aiohttp_10_websocket__websocket_mask_cython(__pyx_self, __pyx_v_mask, __pyx_v_data);
1284 
1285   /* function exit code */
1286   __Pyx_RefNannyFinishContext();
1287   return __pyx_r;
1288 }
1289 
__pyx_pf_7aiohttp_10_websocket__websocket_mask_cython(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v_mask,PyObject * __pyx_v_data)1290 static PyObject *__pyx_pf_7aiohttp_10_websocket__websocket_mask_cython(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_mask, PyObject *__pyx_v_data) {
1291   Py_ssize_t __pyx_v_data_len;
1292   Py_ssize_t __pyx_v_i;
1293   unsigned char *__pyx_v_in_buf;
1294   unsigned char const *__pyx_v_mask_buf;
1295   uint32_t __pyx_v_uint32_msk;
1296   uint64_t __pyx_v_uint64_msk;
1297   PyObject *__pyx_r = NULL;
1298   __Pyx_RefNannyDeclarations
1299   Py_ssize_t __pyx_t_1;
1300   int __pyx_t_2;
1301   int __pyx_t_3;
1302   PyObject *__pyx_t_4 = NULL;
1303   char *__pyx_t_5;
1304   uint64_t *__pyx_t_6;
1305   long __pyx_t_7;
1306   uint32_t *__pyx_t_8;
1307   Py_ssize_t __pyx_t_9;
1308   Py_ssize_t __pyx_t_10;
1309   Py_ssize_t __pyx_t_11;
1310   int __pyx_lineno = 0;
1311   const char *__pyx_filename = NULL;
1312   int __pyx_clineno = 0;
1313   __Pyx_RefNannySetupContext("_websocket_mask_cython", 0);
1314   __Pyx_INCREF(__pyx_v_mask);
1315   __Pyx_INCREF(__pyx_v_data);
1316 
1317   /* "aiohttp/_websocket.pyx":22
1318  *         uint64_t uint64_msk
1319  *
1320  *     assert len(mask) == 4             # <<<<<<<<<<<<<<
1321  *
1322  *     if not isinstance(mask, bytes):
1323  */
1324   #ifndef CYTHON_WITHOUT_ASSERTIONS
1325   if (unlikely(!Py_OptimizeFlag)) {
1326     __pyx_t_1 = PyObject_Length(__pyx_v_mask); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 22, __pyx_L1_error)
1327     if (unlikely(!((__pyx_t_1 == 4) != 0))) {
1328       PyErr_SetNone(PyExc_AssertionError);
1329       __PYX_ERR(0, 22, __pyx_L1_error)
1330     }
1331   }
1332   #endif
1333 
1334   /* "aiohttp/_websocket.pyx":24
1335  *     assert len(mask) == 4
1336  *
1337  *     if not isinstance(mask, bytes):             # <<<<<<<<<<<<<<
1338  *         mask = bytes(mask)
1339  *
1340  */
1341   __pyx_t_2 = PyBytes_Check(__pyx_v_mask);
1342   __pyx_t_3 = ((!(__pyx_t_2 != 0)) != 0);
1343   if (__pyx_t_3) {
1344 
1345     /* "aiohttp/_websocket.pyx":25
1346  *
1347  *     if not isinstance(mask, bytes):
1348  *         mask = bytes(mask)             # <<<<<<<<<<<<<<
1349  *
1350  *     if isinstance(data, bytearray):
1351  */
1352     __pyx_t_4 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyBytes_Type)), __pyx_v_mask); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 25, __pyx_L1_error)
1353     __Pyx_GOTREF(__pyx_t_4);
1354     __Pyx_DECREF_SET(__pyx_v_mask, __pyx_t_4);
1355     __pyx_t_4 = 0;
1356 
1357     /* "aiohttp/_websocket.pyx":24
1358  *     assert len(mask) == 4
1359  *
1360  *     if not isinstance(mask, bytes):             # <<<<<<<<<<<<<<
1361  *         mask = bytes(mask)
1362  *
1363  */
1364   }
1365 
1366   /* "aiohttp/_websocket.pyx":27
1367  *         mask = bytes(mask)
1368  *
1369  *     if isinstance(data, bytearray):             # <<<<<<<<<<<<<<
1370  *         data = <bytearray>data
1371  *     else:
1372  */
1373   __pyx_t_3 = PyByteArray_Check(__pyx_v_data);
1374   __pyx_t_2 = (__pyx_t_3 != 0);
1375   if (__pyx_t_2) {
1376 
1377     /* "aiohttp/_websocket.pyx":28
1378  *
1379  *     if isinstance(data, bytearray):
1380  *         data = <bytearray>data             # <<<<<<<<<<<<<<
1381  *     else:
1382  *         data = bytearray(data)
1383  */
1384     __pyx_t_4 = __pyx_v_data;
1385     __Pyx_INCREF(__pyx_t_4);
1386     __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_4);
1387     __pyx_t_4 = 0;
1388 
1389     /* "aiohttp/_websocket.pyx":27
1390  *         mask = bytes(mask)
1391  *
1392  *     if isinstance(data, bytearray):             # <<<<<<<<<<<<<<
1393  *         data = <bytearray>data
1394  *     else:
1395  */
1396     goto __pyx_L4;
1397   }
1398 
1399   /* "aiohttp/_websocket.pyx":30
1400  *         data = <bytearray>data
1401  *     else:
1402  *         data = bytearray(data)             # <<<<<<<<<<<<<<
1403  *
1404  *     data_len = len(data)
1405  */
1406   /*else*/ {
1407     __pyx_t_4 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyByteArray_Type)), __pyx_v_data); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 30, __pyx_L1_error)
1408     __Pyx_GOTREF(__pyx_t_4);
1409     __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_4);
1410     __pyx_t_4 = 0;
1411   }
1412   __pyx_L4:;
1413 
1414   /* "aiohttp/_websocket.pyx":32
1415  *         data = bytearray(data)
1416  *
1417  *     data_len = len(data)             # <<<<<<<<<<<<<<
1418  *     in_buf = <unsigned char*>PyByteArray_AsString(data)
1419  *     mask_buf = <const unsigned char*>PyBytes_AsString(mask)
1420  */
1421   __pyx_t_1 = PyObject_Length(__pyx_v_data); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 32, __pyx_L1_error)
1422   __pyx_v_data_len = __pyx_t_1;
1423 
1424   /* "aiohttp/_websocket.pyx":33
1425  *
1426  *     data_len = len(data)
1427  *     in_buf = <unsigned char*>PyByteArray_AsString(data)             # <<<<<<<<<<<<<<
1428  *     mask_buf = <const unsigned char*>PyBytes_AsString(mask)
1429  *     uint32_msk = (<uint32_t*>mask_buf)[0]
1430  */
1431   if (!(likely(PyByteArray_CheckExact(__pyx_v_data))||((__pyx_v_data) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytearray", Py_TYPE(__pyx_v_data)->tp_name), 0))) __PYX_ERR(0, 33, __pyx_L1_error)
1432   __pyx_t_5 = PyByteArray_AsString(((PyObject*)__pyx_v_data)); if (unlikely(__pyx_t_5 == ((char *)NULL))) __PYX_ERR(0, 33, __pyx_L1_error)
1433   __pyx_v_in_buf = ((unsigned char *)__pyx_t_5);
1434 
1435   /* "aiohttp/_websocket.pyx":34
1436  *     data_len = len(data)
1437  *     in_buf = <unsigned char*>PyByteArray_AsString(data)
1438  *     mask_buf = <const unsigned char*>PyBytes_AsString(mask)             # <<<<<<<<<<<<<<
1439  *     uint32_msk = (<uint32_t*>mask_buf)[0]
1440  *
1441  */
1442   __pyx_t_5 = PyBytes_AsString(__pyx_v_mask); if (unlikely(__pyx_t_5 == ((char *)NULL))) __PYX_ERR(0, 34, __pyx_L1_error)
1443   __pyx_v_mask_buf = ((unsigned char const *)__pyx_t_5);
1444 
1445   /* "aiohttp/_websocket.pyx":35
1446  *     in_buf = <unsigned char*>PyByteArray_AsString(data)
1447  *     mask_buf = <const unsigned char*>PyBytes_AsString(mask)
1448  *     uint32_msk = (<uint32_t*>mask_buf)[0]             # <<<<<<<<<<<<<<
1449  *
1450  *     # TODO: align in_data ptr to achieve even faster speeds
1451  */
1452   __pyx_v_uint32_msk = (((uint32_t *)__pyx_v_mask_buf)[0]);
1453 
1454   /* "aiohttp/_websocket.pyx":40
1455  *     # does it need in python ?! malloc() always aligns to sizeof(long) bytes
1456  *
1457  *     if sizeof(size_t) >= 8:             # <<<<<<<<<<<<<<
1458  *         uint64_msk = uint32_msk
1459  *         uint64_msk = (uint64_msk << 32) | uint32_msk
1460  */
1461   __pyx_t_2 = (((sizeof(size_t)) >= 8) != 0);
1462   if (__pyx_t_2) {
1463 
1464     /* "aiohttp/_websocket.pyx":41
1465  *
1466  *     if sizeof(size_t) >= 8:
1467  *         uint64_msk = uint32_msk             # <<<<<<<<<<<<<<
1468  *         uint64_msk = (uint64_msk << 32) | uint32_msk
1469  *
1470  */
1471     __pyx_v_uint64_msk = __pyx_v_uint32_msk;
1472 
1473     /* "aiohttp/_websocket.pyx":42
1474  *     if sizeof(size_t) >= 8:
1475  *         uint64_msk = uint32_msk
1476  *         uint64_msk = (uint64_msk << 32) | uint32_msk             # <<<<<<<<<<<<<<
1477  *
1478  *         while data_len >= 8:
1479  */
1480     __pyx_v_uint64_msk = ((__pyx_v_uint64_msk << 32) | __pyx_v_uint32_msk);
1481 
1482     /* "aiohttp/_websocket.pyx":44
1483  *         uint64_msk = (uint64_msk << 32) | uint32_msk
1484  *
1485  *         while data_len >= 8:             # <<<<<<<<<<<<<<
1486  *             (<uint64_t*>in_buf)[0] ^= uint64_msk
1487  *             in_buf += 8
1488  */
1489     while (1) {
1490       __pyx_t_2 = ((__pyx_v_data_len >= 8) != 0);
1491       if (!__pyx_t_2) break;
1492 
1493       /* "aiohttp/_websocket.pyx":45
1494  *
1495  *         while data_len >= 8:
1496  *             (<uint64_t*>in_buf)[0] ^= uint64_msk             # <<<<<<<<<<<<<<
1497  *             in_buf += 8
1498  *             data_len -= 8
1499  */
1500       __pyx_t_6 = ((uint64_t *)__pyx_v_in_buf);
1501       __pyx_t_7 = 0;
1502       (__pyx_t_6[__pyx_t_7]) = ((__pyx_t_6[__pyx_t_7]) ^ __pyx_v_uint64_msk);
1503 
1504       /* "aiohttp/_websocket.pyx":46
1505  *         while data_len >= 8:
1506  *             (<uint64_t*>in_buf)[0] ^= uint64_msk
1507  *             in_buf += 8             # <<<<<<<<<<<<<<
1508  *             data_len -= 8
1509  *
1510  */
1511       __pyx_v_in_buf = (__pyx_v_in_buf + 8);
1512 
1513       /* "aiohttp/_websocket.pyx":47
1514  *             (<uint64_t*>in_buf)[0] ^= uint64_msk
1515  *             in_buf += 8
1516  *             data_len -= 8             # <<<<<<<<<<<<<<
1517  *
1518  *
1519  */
1520       __pyx_v_data_len = (__pyx_v_data_len - 8);
1521     }
1522 
1523     /* "aiohttp/_websocket.pyx":40
1524  *     # does it need in python ?! malloc() always aligns to sizeof(long) bytes
1525  *
1526  *     if sizeof(size_t) >= 8:             # <<<<<<<<<<<<<<
1527  *         uint64_msk = uint32_msk
1528  *         uint64_msk = (uint64_msk << 32) | uint32_msk
1529  */
1530   }
1531 
1532   /* "aiohttp/_websocket.pyx":50
1533  *
1534  *
1535  *     while data_len >= 4:             # <<<<<<<<<<<<<<
1536  *         (<uint32_t*>in_buf)[0] ^= uint32_msk
1537  *         in_buf += 4
1538  */
1539   while (1) {
1540     __pyx_t_2 = ((__pyx_v_data_len >= 4) != 0);
1541     if (!__pyx_t_2) break;
1542 
1543     /* "aiohttp/_websocket.pyx":51
1544  *
1545  *     while data_len >= 4:
1546  *         (<uint32_t*>in_buf)[0] ^= uint32_msk             # <<<<<<<<<<<<<<
1547  *         in_buf += 4
1548  *         data_len -= 4
1549  */
1550     __pyx_t_8 = ((uint32_t *)__pyx_v_in_buf);
1551     __pyx_t_7 = 0;
1552     (__pyx_t_8[__pyx_t_7]) = ((__pyx_t_8[__pyx_t_7]) ^ __pyx_v_uint32_msk);
1553 
1554     /* "aiohttp/_websocket.pyx":52
1555  *     while data_len >= 4:
1556  *         (<uint32_t*>in_buf)[0] ^= uint32_msk
1557  *         in_buf += 4             # <<<<<<<<<<<<<<
1558  *         data_len -= 4
1559  *
1560  */
1561     __pyx_v_in_buf = (__pyx_v_in_buf + 4);
1562 
1563     /* "aiohttp/_websocket.pyx":53
1564  *         (<uint32_t*>in_buf)[0] ^= uint32_msk
1565  *         in_buf += 4
1566  *         data_len -= 4             # <<<<<<<<<<<<<<
1567  *
1568  *     for i in range(0, data_len):
1569  */
1570     __pyx_v_data_len = (__pyx_v_data_len - 4);
1571   }
1572 
1573   /* "aiohttp/_websocket.pyx":55
1574  *         data_len -= 4
1575  *
1576  *     for i in range(0, data_len):             # <<<<<<<<<<<<<<
1577  *         in_buf[i] ^= mask_buf[i]
1578  */
1579   __pyx_t_1 = __pyx_v_data_len;
1580   __pyx_t_9 = __pyx_t_1;
1581   for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) {
1582     __pyx_v_i = __pyx_t_10;
1583 
1584     /* "aiohttp/_websocket.pyx":56
1585  *
1586  *     for i in range(0, data_len):
1587  *         in_buf[i] ^= mask_buf[i]             # <<<<<<<<<<<<<<
1588  */
1589     __pyx_t_11 = __pyx_v_i;
1590     (__pyx_v_in_buf[__pyx_t_11]) = ((__pyx_v_in_buf[__pyx_t_11]) ^ (__pyx_v_mask_buf[__pyx_v_i]));
1591   }
1592 
1593   /* "aiohttp/_websocket.pyx":11
1594  *
1595  *
1596  * def _websocket_mask_cython(object mask, object data):             # <<<<<<<<<<<<<<
1597  *     """Note, this function mutates its `data` argument
1598  *     """
1599  */
1600 
1601   /* function exit code */
1602   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1603   goto __pyx_L0;
1604   __pyx_L1_error:;
1605   __Pyx_XDECREF(__pyx_t_4);
1606   __Pyx_AddTraceback("aiohttp._websocket._websocket_mask_cython", __pyx_clineno, __pyx_lineno, __pyx_filename);
1607   __pyx_r = NULL;
1608   __pyx_L0:;
1609   __Pyx_XDECREF(__pyx_v_mask);
1610   __Pyx_XDECREF(__pyx_v_data);
1611   __Pyx_XGIVEREF(__pyx_r);
1612   __Pyx_RefNannyFinishContext();
1613   return __pyx_r;
1614 }
1615 
1616 static PyMethodDef __pyx_methods[] = {
1617   {0, 0, 0, 0}
1618 };
1619 
1620 #if PY_MAJOR_VERSION >= 3
1621 #if CYTHON_PEP489_MULTI_PHASE_INIT
1622 static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
1623 static int __pyx_pymod_exec__websocket(PyObject* module); /*proto*/
1624 static PyModuleDef_Slot __pyx_moduledef_slots[] = {
1625   {Py_mod_create, (void*)__pyx_pymod_create},
1626   {Py_mod_exec, (void*)__pyx_pymod_exec__websocket},
1627   {0, NULL}
1628 };
1629 #endif
1630 
1631 static struct PyModuleDef __pyx_moduledef = {
1632     PyModuleDef_HEAD_INIT,
1633     "_websocket",
1634     0, /* m_doc */
1635   #if CYTHON_PEP489_MULTI_PHASE_INIT
1636     0, /* m_size */
1637   #else
1638     -1, /* m_size */
1639   #endif
1640     __pyx_methods /* m_methods */,
1641   #if CYTHON_PEP489_MULTI_PHASE_INIT
1642     __pyx_moduledef_slots, /* m_slots */
1643   #else
1644     NULL, /* m_reload */
1645   #endif
1646     NULL, /* m_traverse */
1647     NULL, /* m_clear */
1648     NULL /* m_free */
1649 };
1650 #endif
1651 #ifndef CYTHON_SMALL_CODE
1652 #if defined(__clang__)
1653     #define CYTHON_SMALL_CODE
1654 #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
1655     #define CYTHON_SMALL_CODE __attribute__((cold))
1656 #else
1657     #define CYTHON_SMALL_CODE
1658 #endif
1659 #endif
1660 
1661 static __Pyx_StringTabEntry __pyx_string_tab[] = {
1662   {&__pyx_n_s_aiohttp__websocket, __pyx_k_aiohttp__websocket, sizeof(__pyx_k_aiohttp__websocket), 0, 0, 1, 1},
1663   {&__pyx_kp_s_aiohttp__websocket_pyx, __pyx_k_aiohttp__websocket_pyx, sizeof(__pyx_k_aiohttp__websocket_pyx), 0, 0, 1, 0},
1664   {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
1665   {&__pyx_n_s_data, __pyx_k_data, sizeof(__pyx_k_data), 0, 0, 1, 1},
1666   {&__pyx_n_s_data_len, __pyx_k_data_len, sizeof(__pyx_k_data_len), 0, 0, 1, 1},
1667   {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1},
1668   {&__pyx_n_s_in_buf, __pyx_k_in_buf, sizeof(__pyx_k_in_buf), 0, 0, 1, 1},
1669   {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
1670   {&__pyx_n_s_mask, __pyx_k_mask, sizeof(__pyx_k_mask), 0, 0, 1, 1},
1671   {&__pyx_n_s_mask_buf, __pyx_k_mask_buf, sizeof(__pyx_k_mask_buf), 0, 0, 1, 1},
1672   {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
1673   {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
1674   {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
1675   {&__pyx_n_s_uint32_msk, __pyx_k_uint32_msk, sizeof(__pyx_k_uint32_msk), 0, 0, 1, 1},
1676   {&__pyx_n_s_uint64_msk, __pyx_k_uint64_msk, sizeof(__pyx_k_uint64_msk), 0, 0, 1, 1},
1677   {&__pyx_n_s_websocket_mask_cython, __pyx_k_websocket_mask_cython, sizeof(__pyx_k_websocket_mask_cython), 0, 0, 1, 1},
1678   {0, 0, 0, 0, 0, 0, 0}
1679 };
__Pyx_InitCachedBuiltins(void)1680 static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
1681   __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 55, __pyx_L1_error)
1682   return 0;
1683   __pyx_L1_error:;
1684   return -1;
1685 }
1686 
__Pyx_InitCachedConstants(void)1687 static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
1688   __Pyx_RefNannyDeclarations
1689   __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
1690 
1691   /* "aiohttp/_websocket.pyx":11
1692  *
1693  *
1694  * def _websocket_mask_cython(object mask, object data):             # <<<<<<<<<<<<<<
1695  *     """Note, this function mutates its `data` argument
1696  *     """
1697  */
1698   __pyx_tuple_ = PyTuple_Pack(8, __pyx_n_s_mask, __pyx_n_s_data, __pyx_n_s_data_len, __pyx_n_s_i, __pyx_n_s_in_buf, __pyx_n_s_mask_buf, __pyx_n_s_uint32_msk, __pyx_n_s_uint64_msk); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 11, __pyx_L1_error)
1699   __Pyx_GOTREF(__pyx_tuple_);
1700   __Pyx_GIVEREF(__pyx_tuple_);
1701   __pyx_codeobj__2 = (PyObject*)__Pyx_PyCode_New(2, 0, 8, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple_, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_aiohttp__websocket_pyx, __pyx_n_s_websocket_mask_cython, 11, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__2)) __PYX_ERR(0, 11, __pyx_L1_error)
1702   __Pyx_RefNannyFinishContext();
1703   return 0;
1704   __pyx_L1_error:;
1705   __Pyx_RefNannyFinishContext();
1706   return -1;
1707 }
1708 
__Pyx_InitGlobals(void)1709 static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
1710   if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
1711   return 0;
1712   __pyx_L1_error:;
1713   return -1;
1714 }
1715 
1716 static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/
1717 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/
1718 static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/
1719 static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/
1720 static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/
1721 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/
1722 static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/
1723 
__Pyx_modinit_global_init_code(void)1724 static int __Pyx_modinit_global_init_code(void) {
1725   __Pyx_RefNannyDeclarations
1726   __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
1727   /*--- Global init code ---*/
1728   __Pyx_RefNannyFinishContext();
1729   return 0;
1730 }
1731 
__Pyx_modinit_variable_export_code(void)1732 static int __Pyx_modinit_variable_export_code(void) {
1733   __Pyx_RefNannyDeclarations
1734   __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
1735   /*--- Variable export code ---*/
1736   __Pyx_RefNannyFinishContext();
1737   return 0;
1738 }
1739 
__Pyx_modinit_function_export_code(void)1740 static int __Pyx_modinit_function_export_code(void) {
1741   __Pyx_RefNannyDeclarations
1742   __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
1743   /*--- Function export code ---*/
1744   __Pyx_RefNannyFinishContext();
1745   return 0;
1746 }
1747 
__Pyx_modinit_type_init_code(void)1748 static int __Pyx_modinit_type_init_code(void) {
1749   __Pyx_RefNannyDeclarations
1750   __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
1751   /*--- Type init code ---*/
1752   __Pyx_RefNannyFinishContext();
1753   return 0;
1754 }
1755 
__Pyx_modinit_type_import_code(void)1756 static int __Pyx_modinit_type_import_code(void) {
1757   __Pyx_RefNannyDeclarations
1758   PyObject *__pyx_t_1 = NULL;
1759   int __pyx_lineno = 0;
1760   const char *__pyx_filename = NULL;
1761   int __pyx_clineno = 0;
1762   __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
1763   /*--- Type import code ---*/
1764   __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 9, __pyx_L1_error)
1765   __Pyx_GOTREF(__pyx_t_1);
1766   __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "type",
1767   #if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000
1768   sizeof(PyTypeObject),
1769   #else
1770   sizeof(PyHeapTypeObject),
1771   #endif
1772   __Pyx_ImportType_CheckSize_Warn);
1773    if (!__pyx_ptype_7cpython_4type_type) __PYX_ERR(1, 9, __pyx_L1_error)
1774   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1775   __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 8, __pyx_L1_error)
1776   __Pyx_GOTREF(__pyx_t_1);
1777   __pyx_ptype_7cpython_4bool_bool = __Pyx_ImportType(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "bool", sizeof(PyBoolObject), __Pyx_ImportType_CheckSize_Warn);
1778    if (!__pyx_ptype_7cpython_4bool_bool) __PYX_ERR(2, 8, __pyx_L1_error)
1779   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1780   __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 15, __pyx_L1_error)
1781   __Pyx_GOTREF(__pyx_t_1);
1782   __pyx_ptype_7cpython_7complex_complex = __Pyx_ImportType(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "complex", sizeof(PyComplexObject), __Pyx_ImportType_CheckSize_Warn);
1783    if (!__pyx_ptype_7cpython_7complex_complex) __PYX_ERR(3, 15, __pyx_L1_error)
1784   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1785   __Pyx_RefNannyFinishContext();
1786   return 0;
1787   __pyx_L1_error:;
1788   __Pyx_XDECREF(__pyx_t_1);
1789   __Pyx_RefNannyFinishContext();
1790   return -1;
1791 }
1792 
__Pyx_modinit_variable_import_code(void)1793 static int __Pyx_modinit_variable_import_code(void) {
1794   __Pyx_RefNannyDeclarations
1795   __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
1796   /*--- Variable import code ---*/
1797   __Pyx_RefNannyFinishContext();
1798   return 0;
1799 }
1800 
__Pyx_modinit_function_import_code(void)1801 static int __Pyx_modinit_function_import_code(void) {
1802   __Pyx_RefNannyDeclarations
1803   __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
1804   /*--- Function import code ---*/
1805   __Pyx_RefNannyFinishContext();
1806   return 0;
1807 }
1808 
1809 
1810 #ifndef CYTHON_NO_PYINIT_EXPORT
1811 #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
1812 #elif PY_MAJOR_VERSION < 3
1813 #ifdef __cplusplus
1814 #define __Pyx_PyMODINIT_FUNC extern "C" void
1815 #else
1816 #define __Pyx_PyMODINIT_FUNC void
1817 #endif
1818 #else
1819 #ifdef __cplusplus
1820 #define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
1821 #else
1822 #define __Pyx_PyMODINIT_FUNC PyObject *
1823 #endif
1824 #endif
1825 
1826 
1827 #if PY_MAJOR_VERSION < 3
1828 __Pyx_PyMODINIT_FUNC init_websocket(void) CYTHON_SMALL_CODE; /*proto*/
init_websocket(void)1829 __Pyx_PyMODINIT_FUNC init_websocket(void)
1830 #else
1831 __Pyx_PyMODINIT_FUNC PyInit__websocket(void) CYTHON_SMALL_CODE; /*proto*/
1832 __Pyx_PyMODINIT_FUNC PyInit__websocket(void)
1833 #if CYTHON_PEP489_MULTI_PHASE_INIT
1834 {
1835   return PyModuleDef_Init(&__pyx_moduledef);
1836 }
1837 static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
1838     #if PY_VERSION_HEX >= 0x030700A1
1839     static PY_INT64_T main_interpreter_id = -1;
1840     PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
1841     if (main_interpreter_id == -1) {
1842         main_interpreter_id = current_id;
1843         return (unlikely(current_id == -1)) ? -1 : 0;
1844     } else if (unlikely(main_interpreter_id != current_id))
1845     #else
1846     static PyInterpreterState *main_interpreter = NULL;
1847     PyInterpreterState *current_interpreter = PyThreadState_Get()->interp;
1848     if (!main_interpreter) {
1849         main_interpreter = current_interpreter;
1850     } else if (unlikely(main_interpreter != current_interpreter))
1851     #endif
1852     {
1853         PyErr_SetString(
1854             PyExc_ImportError,
1855             "Interpreter change detected - this module can only be loaded into one interpreter per process.");
1856         return -1;
1857     }
1858     return 0;
1859 }
1860 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) {
1861     PyObject *value = PyObject_GetAttrString(spec, from_name);
1862     int result = 0;
1863     if (likely(value)) {
1864         if (allow_none || value != Py_None) {
1865             result = PyDict_SetItemString(moddict, to_name, value);
1866         }
1867         Py_DECREF(value);
1868     } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
1869         PyErr_Clear();
1870     } else {
1871         result = -1;
1872     }
1873     return result;
1874 }
1875 static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
1876     PyObject *module = NULL, *moddict, *modname;
1877     if (__Pyx_check_single_interpreter())
1878         return NULL;
1879     if (__pyx_m)
1880         return __Pyx_NewRef(__pyx_m);
1881     modname = PyObject_GetAttrString(spec, "name");
1882     if (unlikely(!modname)) goto bad;
1883     module = PyModule_NewObject(modname);
1884     Py_DECREF(modname);
1885     if (unlikely(!module)) goto bad;
1886     moddict = PyModule_GetDict(module);
1887     if (unlikely(!moddict)) goto bad;
1888     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
1889     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
1890     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
1891     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
1892     return module;
1893 bad:
1894     Py_XDECREF(module);
1895     return NULL;
1896 }
1897 
1898 
1899 static CYTHON_SMALL_CODE int __pyx_pymod_exec__websocket(PyObject *__pyx_pyinit_module)
1900 #endif
1901 #endif
1902 {
1903   PyObject *__pyx_t_1 = NULL;
1904   int __pyx_lineno = 0;
1905   const char *__pyx_filename = NULL;
1906   int __pyx_clineno = 0;
1907   __Pyx_RefNannyDeclarations
1908   #if CYTHON_PEP489_MULTI_PHASE_INIT
1909   if (__pyx_m) {
1910     if (__pyx_m == __pyx_pyinit_module) return 0;
1911     PyErr_SetString(PyExc_RuntimeError, "Module '_websocket' has already been imported. Re-initialisation is not supported.");
1912     return -1;
1913   }
1914   #elif PY_MAJOR_VERSION >= 3
1915   if (__pyx_m) return __Pyx_NewRef(__pyx_m);
1916   #endif
1917   #if CYTHON_REFNANNY
1918 __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
1919 if (!__Pyx_RefNanny) {
1920   PyErr_Clear();
1921   __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
1922   if (!__Pyx_RefNanny)
1923       Py_FatalError("failed to import 'refnanny' module");
1924 }
1925 #endif
1926   __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit__websocket(void)", 0);
1927   if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
1928   #ifdef __Pxy_PyFrame_Initialize_Offsets
1929   __Pxy_PyFrame_Initialize_Offsets();
1930   #endif
1931   __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
1932   __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
1933   __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
1934   #ifdef __Pyx_CyFunction_USED
1935   if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
1936   #endif
1937   #ifdef __Pyx_FusedFunction_USED
1938   if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
1939   #endif
1940   #ifdef __Pyx_Coroutine_USED
1941   if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
1942   #endif
1943   #ifdef __Pyx_Generator_USED
1944   if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
1945   #endif
1946   #ifdef __Pyx_AsyncGen_USED
1947   if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
1948   #endif
1949   #ifdef __Pyx_StopAsyncIteration_USED
1950   if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
1951   #endif
1952   /*--- Library function declarations ---*/
1953   /*--- Threads initialization code ---*/
1954   #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
1955   #ifdef WITH_THREAD /* Python build with threading support? */
1956   PyEval_InitThreads();
1957   #endif
1958   #endif
1959   /*--- Module creation code ---*/
1960   #if CYTHON_PEP489_MULTI_PHASE_INIT
1961   __pyx_m = __pyx_pyinit_module;
1962   Py_INCREF(__pyx_m);
1963   #else
1964   #if PY_MAJOR_VERSION < 3
1965   __pyx_m = Py_InitModule4("_websocket", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
1966   #else
1967   __pyx_m = PyModule_Create(&__pyx_moduledef);
1968   #endif
1969   if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
1970   #endif
1971   __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
1972   Py_INCREF(__pyx_d);
1973   __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
1974   Py_INCREF(__pyx_b);
1975   __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
1976   Py_INCREF(__pyx_cython_runtime);
1977   if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
1978   /*--- Initialize various global constants etc. ---*/
1979   if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
1980   #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
1981   if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
1982   #endif
1983   if (__pyx_module_is_main_aiohttp___websocket) {
1984     if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
1985   }
1986   #if PY_MAJOR_VERSION >= 3
1987   {
1988     PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
1989     if (!PyDict_GetItemString(modules, "aiohttp._websocket")) {
1990       if (unlikely(PyDict_SetItemString(modules, "aiohttp._websocket", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
1991     }
1992   }
1993   #endif
1994   /*--- Builtin init code ---*/
1995   if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
1996   /*--- Constants init code ---*/
1997   if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
1998   /*--- Global type/function init code ---*/
1999   (void)__Pyx_modinit_global_init_code();
2000   (void)__Pyx_modinit_variable_export_code();
2001   (void)__Pyx_modinit_function_export_code();
2002   (void)__Pyx_modinit_type_init_code();
2003   if (unlikely(__Pyx_modinit_type_import_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
2004   (void)__Pyx_modinit_variable_import_code();
2005   (void)__Pyx_modinit_function_import_code();
2006   /*--- Execution code ---*/
2007   #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
2008   if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2009   #endif
2010 
2011   /* "aiohttp/_websocket.pyx":11
2012  *
2013  *
2014  * def _websocket_mask_cython(object mask, object data):             # <<<<<<<<<<<<<<
2015  *     """Note, this function mutates its `data` argument
2016  *     """
2017  */
2018   __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_7aiohttp_10_websocket_1_websocket_mask_cython, NULL, __pyx_n_s_aiohttp__websocket); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error)
2019   __Pyx_GOTREF(__pyx_t_1);
2020   if (PyDict_SetItem(__pyx_d, __pyx_n_s_websocket_mask_cython, __pyx_t_1) < 0) __PYX_ERR(0, 11, __pyx_L1_error)
2021   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2022 
2023   /* "aiohttp/_websocket.pyx":1
2024  * from cpython cimport PyBytes_AsString             # <<<<<<<<<<<<<<
2025  *
2026  *
2027  */
2028   __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
2029   __Pyx_GOTREF(__pyx_t_1);
2030   if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2031   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2032 
2033   /*--- Wrapped vars code ---*/
2034 
2035   goto __pyx_L0;
2036   __pyx_L1_error:;
2037   __Pyx_XDECREF(__pyx_t_1);
2038   if (__pyx_m) {
2039     if (__pyx_d) {
2040       __Pyx_AddTraceback("init aiohttp._websocket", __pyx_clineno, __pyx_lineno, __pyx_filename);
2041     }
2042     Py_CLEAR(__pyx_m);
2043   } else if (!PyErr_Occurred()) {
2044     PyErr_SetString(PyExc_ImportError, "init aiohttp._websocket");
2045   }
2046   __pyx_L0:;
2047   __Pyx_RefNannyFinishContext();
2048   #if CYTHON_PEP489_MULTI_PHASE_INIT
2049   return (__pyx_m != NULL) ? 0 : -1;
2050   #elif PY_MAJOR_VERSION >= 3
2051   return __pyx_m;
2052   #else
2053   return;
2054   #endif
2055 }
2056 
2057 /* --- Runtime support code --- */
2058 /* Refnanny */
2059 #if CYTHON_REFNANNY
__Pyx_RefNannyImportAPI(const char * modname)2060 static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
2061     PyObject *m = NULL, *p = NULL;
2062     void *r = NULL;
2063     m = PyImport_ImportModule(modname);
2064     if (!m) goto end;
2065     p = PyObject_GetAttrString(m, "RefNannyAPI");
2066     if (!p) goto end;
2067     r = PyLong_AsVoidPtr(p);
2068 end:
2069     Py_XDECREF(p);
2070     Py_XDECREF(m);
2071     return (__Pyx_RefNannyAPIStruct *)r;
2072 }
2073 #endif
2074 
2075 /* PyObjectGetAttrStr */
2076 #if CYTHON_USE_TYPE_SLOTS
__Pyx_PyObject_GetAttrStr(PyObject * obj,PyObject * attr_name)2077 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
2078     PyTypeObject* tp = Py_TYPE(obj);
2079     if (likely(tp->tp_getattro))
2080         return tp->tp_getattro(obj, attr_name);
2081 #if PY_MAJOR_VERSION < 3
2082     if (likely(tp->tp_getattr))
2083         return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
2084 #endif
2085     return PyObject_GetAttr(obj, attr_name);
2086 }
2087 #endif
2088 
2089 /* GetBuiltinName */
__Pyx_GetBuiltinName(PyObject * name)2090 static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
2091     PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
2092     if (unlikely(!result)) {
2093         PyErr_Format(PyExc_NameError,
2094 #if PY_MAJOR_VERSION >= 3
2095             "name '%U' is not defined", name);
2096 #else
2097             "name '%.200s' is not defined", PyString_AS_STRING(name));
2098 #endif
2099     }
2100     return result;
2101 }
2102 
2103 /* RaiseArgTupleInvalid */
__Pyx_RaiseArgtupleInvalid(const char * func_name,int exact,Py_ssize_t num_min,Py_ssize_t num_max,Py_ssize_t num_found)2104 static void __Pyx_RaiseArgtupleInvalid(
2105     const char* func_name,
2106     int exact,
2107     Py_ssize_t num_min,
2108     Py_ssize_t num_max,
2109     Py_ssize_t num_found)
2110 {
2111     Py_ssize_t num_expected;
2112     const char *more_or_less;
2113     if (num_found < num_min) {
2114         num_expected = num_min;
2115         more_or_less = "at least";
2116     } else {
2117         num_expected = num_max;
2118         more_or_less = "at most";
2119     }
2120     if (exact) {
2121         more_or_less = "exactly";
2122     }
2123     PyErr_Format(PyExc_TypeError,
2124                  "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
2125                  func_name, more_or_less, num_expected,
2126                  (num_expected == 1) ? "" : "s", num_found);
2127 }
2128 
2129 /* RaiseDoubleKeywords */
__Pyx_RaiseDoubleKeywordsError(const char * func_name,PyObject * kw_name)2130 static void __Pyx_RaiseDoubleKeywordsError(
2131     const char* func_name,
2132     PyObject* kw_name)
2133 {
2134     PyErr_Format(PyExc_TypeError,
2135         #if PY_MAJOR_VERSION >= 3
2136         "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
2137         #else
2138         "%s() got multiple values for keyword argument '%s'", func_name,
2139         PyString_AsString(kw_name));
2140         #endif
2141 }
2142 
2143 /* ParseKeywords */
__Pyx_ParseOptionalKeywords(PyObject * kwds,PyObject ** argnames[],PyObject * kwds2,PyObject * values[],Py_ssize_t num_pos_args,const char * function_name)2144 static int __Pyx_ParseOptionalKeywords(
2145     PyObject *kwds,
2146     PyObject **argnames[],
2147     PyObject *kwds2,
2148     PyObject *values[],
2149     Py_ssize_t num_pos_args,
2150     const char* function_name)
2151 {
2152     PyObject *key = 0, *value = 0;
2153     Py_ssize_t pos = 0;
2154     PyObject*** name;
2155     PyObject*** first_kw_arg = argnames + num_pos_args;
2156     while (PyDict_Next(kwds, &pos, &key, &value)) {
2157         name = first_kw_arg;
2158         while (*name && (**name != key)) name++;
2159         if (*name) {
2160             values[name-argnames] = value;
2161             continue;
2162         }
2163         name = first_kw_arg;
2164         #if PY_MAJOR_VERSION < 3
2165         if (likely(PyString_Check(key))) {
2166             while (*name) {
2167                 if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
2168                         && _PyString_Eq(**name, key)) {
2169                     values[name-argnames] = value;
2170                     break;
2171                 }
2172                 name++;
2173             }
2174             if (*name) continue;
2175             else {
2176                 PyObject*** argname = argnames;
2177                 while (argname != first_kw_arg) {
2178                     if ((**argname == key) || (
2179                             (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
2180                              && _PyString_Eq(**argname, key))) {
2181                         goto arg_passed_twice;
2182                     }
2183                     argname++;
2184                 }
2185             }
2186         } else
2187         #endif
2188         if (likely(PyUnicode_Check(key))) {
2189             while (*name) {
2190                 int cmp = (**name == key) ? 0 :
2191                 #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
2192                     (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
2193                 #endif
2194                     PyUnicode_Compare(**name, key);
2195                 if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
2196                 if (cmp == 0) {
2197                     values[name-argnames] = value;
2198                     break;
2199                 }
2200                 name++;
2201             }
2202             if (*name) continue;
2203             else {
2204                 PyObject*** argname = argnames;
2205                 while (argname != first_kw_arg) {
2206                     int cmp = (**argname == key) ? 0 :
2207                     #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
2208                         (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
2209                     #endif
2210                         PyUnicode_Compare(**argname, key);
2211                     if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
2212                     if (cmp == 0) goto arg_passed_twice;
2213                     argname++;
2214                 }
2215             }
2216         } else
2217             goto invalid_keyword_type;
2218         if (kwds2) {
2219             if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
2220         } else {
2221             goto invalid_keyword;
2222         }
2223     }
2224     return 0;
2225 arg_passed_twice:
2226     __Pyx_RaiseDoubleKeywordsError(function_name, key);
2227     goto bad;
2228 invalid_keyword_type:
2229     PyErr_Format(PyExc_TypeError,
2230         "%.200s() keywords must be strings", function_name);
2231     goto bad;
2232 invalid_keyword:
2233     PyErr_Format(PyExc_TypeError,
2234     #if PY_MAJOR_VERSION < 3
2235         "%.200s() got an unexpected keyword argument '%.200s'",
2236         function_name, PyString_AsString(key));
2237     #else
2238         "%s() got an unexpected keyword argument '%U'",
2239         function_name, key);
2240     #endif
2241 bad:
2242     return -1;
2243 }
2244 
2245 /* PyCFunctionFastCall */
2246 #if CYTHON_FAST_PYCCALL
__Pyx_PyCFunction_FastCall(PyObject * func_obj,PyObject ** args,Py_ssize_t nargs)2247 static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
2248     PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
2249     PyCFunction meth = PyCFunction_GET_FUNCTION(func);
2250     PyObject *self = PyCFunction_GET_SELF(func);
2251     int flags = PyCFunction_GET_FLAGS(func);
2252     assert(PyCFunction_Check(func));
2253     assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)));
2254     assert(nargs >= 0);
2255     assert(nargs == 0 || args != NULL);
2256     /* _PyCFunction_FastCallDict() must not be called with an exception set,
2257        because it may clear it (directly or indirectly) and so the
2258        caller loses its exception */
2259     assert(!PyErr_Occurred());
2260     if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
2261         return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL);
2262     } else {
2263         return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs);
2264     }
2265 }
2266 #endif
2267 
2268 /* PyFunctionFastCall */
2269 #if CYTHON_FAST_PYCALL
__Pyx_PyFunction_FastCallNoKw(PyCodeObject * co,PyObject ** args,Py_ssize_t na,PyObject * globals)2270 static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
2271                                                PyObject *globals) {
2272     PyFrameObject *f;
2273     PyThreadState *tstate = __Pyx_PyThreadState_Current;
2274     PyObject **fastlocals;
2275     Py_ssize_t i;
2276     PyObject *result;
2277     assert(globals != NULL);
2278     /* XXX Perhaps we should create a specialized
2279        PyFrame_New() that doesn't take locals, but does
2280        take builtins without sanity checking them.
2281        */
2282     assert(tstate != NULL);
2283     f = PyFrame_New(tstate, co, globals, NULL);
2284     if (f == NULL) {
2285         return NULL;
2286     }
2287     fastlocals = __Pyx_PyFrame_GetLocalsplus(f);
2288     for (i = 0; i < na; i++) {
2289         Py_INCREF(*args);
2290         fastlocals[i] = *args++;
2291     }
2292     result = PyEval_EvalFrameEx(f,0);
2293     ++tstate->recursion_depth;
2294     Py_DECREF(f);
2295     --tstate->recursion_depth;
2296     return result;
2297 }
2298 #if 1 || PY_VERSION_HEX < 0x030600B1
__Pyx_PyFunction_FastCallDict(PyObject * func,PyObject ** args,Py_ssize_t nargs,PyObject * kwargs)2299 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) {
2300     PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
2301     PyObject *globals = PyFunction_GET_GLOBALS(func);
2302     PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
2303     PyObject *closure;
2304 #if PY_MAJOR_VERSION >= 3
2305     PyObject *kwdefs;
2306 #endif
2307     PyObject *kwtuple, **k;
2308     PyObject **d;
2309     Py_ssize_t nd;
2310     Py_ssize_t nk;
2311     PyObject *result;
2312     assert(kwargs == NULL || PyDict_Check(kwargs));
2313     nk = kwargs ? PyDict_Size(kwargs) : 0;
2314     if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
2315         return NULL;
2316     }
2317     if (
2318 #if PY_MAJOR_VERSION >= 3
2319             co->co_kwonlyargcount == 0 &&
2320 #endif
2321             likely(kwargs == NULL || nk == 0) &&
2322             co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
2323         if (argdefs == NULL && co->co_argcount == nargs) {
2324             result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
2325             goto done;
2326         }
2327         else if (nargs == 0 && argdefs != NULL
2328                  && co->co_argcount == Py_SIZE(argdefs)) {
2329             /* function called with no arguments, but all parameters have
2330                a default value: use default values as arguments .*/
2331             args = &PyTuple_GET_ITEM(argdefs, 0);
2332             result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
2333             goto done;
2334         }
2335     }
2336     if (kwargs != NULL) {
2337         Py_ssize_t pos, i;
2338         kwtuple = PyTuple_New(2 * nk);
2339         if (kwtuple == NULL) {
2340             result = NULL;
2341             goto done;
2342         }
2343         k = &PyTuple_GET_ITEM(kwtuple, 0);
2344         pos = i = 0;
2345         while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
2346             Py_INCREF(k[i]);
2347             Py_INCREF(k[i+1]);
2348             i += 2;
2349         }
2350         nk = i / 2;
2351     }
2352     else {
2353         kwtuple = NULL;
2354         k = NULL;
2355     }
2356     closure = PyFunction_GET_CLOSURE(func);
2357 #if PY_MAJOR_VERSION >= 3
2358     kwdefs = PyFunction_GET_KW_DEFAULTS(func);
2359 #endif
2360     if (argdefs != NULL) {
2361         d = &PyTuple_GET_ITEM(argdefs, 0);
2362         nd = Py_SIZE(argdefs);
2363     }
2364     else {
2365         d = NULL;
2366         nd = 0;
2367     }
2368 #if PY_MAJOR_VERSION >= 3
2369     result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
2370                                args, (int)nargs,
2371                                k, (int)nk,
2372                                d, (int)nd, kwdefs, closure);
2373 #else
2374     result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
2375                                args, (int)nargs,
2376                                k, (int)nk,
2377                                d, (int)nd, closure);
2378 #endif
2379     Py_XDECREF(kwtuple);
2380 done:
2381     Py_LeaveRecursiveCall();
2382     return result;
2383 }
2384 #endif
2385 #endif
2386 
2387 /* PyObjectCall */
2388 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_Call(PyObject * func,PyObject * arg,PyObject * kw)2389 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
2390     PyObject *result;
2391     ternaryfunc call = func->ob_type->tp_call;
2392     if (unlikely(!call))
2393         return PyObject_Call(func, arg, kw);
2394     if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
2395         return NULL;
2396     result = (*call)(func, arg, kw);
2397     Py_LeaveRecursiveCall();
2398     if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
2399         PyErr_SetString(
2400             PyExc_SystemError,
2401             "NULL result without error in PyObject_Call");
2402     }
2403     return result;
2404 }
2405 #endif
2406 
2407 /* PyObjectCallMethO */
2408 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_CallMethO(PyObject * func,PyObject * arg)2409 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
2410     PyObject *self, *result;
2411     PyCFunction cfunc;
2412     cfunc = PyCFunction_GET_FUNCTION(func);
2413     self = PyCFunction_GET_SELF(func);
2414     if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
2415         return NULL;
2416     result = cfunc(self, arg);
2417     Py_LeaveRecursiveCall();
2418     if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
2419         PyErr_SetString(
2420             PyExc_SystemError,
2421             "NULL result without error in PyObject_Call");
2422     }
2423     return result;
2424 }
2425 #endif
2426 
2427 /* PyObjectCallOneArg */
2428 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx__PyObject_CallOneArg(PyObject * func,PyObject * arg)2429 static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
2430     PyObject *result;
2431     PyObject *args = PyTuple_New(1);
2432     if (unlikely(!args)) return NULL;
2433     Py_INCREF(arg);
2434     PyTuple_SET_ITEM(args, 0, arg);
2435     result = __Pyx_PyObject_Call(func, args, NULL);
2436     Py_DECREF(args);
2437     return result;
2438 }
__Pyx_PyObject_CallOneArg(PyObject * func,PyObject * arg)2439 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
2440 #if CYTHON_FAST_PYCALL
2441     if (PyFunction_Check(func)) {
2442         return __Pyx_PyFunction_FastCall(func, &arg, 1);
2443     }
2444 #endif
2445     if (likely(PyCFunction_Check(func))) {
2446         if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
2447             return __Pyx_PyObject_CallMethO(func, arg);
2448 #if CYTHON_FAST_PYCCALL
2449         } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) {
2450             return __Pyx_PyCFunction_FastCall(func, &arg, 1);
2451 #endif
2452         }
2453     }
2454     return __Pyx__PyObject_CallOneArg(func, arg);
2455 }
2456 #else
__Pyx_PyObject_CallOneArg(PyObject * func,PyObject * arg)2457 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
2458     PyObject *result;
2459     PyObject *args = PyTuple_Pack(1, arg);
2460     if (unlikely(!args)) return NULL;
2461     result = __Pyx_PyObject_Call(func, args, NULL);
2462     Py_DECREF(args);
2463     return result;
2464 }
2465 #endif
2466 
2467 /* TypeImport */
2468 #ifndef __PYX_HAVE_RT_ImportType
2469 #define __PYX_HAVE_RT_ImportType
__Pyx_ImportType(PyObject * module,const char * module_name,const char * class_name,size_t size,enum __Pyx_ImportType_CheckSize check_size)2470 static PyTypeObject *__Pyx_ImportType(PyObject *module, const char *module_name, const char *class_name,
2471     size_t size, enum __Pyx_ImportType_CheckSize check_size)
2472 {
2473     PyObject *result = 0;
2474     char warning[200];
2475     Py_ssize_t basicsize;
2476 #ifdef Py_LIMITED_API
2477     PyObject *py_basicsize;
2478 #endif
2479     result = PyObject_GetAttrString(module, class_name);
2480     if (!result)
2481         goto bad;
2482     if (!PyType_Check(result)) {
2483         PyErr_Format(PyExc_TypeError,
2484             "%.200s.%.200s is not a type object",
2485             module_name, class_name);
2486         goto bad;
2487     }
2488 #ifndef Py_LIMITED_API
2489     basicsize = ((PyTypeObject *)result)->tp_basicsize;
2490 #else
2491     py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
2492     if (!py_basicsize)
2493         goto bad;
2494     basicsize = PyLong_AsSsize_t(py_basicsize);
2495     Py_DECREF(py_basicsize);
2496     py_basicsize = 0;
2497     if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
2498         goto bad;
2499 #endif
2500     if ((size_t)basicsize < size) {
2501         PyErr_Format(PyExc_ValueError,
2502             "%.200s.%.200s size changed, may indicate binary incompatibility. "
2503             "Expected %zd from C header, got %zd from PyObject",
2504             module_name, class_name, size, basicsize);
2505         goto bad;
2506     }
2507     if (check_size == __Pyx_ImportType_CheckSize_Error && (size_t)basicsize != size) {
2508         PyErr_Format(PyExc_ValueError,
2509             "%.200s.%.200s size changed, may indicate binary incompatibility. "
2510             "Expected %zd from C header, got %zd from PyObject",
2511             module_name, class_name, size, basicsize);
2512         goto bad;
2513     }
2514     else if (check_size == __Pyx_ImportType_CheckSize_Warn && (size_t)basicsize > size) {
2515         PyOS_snprintf(warning, sizeof(warning),
2516             "%s.%s size changed, may indicate binary incompatibility. "
2517             "Expected %zd from C header, got %zd from PyObject",
2518             module_name, class_name, size, basicsize);
2519         if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
2520     }
2521     return (PyTypeObject *)result;
2522 bad:
2523     Py_XDECREF(result);
2524     return NULL;
2525 }
2526 #endif
2527 
2528 /* PyDictVersioning */
2529 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
__Pyx_get_tp_dict_version(PyObject * obj)2530 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
2531     PyObject *dict = Py_TYPE(obj)->tp_dict;
2532     return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
2533 }
__Pyx_get_object_dict_version(PyObject * obj)2534 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
2535     PyObject **dictptr = NULL;
2536     Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
2537     if (offset) {
2538 #if CYTHON_COMPILING_IN_CPYTHON
2539         dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
2540 #else
2541         dictptr = _PyObject_GetDictPtr(obj);
2542 #endif
2543     }
2544     return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
2545 }
__Pyx_object_dict_version_matches(PyObject * obj,PY_UINT64_T tp_dict_version,PY_UINT64_T obj_dict_version)2546 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
2547     PyObject *dict = Py_TYPE(obj)->tp_dict;
2548     if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
2549         return 0;
2550     return obj_dict_version == __Pyx_get_object_dict_version(obj);
2551 }
2552 #endif
2553 
2554 /* PyErrFetchRestore */
2555 #if CYTHON_FAST_THREAD_STATE
__Pyx_ErrRestoreInState(PyThreadState * tstate,PyObject * type,PyObject * value,PyObject * tb)2556 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
2557     PyObject *tmp_type, *tmp_value, *tmp_tb;
2558     tmp_type = tstate->curexc_type;
2559     tmp_value = tstate->curexc_value;
2560     tmp_tb = tstate->curexc_traceback;
2561     tstate->curexc_type = type;
2562     tstate->curexc_value = value;
2563     tstate->curexc_traceback = tb;
2564     Py_XDECREF(tmp_type);
2565     Py_XDECREF(tmp_value);
2566     Py_XDECREF(tmp_tb);
2567 }
__Pyx_ErrFetchInState(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)2568 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
2569     *type = tstate->curexc_type;
2570     *value = tstate->curexc_value;
2571     *tb = tstate->curexc_traceback;
2572     tstate->curexc_type = 0;
2573     tstate->curexc_value = 0;
2574     tstate->curexc_traceback = 0;
2575 }
2576 #endif
2577 
2578 /* CLineInTraceback */
2579 #ifndef CYTHON_CLINE_IN_TRACEBACK
__Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState * tstate,int c_line)2580 static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) {
2581     PyObject *use_cline;
2582     PyObject *ptype, *pvalue, *ptraceback;
2583 #if CYTHON_COMPILING_IN_CPYTHON
2584     PyObject **cython_runtime_dict;
2585 #endif
2586     if (unlikely(!__pyx_cython_runtime)) {
2587         return c_line;
2588     }
2589     __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
2590 #if CYTHON_COMPILING_IN_CPYTHON
2591     cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
2592     if (likely(cython_runtime_dict)) {
2593         __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
2594             use_cline, *cython_runtime_dict,
2595             __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback))
2596     } else
2597 #endif
2598     {
2599       PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
2600       if (use_cline_obj) {
2601         use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
2602         Py_DECREF(use_cline_obj);
2603       } else {
2604         PyErr_Clear();
2605         use_cline = NULL;
2606       }
2607     }
2608     if (!use_cline) {
2609         c_line = 0;
2610         PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
2611     }
2612     else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
2613         c_line = 0;
2614     }
2615     __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
2616     return c_line;
2617 }
2618 #endif
2619 
2620 /* CodeObjectCache */
__pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry * entries,int count,int code_line)2621 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
2622     int start = 0, mid = 0, end = count - 1;
2623     if (end >= 0 && code_line > entries[end].code_line) {
2624         return count;
2625     }
2626     while (start < end) {
2627         mid = start + (end - start) / 2;
2628         if (code_line < entries[mid].code_line) {
2629             end = mid;
2630         } else if (code_line > entries[mid].code_line) {
2631              start = mid + 1;
2632         } else {
2633             return mid;
2634         }
2635     }
2636     if (code_line <= entries[mid].code_line) {
2637         return mid;
2638     } else {
2639         return mid + 1;
2640     }
2641 }
__pyx_find_code_object(int code_line)2642 static PyCodeObject *__pyx_find_code_object(int code_line) {
2643     PyCodeObject* code_object;
2644     int pos;
2645     if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
2646         return NULL;
2647     }
2648     pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
2649     if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
2650         return NULL;
2651     }
2652     code_object = __pyx_code_cache.entries[pos].code_object;
2653     Py_INCREF(code_object);
2654     return code_object;
2655 }
__pyx_insert_code_object(int code_line,PyCodeObject * code_object)2656 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
2657     int pos, i;
2658     __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
2659     if (unlikely(!code_line)) {
2660         return;
2661     }
2662     if (unlikely(!entries)) {
2663         entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
2664         if (likely(entries)) {
2665             __pyx_code_cache.entries = entries;
2666             __pyx_code_cache.max_count = 64;
2667             __pyx_code_cache.count = 1;
2668             entries[0].code_line = code_line;
2669             entries[0].code_object = code_object;
2670             Py_INCREF(code_object);
2671         }
2672         return;
2673     }
2674     pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
2675     if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
2676         PyCodeObject* tmp = entries[pos].code_object;
2677         entries[pos].code_object = code_object;
2678         Py_DECREF(tmp);
2679         return;
2680     }
2681     if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
2682         int new_max = __pyx_code_cache.max_count + 64;
2683         entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
2684             __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry));
2685         if (unlikely(!entries)) {
2686             return;
2687         }
2688         __pyx_code_cache.entries = entries;
2689         __pyx_code_cache.max_count = new_max;
2690     }
2691     for (i=__pyx_code_cache.count; i>pos; i--) {
2692         entries[i] = entries[i-1];
2693     }
2694     entries[pos].code_line = code_line;
2695     entries[pos].code_object = code_object;
2696     __pyx_code_cache.count++;
2697     Py_INCREF(code_object);
2698 }
2699 
2700 /* AddTraceback */
2701 #include "compile.h"
2702 #include "frameobject.h"
2703 #include "traceback.h"
__Pyx_CreateCodeObjectForTraceback(const char * funcname,int c_line,int py_line,const char * filename)2704 static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
2705             const char *funcname, int c_line,
2706             int py_line, const char *filename) {
2707     PyCodeObject *py_code = 0;
2708     PyObject *py_srcfile = 0;
2709     PyObject *py_funcname = 0;
2710     #if PY_MAJOR_VERSION < 3
2711     py_srcfile = PyString_FromString(filename);
2712     #else
2713     py_srcfile = PyUnicode_FromString(filename);
2714     #endif
2715     if (!py_srcfile) goto bad;
2716     if (c_line) {
2717         #if PY_MAJOR_VERSION < 3
2718         py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
2719         #else
2720         py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
2721         #endif
2722     }
2723     else {
2724         #if PY_MAJOR_VERSION < 3
2725         py_funcname = PyString_FromString(funcname);
2726         #else
2727         py_funcname = PyUnicode_FromString(funcname);
2728         #endif
2729     }
2730     if (!py_funcname) goto bad;
2731     py_code = __Pyx_PyCode_New(
2732         0,
2733         0,
2734         0,
2735         0,
2736         0,
2737         __pyx_empty_bytes, /*PyObject *code,*/
2738         __pyx_empty_tuple, /*PyObject *consts,*/
2739         __pyx_empty_tuple, /*PyObject *names,*/
2740         __pyx_empty_tuple, /*PyObject *varnames,*/
2741         __pyx_empty_tuple, /*PyObject *freevars,*/
2742         __pyx_empty_tuple, /*PyObject *cellvars,*/
2743         py_srcfile,   /*PyObject *filename,*/
2744         py_funcname,  /*PyObject *name,*/
2745         py_line,
2746         __pyx_empty_bytes  /*PyObject *lnotab*/
2747     );
2748     Py_DECREF(py_srcfile);
2749     Py_DECREF(py_funcname);
2750     return py_code;
2751 bad:
2752     Py_XDECREF(py_srcfile);
2753     Py_XDECREF(py_funcname);
2754     return NULL;
2755 }
__Pyx_AddTraceback(const char * funcname,int c_line,int py_line,const char * filename)2756 static void __Pyx_AddTraceback(const char *funcname, int c_line,
2757                                int py_line, const char *filename) {
2758     PyCodeObject *py_code = 0;
2759     PyFrameObject *py_frame = 0;
2760     PyThreadState *tstate = __Pyx_PyThreadState_Current;
2761     if (c_line) {
2762         c_line = __Pyx_CLineForTraceback(tstate, c_line);
2763     }
2764     py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
2765     if (!py_code) {
2766         py_code = __Pyx_CreateCodeObjectForTraceback(
2767             funcname, c_line, py_line, filename);
2768         if (!py_code) goto bad;
2769         __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
2770     }
2771     py_frame = PyFrame_New(
2772         tstate,            /*PyThreadState *tstate,*/
2773         py_code,           /*PyCodeObject *code,*/
2774         __pyx_d,    /*PyObject *globals,*/
2775         0                  /*PyObject *locals*/
2776     );
2777     if (!py_frame) goto bad;
2778     __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
2779     PyTraceBack_Here(py_frame);
2780 bad:
2781     Py_XDECREF(py_code);
2782     Py_XDECREF(py_frame);
2783 }
2784 
2785 /* CIntToPy */
__Pyx_PyInt_From_long(long value)2786 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
2787     const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0;
2788     const int is_unsigned = neg_one > const_zero;
2789     if (is_unsigned) {
2790         if (sizeof(long) < sizeof(long)) {
2791             return PyInt_FromLong((long) value);
2792         } else if (sizeof(long) <= sizeof(unsigned long)) {
2793             return PyLong_FromUnsignedLong((unsigned long) value);
2794 #ifdef HAVE_LONG_LONG
2795         } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
2796             return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
2797 #endif
2798         }
2799     } else {
2800         if (sizeof(long) <= sizeof(long)) {
2801             return PyInt_FromLong((long) value);
2802 #ifdef HAVE_LONG_LONG
2803         } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
2804             return PyLong_FromLongLong((PY_LONG_LONG) value);
2805 #endif
2806         }
2807     }
2808     {
2809         int one = 1; int little = (int)*(unsigned char *)&one;
2810         unsigned char *bytes = (unsigned char *)&value;
2811         return _PyLong_FromByteArray(bytes, sizeof(long),
2812                                      little, !is_unsigned);
2813     }
2814 }
2815 
2816 /* CIntFromPyVerify */
2817 #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
2818     __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
2819 #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
2820     __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
2821 #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
2822     {\
2823         func_type value = func_value;\
2824         if (sizeof(target_type) < sizeof(func_type)) {\
2825             if (unlikely(value != (func_type) (target_type) value)) {\
2826                 func_type zero = 0;\
2827                 if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
2828                     return (target_type) -1;\
2829                 if (is_unsigned && unlikely(value < zero))\
2830                     goto raise_neg_overflow;\
2831                 else\
2832                     goto raise_overflow;\
2833             }\
2834         }\
2835         return (target_type) value;\
2836     }
2837 
2838 /* CIntFromPy */
__Pyx_PyInt_As_long(PyObject * x)2839 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
2840     const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0;
2841     const int is_unsigned = neg_one > const_zero;
2842 #if PY_MAJOR_VERSION < 3
2843     if (likely(PyInt_Check(x))) {
2844         if (sizeof(long) < sizeof(long)) {
2845             __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
2846         } else {
2847             long val = PyInt_AS_LONG(x);
2848             if (is_unsigned && unlikely(val < 0)) {
2849                 goto raise_neg_overflow;
2850             }
2851             return (long) val;
2852         }
2853     } else
2854 #endif
2855     if (likely(PyLong_Check(x))) {
2856         if (is_unsigned) {
2857 #if CYTHON_USE_PYLONG_INTERNALS
2858             const digit* digits = ((PyLongObject*)x)->ob_digit;
2859             switch (Py_SIZE(x)) {
2860                 case  0: return (long) 0;
2861                 case  1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
2862                 case 2:
2863                     if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
2864                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
2865                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
2866                         } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
2867                             return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
2868                         }
2869                     }
2870                     break;
2871                 case 3:
2872                     if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
2873                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
2874                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
2875                         } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
2876                             return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
2877                         }
2878                     }
2879                     break;
2880                 case 4:
2881                     if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
2882                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
2883                             __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])))
2884                         } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
2885                             return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
2886                         }
2887                     }
2888                     break;
2889             }
2890 #endif
2891 #if CYTHON_COMPILING_IN_CPYTHON
2892             if (unlikely(Py_SIZE(x) < 0)) {
2893                 goto raise_neg_overflow;
2894             }
2895 #else
2896             {
2897                 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
2898                 if (unlikely(result < 0))
2899                     return (long) -1;
2900                 if (unlikely(result == 1))
2901                     goto raise_neg_overflow;
2902             }
2903 #endif
2904             if (sizeof(long) <= sizeof(unsigned long)) {
2905                 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
2906 #ifdef HAVE_LONG_LONG
2907             } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
2908                 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
2909 #endif
2910             }
2911         } else {
2912 #if CYTHON_USE_PYLONG_INTERNALS
2913             const digit* digits = ((PyLongObject*)x)->ob_digit;
2914             switch (Py_SIZE(x)) {
2915                 case  0: return (long) 0;
2916                 case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
2917                 case  1: __PYX_VERIFY_RETURN_INT(long,  digit, +digits[0])
2918                 case -2:
2919                     if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
2920                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
2921                             __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
2922                         } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
2923                             return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
2924                         }
2925                     }
2926                     break;
2927                 case 2:
2928                     if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
2929                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
2930                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
2931                         } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
2932                             return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
2933                         }
2934                     }
2935                     break;
2936                 case -3:
2937                     if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
2938                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
2939                             __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
2940                         } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
2941                             return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
2942                         }
2943                     }
2944                     break;
2945                 case 3:
2946                     if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
2947                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
2948                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
2949                         } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
2950                             return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
2951                         }
2952                     }
2953                     break;
2954                 case -4:
2955                     if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
2956                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
2957                             __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])))
2958                         } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
2959                             return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
2960                         }
2961                     }
2962                     break;
2963                 case 4:
2964                     if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
2965                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
2966                             __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])))
2967                         } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
2968                             return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
2969                         }
2970                     }
2971                     break;
2972             }
2973 #endif
2974             if (sizeof(long) <= sizeof(long)) {
2975                 __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
2976 #ifdef HAVE_LONG_LONG
2977             } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
2978                 __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
2979 #endif
2980             }
2981         }
2982         {
2983 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
2984             PyErr_SetString(PyExc_RuntimeError,
2985                             "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
2986 #else
2987             long val;
2988             PyObject *v = __Pyx_PyNumber_IntOrLong(x);
2989  #if PY_MAJOR_VERSION < 3
2990             if (likely(v) && !PyLong_Check(v)) {
2991                 PyObject *tmp = v;
2992                 v = PyNumber_Long(tmp);
2993                 Py_DECREF(tmp);
2994             }
2995  #endif
2996             if (likely(v)) {
2997                 int one = 1; int is_little = (int)*(unsigned char *)&one;
2998                 unsigned char *bytes = (unsigned char *)&val;
2999                 int ret = _PyLong_AsByteArray((PyLongObject *)v,
3000                                               bytes, sizeof(val),
3001                                               is_little, !is_unsigned);
3002                 Py_DECREF(v);
3003                 if (likely(!ret))
3004                     return val;
3005             }
3006 #endif
3007             return (long) -1;
3008         }
3009     } else {
3010         long val;
3011         PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
3012         if (!tmp) return (long) -1;
3013         val = __Pyx_PyInt_As_long(tmp);
3014         Py_DECREF(tmp);
3015         return val;
3016     }
3017 raise_overflow:
3018     PyErr_SetString(PyExc_OverflowError,
3019         "value too large to convert to long");
3020     return (long) -1;
3021 raise_neg_overflow:
3022     PyErr_SetString(PyExc_OverflowError,
3023         "can't convert negative value to long");
3024     return (long) -1;
3025 }
3026 
3027 /* CIntFromPy */
__Pyx_PyInt_As_int(PyObject * x)3028 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
3029     const int neg_one = (int) ((int) 0 - (int) 1), const_zero = (int) 0;
3030     const int is_unsigned = neg_one > const_zero;
3031 #if PY_MAJOR_VERSION < 3
3032     if (likely(PyInt_Check(x))) {
3033         if (sizeof(int) < sizeof(long)) {
3034             __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
3035         } else {
3036             long val = PyInt_AS_LONG(x);
3037             if (is_unsigned && unlikely(val < 0)) {
3038                 goto raise_neg_overflow;
3039             }
3040             return (int) val;
3041         }
3042     } else
3043 #endif
3044     if (likely(PyLong_Check(x))) {
3045         if (is_unsigned) {
3046 #if CYTHON_USE_PYLONG_INTERNALS
3047             const digit* digits = ((PyLongObject*)x)->ob_digit;
3048             switch (Py_SIZE(x)) {
3049                 case  0: return (int) 0;
3050                 case  1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
3051                 case 2:
3052                     if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
3053                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
3054                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3055                         } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
3056                             return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
3057                         }
3058                     }
3059                     break;
3060                 case 3:
3061                     if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
3062                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
3063                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3064                         } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
3065                             return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
3066                         }
3067                     }
3068                     break;
3069                 case 4:
3070                     if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
3071                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
3072                             __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])))
3073                         } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
3074                             return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
3075                         }
3076                     }
3077                     break;
3078             }
3079 #endif
3080 #if CYTHON_COMPILING_IN_CPYTHON
3081             if (unlikely(Py_SIZE(x) < 0)) {
3082                 goto raise_neg_overflow;
3083             }
3084 #else
3085             {
3086                 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
3087                 if (unlikely(result < 0))
3088                     return (int) -1;
3089                 if (unlikely(result == 1))
3090                     goto raise_neg_overflow;
3091             }
3092 #endif
3093             if (sizeof(int) <= sizeof(unsigned long)) {
3094                 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
3095 #ifdef HAVE_LONG_LONG
3096             } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
3097                 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
3098 #endif
3099             }
3100         } else {
3101 #if CYTHON_USE_PYLONG_INTERNALS
3102             const digit* digits = ((PyLongObject*)x)->ob_digit;
3103             switch (Py_SIZE(x)) {
3104                 case  0: return (int) 0;
3105                 case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
3106                 case  1: __PYX_VERIFY_RETURN_INT(int,  digit, +digits[0])
3107                 case -2:
3108                     if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
3109                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
3110                             __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3111                         } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
3112                             return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
3113                         }
3114                     }
3115                     break;
3116                 case 2:
3117                     if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
3118                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
3119                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3120                         } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
3121                             return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
3122                         }
3123                     }
3124                     break;
3125                 case -3:
3126                     if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
3127                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
3128                             __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3129                         } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
3130                             return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
3131                         }
3132                     }
3133                     break;
3134                 case 3:
3135                     if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
3136                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
3137                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3138                         } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
3139                             return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
3140                         }
3141                     }
3142                     break;
3143                 case -4:
3144                     if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
3145                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
3146                             __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])))
3147                         } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
3148                             return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
3149                         }
3150                     }
3151                     break;
3152                 case 4:
3153                     if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
3154                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
3155                             __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])))
3156                         } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
3157                             return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
3158                         }
3159                     }
3160                     break;
3161             }
3162 #endif
3163             if (sizeof(int) <= sizeof(long)) {
3164                 __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
3165 #ifdef HAVE_LONG_LONG
3166             } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
3167                 __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
3168 #endif
3169             }
3170         }
3171         {
3172 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
3173             PyErr_SetString(PyExc_RuntimeError,
3174                             "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
3175 #else
3176             int val;
3177             PyObject *v = __Pyx_PyNumber_IntOrLong(x);
3178  #if PY_MAJOR_VERSION < 3
3179             if (likely(v) && !PyLong_Check(v)) {
3180                 PyObject *tmp = v;
3181                 v = PyNumber_Long(tmp);
3182                 Py_DECREF(tmp);
3183             }
3184  #endif
3185             if (likely(v)) {
3186                 int one = 1; int is_little = (int)*(unsigned char *)&one;
3187                 unsigned char *bytes = (unsigned char *)&val;
3188                 int ret = _PyLong_AsByteArray((PyLongObject *)v,
3189                                               bytes, sizeof(val),
3190                                               is_little, !is_unsigned);
3191                 Py_DECREF(v);
3192                 if (likely(!ret))
3193                     return val;
3194             }
3195 #endif
3196             return (int) -1;
3197         }
3198     } else {
3199         int val;
3200         PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
3201         if (!tmp) return (int) -1;
3202         val = __Pyx_PyInt_As_int(tmp);
3203         Py_DECREF(tmp);
3204         return val;
3205     }
3206 raise_overflow:
3207     PyErr_SetString(PyExc_OverflowError,
3208         "value too large to convert to int");
3209     return (int) -1;
3210 raise_neg_overflow:
3211     PyErr_SetString(PyExc_OverflowError,
3212         "can't convert negative value to int");
3213     return (int) -1;
3214 }
3215 
3216 /* FastTypeChecks */
3217 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_InBases(PyTypeObject * a,PyTypeObject * b)3218 static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
3219     while (a) {
3220         a = a->tp_base;
3221         if (a == b)
3222             return 1;
3223     }
3224     return b == &PyBaseObject_Type;
3225 }
__Pyx_IsSubtype(PyTypeObject * a,PyTypeObject * b)3226 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
3227     PyObject *mro;
3228     if (a == b) return 1;
3229     mro = a->tp_mro;
3230     if (likely(mro)) {
3231         Py_ssize_t i, n;
3232         n = PyTuple_GET_SIZE(mro);
3233         for (i = 0; i < n; i++) {
3234             if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
3235                 return 1;
3236         }
3237         return 0;
3238     }
3239     return __Pyx_InBases(a, b);
3240 }
3241 #if PY_MAJOR_VERSION == 2
__Pyx_inner_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)3242 static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
3243     PyObject *exception, *value, *tb;
3244     int res;
3245     __Pyx_PyThreadState_declare
3246     __Pyx_PyThreadState_assign
3247     __Pyx_ErrFetch(&exception, &value, &tb);
3248     res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
3249     if (unlikely(res == -1)) {
3250         PyErr_WriteUnraisable(err);
3251         res = 0;
3252     }
3253     if (!res) {
3254         res = PyObject_IsSubclass(err, exc_type2);
3255         if (unlikely(res == -1)) {
3256             PyErr_WriteUnraisable(err);
3257             res = 0;
3258         }
3259     }
3260     __Pyx_ErrRestore(exception, value, tb);
3261     return res;
3262 }
3263 #else
__Pyx_inner_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)3264 static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
3265     int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
3266     if (!res) {
3267         res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
3268     }
3269     return res;
3270 }
3271 #endif
__Pyx_PyErr_GivenExceptionMatchesTuple(PyObject * exc_type,PyObject * tuple)3272 static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
3273     Py_ssize_t i, n;
3274     assert(PyExceptionClass_Check(exc_type));
3275     n = PyTuple_GET_SIZE(tuple);
3276 #if PY_MAJOR_VERSION >= 3
3277     for (i=0; i<n; i++) {
3278         if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
3279     }
3280 #endif
3281     for (i=0; i<n; i++) {
3282         PyObject *t = PyTuple_GET_ITEM(tuple, i);
3283         #if PY_MAJOR_VERSION < 3
3284         if (likely(exc_type == t)) return 1;
3285         #endif
3286         if (likely(PyExceptionClass_Check(t))) {
3287             if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
3288         } else {
3289         }
3290     }
3291     return 0;
3292 }
__Pyx_PyErr_GivenExceptionMatches(PyObject * err,PyObject * exc_type)3293 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
3294     if (likely(err == exc_type)) return 1;
3295     if (likely(PyExceptionClass_Check(err))) {
3296         if (likely(PyExceptionClass_Check(exc_type))) {
3297             return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
3298         } else if (likely(PyTuple_Check(exc_type))) {
3299             return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
3300         } else {
3301         }
3302     }
3303     return PyErr_GivenExceptionMatches(err, exc_type);
3304 }
__Pyx_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)3305 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
3306     assert(PyExceptionClass_Check(exc_type1));
3307     assert(PyExceptionClass_Check(exc_type2));
3308     if (likely(err == exc_type1 || err == exc_type2)) return 1;
3309     if (likely(PyExceptionClass_Check(err))) {
3310         return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
3311     }
3312     return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
3313 }
3314 #endif
3315 
3316 /* CheckBinaryVersion */
__Pyx_check_binary_version(void)3317 static int __Pyx_check_binary_version(void) {
3318     char ctversion[4], rtversion[4];
3319     PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
3320     PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
3321     if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
3322         char message[200];
3323         PyOS_snprintf(message, sizeof(message),
3324                       "compiletime version %s of module '%.100s' "
3325                       "does not match runtime version %s",
3326                       ctversion, __Pyx_MODULE_NAME, rtversion);
3327         return PyErr_WarnEx(NULL, message, 1);
3328     }
3329     return 0;
3330 }
3331 
3332 /* InitStrings */
__Pyx_InitStrings(__Pyx_StringTabEntry * t)3333 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
3334     while (t->p) {
3335         #if PY_MAJOR_VERSION < 3
3336         if (t->is_unicode) {
3337             *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
3338         } else if (t->intern) {
3339             *t->p = PyString_InternFromString(t->s);
3340         } else {
3341             *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
3342         }
3343         #else
3344         if (t->is_unicode | t->is_str) {
3345             if (t->intern) {
3346                 *t->p = PyUnicode_InternFromString(t->s);
3347             } else if (t->encoding) {
3348                 *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
3349             } else {
3350                 *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
3351             }
3352         } else {
3353             *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
3354         }
3355         #endif
3356         if (!*t->p)
3357             return -1;
3358         if (PyObject_Hash(*t->p) == -1)
3359             return -1;
3360         ++t;
3361     }
3362     return 0;
3363 }
3364 
__Pyx_PyUnicode_FromString(const char * c_str)3365 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
3366     return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
3367 }
__Pyx_PyObject_AsString(PyObject * o)3368 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
3369     Py_ssize_t ignore;
3370     return __Pyx_PyObject_AsStringAndSize(o, &ignore);
3371 }
3372 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
3373 #if !CYTHON_PEP393_ENABLED
__Pyx_PyUnicode_AsStringAndSize(PyObject * o,Py_ssize_t * length)3374 static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
3375     char* defenc_c;
3376     PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
3377     if (!defenc) return NULL;
3378     defenc_c = PyBytes_AS_STRING(defenc);
3379 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
3380     {
3381         char* end = defenc_c + PyBytes_GET_SIZE(defenc);
3382         char* c;
3383         for (c = defenc_c; c < end; c++) {
3384             if ((unsigned char) (*c) >= 128) {
3385                 PyUnicode_AsASCIIString(o);
3386                 return NULL;
3387             }
3388         }
3389     }
3390 #endif
3391     *length = PyBytes_GET_SIZE(defenc);
3392     return defenc_c;
3393 }
3394 #else
__Pyx_PyUnicode_AsStringAndSize(PyObject * o,Py_ssize_t * length)3395 static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
3396     if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
3397 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
3398     if (likely(PyUnicode_IS_ASCII(o))) {
3399         *length = PyUnicode_GET_LENGTH(o);
3400         return PyUnicode_AsUTF8(o);
3401     } else {
3402         PyUnicode_AsASCIIString(o);
3403         return NULL;
3404     }
3405 #else
3406     return PyUnicode_AsUTF8AndSize(o, length);
3407 #endif
3408 }
3409 #endif
3410 #endif
__Pyx_PyObject_AsStringAndSize(PyObject * o,Py_ssize_t * length)3411 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
3412 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
3413     if (
3414 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
3415             __Pyx_sys_getdefaultencoding_not_ascii &&
3416 #endif
3417             PyUnicode_Check(o)) {
3418         return __Pyx_PyUnicode_AsStringAndSize(o, length);
3419     } else
3420 #endif
3421 #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
3422     if (PyByteArray_Check(o)) {
3423         *length = PyByteArray_GET_SIZE(o);
3424         return PyByteArray_AS_STRING(o);
3425     } else
3426 #endif
3427     {
3428         char* result;
3429         int r = PyBytes_AsStringAndSize(o, &result, length);
3430         if (unlikely(r < 0)) {
3431             return NULL;
3432         } else {
3433             return result;
3434         }
3435     }
3436 }
__Pyx_PyObject_IsTrue(PyObject * x)3437 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
3438    int is_true = x == Py_True;
3439    if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
3440    else return PyObject_IsTrue(x);
3441 }
__Pyx_PyObject_IsTrueAndDecref(PyObject * x)3442 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
3443     int retval;
3444     if (unlikely(!x)) return -1;
3445     retval = __Pyx_PyObject_IsTrue(x);
3446     Py_DECREF(x);
3447     return retval;
3448 }
__Pyx_PyNumber_IntOrLongWrongResultType(PyObject * result,const char * type_name)3449 static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
3450 #if PY_MAJOR_VERSION >= 3
3451     if (PyLong_Check(result)) {
3452         if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
3453                 "__int__ returned non-int (type %.200s).  "
3454                 "The ability to return an instance of a strict subclass of int "
3455                 "is deprecated, and may be removed in a future version of Python.",
3456                 Py_TYPE(result)->tp_name)) {
3457             Py_DECREF(result);
3458             return NULL;
3459         }
3460         return result;
3461     }
3462 #endif
3463     PyErr_Format(PyExc_TypeError,
3464                  "__%.4s__ returned non-%.4s (type %.200s)",
3465                  type_name, type_name, Py_TYPE(result)->tp_name);
3466     Py_DECREF(result);
3467     return NULL;
3468 }
__Pyx_PyNumber_IntOrLong(PyObject * x)3469 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
3470 #if CYTHON_USE_TYPE_SLOTS
3471   PyNumberMethods *m;
3472 #endif
3473   const char *name = NULL;
3474   PyObject *res = NULL;
3475 #if PY_MAJOR_VERSION < 3
3476   if (likely(PyInt_Check(x) || PyLong_Check(x)))
3477 #else
3478   if (likely(PyLong_Check(x)))
3479 #endif
3480     return __Pyx_NewRef(x);
3481 #if CYTHON_USE_TYPE_SLOTS
3482   m = Py_TYPE(x)->tp_as_number;
3483   #if PY_MAJOR_VERSION < 3
3484   if (m && m->nb_int) {
3485     name = "int";
3486     res = m->nb_int(x);
3487   }
3488   else if (m && m->nb_long) {
3489     name = "long";
3490     res = m->nb_long(x);
3491   }
3492   #else
3493   if (likely(m && m->nb_int)) {
3494     name = "int";
3495     res = m->nb_int(x);
3496   }
3497   #endif
3498 #else
3499   if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
3500     res = PyNumber_Int(x);
3501   }
3502 #endif
3503   if (likely(res)) {
3504 #if PY_MAJOR_VERSION < 3
3505     if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
3506 #else
3507     if (unlikely(!PyLong_CheckExact(res))) {
3508 #endif
3509         return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
3510     }
3511   }
3512   else if (!PyErr_Occurred()) {
3513     PyErr_SetString(PyExc_TypeError,
3514                     "an integer is required");
3515   }
3516   return res;
3517 }
3518 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
3519   Py_ssize_t ival;
3520   PyObject *x;
3521 #if PY_MAJOR_VERSION < 3
3522   if (likely(PyInt_CheckExact(b))) {
3523     if (sizeof(Py_ssize_t) >= sizeof(long))
3524         return PyInt_AS_LONG(b);
3525     else
3526         return PyInt_AsSsize_t(b);
3527   }
3528 #endif
3529   if (likely(PyLong_CheckExact(b))) {
3530     #if CYTHON_USE_PYLONG_INTERNALS
3531     const digit* digits = ((PyLongObject*)b)->ob_digit;
3532     const Py_ssize_t size = Py_SIZE(b);
3533     if (likely(__Pyx_sst_abs(size) <= 1)) {
3534         ival = likely(size) ? digits[0] : 0;
3535         if (size == -1) ival = -ival;
3536         return ival;
3537     } else {
3538       switch (size) {
3539          case 2:
3540            if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
3541              return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
3542            }
3543            break;
3544          case -2:
3545            if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
3546              return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
3547            }
3548            break;
3549          case 3:
3550            if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
3551              return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
3552            }
3553            break;
3554          case -3:
3555            if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
3556              return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
3557            }
3558            break;
3559          case 4:
3560            if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
3561              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]));
3562            }
3563            break;
3564          case -4:
3565            if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
3566              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]));
3567            }
3568            break;
3569       }
3570     }
3571     #endif
3572     return PyLong_AsSsize_t(b);
3573   }
3574   x = PyNumber_Index(b);
3575   if (!x) return -1;
3576   ival = PyInt_AsSsize_t(x);
3577   Py_DECREF(x);
3578   return ival;
3579 }
3580 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
3581   return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
3582 }
3583 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
3584     return PyInt_FromSize_t(ival);
3585 }
3586 
3587 
3588 #endif /* Py_PYTHON_H */
3589