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