Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/wapython
Path: blob/main/python/bench/src/cython/numbers.c
1067 views
1
/* Generated by Cython 0.29.32 */
2
3
/* BEGIN: Cython Metadata
4
{
5
"distutils": {
6
"name": "numbers",
7
"sources": [
8
"numbers.pyx"
9
]
10
},
11
"module_name": "numbers"
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__numbers
754
#define __PYX_HAVE_API__numbers
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
"numbers.pyx",
966
"stringsource",
967
};
968
969
/*--- Type declarations ---*/
970
struct __pyx_obj_7numbers_A;
971
972
/* "numbers.pyx":12
973
* register("pi(10**5)", pi)
974
*
975
* cdef class A: # <<<<<<<<<<<<<<
976
* cdef int i
977
* def __init__(self, int i):
978
*/
979
struct __pyx_obj_7numbers_A {
980
PyObject_HEAD
981
int i;
982
};
983
984
985
/* --- Runtime support code (head) --- */
986
/* Refnanny.proto */
987
#ifndef CYTHON_REFNANNY
988
#define CYTHON_REFNANNY 0
989
#endif
990
#if CYTHON_REFNANNY
991
typedef struct {
992
void (*INCREF)(void*, PyObject*, int);
993
void (*DECREF)(void*, PyObject*, int);
994
void (*GOTREF)(void*, PyObject*, int);
995
void (*GIVEREF)(void*, PyObject*, int);
996
void* (*SetupContext)(const char*, int, const char*);
997
void (*FinishContext)(void**);
998
} __Pyx_RefNannyAPIStruct;
999
static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
1000
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
1001
#define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
1002
#ifdef WITH_THREAD
1003
#define __Pyx_RefNannySetupContext(name, acquire_gil)\
1004
if (acquire_gil) {\
1005
PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
1006
__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
1007
PyGILState_Release(__pyx_gilstate_save);\
1008
} else {\
1009
__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
1010
}
1011
#else
1012
#define __Pyx_RefNannySetupContext(name, acquire_gil)\
1013
__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
1014
#endif
1015
#define __Pyx_RefNannyFinishContext()\
1016
__Pyx_RefNanny->FinishContext(&__pyx_refnanny)
1017
#define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1018
#define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1019
#define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1020
#define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1021
#define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
1022
#define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
1023
#define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
1024
#define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
1025
#else
1026
#define __Pyx_RefNannyDeclarations
1027
#define __Pyx_RefNannySetupContext(name, acquire_gil)
1028
#define __Pyx_RefNannyFinishContext()
1029
#define __Pyx_INCREF(r) Py_INCREF(r)
1030
#define __Pyx_DECREF(r) Py_DECREF(r)
1031
#define __Pyx_GOTREF(r)
1032
#define __Pyx_GIVEREF(r)
1033
#define __Pyx_XINCREF(r) Py_XINCREF(r)
1034
#define __Pyx_XDECREF(r) Py_XDECREF(r)
1035
#define __Pyx_XGOTREF(r)
1036
#define __Pyx_XGIVEREF(r)
1037
#endif
1038
#define __Pyx_XDECREF_SET(r, v) do {\
1039
PyObject *tmp = (PyObject *) r;\
1040
r = v; __Pyx_XDECREF(tmp);\
1041
} while (0)
1042
#define __Pyx_DECREF_SET(r, v) do {\
1043
PyObject *tmp = (PyObject *) r;\
1044
r = v; __Pyx_DECREF(tmp);\
1045
} while (0)
1046
#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
1047
#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
1048
1049
/* PyObjectGetAttrStr.proto */
1050
#if CYTHON_USE_TYPE_SLOTS
1051
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
1052
#else
1053
#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
1054
#endif
1055
1056
/* GetBuiltinName.proto */
1057
static PyObject *__Pyx_GetBuiltinName(PyObject *name);
1058
1059
/* RaiseDoubleKeywords.proto */
1060
static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
1061
1062
/* ParseKeywords.proto */
1063
static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
1064
PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
1065
const char* function_name);
1066
1067
/* RaiseArgTupleInvalid.proto */
1068
static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
1069
Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
1070
1071
/* PyIntCompare.proto */
1072
static CYTHON_INLINE PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, long intval, long inplace);
1073
1074
/* PyDictVersioning.proto */
1075
#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
1076
#define __PYX_DICT_VERSION_INIT ((PY_UINT64_T) -1)
1077
#define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag)
1078
#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
1079
(version_var) = __PYX_GET_DICT_VERSION(dict);\
1080
(cache_var) = (value);
1081
#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
1082
static PY_UINT64_T __pyx_dict_version = 0;\
1083
static PyObject *__pyx_dict_cached_value = NULL;\
1084
if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
1085
(VAR) = __pyx_dict_cached_value;\
1086
} else {\
1087
(VAR) = __pyx_dict_cached_value = (LOOKUP);\
1088
__pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
1089
}\
1090
}
1091
static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj);
1092
static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj);
1093
static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version);
1094
#else
1095
#define __PYX_GET_DICT_VERSION(dict) (0)
1096
#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
1097
#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) (VAR) = (LOOKUP);
1098
#endif
1099
1100
/* GetModuleGlobalName.proto */
1101
#if CYTHON_USE_DICT_VERSIONS
1102
#define __Pyx_GetModuleGlobalName(var, name) {\
1103
static PY_UINT64_T __pyx_dict_version = 0;\
1104
static PyObject *__pyx_dict_cached_value = NULL;\
1105
(var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\
1106
(likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\
1107
__Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
1108
}
1109
#define __Pyx_GetModuleGlobalNameUncached(var, name) {\
1110
PY_UINT64_T __pyx_dict_version;\
1111
PyObject *__pyx_dict_cached_value;\
1112
(var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
1113
}
1114
static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value);
1115
#else
1116
#define __Pyx_GetModuleGlobalName(var, name) (var) = __Pyx__GetModuleGlobalName(name)
1117
#define __Pyx_GetModuleGlobalNameUncached(var, name) (var) = __Pyx__GetModuleGlobalName(name)
1118
static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name);
1119
#endif
1120
1121
/* PyCFunctionFastCall.proto */
1122
#if CYTHON_FAST_PYCCALL
1123
static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
1124
#else
1125
#define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL)
1126
#endif
1127
1128
/* PyFunctionFastCall.proto */
1129
#if CYTHON_FAST_PYCALL
1130
#define __Pyx_PyFunction_FastCall(func, args, nargs)\
1131
__Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
1132
#if 1 || PY_VERSION_HEX < 0x030600B1
1133
static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs);
1134
#else
1135
#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
1136
#endif
1137
#define __Pyx_BUILD_ASSERT_EXPR(cond)\
1138
(sizeof(char [1 - 2*!(cond)]) - 1)
1139
#ifndef Py_MEMBER_SIZE
1140
#define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
1141
#endif
1142
#if CYTHON_FAST_PYCALL
1143
static size_t __pyx_pyframe_localsplus_offset = 0;
1144
#include "frameobject.h"
1145
#if PY_VERSION_HEX >= 0x030b00a6
1146
#ifndef Py_BUILD_CORE
1147
#define Py_BUILD_CORE 1
1148
#endif
1149
#include "internal/pycore_frame.h"
1150
#endif
1151
#define __Pxy_PyFrame_Initialize_Offsets()\
1152
((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\
1153
(void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus)))
1154
#define __Pyx_PyFrame_GetLocalsplus(frame)\
1155
(assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset))
1156
#endif // CYTHON_FAST_PYCALL
1157
#endif
1158
1159
/* PyObjectCall.proto */
1160
#if CYTHON_COMPILING_IN_CPYTHON
1161
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
1162
#else
1163
#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
1164
#endif
1165
1166
/* PyObjectCall2Args.proto */
1167
static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2);
1168
1169
/* PyObjectCallMethO.proto */
1170
#if CYTHON_COMPILING_IN_CPYTHON
1171
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
1172
#endif
1173
1174
/* PyObjectCallOneArg.proto */
1175
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
1176
1177
/* PyErrExceptionMatches.proto */
1178
#if CYTHON_FAST_THREAD_STATE
1179
#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
1180
static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
1181
#else
1182
#define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err)
1183
#endif
1184
1185
/* PyThreadStateGet.proto */
1186
#if CYTHON_FAST_THREAD_STATE
1187
#define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
1188
#define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current;
1189
#define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type
1190
#else
1191
#define __Pyx_PyThreadState_declare
1192
#define __Pyx_PyThreadState_assign
1193
#define __Pyx_PyErr_Occurred() PyErr_Occurred()
1194
#endif
1195
1196
/* PyErrFetchRestore.proto */
1197
#if CYTHON_FAST_THREAD_STATE
1198
#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
1199
#define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
1200
#define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
1201
#define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
1202
#define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
1203
static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
1204
static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1205
#if CYTHON_COMPILING_IN_CPYTHON
1206
#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
1207
#else
1208
#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
1209
#endif
1210
#else
1211
#define __Pyx_PyErr_Clear() PyErr_Clear()
1212
#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
1213
#define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
1214
#define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
1215
#define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb)
1216
#define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb)
1217
#define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
1218
#define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
1219
#endif
1220
1221
/* GetAttr.proto */
1222
static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *);
1223
1224
/* GetAttr3.proto */
1225
static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *);
1226
1227
/* None.proto */
1228
static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname);
1229
1230
/* PyObjectCallNoArg.proto */
1231
#if CYTHON_COMPILING_IN_CPYTHON
1232
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
1233
#else
1234
#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
1235
#endif
1236
1237
/* PyIntBinop.proto */
1238
#if !CYTHON_COMPILING_IN_PYPY
1239
static PyObject* __Pyx_PyInt_AddCObj(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
1240
#else
1241
#define __Pyx_PyInt_AddCObj(op1, op2, intval, inplace, zerodivision_check)\
1242
(inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2))
1243
#endif
1244
1245
/* GetItemInt.proto */
1246
#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1247
(__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1248
__Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\
1249
(is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
1250
__Pyx_GetItemInt_Generic(o, to_py_func(i))))
1251
#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1252
(__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1253
__Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
1254
(PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
1255
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
1256
int wraparound, int boundscheck);
1257
#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1258
(__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1259
__Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
1260
(PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
1261
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
1262
int wraparound, int boundscheck);
1263
static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
1264
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
1265
int is_list, int wraparound, int boundscheck);
1266
1267
/* PySequenceContains.proto */
1268
static CYTHON_INLINE int __Pyx_PySequence_ContainsTF(PyObject* item, PyObject* seq, int eq) {
1269
int result = PySequence_Contains(seq, item);
1270
return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
1271
}
1272
1273
/* Import.proto */
1274
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
1275
1276
/* ImportFrom.proto */
1277
static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
1278
1279
/* RaiseException.proto */
1280
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
1281
1282
/* HasAttr.proto */
1283
static CYTHON_INLINE int __Pyx_HasAttr(PyObject *, PyObject *);
1284
1285
/* PyObject_GenericGetAttrNoDict.proto */
1286
#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
1287
static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
1288
#else
1289
#define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
1290
#endif
1291
1292
/* PyObject_GenericGetAttr.proto */
1293
#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
1294
static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name);
1295
#else
1296
#define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr
1297
#endif
1298
1299
/* PyObjectGetAttrStrNoError.proto */
1300
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name);
1301
1302
/* SetupReduce.proto */
1303
static int __Pyx_setup_reduce(PyObject* type_obj);
1304
1305
/* IncludeStringH.proto */
1306
#include <string.h>
1307
1308
/* BytesEquals.proto */
1309
static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals);
1310
1311
/* UnicodeEquals.proto */
1312
static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals);
1313
1314
/* StrEquals.proto */
1315
#if PY_MAJOR_VERSION >= 3
1316
#define __Pyx_PyString_Equals __Pyx_PyUnicode_Equals
1317
#else
1318
#define __Pyx_PyString_Equals __Pyx_PyBytes_Equals
1319
#endif
1320
1321
/* CLineInTraceback.proto */
1322
#ifdef CYTHON_CLINE_IN_TRACEBACK
1323
#define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
1324
#else
1325
static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
1326
#endif
1327
1328
/* CodeObjectCache.proto */
1329
typedef struct {
1330
PyCodeObject* code_object;
1331
int code_line;
1332
} __Pyx_CodeObjectCacheEntry;
1333
struct __Pyx_CodeObjectCache {
1334
int count;
1335
int max_count;
1336
__Pyx_CodeObjectCacheEntry* entries;
1337
};
1338
static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
1339
static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
1340
static PyCodeObject *__pyx_find_code_object(int code_line);
1341
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
1342
1343
/* AddTraceback.proto */
1344
static void __Pyx_AddTraceback(const char *funcname, int c_line,
1345
int py_line, const char *filename);
1346
1347
/* GCCDiagnostics.proto */
1348
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
1349
#define __Pyx_HAS_GCC_DIAGNOSTIC
1350
#endif
1351
1352
/* CIntToPy.proto */
1353
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
1354
1355
/* CIntFromPy.proto */
1356
static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
1357
1358
/* CIntFromPy.proto */
1359
static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_As_PY_LONG_LONG(PyObject *);
1360
1361
/* CIntFromPy.proto */
1362
static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
1363
1364
/* CIntToPy.proto */
1365
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
1366
1367
/* CIntToPy.proto */
1368
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_PY_LONG_LONG(PY_LONG_LONG value);
1369
1370
/* FastTypeChecks.proto */
1371
#if CYTHON_COMPILING_IN_CPYTHON
1372
#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
1373
static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
1374
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
1375
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
1376
#else
1377
#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
1378
#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
1379
#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
1380
#endif
1381
#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
1382
1383
/* CheckBinaryVersion.proto */
1384
static int __Pyx_check_binary_version(void);
1385
1386
/* FunctionImport.proto */
1387
static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig);
1388
1389
/* InitStrings.proto */
1390
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
1391
1392
1393
/* Module declarations from 'nt' */
1394
static int (*__pyx_f_2nt_gcd)(int, int, int __pyx_skip_dispatch); /*proto*/
1395
static int (*__pyx_f_2nt_xgcd_c)(int, int, int *, int *); /*proto*/
1396
static int (*__pyx_f_2nt_inverse_mod)(int, int, int __pyx_skip_dispatch); /*proto*/
1397
1398
/* Module declarations from 'numbers' */
1399
static PyTypeObject *__pyx_ptype_7numbers_A = 0;
1400
static PyObject *__pyx_f_7numbers___pyx_unpickle_A__set_state(struct __pyx_obj_7numbers_A *, PyObject *); /*proto*/
1401
#define __Pyx_MODULE_NAME "numbers"
1402
extern int __pyx_module_is_main_numbers;
1403
int __pyx_module_is_main_numbers = 0;
1404
1405
/* Implementation of 'numbers' */
1406
static PyObject *__pyx_builtin_range;
1407
static PyObject *__pyx_builtin_sum;
1408
static PyObject *__pyx_builtin_reversed;
1409
static const char __pyx_k_A[] = "A";
1410
static const char __pyx_k_a[] = "a";
1411
static const char __pyx_k_b[] = "b";
1412
static const char __pyx_k_c[] = "c";
1413
static const char __pyx_k_i[] = "i";
1414
static const char __pyx_k_n[] = "n";
1415
static const char __pyx_k_s[] = "s";
1416
static const char __pyx_k_cx[] = "cx";
1417
static const char __pyx_k_cy[] = "cy";
1418
static const char __pyx_k_nt[] = "nt";
1419
static const char __pyx_k_pi[] = "pi";
1420
static const char __pyx_k_all[] = "all";
1421
static const char __pyx_k_gcd[] = "gcd";
1422
static const char __pyx_k_new[] = "__new__";
1423
static const char __pyx_k_sum[] = "sum";
1424
static const char __pyx_k_dict[] = "__dict__";
1425
static const char __pyx_k_main[] = "__main__";
1426
static const char __pyx_k_name[] = "__name__";
1427
static const char __pyx_k_test[] = "__test__";
1428
static const char __pyx_k_xgcd[] = "xgcd";
1429
static const char __pyx_k_bench[] = "bench";
1430
static const char __pyx_k_range[] = "range";
1431
static const char __pyx_k_value[] = "value";
1432
static const char __pyx_k_import[] = "__import__";
1433
static const char __pyx_k_pickle[] = "pickle";
1434
static const char __pyx_k_reduce[] = "__reduce__";
1435
static const char __pyx_k_update[] = "update";
1436
static const char __pyx_k_numbers[] = "numbers";
1437
static const char __pyx_k_pi_10_5[] = "pi(10**5)";
1438
static const char __pyx_k_test_pi[] = "test_pi";
1439
static const char __pyx_k_getstate[] = "__getstate__";
1440
static const char __pyx_k_pyx_type[] = "__pyx_type";
1441
static const char __pyx_k_register[] = "register";
1442
static const char __pyx_k_reversed[] = "reversed";
1443
static const char __pyx_k_setstate[] = "__setstate__";
1444
static const char __pyx_k_sum_loop[] = "sum_loop";
1445
static const char __pyx_k_bench_gcd[] = "bench_gcd";
1446
static const char __pyx_k_pyx_state[] = "__pyx_state";
1447
static const char __pyx_k_reduce_ex[] = "__reduce_ex__";
1448
static const char __pyx_k_sum_range[] = "sum_range";
1449
static const char __pyx_k_bench_xgcd[] = "bench_xgcd";
1450
static const char __pyx_k_pyx_result[] = "__pyx_result";
1451
static const char __pyx_k_PickleError[] = "PickleError";
1452
static const char __pyx_k_numbers_pyx[] = "numbers.pyx";
1453
static const char __pyx_k_operator_add[] = "operator_add";
1454
static const char __pyx_k_pyx_checksum[] = "__pyx_checksum";
1455
static const char __pyx_k_stringsource[] = "stringsource";
1456
static const char __pyx_k_sum_reversed[] = "sum_reversed";
1457
static const char __pyx_k_bench_xgcd_py[] = "bench_xgcd_py";
1458
static const char __pyx_k_reduce_cython[] = "__reduce_cython__";
1459
static const char __pyx_k_pyx_unpickle_A[] = "__pyx_unpickle_A";
1460
static const char __pyx_k_pyx_PickleError[] = "__pyx_PickleError";
1461
static const char __pyx_k_setstate_cython[] = "__setstate_cython__";
1462
static const char __pyx_k_bench_inverse_mod[] = "bench_inverse_mod";
1463
static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
1464
static const char __pyx_k_Incompatible_checksums_0x_x_vs_0[] = "Incompatible checksums (0x%x vs (0x865c0c0, 0xde7d1b7, 0x042dc45) = (i))";
1465
static PyObject *__pyx_n_s_A;
1466
static PyObject *__pyx_kp_s_Incompatible_checksums_0x_x_vs_0;
1467
static PyObject *__pyx_n_s_PickleError;
1468
static PyObject *__pyx_n_s_a;
1469
static PyObject *__pyx_n_s_all;
1470
static PyObject *__pyx_n_s_b;
1471
static PyObject *__pyx_n_s_bench;
1472
static PyObject *__pyx_n_s_bench_gcd;
1473
static PyObject *__pyx_n_s_bench_inverse_mod;
1474
static PyObject *__pyx_n_s_bench_xgcd;
1475
static PyObject *__pyx_n_s_bench_xgcd_py;
1476
static PyObject *__pyx_n_s_c;
1477
static PyObject *__pyx_n_s_cline_in_traceback;
1478
static PyObject *__pyx_n_s_cx;
1479
static PyObject *__pyx_n_s_cy;
1480
static PyObject *__pyx_n_s_dict;
1481
static PyObject *__pyx_n_s_gcd;
1482
static PyObject *__pyx_n_s_getstate;
1483
static PyObject *__pyx_n_s_i;
1484
static PyObject *__pyx_n_s_import;
1485
static PyObject *__pyx_n_s_main;
1486
static PyObject *__pyx_n_s_n;
1487
static PyObject *__pyx_n_s_name;
1488
static PyObject *__pyx_n_s_new;
1489
static PyObject *__pyx_n_s_nt;
1490
static PyObject *__pyx_n_s_numbers;
1491
static PyObject *__pyx_kp_s_numbers_pyx;
1492
static PyObject *__pyx_n_s_operator_add;
1493
static PyObject *__pyx_n_s_pi;
1494
static PyObject *__pyx_kp_s_pi_10_5;
1495
static PyObject *__pyx_n_s_pickle;
1496
static PyObject *__pyx_n_s_pyx_PickleError;
1497
static PyObject *__pyx_n_s_pyx_checksum;
1498
static PyObject *__pyx_n_s_pyx_result;
1499
static PyObject *__pyx_n_s_pyx_state;
1500
static PyObject *__pyx_n_s_pyx_type;
1501
static PyObject *__pyx_n_s_pyx_unpickle_A;
1502
static PyObject *__pyx_n_s_range;
1503
static PyObject *__pyx_n_s_reduce;
1504
static PyObject *__pyx_n_s_reduce_cython;
1505
static PyObject *__pyx_n_s_reduce_ex;
1506
static PyObject *__pyx_n_s_register;
1507
static PyObject *__pyx_n_s_reversed;
1508
static PyObject *__pyx_n_s_s;
1509
static PyObject *__pyx_n_s_setstate;
1510
static PyObject *__pyx_n_s_setstate_cython;
1511
static PyObject *__pyx_kp_s_stringsource;
1512
static PyObject *__pyx_n_s_sum;
1513
static PyObject *__pyx_n_s_sum_loop;
1514
static PyObject *__pyx_n_s_sum_range;
1515
static PyObject *__pyx_n_s_sum_reversed;
1516
static PyObject *__pyx_n_s_test;
1517
static PyObject *__pyx_n_s_test_pi;
1518
static PyObject *__pyx_n_s_update;
1519
static PyObject *__pyx_n_s_value;
1520
static PyObject *__pyx_n_s_xgcd;
1521
static PyObject *__pyx_pf_7numbers_test_pi(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_n); /* proto */
1522
static int __pyx_pf_7numbers_1A___init__(struct __pyx_obj_7numbers_A *__pyx_v_self, int __pyx_v_i); /* proto */
1523
static PyObject *__pyx_pf_7numbers_1A_2value(struct __pyx_obj_7numbers_A *__pyx_v_self); /* proto */
1524
static PyObject *__pyx_pf_7numbers_1A_4__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_right); /* proto */
1525
static PyObject *__pyx_pf_7numbers_1A_6__reduce_cython__(struct __pyx_obj_7numbers_A *__pyx_v_self); /* proto */
1526
static PyObject *__pyx_pf_7numbers_1A_8__setstate_cython__(struct __pyx_obj_7numbers_A *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
1527
static PyObject *__pyx_pf_7numbers_2operator_add(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_n); /* proto */
1528
static PyObject *__pyx_pf_7numbers_4bench_gcd(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_n); /* proto */
1529
static PyObject *__pyx_pf_7numbers_6bench_xgcd_py(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_n); /* proto */
1530
static PyObject *__pyx_pf_7numbers_8bench_xgcd(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_n); /* proto */
1531
static PyObject *__pyx_pf_7numbers_10bench_inverse_mod(CYTHON_UNUSED PyObject *__pyx_self, PY_LONG_LONG __pyx_v_n); /* proto */
1532
static PyObject *__pyx_pf_7numbers_12sum_loop(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_n); /* proto */
1533
static PyObject *__pyx_pf_7numbers_14sum_range(CYTHON_UNUSED PyObject *__pyx_self, PY_LONG_LONG __pyx_v_n); /* proto */
1534
static PyObject *__pyx_pf_7numbers_16sum_reversed(CYTHON_UNUSED PyObject *__pyx_self, PY_LONG_LONG __pyx_v_n); /* proto */
1535
static PyObject *__pyx_pf_7numbers_18__pyx_unpickle_A(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
1536
static PyObject *__pyx_tp_new_7numbers_A(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
1537
static PyObject *__pyx_int_0;
1538
static PyObject *__pyx_int_2;
1539
static PyObject *__pyx_int_3;
1540
static PyObject *__pyx_int_5;
1541
static PyObject *__pyx_int_9592;
1542
static PyObject *__pyx_int_92250;
1543
static PyObject *__pyx_int_100000;
1544
static PyObject *__pyx_int_922350;
1545
static PyObject *__pyx_int_2414484;
1546
static PyObject *__pyx_int_4381765;
1547
static PyObject *__pyx_int_140886208;
1548
static PyObject *__pyx_int_233296311;
1549
static PyObject *__pyx_int_166666833333;
1550
static PyObject *__pyx_int_53532319533988;
1551
static PyObject *__pyx_tuple_;
1552
static PyObject *__pyx_tuple__2;
1553
static PyObject *__pyx_tuple__3;
1554
static PyObject *__pyx_tuple__4;
1555
static PyObject *__pyx_tuple__6;
1556
static PyObject *__pyx_tuple__8;
1557
static PyObject *__pyx_tuple__10;
1558
static PyObject *__pyx_tuple__12;
1559
static PyObject *__pyx_tuple__14;
1560
static PyObject *__pyx_tuple__16;
1561
static PyObject *__pyx_tuple__18;
1562
static PyObject *__pyx_tuple__20;
1563
static PyObject *__pyx_tuple__22;
1564
static PyObject *__pyx_tuple__23;
1565
static PyObject *__pyx_codeobj__5;
1566
static PyObject *__pyx_codeobj__7;
1567
static PyObject *__pyx_codeobj__9;
1568
static PyObject *__pyx_codeobj__11;
1569
static PyObject *__pyx_codeobj__13;
1570
static PyObject *__pyx_codeobj__15;
1571
static PyObject *__pyx_codeobj__17;
1572
static PyObject *__pyx_codeobj__19;
1573
static PyObject *__pyx_codeobj__21;
1574
static PyObject *__pyx_codeobj__24;
1575
/* Late includes */
1576
1577
/* "numbers.pyx":6
1578
* from nt cimport gcd, xgcd_c, inverse_mod
1579
*
1580
* def test_pi(n=100000): # <<<<<<<<<<<<<<
1581
* assert pi(n) == 9592
1582
*
1583
*/
1584
1585
/* Python wrapper */
1586
static PyObject *__pyx_pw_7numbers_1test_pi(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
1587
static PyMethodDef __pyx_mdef_7numbers_1test_pi = {"test_pi", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7numbers_1test_pi, METH_VARARGS|METH_KEYWORDS, 0};
1588
static PyObject *__pyx_pw_7numbers_1test_pi(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
1589
PyObject *__pyx_v_n = 0;
1590
int __pyx_lineno = 0;
1591
const char *__pyx_filename = NULL;
1592
int __pyx_clineno = 0;
1593
PyObject *__pyx_r = 0;
1594
__Pyx_RefNannyDeclarations
1595
__Pyx_RefNannySetupContext("test_pi (wrapper)", 0);
1596
{
1597
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_n,0};
1598
PyObject* values[1] = {0};
1599
values[0] = ((PyObject *)__pyx_int_100000);
1600
if (unlikely(__pyx_kwds)) {
1601
Py_ssize_t kw_args;
1602
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
1603
switch (pos_args) {
1604
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1605
CYTHON_FALLTHROUGH;
1606
case 0: break;
1607
default: goto __pyx_L5_argtuple_error;
1608
}
1609
kw_args = PyDict_Size(__pyx_kwds);
1610
switch (pos_args) {
1611
case 0:
1612
if (kw_args > 0) {
1613
PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_n);
1614
if (value) { values[0] = value; kw_args--; }
1615
}
1616
}
1617
if (unlikely(kw_args > 0)) {
1618
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "test_pi") < 0)) __PYX_ERR(0, 6, __pyx_L3_error)
1619
}
1620
} else {
1621
switch (PyTuple_GET_SIZE(__pyx_args)) {
1622
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1623
CYTHON_FALLTHROUGH;
1624
case 0: break;
1625
default: goto __pyx_L5_argtuple_error;
1626
}
1627
}
1628
__pyx_v_n = values[0];
1629
}
1630
goto __pyx_L4_argument_unpacking_done;
1631
__pyx_L5_argtuple_error:;
1632
__Pyx_RaiseArgtupleInvalid("test_pi", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 6, __pyx_L3_error)
1633
__pyx_L3_error:;
1634
__Pyx_AddTraceback("numbers.test_pi", __pyx_clineno, __pyx_lineno, __pyx_filename);
1635
__Pyx_RefNannyFinishContext();
1636
return NULL;
1637
__pyx_L4_argument_unpacking_done:;
1638
__pyx_r = __pyx_pf_7numbers_test_pi(__pyx_self, __pyx_v_n);
1639
1640
/* function exit code */
1641
__Pyx_RefNannyFinishContext();
1642
return __pyx_r;
1643
}
1644
1645
static PyObject *__pyx_pf_7numbers_test_pi(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_n) {
1646
PyObject *__pyx_r = NULL;
1647
__Pyx_RefNannyDeclarations
1648
PyObject *__pyx_t_1 = NULL;
1649
PyObject *__pyx_t_2 = NULL;
1650
PyObject *__pyx_t_3 = NULL;
1651
int __pyx_t_4;
1652
int __pyx_lineno = 0;
1653
const char *__pyx_filename = NULL;
1654
int __pyx_clineno = 0;
1655
__Pyx_RefNannySetupContext("test_pi", 0);
1656
1657
/* "numbers.pyx":7
1658
*
1659
* def test_pi(n=100000):
1660
* assert pi(n) == 9592 # <<<<<<<<<<<<<<
1661
*
1662
*
1663
*/
1664
#ifndef CYTHON_WITHOUT_ASSERTIONS
1665
if (unlikely(!Py_OptimizeFlag)) {
1666
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_pi); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7, __pyx_L1_error)
1667
__Pyx_GOTREF(__pyx_t_2);
1668
__pyx_t_3 = NULL;
1669
if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
1670
__pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
1671
if (likely(__pyx_t_3)) {
1672
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
1673
__Pyx_INCREF(__pyx_t_3);
1674
__Pyx_INCREF(function);
1675
__Pyx_DECREF_SET(__pyx_t_2, function);
1676
}
1677
}
1678
__pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_n) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_n);
1679
__Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
1680
if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7, __pyx_L1_error)
1681
__Pyx_GOTREF(__pyx_t_1);
1682
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1683
__pyx_t_2 = __Pyx_PyInt_EqObjC(__pyx_t_1, __pyx_int_9592, 0x2578, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7, __pyx_L1_error)
1684
__Pyx_GOTREF(__pyx_t_2);
1685
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1686
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 7, __pyx_L1_error)
1687
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1688
if (unlikely(!__pyx_t_4)) {
1689
PyErr_SetNone(PyExc_AssertionError);
1690
__PYX_ERR(0, 7, __pyx_L1_error)
1691
}
1692
}
1693
#endif
1694
1695
/* "numbers.pyx":6
1696
* from nt cimport gcd, xgcd_c, inverse_mod
1697
*
1698
* def test_pi(n=100000): # <<<<<<<<<<<<<<
1699
* assert pi(n) == 9592
1700
*
1701
*/
1702
1703
/* function exit code */
1704
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
1705
goto __pyx_L0;
1706
__pyx_L1_error:;
1707
__Pyx_XDECREF(__pyx_t_1);
1708
__Pyx_XDECREF(__pyx_t_2);
1709
__Pyx_XDECREF(__pyx_t_3);
1710
__Pyx_AddTraceback("numbers.test_pi", __pyx_clineno, __pyx_lineno, __pyx_filename);
1711
__pyx_r = NULL;
1712
__pyx_L0:;
1713
__Pyx_XGIVEREF(__pyx_r);
1714
__Pyx_RefNannyFinishContext();
1715
return __pyx_r;
1716
}
1717
1718
/* "numbers.pyx":14
1719
* cdef class A:
1720
* cdef int i
1721
* def __init__(self, int i): # <<<<<<<<<<<<<<
1722
* self.i = i
1723
*
1724
*/
1725
1726
/* Python wrapper */
1727
static int __pyx_pw_7numbers_1A_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
1728
static int __pyx_pw_7numbers_1A_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
1729
int __pyx_v_i;
1730
int __pyx_lineno = 0;
1731
const char *__pyx_filename = NULL;
1732
int __pyx_clineno = 0;
1733
int __pyx_r;
1734
__Pyx_RefNannyDeclarations
1735
__Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
1736
{
1737
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_i,0};
1738
PyObject* values[1] = {0};
1739
if (unlikely(__pyx_kwds)) {
1740
Py_ssize_t kw_args;
1741
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
1742
switch (pos_args) {
1743
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1744
CYTHON_FALLTHROUGH;
1745
case 0: break;
1746
default: goto __pyx_L5_argtuple_error;
1747
}
1748
kw_args = PyDict_Size(__pyx_kwds);
1749
switch (pos_args) {
1750
case 0:
1751
if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_i)) != 0)) kw_args--;
1752
else goto __pyx_L5_argtuple_error;
1753
}
1754
if (unlikely(kw_args > 0)) {
1755
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 14, __pyx_L3_error)
1756
}
1757
} else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
1758
goto __pyx_L5_argtuple_error;
1759
} else {
1760
values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1761
}
1762
__pyx_v_i = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_i == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 14, __pyx_L3_error)
1763
}
1764
goto __pyx_L4_argument_unpacking_done;
1765
__pyx_L5_argtuple_error:;
1766
__Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 14, __pyx_L3_error)
1767
__pyx_L3_error:;
1768
__Pyx_AddTraceback("numbers.A.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
1769
__Pyx_RefNannyFinishContext();
1770
return -1;
1771
__pyx_L4_argument_unpacking_done:;
1772
__pyx_r = __pyx_pf_7numbers_1A___init__(((struct __pyx_obj_7numbers_A *)__pyx_v_self), __pyx_v_i);
1773
1774
/* function exit code */
1775
__Pyx_RefNannyFinishContext();
1776
return __pyx_r;
1777
}
1778
1779
static int __pyx_pf_7numbers_1A___init__(struct __pyx_obj_7numbers_A *__pyx_v_self, int __pyx_v_i) {
1780
int __pyx_r;
1781
__Pyx_RefNannyDeclarations
1782
__Pyx_RefNannySetupContext("__init__", 0);
1783
1784
/* "numbers.pyx":15
1785
* cdef int i
1786
* def __init__(self, int i):
1787
* self.i = i # <<<<<<<<<<<<<<
1788
*
1789
* def value(self):
1790
*/
1791
__pyx_v_self->i = __pyx_v_i;
1792
1793
/* "numbers.pyx":14
1794
* cdef class A:
1795
* cdef int i
1796
* def __init__(self, int i): # <<<<<<<<<<<<<<
1797
* self.i = i
1798
*
1799
*/
1800
1801
/* function exit code */
1802
__pyx_r = 0;
1803
__Pyx_RefNannyFinishContext();
1804
return __pyx_r;
1805
}
1806
1807
/* "numbers.pyx":17
1808
* self.i = i
1809
*
1810
* def value(self): # <<<<<<<<<<<<<<
1811
* return self.i
1812
*
1813
*/
1814
1815
/* Python wrapper */
1816
static PyObject *__pyx_pw_7numbers_1A_3value(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
1817
static PyObject *__pyx_pw_7numbers_1A_3value(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
1818
PyObject *__pyx_r = 0;
1819
__Pyx_RefNannyDeclarations
1820
__Pyx_RefNannySetupContext("value (wrapper)", 0);
1821
__pyx_r = __pyx_pf_7numbers_1A_2value(((struct __pyx_obj_7numbers_A *)__pyx_v_self));
1822
1823
/* function exit code */
1824
__Pyx_RefNannyFinishContext();
1825
return __pyx_r;
1826
}
1827
1828
static PyObject *__pyx_pf_7numbers_1A_2value(struct __pyx_obj_7numbers_A *__pyx_v_self) {
1829
PyObject *__pyx_r = NULL;
1830
__Pyx_RefNannyDeclarations
1831
PyObject *__pyx_t_1 = NULL;
1832
int __pyx_lineno = 0;
1833
const char *__pyx_filename = NULL;
1834
int __pyx_clineno = 0;
1835
__Pyx_RefNannySetupContext("value", 0);
1836
1837
/* "numbers.pyx":18
1838
*
1839
* def value(self):
1840
* return self.i # <<<<<<<<<<<<<<
1841
*
1842
* def __add__(self, right):
1843
*/
1844
__Pyx_XDECREF(__pyx_r);
1845
__pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->i); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 18, __pyx_L1_error)
1846
__Pyx_GOTREF(__pyx_t_1);
1847
__pyx_r = __pyx_t_1;
1848
__pyx_t_1 = 0;
1849
goto __pyx_L0;
1850
1851
/* "numbers.pyx":17
1852
* self.i = i
1853
*
1854
* def value(self): # <<<<<<<<<<<<<<
1855
* return self.i
1856
*
1857
*/
1858
1859
/* function exit code */
1860
__pyx_L1_error:;
1861
__Pyx_XDECREF(__pyx_t_1);
1862
__Pyx_AddTraceback("numbers.A.value", __pyx_clineno, __pyx_lineno, __pyx_filename);
1863
__pyx_r = NULL;
1864
__pyx_L0:;
1865
__Pyx_XGIVEREF(__pyx_r);
1866
__Pyx_RefNannyFinishContext();
1867
return __pyx_r;
1868
}
1869
1870
/* "numbers.pyx":20
1871
* return self.i
1872
*
1873
* def __add__(self, right): # <<<<<<<<<<<<<<
1874
* return A((<A>self).i + (<A>right).i)
1875
*
1876
*/
1877
1878
/* Python wrapper */
1879
static PyObject *__pyx_pw_7numbers_1A_5__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_right); /*proto*/
1880
static PyObject *__pyx_pw_7numbers_1A_5__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_right) {
1881
PyObject *__pyx_r = 0;
1882
__Pyx_RefNannyDeclarations
1883
__Pyx_RefNannySetupContext("__add__ (wrapper)", 0);
1884
__pyx_r = __pyx_pf_7numbers_1A_4__add__(((PyObject *)__pyx_v_self), ((PyObject *)__pyx_v_right));
1885
1886
/* function exit code */
1887
__Pyx_RefNannyFinishContext();
1888
return __pyx_r;
1889
}
1890
1891
static PyObject *__pyx_pf_7numbers_1A_4__add__(PyObject *__pyx_v_self, PyObject *__pyx_v_right) {
1892
PyObject *__pyx_r = NULL;
1893
__Pyx_RefNannyDeclarations
1894
PyObject *__pyx_t_1 = NULL;
1895
PyObject *__pyx_t_2 = NULL;
1896
int __pyx_lineno = 0;
1897
const char *__pyx_filename = NULL;
1898
int __pyx_clineno = 0;
1899
__Pyx_RefNannySetupContext("__add__", 0);
1900
1901
/* "numbers.pyx":21
1902
*
1903
* def __add__(self, right):
1904
* return A((<A>self).i + (<A>right).i) # <<<<<<<<<<<<<<
1905
*
1906
* def operator_add(int n=100000):
1907
*/
1908
__Pyx_XDECREF(__pyx_r);
1909
__pyx_t_1 = __Pyx_PyInt_From_int((((struct __pyx_obj_7numbers_A *)__pyx_v_self)->i + ((struct __pyx_obj_7numbers_A *)__pyx_v_right)->i)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 21, __pyx_L1_error)
1910
__Pyx_GOTREF(__pyx_t_1);
1911
__pyx_t_2 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_7numbers_A), __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 21, __pyx_L1_error)
1912
__Pyx_GOTREF(__pyx_t_2);
1913
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1914
__pyx_r = __pyx_t_2;
1915
__pyx_t_2 = 0;
1916
goto __pyx_L0;
1917
1918
/* "numbers.pyx":20
1919
* return self.i
1920
*
1921
* def __add__(self, right): # <<<<<<<<<<<<<<
1922
* return A((<A>self).i + (<A>right).i)
1923
*
1924
*/
1925
1926
/* function exit code */
1927
__pyx_L1_error:;
1928
__Pyx_XDECREF(__pyx_t_1);
1929
__Pyx_XDECREF(__pyx_t_2);
1930
__Pyx_AddTraceback("numbers.A.__add__", __pyx_clineno, __pyx_lineno, __pyx_filename);
1931
__pyx_r = NULL;
1932
__pyx_L0:;
1933
__Pyx_XGIVEREF(__pyx_r);
1934
__Pyx_RefNannyFinishContext();
1935
return __pyx_r;
1936
}
1937
1938
/* "(tree fragment)":1
1939
* def __reduce_cython__(self): # <<<<<<<<<<<<<<
1940
* cdef tuple state
1941
* cdef object _dict
1942
*/
1943
1944
/* Python wrapper */
1945
static PyObject *__pyx_pw_7numbers_1A_7__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
1946
static PyObject *__pyx_pw_7numbers_1A_7__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
1947
PyObject *__pyx_r = 0;
1948
__Pyx_RefNannyDeclarations
1949
__Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
1950
__pyx_r = __pyx_pf_7numbers_1A_6__reduce_cython__(((struct __pyx_obj_7numbers_A *)__pyx_v_self));
1951
1952
/* function exit code */
1953
__Pyx_RefNannyFinishContext();
1954
return __pyx_r;
1955
}
1956
1957
static PyObject *__pyx_pf_7numbers_1A_6__reduce_cython__(struct __pyx_obj_7numbers_A *__pyx_v_self) {
1958
PyObject *__pyx_v_state = 0;
1959
PyObject *__pyx_v__dict = 0;
1960
int __pyx_v_use_setstate;
1961
PyObject *__pyx_r = NULL;
1962
__Pyx_RefNannyDeclarations
1963
PyObject *__pyx_t_1 = NULL;
1964
PyObject *__pyx_t_2 = NULL;
1965
int __pyx_t_3;
1966
int __pyx_t_4;
1967
PyObject *__pyx_t_5 = NULL;
1968
int __pyx_lineno = 0;
1969
const char *__pyx_filename = NULL;
1970
int __pyx_clineno = 0;
1971
__Pyx_RefNannySetupContext("__reduce_cython__", 0);
1972
1973
/* "(tree fragment)":5
1974
* cdef object _dict
1975
* cdef bint use_setstate
1976
* state = (self.i,) # <<<<<<<<<<<<<<
1977
* _dict = getattr(self, '__dict__', None)
1978
* if _dict is not None:
1979
*/
1980
__pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->i); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
1981
__Pyx_GOTREF(__pyx_t_1);
1982
__pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
1983
__Pyx_GOTREF(__pyx_t_2);
1984
__Pyx_GIVEREF(__pyx_t_1);
1985
PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
1986
__pyx_t_1 = 0;
1987
__pyx_v_state = ((PyObject*)__pyx_t_2);
1988
__pyx_t_2 = 0;
1989
1990
/* "(tree fragment)":6
1991
* cdef bint use_setstate
1992
* state = (self.i,)
1993
* _dict = getattr(self, '__dict__', None) # <<<<<<<<<<<<<<
1994
* if _dict is not None:
1995
* state += (_dict,)
1996
*/
1997
__pyx_t_2 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6, __pyx_L1_error)
1998
__Pyx_GOTREF(__pyx_t_2);
1999
__pyx_v__dict = __pyx_t_2;
2000
__pyx_t_2 = 0;
2001
2002
/* "(tree fragment)":7
2003
* state = (self.i,)
2004
* _dict = getattr(self, '__dict__', None)
2005
* if _dict is not None: # <<<<<<<<<<<<<<
2006
* state += (_dict,)
2007
* use_setstate = True
2008
*/
2009
__pyx_t_3 = (__pyx_v__dict != Py_None);
2010
__pyx_t_4 = (__pyx_t_3 != 0);
2011
if (__pyx_t_4) {
2012
2013
/* "(tree fragment)":8
2014
* _dict = getattr(self, '__dict__', None)
2015
* if _dict is not None:
2016
* state += (_dict,) # <<<<<<<<<<<<<<
2017
* use_setstate = True
2018
* else:
2019
*/
2020
__pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 8, __pyx_L1_error)
2021
__Pyx_GOTREF(__pyx_t_2);
2022
__Pyx_INCREF(__pyx_v__dict);
2023
__Pyx_GIVEREF(__pyx_v__dict);
2024
PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v__dict);
2025
__pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8, __pyx_L1_error)
2026
__Pyx_GOTREF(__pyx_t_1);
2027
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2028
__Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_1));
2029
__pyx_t_1 = 0;
2030
2031
/* "(tree fragment)":9
2032
* if _dict is not None:
2033
* state += (_dict,)
2034
* use_setstate = True # <<<<<<<<<<<<<<
2035
* else:
2036
* use_setstate = False
2037
*/
2038
__pyx_v_use_setstate = 1;
2039
2040
/* "(tree fragment)":7
2041
* state = (self.i,)
2042
* _dict = getattr(self, '__dict__', None)
2043
* if _dict is not None: # <<<<<<<<<<<<<<
2044
* state += (_dict,)
2045
* use_setstate = True
2046
*/
2047
goto __pyx_L3;
2048
}
2049
2050
/* "(tree fragment)":11
2051
* use_setstate = True
2052
* else:
2053
* use_setstate = False # <<<<<<<<<<<<<<
2054
* if use_setstate:
2055
* return __pyx_unpickle_A, (type(self), 0x865c0c0, None), state
2056
*/
2057
/*else*/ {
2058
__pyx_v_use_setstate = 0;
2059
}
2060
__pyx_L3:;
2061
2062
/* "(tree fragment)":12
2063
* else:
2064
* use_setstate = False
2065
* if use_setstate: # <<<<<<<<<<<<<<
2066
* return __pyx_unpickle_A, (type(self), 0x865c0c0, None), state
2067
* else:
2068
*/
2069
__pyx_t_4 = (__pyx_v_use_setstate != 0);
2070
if (__pyx_t_4) {
2071
2072
/* "(tree fragment)":13
2073
* use_setstate = False
2074
* if use_setstate:
2075
* return __pyx_unpickle_A, (type(self), 0x865c0c0, None), state # <<<<<<<<<<<<<<
2076
* else:
2077
* return __pyx_unpickle_A, (type(self), 0x865c0c0, state)
2078
*/
2079
__Pyx_XDECREF(__pyx_r);
2080
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pyx_unpickle_A); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 13, __pyx_L1_error)
2081
__Pyx_GOTREF(__pyx_t_1);
2082
__pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 13, __pyx_L1_error)
2083
__Pyx_GOTREF(__pyx_t_2);
2084
__Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
2085
__Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
2086
PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
2087
__Pyx_INCREF(__pyx_int_140886208);
2088
__Pyx_GIVEREF(__pyx_int_140886208);
2089
PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_140886208);
2090
__Pyx_INCREF(Py_None);
2091
__Pyx_GIVEREF(Py_None);
2092
PyTuple_SET_ITEM(__pyx_t_2, 2, Py_None);
2093
__pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 13, __pyx_L1_error)
2094
__Pyx_GOTREF(__pyx_t_5);
2095
__Pyx_GIVEREF(__pyx_t_1);
2096
PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
2097
__Pyx_GIVEREF(__pyx_t_2);
2098
PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2);
2099
__Pyx_INCREF(__pyx_v_state);
2100
__Pyx_GIVEREF(__pyx_v_state);
2101
PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_state);
2102
__pyx_t_1 = 0;
2103
__pyx_t_2 = 0;
2104
__pyx_r = __pyx_t_5;
2105
__pyx_t_5 = 0;
2106
goto __pyx_L0;
2107
2108
/* "(tree fragment)":12
2109
* else:
2110
* use_setstate = False
2111
* if use_setstate: # <<<<<<<<<<<<<<
2112
* return __pyx_unpickle_A, (type(self), 0x865c0c0, None), state
2113
* else:
2114
*/
2115
}
2116
2117
/* "(tree fragment)":15
2118
* return __pyx_unpickle_A, (type(self), 0x865c0c0, None), state
2119
* else:
2120
* return __pyx_unpickle_A, (type(self), 0x865c0c0, state) # <<<<<<<<<<<<<<
2121
* def __setstate_cython__(self, __pyx_state):
2122
* __pyx_unpickle_A__set_state(self, __pyx_state)
2123
*/
2124
/*else*/ {
2125
__Pyx_XDECREF(__pyx_r);
2126
__Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_pyx_unpickle_A); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 15, __pyx_L1_error)
2127
__Pyx_GOTREF(__pyx_t_5);
2128
__pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 15, __pyx_L1_error)
2129
__Pyx_GOTREF(__pyx_t_2);
2130
__Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
2131
__Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
2132
PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
2133
__Pyx_INCREF(__pyx_int_140886208);
2134
__Pyx_GIVEREF(__pyx_int_140886208);
2135
PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_140886208);
2136
__Pyx_INCREF(__pyx_v_state);
2137
__Pyx_GIVEREF(__pyx_v_state);
2138
PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_state);
2139
__pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 15, __pyx_L1_error)
2140
__Pyx_GOTREF(__pyx_t_1);
2141
__Pyx_GIVEREF(__pyx_t_5);
2142
PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5);
2143
__Pyx_GIVEREF(__pyx_t_2);
2144
PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
2145
__pyx_t_5 = 0;
2146
__pyx_t_2 = 0;
2147
__pyx_r = __pyx_t_1;
2148
__pyx_t_1 = 0;
2149
goto __pyx_L0;
2150
}
2151
2152
/* "(tree fragment)":1
2153
* def __reduce_cython__(self): # <<<<<<<<<<<<<<
2154
* cdef tuple state
2155
* cdef object _dict
2156
*/
2157
2158
/* function exit code */
2159
__pyx_L1_error:;
2160
__Pyx_XDECREF(__pyx_t_1);
2161
__Pyx_XDECREF(__pyx_t_2);
2162
__Pyx_XDECREF(__pyx_t_5);
2163
__Pyx_AddTraceback("numbers.A.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
2164
__pyx_r = NULL;
2165
__pyx_L0:;
2166
__Pyx_XDECREF(__pyx_v_state);
2167
__Pyx_XDECREF(__pyx_v__dict);
2168
__Pyx_XGIVEREF(__pyx_r);
2169
__Pyx_RefNannyFinishContext();
2170
return __pyx_r;
2171
}
2172
2173
/* "(tree fragment)":16
2174
* else:
2175
* return __pyx_unpickle_A, (type(self), 0x865c0c0, state)
2176
* def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
2177
* __pyx_unpickle_A__set_state(self, __pyx_state)
2178
*/
2179
2180
/* Python wrapper */
2181
static PyObject *__pyx_pw_7numbers_1A_9__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
2182
static PyObject *__pyx_pw_7numbers_1A_9__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
2183
PyObject *__pyx_r = 0;
2184
__Pyx_RefNannyDeclarations
2185
__Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
2186
__pyx_r = __pyx_pf_7numbers_1A_8__setstate_cython__(((struct __pyx_obj_7numbers_A *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
2187
2188
/* function exit code */
2189
__Pyx_RefNannyFinishContext();
2190
return __pyx_r;
2191
}
2192
2193
static PyObject *__pyx_pf_7numbers_1A_8__setstate_cython__(struct __pyx_obj_7numbers_A *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
2194
PyObject *__pyx_r = NULL;
2195
__Pyx_RefNannyDeclarations
2196
PyObject *__pyx_t_1 = NULL;
2197
int __pyx_lineno = 0;
2198
const char *__pyx_filename = NULL;
2199
int __pyx_clineno = 0;
2200
__Pyx_RefNannySetupContext("__setstate_cython__", 0);
2201
2202
/* "(tree fragment)":17
2203
* return __pyx_unpickle_A, (type(self), 0x865c0c0, state)
2204
* def __setstate_cython__(self, __pyx_state):
2205
* __pyx_unpickle_A__set_state(self, __pyx_state) # <<<<<<<<<<<<<<
2206
*/
2207
if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 17, __pyx_L1_error)
2208
__pyx_t_1 = __pyx_f_7numbers___pyx_unpickle_A__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 17, __pyx_L1_error)
2209
__Pyx_GOTREF(__pyx_t_1);
2210
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2211
2212
/* "(tree fragment)":16
2213
* else:
2214
* return __pyx_unpickle_A, (type(self), 0x865c0c0, state)
2215
* def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
2216
* __pyx_unpickle_A__set_state(self, __pyx_state)
2217
*/
2218
2219
/* function exit code */
2220
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
2221
goto __pyx_L0;
2222
__pyx_L1_error:;
2223
__Pyx_XDECREF(__pyx_t_1);
2224
__Pyx_AddTraceback("numbers.A.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
2225
__pyx_r = NULL;
2226
__pyx_L0:;
2227
__Pyx_XGIVEREF(__pyx_r);
2228
__Pyx_RefNannyFinishContext();
2229
return __pyx_r;
2230
}
2231
2232
/* "numbers.pyx":23
2233
* return A((<A>self).i + (<A>right).i)
2234
*
2235
* def operator_add(int n=100000): # <<<<<<<<<<<<<<
2236
*
2237
* a = A(2)
2238
*/
2239
2240
/* Python wrapper */
2241
static PyObject *__pyx_pw_7numbers_3operator_add(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
2242
static PyMethodDef __pyx_mdef_7numbers_3operator_add = {"operator_add", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7numbers_3operator_add, METH_VARARGS|METH_KEYWORDS, 0};
2243
static PyObject *__pyx_pw_7numbers_3operator_add(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
2244
int __pyx_v_n;
2245
int __pyx_lineno = 0;
2246
const char *__pyx_filename = NULL;
2247
int __pyx_clineno = 0;
2248
PyObject *__pyx_r = 0;
2249
__Pyx_RefNannyDeclarations
2250
__Pyx_RefNannySetupContext("operator_add (wrapper)", 0);
2251
{
2252
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_n,0};
2253
PyObject* values[1] = {0};
2254
if (unlikely(__pyx_kwds)) {
2255
Py_ssize_t kw_args;
2256
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
2257
switch (pos_args) {
2258
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2259
CYTHON_FALLTHROUGH;
2260
case 0: break;
2261
default: goto __pyx_L5_argtuple_error;
2262
}
2263
kw_args = PyDict_Size(__pyx_kwds);
2264
switch (pos_args) {
2265
case 0:
2266
if (kw_args > 0) {
2267
PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_n);
2268
if (value) { values[0] = value; kw_args--; }
2269
}
2270
}
2271
if (unlikely(kw_args > 0)) {
2272
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "operator_add") < 0)) __PYX_ERR(0, 23, __pyx_L3_error)
2273
}
2274
} else {
2275
switch (PyTuple_GET_SIZE(__pyx_args)) {
2276
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2277
CYTHON_FALLTHROUGH;
2278
case 0: break;
2279
default: goto __pyx_L5_argtuple_error;
2280
}
2281
}
2282
if (values[0]) {
2283
__pyx_v_n = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_n == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 23, __pyx_L3_error)
2284
} else {
2285
__pyx_v_n = ((int)0x186A0);
2286
}
2287
}
2288
goto __pyx_L4_argument_unpacking_done;
2289
__pyx_L5_argtuple_error:;
2290
__Pyx_RaiseArgtupleInvalid("operator_add", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 23, __pyx_L3_error)
2291
__pyx_L3_error:;
2292
__Pyx_AddTraceback("numbers.operator_add", __pyx_clineno, __pyx_lineno, __pyx_filename);
2293
__Pyx_RefNannyFinishContext();
2294
return NULL;
2295
__pyx_L4_argument_unpacking_done:;
2296
__pyx_r = __pyx_pf_7numbers_2operator_add(__pyx_self, __pyx_v_n);
2297
2298
/* function exit code */
2299
__Pyx_RefNannyFinishContext();
2300
return __pyx_r;
2301
}
2302
2303
static PyObject *__pyx_pf_7numbers_2operator_add(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_n) {
2304
struct __pyx_obj_7numbers_A *__pyx_v_a = NULL;
2305
struct __pyx_obj_7numbers_A *__pyx_v_b = NULL;
2306
CYTHON_UNUSED int __pyx_v_i;
2307
PyObject *__pyx_v_c = NULL;
2308
PyObject *__pyx_r = NULL;
2309
__Pyx_RefNannyDeclarations
2310
PyObject *__pyx_t_1 = NULL;
2311
int __pyx_t_2;
2312
int __pyx_t_3;
2313
int __pyx_t_4;
2314
PyObject *__pyx_t_5 = NULL;
2315
PyObject *__pyx_t_6 = NULL;
2316
int __pyx_t_7;
2317
int __pyx_lineno = 0;
2318
const char *__pyx_filename = NULL;
2319
int __pyx_clineno = 0;
2320
__Pyx_RefNannySetupContext("operator_add", 0);
2321
2322
/* "numbers.pyx":25
2323
* def operator_add(int n=100000):
2324
*
2325
* a = A(2) # <<<<<<<<<<<<<<
2326
* b = A(3)
2327
* cdef int i
2328
*/
2329
__pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7numbers_A), __pyx_tuple_, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 25, __pyx_L1_error)
2330
__Pyx_GOTREF(__pyx_t_1);
2331
__pyx_v_a = ((struct __pyx_obj_7numbers_A *)__pyx_t_1);
2332
__pyx_t_1 = 0;
2333
2334
/* "numbers.pyx":26
2335
*
2336
* a = A(2)
2337
* b = A(3) # <<<<<<<<<<<<<<
2338
* cdef int i
2339
* for i in range(n):
2340
*/
2341
__pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7numbers_A), __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 26, __pyx_L1_error)
2342
__Pyx_GOTREF(__pyx_t_1);
2343
__pyx_v_b = ((struct __pyx_obj_7numbers_A *)__pyx_t_1);
2344
__pyx_t_1 = 0;
2345
2346
/* "numbers.pyx":28
2347
* b = A(3)
2348
* cdef int i
2349
* for i in range(n): # <<<<<<<<<<<<<<
2350
* c = a + b
2351
* assert c.value() == 5
2352
*/
2353
__pyx_t_2 = __pyx_v_n;
2354
__pyx_t_3 = __pyx_t_2;
2355
for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
2356
__pyx_v_i = __pyx_t_4;
2357
2358
/* "numbers.pyx":29
2359
* cdef int i
2360
* for i in range(n):
2361
* c = a + b # <<<<<<<<<<<<<<
2362
* assert c.value() == 5
2363
*
2364
*/
2365
__pyx_t_1 = PyNumber_Add(((PyObject *)__pyx_v_a), ((PyObject *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 29, __pyx_L1_error)
2366
__Pyx_GOTREF(__pyx_t_1);
2367
__Pyx_XDECREF_SET(__pyx_v_c, __pyx_t_1);
2368
__pyx_t_1 = 0;
2369
}
2370
2371
/* "numbers.pyx":30
2372
* for i in range(n):
2373
* c = a + b
2374
* assert c.value() == 5 # <<<<<<<<<<<<<<
2375
*
2376
*
2377
*/
2378
#ifndef CYTHON_WITHOUT_ASSERTIONS
2379
if (unlikely(!Py_OptimizeFlag)) {
2380
if (unlikely(!__pyx_v_c)) { __Pyx_RaiseUnboundLocalError("c"); __PYX_ERR(0, 30, __pyx_L1_error) }
2381
__pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_c, __pyx_n_s_value); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 30, __pyx_L1_error)
2382
__Pyx_GOTREF(__pyx_t_5);
2383
__pyx_t_6 = NULL;
2384
if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
2385
__pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
2386
if (likely(__pyx_t_6)) {
2387
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
2388
__Pyx_INCREF(__pyx_t_6);
2389
__Pyx_INCREF(function);
2390
__Pyx_DECREF_SET(__pyx_t_5, function);
2391
}
2392
}
2393
__pyx_t_1 = (__pyx_t_6) ? __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6) : __Pyx_PyObject_CallNoArg(__pyx_t_5);
2394
__Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
2395
if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 30, __pyx_L1_error)
2396
__Pyx_GOTREF(__pyx_t_1);
2397
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2398
__pyx_t_5 = __Pyx_PyInt_EqObjC(__pyx_t_1, __pyx_int_5, 5, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 30, __pyx_L1_error)
2399
__Pyx_GOTREF(__pyx_t_5);
2400
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2401
__pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 30, __pyx_L1_error)
2402
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2403
if (unlikely(!__pyx_t_7)) {
2404
PyErr_SetNone(PyExc_AssertionError);
2405
__PYX_ERR(0, 30, __pyx_L1_error)
2406
}
2407
}
2408
#endif
2409
2410
/* "numbers.pyx":23
2411
* return A((<A>self).i + (<A>right).i)
2412
*
2413
* def operator_add(int n=100000): # <<<<<<<<<<<<<<
2414
*
2415
* a = A(2)
2416
*/
2417
2418
/* function exit code */
2419
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
2420
goto __pyx_L0;
2421
__pyx_L1_error:;
2422
__Pyx_XDECREF(__pyx_t_1);
2423
__Pyx_XDECREF(__pyx_t_5);
2424
__Pyx_XDECREF(__pyx_t_6);
2425
__Pyx_AddTraceback("numbers.operator_add", __pyx_clineno, __pyx_lineno, __pyx_filename);
2426
__pyx_r = NULL;
2427
__pyx_L0:;
2428
__Pyx_XDECREF((PyObject *)__pyx_v_a);
2429
__Pyx_XDECREF((PyObject *)__pyx_v_b);
2430
__Pyx_XDECREF(__pyx_v_c);
2431
__Pyx_XGIVEREF(__pyx_r);
2432
__Pyx_RefNannyFinishContext();
2433
return __pyx_r;
2434
}
2435
2436
/* "numbers.pyx":36
2437
*
2438
*
2439
* def bench_gcd(int n=10**5): # <<<<<<<<<<<<<<
2440
* cdef int s = 0
2441
* cdef int i
2442
*/
2443
2444
/* Python wrapper */
2445
static PyObject *__pyx_pw_7numbers_5bench_gcd(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
2446
static PyMethodDef __pyx_mdef_7numbers_5bench_gcd = {"bench_gcd", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7numbers_5bench_gcd, METH_VARARGS|METH_KEYWORDS, 0};
2447
static PyObject *__pyx_pw_7numbers_5bench_gcd(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
2448
int __pyx_v_n;
2449
int __pyx_lineno = 0;
2450
const char *__pyx_filename = NULL;
2451
int __pyx_clineno = 0;
2452
PyObject *__pyx_r = 0;
2453
__Pyx_RefNannyDeclarations
2454
__Pyx_RefNannySetupContext("bench_gcd (wrapper)", 0);
2455
{
2456
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_n,0};
2457
PyObject* values[1] = {0};
2458
if (unlikely(__pyx_kwds)) {
2459
Py_ssize_t kw_args;
2460
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
2461
switch (pos_args) {
2462
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2463
CYTHON_FALLTHROUGH;
2464
case 0: break;
2465
default: goto __pyx_L5_argtuple_error;
2466
}
2467
kw_args = PyDict_Size(__pyx_kwds);
2468
switch (pos_args) {
2469
case 0:
2470
if (kw_args > 0) {
2471
PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_n);
2472
if (value) { values[0] = value; kw_args--; }
2473
}
2474
}
2475
if (unlikely(kw_args > 0)) {
2476
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "bench_gcd") < 0)) __PYX_ERR(0, 36, __pyx_L3_error)
2477
}
2478
} else {
2479
switch (PyTuple_GET_SIZE(__pyx_args)) {
2480
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2481
CYTHON_FALLTHROUGH;
2482
case 0: break;
2483
default: goto __pyx_L5_argtuple_error;
2484
}
2485
}
2486
if (values[0]) {
2487
__pyx_v_n = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_n == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 36, __pyx_L3_error)
2488
} else {
2489
__pyx_v_n = ((int)0x186A0);
2490
}
2491
}
2492
goto __pyx_L4_argument_unpacking_done;
2493
__pyx_L5_argtuple_error:;
2494
__Pyx_RaiseArgtupleInvalid("bench_gcd", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 36, __pyx_L3_error)
2495
__pyx_L3_error:;
2496
__Pyx_AddTraceback("numbers.bench_gcd", __pyx_clineno, __pyx_lineno, __pyx_filename);
2497
__Pyx_RefNannyFinishContext();
2498
return NULL;
2499
__pyx_L4_argument_unpacking_done:;
2500
__pyx_r = __pyx_pf_7numbers_4bench_gcd(__pyx_self, __pyx_v_n);
2501
2502
/* function exit code */
2503
__Pyx_RefNannyFinishContext();
2504
return __pyx_r;
2505
}
2506
2507
static PyObject *__pyx_pf_7numbers_4bench_gcd(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_n) {
2508
int __pyx_v_s;
2509
int __pyx_v_i;
2510
PyObject *__pyx_r = NULL;
2511
__Pyx_RefNannyDeclarations
2512
int __pyx_t_1;
2513
int __pyx_t_2;
2514
int __pyx_t_3;
2515
PyObject *__pyx_t_4 = NULL;
2516
int __pyx_lineno = 0;
2517
const char *__pyx_filename = NULL;
2518
int __pyx_clineno = 0;
2519
__Pyx_RefNannySetupContext("bench_gcd", 0);
2520
2521
/* "numbers.pyx":37
2522
*
2523
* def bench_gcd(int n=10**5):
2524
* cdef int s = 0 # <<<<<<<<<<<<<<
2525
* cdef int i
2526
* for i in range(n):
2527
*/
2528
__pyx_v_s = 0;
2529
2530
/* "numbers.pyx":39
2531
* cdef int s = 0
2532
* cdef int i
2533
* for i in range(n): # <<<<<<<<<<<<<<
2534
* s += gcd(92250, 922350 + i)
2535
* assert s == 2414484
2536
*/
2537
__pyx_t_1 = __pyx_v_n;
2538
__pyx_t_2 = __pyx_t_1;
2539
for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
2540
__pyx_v_i = __pyx_t_3;
2541
2542
/* "numbers.pyx":40
2543
* cdef int i
2544
* for i in range(n):
2545
* s += gcd(92250, 922350 + i) # <<<<<<<<<<<<<<
2546
* assert s == 2414484
2547
* return s
2548
*/
2549
__pyx_v_s = (__pyx_v_s + __pyx_f_2nt_gcd(0x1685A, (0xE12EE + __pyx_v_i), 0));
2550
}
2551
2552
/* "numbers.pyx":41
2553
* for i in range(n):
2554
* s += gcd(92250, 922350 + i)
2555
* assert s == 2414484 # <<<<<<<<<<<<<<
2556
* return s
2557
*
2558
*/
2559
#ifndef CYTHON_WITHOUT_ASSERTIONS
2560
if (unlikely(!Py_OptimizeFlag)) {
2561
if (unlikely(!((__pyx_v_s == 0x24D794) != 0))) {
2562
PyErr_SetNone(PyExc_AssertionError);
2563
__PYX_ERR(0, 41, __pyx_L1_error)
2564
}
2565
}
2566
#endif
2567
2568
/* "numbers.pyx":42
2569
* s += gcd(92250, 922350 + i)
2570
* assert s == 2414484
2571
* return s # <<<<<<<<<<<<<<
2572
*
2573
*
2574
*/
2575
__Pyx_XDECREF(__pyx_r);
2576
__pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_s); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 42, __pyx_L1_error)
2577
__Pyx_GOTREF(__pyx_t_4);
2578
__pyx_r = __pyx_t_4;
2579
__pyx_t_4 = 0;
2580
goto __pyx_L0;
2581
2582
/* "numbers.pyx":36
2583
*
2584
*
2585
* def bench_gcd(int n=10**5): # <<<<<<<<<<<<<<
2586
* cdef int s = 0
2587
* cdef int i
2588
*/
2589
2590
/* function exit code */
2591
__pyx_L1_error:;
2592
__Pyx_XDECREF(__pyx_t_4);
2593
__Pyx_AddTraceback("numbers.bench_gcd", __pyx_clineno, __pyx_lineno, __pyx_filename);
2594
__pyx_r = NULL;
2595
__pyx_L0:;
2596
__Pyx_XGIVEREF(__pyx_r);
2597
__Pyx_RefNannyFinishContext();
2598
return __pyx_r;
2599
}
2600
2601
/* "numbers.pyx":48
2602
*
2603
*
2604
* def bench_xgcd_py(n=10**5): # <<<<<<<<<<<<<<
2605
* s = 0
2606
* for i in range(n):
2607
*/
2608
2609
/* Python wrapper */
2610
static PyObject *__pyx_pw_7numbers_7bench_xgcd_py(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
2611
static PyMethodDef __pyx_mdef_7numbers_7bench_xgcd_py = {"bench_xgcd_py", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7numbers_7bench_xgcd_py, METH_VARARGS|METH_KEYWORDS, 0};
2612
static PyObject *__pyx_pw_7numbers_7bench_xgcd_py(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
2613
PyObject *__pyx_v_n = 0;
2614
int __pyx_lineno = 0;
2615
const char *__pyx_filename = NULL;
2616
int __pyx_clineno = 0;
2617
PyObject *__pyx_r = 0;
2618
__Pyx_RefNannyDeclarations
2619
__Pyx_RefNannySetupContext("bench_xgcd_py (wrapper)", 0);
2620
{
2621
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_n,0};
2622
PyObject* values[1] = {0};
2623
values[0] = ((PyObject *)__pyx_int_100000);
2624
if (unlikely(__pyx_kwds)) {
2625
Py_ssize_t kw_args;
2626
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
2627
switch (pos_args) {
2628
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2629
CYTHON_FALLTHROUGH;
2630
case 0: break;
2631
default: goto __pyx_L5_argtuple_error;
2632
}
2633
kw_args = PyDict_Size(__pyx_kwds);
2634
switch (pos_args) {
2635
case 0:
2636
if (kw_args > 0) {
2637
PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_n);
2638
if (value) { values[0] = value; kw_args--; }
2639
}
2640
}
2641
if (unlikely(kw_args > 0)) {
2642
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "bench_xgcd_py") < 0)) __PYX_ERR(0, 48, __pyx_L3_error)
2643
}
2644
} else {
2645
switch (PyTuple_GET_SIZE(__pyx_args)) {
2646
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2647
CYTHON_FALLTHROUGH;
2648
case 0: break;
2649
default: goto __pyx_L5_argtuple_error;
2650
}
2651
}
2652
__pyx_v_n = values[0];
2653
}
2654
goto __pyx_L4_argument_unpacking_done;
2655
__pyx_L5_argtuple_error:;
2656
__Pyx_RaiseArgtupleInvalid("bench_xgcd_py", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 48, __pyx_L3_error)
2657
__pyx_L3_error:;
2658
__Pyx_AddTraceback("numbers.bench_xgcd_py", __pyx_clineno, __pyx_lineno, __pyx_filename);
2659
__Pyx_RefNannyFinishContext();
2660
return NULL;
2661
__pyx_L4_argument_unpacking_done:;
2662
__pyx_r = __pyx_pf_7numbers_6bench_xgcd_py(__pyx_self, __pyx_v_n);
2663
2664
/* function exit code */
2665
__Pyx_RefNannyFinishContext();
2666
return __pyx_r;
2667
}
2668
2669
static PyObject *__pyx_pf_7numbers_6bench_xgcd_py(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_n) {
2670
PyObject *__pyx_v_s = NULL;
2671
PyObject *__pyx_v_i = NULL;
2672
PyObject *__pyx_r = NULL;
2673
__Pyx_RefNannyDeclarations
2674
PyObject *__pyx_t_1 = NULL;
2675
PyObject *__pyx_t_2 = NULL;
2676
Py_ssize_t __pyx_t_3;
2677
PyObject *(*__pyx_t_4)(PyObject *);
2678
PyObject *__pyx_t_5 = NULL;
2679
PyObject *__pyx_t_6 = NULL;
2680
PyObject *__pyx_t_7 = NULL;
2681
int __pyx_t_8;
2682
PyObject *__pyx_t_9 = NULL;
2683
int __pyx_t_10;
2684
int __pyx_lineno = 0;
2685
const char *__pyx_filename = NULL;
2686
int __pyx_clineno = 0;
2687
__Pyx_RefNannySetupContext("bench_xgcd_py", 0);
2688
2689
/* "numbers.pyx":49
2690
*
2691
* def bench_xgcd_py(n=10**5):
2692
* s = 0 # <<<<<<<<<<<<<<
2693
* for i in range(n):
2694
* s += xgcd(92250, 922350 + i)[0]
2695
*/
2696
__Pyx_INCREF(__pyx_int_0);
2697
__pyx_v_s = __pyx_int_0;
2698
2699
/* "numbers.pyx":50
2700
* def bench_xgcd_py(n=10**5):
2701
* s = 0
2702
* for i in range(n): # <<<<<<<<<<<<<<
2703
* s += xgcd(92250, 922350 + i)[0]
2704
* assert s == 2414484
2705
*/
2706
__pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_range, __pyx_v_n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 50, __pyx_L1_error)
2707
__Pyx_GOTREF(__pyx_t_1);
2708
if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
2709
__pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
2710
__pyx_t_4 = NULL;
2711
} else {
2712
__pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 50, __pyx_L1_error)
2713
__Pyx_GOTREF(__pyx_t_2);
2714
__pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 50, __pyx_L1_error)
2715
}
2716
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2717
for (;;) {
2718
if (likely(!__pyx_t_4)) {
2719
if (likely(PyList_CheckExact(__pyx_t_2))) {
2720
if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
2721
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
2722
__pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 50, __pyx_L1_error)
2723
#else
2724
__pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 50, __pyx_L1_error)
2725
__Pyx_GOTREF(__pyx_t_1);
2726
#endif
2727
} else {
2728
if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
2729
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
2730
__pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 50, __pyx_L1_error)
2731
#else
2732
__pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 50, __pyx_L1_error)
2733
__Pyx_GOTREF(__pyx_t_1);
2734
#endif
2735
}
2736
} else {
2737
__pyx_t_1 = __pyx_t_4(__pyx_t_2);
2738
if (unlikely(!__pyx_t_1)) {
2739
PyObject* exc_type = PyErr_Occurred();
2740
if (exc_type) {
2741
if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
2742
else __PYX_ERR(0, 50, __pyx_L1_error)
2743
}
2744
break;
2745
}
2746
__Pyx_GOTREF(__pyx_t_1);
2747
}
2748
__Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_1);
2749
__pyx_t_1 = 0;
2750
2751
/* "numbers.pyx":51
2752
* s = 0
2753
* for i in range(n):
2754
* s += xgcd(92250, 922350 + i)[0] # <<<<<<<<<<<<<<
2755
* assert s == 2414484
2756
* return s
2757
*/
2758
__Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_xgcd); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 51, __pyx_L1_error)
2759
__Pyx_GOTREF(__pyx_t_5);
2760
__pyx_t_6 = __Pyx_PyInt_AddCObj(__pyx_int_922350, __pyx_v_i, 0xE12EE, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 51, __pyx_L1_error)
2761
__Pyx_GOTREF(__pyx_t_6);
2762
__pyx_t_7 = NULL;
2763
__pyx_t_8 = 0;
2764
if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
2765
__pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
2766
if (likely(__pyx_t_7)) {
2767
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
2768
__Pyx_INCREF(__pyx_t_7);
2769
__Pyx_INCREF(function);
2770
__Pyx_DECREF_SET(__pyx_t_5, function);
2771
__pyx_t_8 = 1;
2772
}
2773
}
2774
#if CYTHON_FAST_PYCALL
2775
if (PyFunction_Check(__pyx_t_5)) {
2776
PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_int_92250, __pyx_t_6};
2777
__pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 51, __pyx_L1_error)
2778
__Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
2779
__Pyx_GOTREF(__pyx_t_1);
2780
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
2781
} else
2782
#endif
2783
#if CYTHON_FAST_PYCCALL
2784
if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
2785
PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_int_92250, __pyx_t_6};
2786
__pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 51, __pyx_L1_error)
2787
__Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
2788
__Pyx_GOTREF(__pyx_t_1);
2789
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
2790
} else
2791
#endif
2792
{
2793
__pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 51, __pyx_L1_error)
2794
__Pyx_GOTREF(__pyx_t_9);
2795
if (__pyx_t_7) {
2796
__Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
2797
}
2798
__Pyx_INCREF(__pyx_int_92250);
2799
__Pyx_GIVEREF(__pyx_int_92250);
2800
PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_int_92250);
2801
__Pyx_GIVEREF(__pyx_t_6);
2802
PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_6);
2803
__pyx_t_6 = 0;
2804
__pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 51, __pyx_L1_error)
2805
__Pyx_GOTREF(__pyx_t_1);
2806
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
2807
}
2808
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2809
__pyx_t_5 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 51, __pyx_L1_error)
2810
__Pyx_GOTREF(__pyx_t_5);
2811
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2812
__pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_s, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 51, __pyx_L1_error)
2813
__Pyx_GOTREF(__pyx_t_1);
2814
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2815
__Pyx_DECREF_SET(__pyx_v_s, __pyx_t_1);
2816
__pyx_t_1 = 0;
2817
2818
/* "numbers.pyx":50
2819
* def bench_xgcd_py(n=10**5):
2820
* s = 0
2821
* for i in range(n): # <<<<<<<<<<<<<<
2822
* s += xgcd(92250, 922350 + i)[0]
2823
* assert s == 2414484
2824
*/
2825
}
2826
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2827
2828
/* "numbers.pyx":52
2829
* for i in range(n):
2830
* s += xgcd(92250, 922350 + i)[0]
2831
* assert s == 2414484 # <<<<<<<<<<<<<<
2832
* return s
2833
*
2834
*/
2835
#ifndef CYTHON_WITHOUT_ASSERTIONS
2836
if (unlikely(!Py_OptimizeFlag)) {
2837
__pyx_t_2 = __Pyx_PyInt_EqObjC(__pyx_v_s, __pyx_int_2414484, 0x24D794, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 52, __pyx_L1_error)
2838
__Pyx_GOTREF(__pyx_t_2);
2839
__pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 52, __pyx_L1_error)
2840
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2841
if (unlikely(!__pyx_t_10)) {
2842
PyErr_SetNone(PyExc_AssertionError);
2843
__PYX_ERR(0, 52, __pyx_L1_error)
2844
}
2845
}
2846
#endif
2847
2848
/* "numbers.pyx":53
2849
* s += xgcd(92250, 922350 + i)[0]
2850
* assert s == 2414484
2851
* return s # <<<<<<<<<<<<<<
2852
*
2853
* # 10x slower, of course
2854
*/
2855
__Pyx_XDECREF(__pyx_r);
2856
__Pyx_INCREF(__pyx_v_s);
2857
__pyx_r = __pyx_v_s;
2858
goto __pyx_L0;
2859
2860
/* "numbers.pyx":48
2861
*
2862
*
2863
* def bench_xgcd_py(n=10**5): # <<<<<<<<<<<<<<
2864
* s = 0
2865
* for i in range(n):
2866
*/
2867
2868
/* function exit code */
2869
__pyx_L1_error:;
2870
__Pyx_XDECREF(__pyx_t_1);
2871
__Pyx_XDECREF(__pyx_t_2);
2872
__Pyx_XDECREF(__pyx_t_5);
2873
__Pyx_XDECREF(__pyx_t_6);
2874
__Pyx_XDECREF(__pyx_t_7);
2875
__Pyx_XDECREF(__pyx_t_9);
2876
__Pyx_AddTraceback("numbers.bench_xgcd_py", __pyx_clineno, __pyx_lineno, __pyx_filename);
2877
__pyx_r = NULL;
2878
__pyx_L0:;
2879
__Pyx_XDECREF(__pyx_v_s);
2880
__Pyx_XDECREF(__pyx_v_i);
2881
__Pyx_XGIVEREF(__pyx_r);
2882
__Pyx_RefNannyFinishContext();
2883
return __pyx_r;
2884
}
2885
2886
/* "numbers.pyx":59
2887
*
2888
*
2889
* def bench_xgcd(int n=10**5): # <<<<<<<<<<<<<<
2890
* cdef int s = 0, cx, cy, i
2891
* for i in range(n):
2892
*/
2893
2894
/* Python wrapper */
2895
static PyObject *__pyx_pw_7numbers_9bench_xgcd(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
2896
static PyMethodDef __pyx_mdef_7numbers_9bench_xgcd = {"bench_xgcd", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7numbers_9bench_xgcd, METH_VARARGS|METH_KEYWORDS, 0};
2897
static PyObject *__pyx_pw_7numbers_9bench_xgcd(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
2898
int __pyx_v_n;
2899
int __pyx_lineno = 0;
2900
const char *__pyx_filename = NULL;
2901
int __pyx_clineno = 0;
2902
PyObject *__pyx_r = 0;
2903
__Pyx_RefNannyDeclarations
2904
__Pyx_RefNannySetupContext("bench_xgcd (wrapper)", 0);
2905
{
2906
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_n,0};
2907
PyObject* values[1] = {0};
2908
if (unlikely(__pyx_kwds)) {
2909
Py_ssize_t kw_args;
2910
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
2911
switch (pos_args) {
2912
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2913
CYTHON_FALLTHROUGH;
2914
case 0: break;
2915
default: goto __pyx_L5_argtuple_error;
2916
}
2917
kw_args = PyDict_Size(__pyx_kwds);
2918
switch (pos_args) {
2919
case 0:
2920
if (kw_args > 0) {
2921
PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_n);
2922
if (value) { values[0] = value; kw_args--; }
2923
}
2924
}
2925
if (unlikely(kw_args > 0)) {
2926
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "bench_xgcd") < 0)) __PYX_ERR(0, 59, __pyx_L3_error)
2927
}
2928
} else {
2929
switch (PyTuple_GET_SIZE(__pyx_args)) {
2930
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2931
CYTHON_FALLTHROUGH;
2932
case 0: break;
2933
default: goto __pyx_L5_argtuple_error;
2934
}
2935
}
2936
if (values[0]) {
2937
__pyx_v_n = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_n == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 59, __pyx_L3_error)
2938
} else {
2939
__pyx_v_n = ((int)0x186A0);
2940
}
2941
}
2942
goto __pyx_L4_argument_unpacking_done;
2943
__pyx_L5_argtuple_error:;
2944
__Pyx_RaiseArgtupleInvalid("bench_xgcd", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 59, __pyx_L3_error)
2945
__pyx_L3_error:;
2946
__Pyx_AddTraceback("numbers.bench_xgcd", __pyx_clineno, __pyx_lineno, __pyx_filename);
2947
__Pyx_RefNannyFinishContext();
2948
return NULL;
2949
__pyx_L4_argument_unpacking_done:;
2950
__pyx_r = __pyx_pf_7numbers_8bench_xgcd(__pyx_self, __pyx_v_n);
2951
2952
/* function exit code */
2953
__Pyx_RefNannyFinishContext();
2954
return __pyx_r;
2955
}
2956
2957
static PyObject *__pyx_pf_7numbers_8bench_xgcd(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_n) {
2958
int __pyx_v_s;
2959
int __pyx_v_cx;
2960
int __pyx_v_cy;
2961
int __pyx_v_i;
2962
PyObject *__pyx_r = NULL;
2963
__Pyx_RefNannyDeclarations
2964
int __pyx_t_1;
2965
int __pyx_t_2;
2966
int __pyx_t_3;
2967
PyObject *__pyx_t_4 = NULL;
2968
int __pyx_lineno = 0;
2969
const char *__pyx_filename = NULL;
2970
int __pyx_clineno = 0;
2971
__Pyx_RefNannySetupContext("bench_xgcd", 0);
2972
2973
/* "numbers.pyx":60
2974
*
2975
* def bench_xgcd(int n=10**5):
2976
* cdef int s = 0, cx, cy, i # <<<<<<<<<<<<<<
2977
* for i in range(n):
2978
* s += xgcd_c(92250, 922350 + i, &cx, &cy)
2979
*/
2980
__pyx_v_s = 0;
2981
2982
/* "numbers.pyx":61
2983
* def bench_xgcd(int n=10**5):
2984
* cdef int s = 0, cx, cy, i
2985
* for i in range(n): # <<<<<<<<<<<<<<
2986
* s += xgcd_c(92250, 922350 + i, &cx, &cy)
2987
* assert s == 2414484
2988
*/
2989
__pyx_t_1 = __pyx_v_n;
2990
__pyx_t_2 = __pyx_t_1;
2991
for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
2992
__pyx_v_i = __pyx_t_3;
2993
2994
/* "numbers.pyx":62
2995
* cdef int s = 0, cx, cy, i
2996
* for i in range(n):
2997
* s += xgcd_c(92250, 922350 + i, &cx, &cy) # <<<<<<<<<<<<<<
2998
* assert s == 2414484
2999
* return s
3000
*/
3001
__pyx_v_s = (__pyx_v_s + __pyx_f_2nt_xgcd_c(0x1685A, (0xE12EE + __pyx_v_i), (&__pyx_v_cx), (&__pyx_v_cy)));
3002
}
3003
3004
/* "numbers.pyx":63
3005
* for i in range(n):
3006
* s += xgcd_c(92250, 922350 + i, &cx, &cy)
3007
* assert s == 2414484 # <<<<<<<<<<<<<<
3008
* return s
3009
*
3010
*/
3011
#ifndef CYTHON_WITHOUT_ASSERTIONS
3012
if (unlikely(!Py_OptimizeFlag)) {
3013
if (unlikely(!((__pyx_v_s == 0x24D794) != 0))) {
3014
PyErr_SetNone(PyExc_AssertionError);
3015
__PYX_ERR(0, 63, __pyx_L1_error)
3016
}
3017
}
3018
#endif
3019
3020
/* "numbers.pyx":64
3021
* s += xgcd_c(92250, 922350 + i, &cx, &cy)
3022
* assert s == 2414484
3023
* return s # <<<<<<<<<<<<<<
3024
*
3025
*
3026
*/
3027
__Pyx_XDECREF(__pyx_r);
3028
__pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_s); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 64, __pyx_L1_error)
3029
__Pyx_GOTREF(__pyx_t_4);
3030
__pyx_r = __pyx_t_4;
3031
__pyx_t_4 = 0;
3032
goto __pyx_L0;
3033
3034
/* "numbers.pyx":59
3035
*
3036
*
3037
* def bench_xgcd(int n=10**5): # <<<<<<<<<<<<<<
3038
* cdef int s = 0, cx, cy, i
3039
* for i in range(n):
3040
*/
3041
3042
/* function exit code */
3043
__pyx_L1_error:;
3044
__Pyx_XDECREF(__pyx_t_4);
3045
__Pyx_AddTraceback("numbers.bench_xgcd", __pyx_clineno, __pyx_lineno, __pyx_filename);
3046
__pyx_r = NULL;
3047
__pyx_L0:;
3048
__Pyx_XGIVEREF(__pyx_r);
3049
__Pyx_RefNannyFinishContext();
3050
return __pyx_r;
3051
}
3052
3053
/* "numbers.pyx":70
3054
*
3055
*
3056
* def bench_inverse_mod(long long n=10**5): # <<<<<<<<<<<<<<
3057
* cdef long long i, s = 0
3058
* for i in range(1, n):
3059
*/
3060
3061
/* Python wrapper */
3062
static PyObject *__pyx_pw_7numbers_11bench_inverse_mod(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
3063
static PyMethodDef __pyx_mdef_7numbers_11bench_inverse_mod = {"bench_inverse_mod", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7numbers_11bench_inverse_mod, METH_VARARGS|METH_KEYWORDS, 0};
3064
static PyObject *__pyx_pw_7numbers_11bench_inverse_mod(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
3065
PY_LONG_LONG __pyx_v_n;
3066
int __pyx_lineno = 0;
3067
const char *__pyx_filename = NULL;
3068
int __pyx_clineno = 0;
3069
PyObject *__pyx_r = 0;
3070
__Pyx_RefNannyDeclarations
3071
__Pyx_RefNannySetupContext("bench_inverse_mod (wrapper)", 0);
3072
{
3073
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_n,0};
3074
PyObject* values[1] = {0};
3075
if (unlikely(__pyx_kwds)) {
3076
Py_ssize_t kw_args;
3077
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
3078
switch (pos_args) {
3079
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3080
CYTHON_FALLTHROUGH;
3081
case 0: break;
3082
default: goto __pyx_L5_argtuple_error;
3083
}
3084
kw_args = PyDict_Size(__pyx_kwds);
3085
switch (pos_args) {
3086
case 0:
3087
if (kw_args > 0) {
3088
PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_n);
3089
if (value) { values[0] = value; kw_args--; }
3090
}
3091
}
3092
if (unlikely(kw_args > 0)) {
3093
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "bench_inverse_mod") < 0)) __PYX_ERR(0, 70, __pyx_L3_error)
3094
}
3095
} else {
3096
switch (PyTuple_GET_SIZE(__pyx_args)) {
3097
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3098
CYTHON_FALLTHROUGH;
3099
case 0: break;
3100
default: goto __pyx_L5_argtuple_error;
3101
}
3102
}
3103
if (values[0]) {
3104
__pyx_v_n = __Pyx_PyInt_As_PY_LONG_LONG(values[0]); if (unlikely((__pyx_v_n == (PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(0, 70, __pyx_L3_error)
3105
} else {
3106
__pyx_v_n = ((PY_LONG_LONG)0x186A0);
3107
}
3108
}
3109
goto __pyx_L4_argument_unpacking_done;
3110
__pyx_L5_argtuple_error:;
3111
__Pyx_RaiseArgtupleInvalid("bench_inverse_mod", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 70, __pyx_L3_error)
3112
__pyx_L3_error:;
3113
__Pyx_AddTraceback("numbers.bench_inverse_mod", __pyx_clineno, __pyx_lineno, __pyx_filename);
3114
__Pyx_RefNannyFinishContext();
3115
return NULL;
3116
__pyx_L4_argument_unpacking_done:;
3117
__pyx_r = __pyx_pf_7numbers_10bench_inverse_mod(__pyx_self, __pyx_v_n);
3118
3119
/* function exit code */
3120
__Pyx_RefNannyFinishContext();
3121
return __pyx_r;
3122
}
3123
3124
static PyObject *__pyx_pf_7numbers_10bench_inverse_mod(CYTHON_UNUSED PyObject *__pyx_self, PY_LONG_LONG __pyx_v_n) {
3125
PY_LONG_LONG __pyx_v_i;
3126
PY_LONG_LONG __pyx_v_s;
3127
PyObject *__pyx_r = NULL;
3128
__Pyx_RefNannyDeclarations
3129
PY_LONG_LONG __pyx_t_1;
3130
PY_LONG_LONG __pyx_t_2;
3131
PY_LONG_LONG __pyx_t_3;
3132
PyObject *__pyx_t_4 = NULL;
3133
PyObject *__pyx_t_5 = NULL;
3134
int __pyx_t_6;
3135
int __pyx_lineno = 0;
3136
const char *__pyx_filename = NULL;
3137
int __pyx_clineno = 0;
3138
__Pyx_RefNannySetupContext("bench_inverse_mod", 0);
3139
3140
/* "numbers.pyx":71
3141
*
3142
* def bench_inverse_mod(long long n=10**5):
3143
* cdef long long i, s = 0 # <<<<<<<<<<<<<<
3144
* for i in range(1, n):
3145
* s += inverse_mod(i, 1073741827) # nextprime(2^30)
3146
*/
3147
__pyx_v_s = 0;
3148
3149
/* "numbers.pyx":72
3150
* def bench_inverse_mod(long long n=10**5):
3151
* cdef long long i, s = 0
3152
* for i in range(1, n): # <<<<<<<<<<<<<<
3153
* s += inverse_mod(i, 1073741827) # nextprime(2^30)
3154
* assert s == 53532319533988
3155
*/
3156
__pyx_t_1 = __pyx_v_n;
3157
__pyx_t_2 = __pyx_t_1;
3158
for (__pyx_t_3 = 1; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
3159
__pyx_v_i = __pyx_t_3;
3160
3161
/* "numbers.pyx":73
3162
* cdef long long i, s = 0
3163
* for i in range(1, n):
3164
* s += inverse_mod(i, 1073741827) # nextprime(2^30) # <<<<<<<<<<<<<<
3165
* assert s == 53532319533988
3166
*
3167
*/
3168
__pyx_v_s = (__pyx_v_s + __pyx_f_2nt_inverse_mod(__pyx_v_i, 0x40000003, 0));
3169
}
3170
3171
/* "numbers.pyx":74
3172
* for i in range(1, n):
3173
* s += inverse_mod(i, 1073741827) # nextprime(2^30)
3174
* assert s == 53532319533988 # <<<<<<<<<<<<<<
3175
*
3176
*
3177
*/
3178
#ifndef CYTHON_WITHOUT_ASSERTIONS
3179
if (unlikely(!Py_OptimizeFlag)) {
3180
__pyx_t_4 = __Pyx_PyInt_From_PY_LONG_LONG(__pyx_v_s); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 74, __pyx_L1_error)
3181
__Pyx_GOTREF(__pyx_t_4);
3182
__pyx_t_5 = PyObject_RichCompare(__pyx_t_4, __pyx_int_53532319533988, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 74, __pyx_L1_error)
3183
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3184
__pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 74, __pyx_L1_error)
3185
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
3186
if (unlikely(!__pyx_t_6)) {
3187
PyErr_SetNone(PyExc_AssertionError);
3188
__PYX_ERR(0, 74, __pyx_L1_error)
3189
}
3190
}
3191
#endif
3192
3193
/* "numbers.pyx":70
3194
*
3195
*
3196
* def bench_inverse_mod(long long n=10**5): # <<<<<<<<<<<<<<
3197
* cdef long long i, s = 0
3198
* for i in range(1, n):
3199
*/
3200
3201
/* function exit code */
3202
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
3203
goto __pyx_L0;
3204
__pyx_L1_error:;
3205
__Pyx_XDECREF(__pyx_t_4);
3206
__Pyx_XDECREF(__pyx_t_5);
3207
__Pyx_AddTraceback("numbers.bench_inverse_mod", __pyx_clineno, __pyx_lineno, __pyx_filename);
3208
__pyx_r = NULL;
3209
__pyx_L0:;
3210
__Pyx_XGIVEREF(__pyx_r);
3211
__Pyx_RefNannyFinishContext();
3212
return __pyx_r;
3213
}
3214
3215
/* "numbers.pyx":80
3216
*
3217
*
3218
* def sum_loop(int n=1000000): # <<<<<<<<<<<<<<
3219
* cdef int s = 0, i
3220
* for i in range(0, n, 3):
3221
*/
3222
3223
/* Python wrapper */
3224
static PyObject *__pyx_pw_7numbers_13sum_loop(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
3225
static PyMethodDef __pyx_mdef_7numbers_13sum_loop = {"sum_loop", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7numbers_13sum_loop, METH_VARARGS|METH_KEYWORDS, 0};
3226
static PyObject *__pyx_pw_7numbers_13sum_loop(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
3227
int __pyx_v_n;
3228
int __pyx_lineno = 0;
3229
const char *__pyx_filename = NULL;
3230
int __pyx_clineno = 0;
3231
PyObject *__pyx_r = 0;
3232
__Pyx_RefNannyDeclarations
3233
__Pyx_RefNannySetupContext("sum_loop (wrapper)", 0);
3234
{
3235
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_n,0};
3236
PyObject* values[1] = {0};
3237
if (unlikely(__pyx_kwds)) {
3238
Py_ssize_t kw_args;
3239
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
3240
switch (pos_args) {
3241
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3242
CYTHON_FALLTHROUGH;
3243
case 0: break;
3244
default: goto __pyx_L5_argtuple_error;
3245
}
3246
kw_args = PyDict_Size(__pyx_kwds);
3247
switch (pos_args) {
3248
case 0:
3249
if (kw_args > 0) {
3250
PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_n);
3251
if (value) { values[0] = value; kw_args--; }
3252
}
3253
}
3254
if (unlikely(kw_args > 0)) {
3255
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "sum_loop") < 0)) __PYX_ERR(0, 80, __pyx_L3_error)
3256
}
3257
} else {
3258
switch (PyTuple_GET_SIZE(__pyx_args)) {
3259
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3260
CYTHON_FALLTHROUGH;
3261
case 0: break;
3262
default: goto __pyx_L5_argtuple_error;
3263
}
3264
}
3265
if (values[0]) {
3266
__pyx_v_n = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_n == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 80, __pyx_L3_error)
3267
} else {
3268
__pyx_v_n = ((int)0xF4240);
3269
}
3270
}
3271
goto __pyx_L4_argument_unpacking_done;
3272
__pyx_L5_argtuple_error:;
3273
__Pyx_RaiseArgtupleInvalid("sum_loop", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 80, __pyx_L3_error)
3274
__pyx_L3_error:;
3275
__Pyx_AddTraceback("numbers.sum_loop", __pyx_clineno, __pyx_lineno, __pyx_filename);
3276
__Pyx_RefNannyFinishContext();
3277
return NULL;
3278
__pyx_L4_argument_unpacking_done:;
3279
__pyx_r = __pyx_pf_7numbers_12sum_loop(__pyx_self, __pyx_v_n);
3280
3281
/* function exit code */
3282
__Pyx_RefNannyFinishContext();
3283
return __pyx_r;
3284
}
3285
3286
static PyObject *__pyx_pf_7numbers_12sum_loop(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_n) {
3287
int __pyx_v_s;
3288
CYTHON_UNUSED int __pyx_v_i;
3289
PyObject *__pyx_r = NULL;
3290
__Pyx_RefNannyDeclarations
3291
int __pyx_t_1;
3292
int __pyx_t_2;
3293
int __pyx_t_3;
3294
PyObject *__pyx_t_4 = NULL;
3295
int __pyx_lineno = 0;
3296
const char *__pyx_filename = NULL;
3297
int __pyx_clineno = 0;
3298
__Pyx_RefNannySetupContext("sum_loop", 0);
3299
3300
/* "numbers.pyx":81
3301
*
3302
* def sum_loop(int n=1000000):
3303
* cdef int s = 0, i # <<<<<<<<<<<<<<
3304
* for i in range(0, n, 3):
3305
* s += 1
3306
*/
3307
__pyx_v_s = 0;
3308
3309
/* "numbers.pyx":82
3310
* def sum_loop(int n=1000000):
3311
* cdef int s = 0, i
3312
* for i in range(0, n, 3): # <<<<<<<<<<<<<<
3313
* s += 1
3314
* assert s == 333334
3315
*/
3316
__pyx_t_1 = __pyx_v_n;
3317
__pyx_t_2 = __pyx_t_1;
3318
for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=3) {
3319
__pyx_v_i = __pyx_t_3;
3320
3321
/* "numbers.pyx":83
3322
* cdef int s = 0, i
3323
* for i in range(0, n, 3):
3324
* s += 1 # <<<<<<<<<<<<<<
3325
* assert s == 333334
3326
* return s
3327
*/
3328
__pyx_v_s = (__pyx_v_s + 1);
3329
}
3330
3331
/* "numbers.pyx":84
3332
* for i in range(0, n, 3):
3333
* s += 1
3334
* assert s == 333334 # <<<<<<<<<<<<<<
3335
* return s
3336
*
3337
*/
3338
#ifndef CYTHON_WITHOUT_ASSERTIONS
3339
if (unlikely(!Py_OptimizeFlag)) {
3340
if (unlikely(!((__pyx_v_s == 0x51616) != 0))) {
3341
PyErr_SetNone(PyExc_AssertionError);
3342
__PYX_ERR(0, 84, __pyx_L1_error)
3343
}
3344
}
3345
#endif
3346
3347
/* "numbers.pyx":85
3348
* s += 1
3349
* assert s == 333334
3350
* return s # <<<<<<<<<<<<<<
3351
*
3352
*
3353
*/
3354
__Pyx_XDECREF(__pyx_r);
3355
__pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_s); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 85, __pyx_L1_error)
3356
__Pyx_GOTREF(__pyx_t_4);
3357
__pyx_r = __pyx_t_4;
3358
__pyx_t_4 = 0;
3359
goto __pyx_L0;
3360
3361
/* "numbers.pyx":80
3362
*
3363
*
3364
* def sum_loop(int n=1000000): # <<<<<<<<<<<<<<
3365
* cdef int s = 0, i
3366
* for i in range(0, n, 3):
3367
*/
3368
3369
/* function exit code */
3370
__pyx_L1_error:;
3371
__Pyx_XDECREF(__pyx_t_4);
3372
__Pyx_AddTraceback("numbers.sum_loop", __pyx_clineno, __pyx_lineno, __pyx_filename);
3373
__pyx_r = NULL;
3374
__pyx_L0:;
3375
__Pyx_XGIVEREF(__pyx_r);
3376
__Pyx_RefNannyFinishContext();
3377
return __pyx_r;
3378
}
3379
3380
/* "numbers.pyx":91
3381
*
3382
*
3383
* def sum_range(long long n=1000000): # <<<<<<<<<<<<<<
3384
* n = sum(range(0, n, 3))
3385
* assert n == 166666833333
3386
*/
3387
3388
/* Python wrapper */
3389
static PyObject *__pyx_pw_7numbers_15sum_range(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
3390
static PyMethodDef __pyx_mdef_7numbers_15sum_range = {"sum_range", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7numbers_15sum_range, METH_VARARGS|METH_KEYWORDS, 0};
3391
static PyObject *__pyx_pw_7numbers_15sum_range(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
3392
PY_LONG_LONG __pyx_v_n;
3393
int __pyx_lineno = 0;
3394
const char *__pyx_filename = NULL;
3395
int __pyx_clineno = 0;
3396
PyObject *__pyx_r = 0;
3397
__Pyx_RefNannyDeclarations
3398
__Pyx_RefNannySetupContext("sum_range (wrapper)", 0);
3399
{
3400
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_n,0};
3401
PyObject* values[1] = {0};
3402
if (unlikely(__pyx_kwds)) {
3403
Py_ssize_t kw_args;
3404
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
3405
switch (pos_args) {
3406
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3407
CYTHON_FALLTHROUGH;
3408
case 0: break;
3409
default: goto __pyx_L5_argtuple_error;
3410
}
3411
kw_args = PyDict_Size(__pyx_kwds);
3412
switch (pos_args) {
3413
case 0:
3414
if (kw_args > 0) {
3415
PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_n);
3416
if (value) { values[0] = value; kw_args--; }
3417
}
3418
}
3419
if (unlikely(kw_args > 0)) {
3420
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "sum_range") < 0)) __PYX_ERR(0, 91, __pyx_L3_error)
3421
}
3422
} else {
3423
switch (PyTuple_GET_SIZE(__pyx_args)) {
3424
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3425
CYTHON_FALLTHROUGH;
3426
case 0: break;
3427
default: goto __pyx_L5_argtuple_error;
3428
}
3429
}
3430
if (values[0]) {
3431
__pyx_v_n = __Pyx_PyInt_As_PY_LONG_LONG(values[0]); if (unlikely((__pyx_v_n == (PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(0, 91, __pyx_L3_error)
3432
} else {
3433
__pyx_v_n = ((PY_LONG_LONG)0xF4240);
3434
}
3435
}
3436
goto __pyx_L4_argument_unpacking_done;
3437
__pyx_L5_argtuple_error:;
3438
__Pyx_RaiseArgtupleInvalid("sum_range", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 91, __pyx_L3_error)
3439
__pyx_L3_error:;
3440
__Pyx_AddTraceback("numbers.sum_range", __pyx_clineno, __pyx_lineno, __pyx_filename);
3441
__Pyx_RefNannyFinishContext();
3442
return NULL;
3443
__pyx_L4_argument_unpacking_done:;
3444
__pyx_r = __pyx_pf_7numbers_14sum_range(__pyx_self, __pyx_v_n);
3445
3446
/* function exit code */
3447
__Pyx_RefNannyFinishContext();
3448
return __pyx_r;
3449
}
3450
3451
static PyObject *__pyx_pf_7numbers_14sum_range(CYTHON_UNUSED PyObject *__pyx_self, PY_LONG_LONG __pyx_v_n) {
3452
PyObject *__pyx_r = NULL;
3453
__Pyx_RefNannyDeclarations
3454
PyObject *__pyx_t_1 = NULL;
3455
PyObject *__pyx_t_2 = NULL;
3456
PY_LONG_LONG __pyx_t_3;
3457
int __pyx_t_4;
3458
int __pyx_lineno = 0;
3459
const char *__pyx_filename = NULL;
3460
int __pyx_clineno = 0;
3461
__Pyx_RefNannySetupContext("sum_range", 0);
3462
3463
/* "numbers.pyx":92
3464
*
3465
* def sum_range(long long n=1000000):
3466
* n = sum(range(0, n, 3)) # <<<<<<<<<<<<<<
3467
* assert n == 166666833333
3468
*
3469
*/
3470
__pyx_t_1 = __Pyx_PyInt_From_PY_LONG_LONG(__pyx_v_n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 92, __pyx_L1_error)
3471
__Pyx_GOTREF(__pyx_t_1);
3472
__pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 92, __pyx_L1_error)
3473
__Pyx_GOTREF(__pyx_t_2);
3474
__Pyx_INCREF(__pyx_int_0);
3475
__Pyx_GIVEREF(__pyx_int_0);
3476
PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_int_0);
3477
__Pyx_GIVEREF(__pyx_t_1);
3478
PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
3479
__Pyx_INCREF(__pyx_int_3);
3480
__Pyx_GIVEREF(__pyx_int_3);
3481
PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_int_3);
3482
__pyx_t_1 = 0;
3483
__pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 92, __pyx_L1_error)
3484
__Pyx_GOTREF(__pyx_t_1);
3485
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3486
__pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_sum, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 92, __pyx_L1_error)
3487
__Pyx_GOTREF(__pyx_t_2);
3488
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3489
__pyx_t_3 = __Pyx_PyInt_As_PY_LONG_LONG(__pyx_t_2); if (unlikely((__pyx_t_3 == (PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(0, 92, __pyx_L1_error)
3490
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3491
__pyx_v_n = __pyx_t_3;
3492
3493
/* "numbers.pyx":93
3494
* def sum_range(long long n=1000000):
3495
* n = sum(range(0, n, 3))
3496
* assert n == 166666833333 # <<<<<<<<<<<<<<
3497
*
3498
*
3499
*/
3500
#ifndef CYTHON_WITHOUT_ASSERTIONS
3501
if (unlikely(!Py_OptimizeFlag)) {
3502
__pyx_t_2 = __Pyx_PyInt_From_PY_LONG_LONG(__pyx_v_n); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 93, __pyx_L1_error)
3503
__Pyx_GOTREF(__pyx_t_2);
3504
__pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_166666833333, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 93, __pyx_L1_error)
3505
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3506
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 93, __pyx_L1_error)
3507
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3508
if (unlikely(!__pyx_t_4)) {
3509
PyErr_SetNone(PyExc_AssertionError);
3510
__PYX_ERR(0, 93, __pyx_L1_error)
3511
}
3512
}
3513
#endif
3514
3515
/* "numbers.pyx":91
3516
*
3517
*
3518
* def sum_range(long long n=1000000): # <<<<<<<<<<<<<<
3519
* n = sum(range(0, n, 3))
3520
* assert n == 166666833333
3521
*/
3522
3523
/* function exit code */
3524
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
3525
goto __pyx_L0;
3526
__pyx_L1_error:;
3527
__Pyx_XDECREF(__pyx_t_1);
3528
__Pyx_XDECREF(__pyx_t_2);
3529
__Pyx_AddTraceback("numbers.sum_range", __pyx_clineno, __pyx_lineno, __pyx_filename);
3530
__pyx_r = NULL;
3531
__pyx_L0:;
3532
__Pyx_XGIVEREF(__pyx_r);
3533
__Pyx_RefNannyFinishContext();
3534
return __pyx_r;
3535
}
3536
3537
/* "numbers.pyx":99
3538
*
3539
*
3540
* def sum_reversed(long long n=1000000): # <<<<<<<<<<<<<<
3541
* n = sum(reversed(list(range(0, n, 3))))
3542
* assert n == 166666833333
3543
*/
3544
3545
/* Python wrapper */
3546
static PyObject *__pyx_pw_7numbers_17sum_reversed(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
3547
static PyMethodDef __pyx_mdef_7numbers_17sum_reversed = {"sum_reversed", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7numbers_17sum_reversed, METH_VARARGS|METH_KEYWORDS, 0};
3548
static PyObject *__pyx_pw_7numbers_17sum_reversed(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
3549
PY_LONG_LONG __pyx_v_n;
3550
int __pyx_lineno = 0;
3551
const char *__pyx_filename = NULL;
3552
int __pyx_clineno = 0;
3553
PyObject *__pyx_r = 0;
3554
__Pyx_RefNannyDeclarations
3555
__Pyx_RefNannySetupContext("sum_reversed (wrapper)", 0);
3556
{
3557
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_n,0};
3558
PyObject* values[1] = {0};
3559
if (unlikely(__pyx_kwds)) {
3560
Py_ssize_t kw_args;
3561
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
3562
switch (pos_args) {
3563
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3564
CYTHON_FALLTHROUGH;
3565
case 0: break;
3566
default: goto __pyx_L5_argtuple_error;
3567
}
3568
kw_args = PyDict_Size(__pyx_kwds);
3569
switch (pos_args) {
3570
case 0:
3571
if (kw_args > 0) {
3572
PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_n);
3573
if (value) { values[0] = value; kw_args--; }
3574
}
3575
}
3576
if (unlikely(kw_args > 0)) {
3577
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "sum_reversed") < 0)) __PYX_ERR(0, 99, __pyx_L3_error)
3578
}
3579
} else {
3580
switch (PyTuple_GET_SIZE(__pyx_args)) {
3581
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3582
CYTHON_FALLTHROUGH;
3583
case 0: break;
3584
default: goto __pyx_L5_argtuple_error;
3585
}
3586
}
3587
if (values[0]) {
3588
__pyx_v_n = __Pyx_PyInt_As_PY_LONG_LONG(values[0]); if (unlikely((__pyx_v_n == (PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(0, 99, __pyx_L3_error)
3589
} else {
3590
__pyx_v_n = ((PY_LONG_LONG)0xF4240);
3591
}
3592
}
3593
goto __pyx_L4_argument_unpacking_done;
3594
__pyx_L5_argtuple_error:;
3595
__Pyx_RaiseArgtupleInvalid("sum_reversed", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 99, __pyx_L3_error)
3596
__pyx_L3_error:;
3597
__Pyx_AddTraceback("numbers.sum_reversed", __pyx_clineno, __pyx_lineno, __pyx_filename);
3598
__Pyx_RefNannyFinishContext();
3599
return NULL;
3600
__pyx_L4_argument_unpacking_done:;
3601
__pyx_r = __pyx_pf_7numbers_16sum_reversed(__pyx_self, __pyx_v_n);
3602
3603
/* function exit code */
3604
__Pyx_RefNannyFinishContext();
3605
return __pyx_r;
3606
}
3607
3608
static PyObject *__pyx_pf_7numbers_16sum_reversed(CYTHON_UNUSED PyObject *__pyx_self, PY_LONG_LONG __pyx_v_n) {
3609
PyObject *__pyx_r = NULL;
3610
__Pyx_RefNannyDeclarations
3611
PyObject *__pyx_t_1 = NULL;
3612
PyObject *__pyx_t_2 = NULL;
3613
PY_LONG_LONG __pyx_t_3;
3614
int __pyx_t_4;
3615
int __pyx_lineno = 0;
3616
const char *__pyx_filename = NULL;
3617
int __pyx_clineno = 0;
3618
__Pyx_RefNannySetupContext("sum_reversed", 0);
3619
3620
/* "numbers.pyx":100
3621
*
3622
* def sum_reversed(long long n=1000000):
3623
* n = sum(reversed(list(range(0, n, 3)))) # <<<<<<<<<<<<<<
3624
* assert n == 166666833333
3625
*
3626
*/
3627
__pyx_t_1 = __Pyx_PyInt_From_PY_LONG_LONG(__pyx_v_n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 100, __pyx_L1_error)
3628
__Pyx_GOTREF(__pyx_t_1);
3629
__pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 100, __pyx_L1_error)
3630
__Pyx_GOTREF(__pyx_t_2);
3631
__Pyx_INCREF(__pyx_int_0);
3632
__Pyx_GIVEREF(__pyx_int_0);
3633
PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_int_0);
3634
__Pyx_GIVEREF(__pyx_t_1);
3635
PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
3636
__Pyx_INCREF(__pyx_int_3);
3637
__Pyx_GIVEREF(__pyx_int_3);
3638
PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_int_3);
3639
__pyx_t_1 = 0;
3640
__pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 100, __pyx_L1_error)
3641
__Pyx_GOTREF(__pyx_t_1);
3642
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3643
__pyx_t_2 = PySequence_List(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 100, __pyx_L1_error)
3644
__Pyx_GOTREF(__pyx_t_2);
3645
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3646
__pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_reversed, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 100, __pyx_L1_error)
3647
__Pyx_GOTREF(__pyx_t_1);
3648
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3649
__pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_sum, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 100, __pyx_L1_error)
3650
__Pyx_GOTREF(__pyx_t_2);
3651
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3652
__pyx_t_3 = __Pyx_PyInt_As_PY_LONG_LONG(__pyx_t_2); if (unlikely((__pyx_t_3 == (PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(0, 100, __pyx_L1_error)
3653
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3654
__pyx_v_n = __pyx_t_3;
3655
3656
/* "numbers.pyx":101
3657
* def sum_reversed(long long n=1000000):
3658
* n = sum(reversed(list(range(0, n, 3))))
3659
* assert n == 166666833333 # <<<<<<<<<<<<<<
3660
*
3661
*
3662
*/
3663
#ifndef CYTHON_WITHOUT_ASSERTIONS
3664
if (unlikely(!Py_OptimizeFlag)) {
3665
__pyx_t_2 = __Pyx_PyInt_From_PY_LONG_LONG(__pyx_v_n); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 101, __pyx_L1_error)
3666
__Pyx_GOTREF(__pyx_t_2);
3667
__pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_166666833333, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 101, __pyx_L1_error)
3668
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3669
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 101, __pyx_L1_error)
3670
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3671
if (unlikely(!__pyx_t_4)) {
3672
PyErr_SetNone(PyExc_AssertionError);
3673
__PYX_ERR(0, 101, __pyx_L1_error)
3674
}
3675
}
3676
#endif
3677
3678
/* "numbers.pyx":99
3679
*
3680
*
3681
* def sum_reversed(long long n=1000000): # <<<<<<<<<<<<<<
3682
* n = sum(reversed(list(range(0, n, 3))))
3683
* assert n == 166666833333
3684
*/
3685
3686
/* function exit code */
3687
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
3688
goto __pyx_L0;
3689
__pyx_L1_error:;
3690
__Pyx_XDECREF(__pyx_t_1);
3691
__Pyx_XDECREF(__pyx_t_2);
3692
__Pyx_AddTraceback("numbers.sum_reversed", __pyx_clineno, __pyx_lineno, __pyx_filename);
3693
__pyx_r = NULL;
3694
__pyx_L0:;
3695
__Pyx_XGIVEREF(__pyx_r);
3696
__Pyx_RefNannyFinishContext();
3697
return __pyx_r;
3698
}
3699
3700
/* "(tree fragment)":1
3701
* def __pyx_unpickle_A(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<<
3702
* cdef object __pyx_PickleError
3703
* cdef object __pyx_result
3704
*/
3705
3706
/* Python wrapper */
3707
static PyObject *__pyx_pw_7numbers_19__pyx_unpickle_A(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
3708
static PyMethodDef __pyx_mdef_7numbers_19__pyx_unpickle_A = {"__pyx_unpickle_A", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7numbers_19__pyx_unpickle_A, METH_VARARGS|METH_KEYWORDS, 0};
3709
static PyObject *__pyx_pw_7numbers_19__pyx_unpickle_A(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
3710
PyObject *__pyx_v___pyx_type = 0;
3711
long __pyx_v___pyx_checksum;
3712
PyObject *__pyx_v___pyx_state = 0;
3713
int __pyx_lineno = 0;
3714
const char *__pyx_filename = NULL;
3715
int __pyx_clineno = 0;
3716
PyObject *__pyx_r = 0;
3717
__Pyx_RefNannyDeclarations
3718
__Pyx_RefNannySetupContext("__pyx_unpickle_A (wrapper)", 0);
3719
{
3720
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,0};
3721
PyObject* values[3] = {0,0,0};
3722
if (unlikely(__pyx_kwds)) {
3723
Py_ssize_t kw_args;
3724
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
3725
switch (pos_args) {
3726
case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
3727
CYTHON_FALLTHROUGH;
3728
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
3729
CYTHON_FALLTHROUGH;
3730
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3731
CYTHON_FALLTHROUGH;
3732
case 0: break;
3733
default: goto __pyx_L5_argtuple_error;
3734
}
3735
kw_args = PyDict_Size(__pyx_kwds);
3736
switch (pos_args) {
3737
case 0:
3738
if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
3739
else goto __pyx_L5_argtuple_error;
3740
CYTHON_FALLTHROUGH;
3741
case 1:
3742
if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
3743
else {
3744
__Pyx_RaiseArgtupleInvalid("__pyx_unpickle_A", 1, 3, 3, 1); __PYX_ERR(1, 1, __pyx_L3_error)
3745
}
3746
CYTHON_FALLTHROUGH;
3747
case 2:
3748
if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
3749
else {
3750
__Pyx_RaiseArgtupleInvalid("__pyx_unpickle_A", 1, 3, 3, 2); __PYX_ERR(1, 1, __pyx_L3_error)
3751
}
3752
}
3753
if (unlikely(kw_args > 0)) {
3754
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_A") < 0)) __PYX_ERR(1, 1, __pyx_L3_error)
3755
}
3756
} else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
3757
goto __pyx_L5_argtuple_error;
3758
} else {
3759
values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3760
values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
3761
values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
3762
}
3763
__pyx_v___pyx_type = values[0];
3764
__pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 1, __pyx_L3_error)
3765
__pyx_v___pyx_state = values[2];
3766
}
3767
goto __pyx_L4_argument_unpacking_done;
3768
__pyx_L5_argtuple_error:;
3769
__Pyx_RaiseArgtupleInvalid("__pyx_unpickle_A", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1, __pyx_L3_error)
3770
__pyx_L3_error:;
3771
__Pyx_AddTraceback("numbers.__pyx_unpickle_A", __pyx_clineno, __pyx_lineno, __pyx_filename);
3772
__Pyx_RefNannyFinishContext();
3773
return NULL;
3774
__pyx_L4_argument_unpacking_done:;
3775
__pyx_r = __pyx_pf_7numbers_18__pyx_unpickle_A(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);
3776
3777
/* function exit code */
3778
__Pyx_RefNannyFinishContext();
3779
return __pyx_r;
3780
}
3781
3782
static PyObject *__pyx_pf_7numbers_18__pyx_unpickle_A(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
3783
PyObject *__pyx_v___pyx_PickleError = 0;
3784
PyObject *__pyx_v___pyx_result = 0;
3785
PyObject *__pyx_r = NULL;
3786
__Pyx_RefNannyDeclarations
3787
PyObject *__pyx_t_1 = NULL;
3788
int __pyx_t_2;
3789
int __pyx_t_3;
3790
PyObject *__pyx_t_4 = NULL;
3791
PyObject *__pyx_t_5 = NULL;
3792
PyObject *__pyx_t_6 = NULL;
3793
int __pyx_lineno = 0;
3794
const char *__pyx_filename = NULL;
3795
int __pyx_clineno = 0;
3796
__Pyx_RefNannySetupContext("__pyx_unpickle_A", 0);
3797
3798
/* "(tree fragment)":4
3799
* cdef object __pyx_PickleError
3800
* cdef object __pyx_result
3801
* if __pyx_checksum not in (0x865c0c0, 0xde7d1b7, 0x042dc45): # <<<<<<<<<<<<<<
3802
* from pickle import PickleError as __pyx_PickleError
3803
* raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x865c0c0, 0xde7d1b7, 0x042dc45) = (i))" % __pyx_checksum)
3804
*/
3805
__pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error)
3806
__Pyx_GOTREF(__pyx_t_1);
3807
__pyx_t_2 = (__Pyx_PySequence_ContainsTF(__pyx_t_1, __pyx_tuple__3, Py_NE)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 4, __pyx_L1_error)
3808
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3809
__pyx_t_3 = (__pyx_t_2 != 0);
3810
if (__pyx_t_3) {
3811
3812
/* "(tree fragment)":5
3813
* cdef object __pyx_result
3814
* if __pyx_checksum not in (0x865c0c0, 0xde7d1b7, 0x042dc45):
3815
* from pickle import PickleError as __pyx_PickleError # <<<<<<<<<<<<<<
3816
* raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x865c0c0, 0xde7d1b7, 0x042dc45) = (i))" % __pyx_checksum)
3817
* __pyx_result = A.__new__(__pyx_type)
3818
*/
3819
__pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
3820
__Pyx_GOTREF(__pyx_t_1);
3821
__Pyx_INCREF(__pyx_n_s_PickleError);
3822
__Pyx_GIVEREF(__pyx_n_s_PickleError);
3823
PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_PickleError);
3824
__pyx_t_4 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_1, -1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5, __pyx_L1_error)
3825
__Pyx_GOTREF(__pyx_t_4);
3826
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3827
__pyx_t_1 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
3828
__Pyx_GOTREF(__pyx_t_1);
3829
__Pyx_INCREF(__pyx_t_1);
3830
__pyx_v___pyx_PickleError = __pyx_t_1;
3831
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3832
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3833
3834
/* "(tree fragment)":6
3835
* if __pyx_checksum not in (0x865c0c0, 0xde7d1b7, 0x042dc45):
3836
* from pickle import PickleError as __pyx_PickleError
3837
* raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x865c0c0, 0xde7d1b7, 0x042dc45) = (i))" % __pyx_checksum) # <<<<<<<<<<<<<<
3838
* __pyx_result = A.__new__(__pyx_type)
3839
* if __pyx_state is not None:
3840
*/
3841
__pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6, __pyx_L1_error)
3842
__Pyx_GOTREF(__pyx_t_1);
3843
__pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_0x_x_vs_0, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 6, __pyx_L1_error)
3844
__Pyx_GOTREF(__pyx_t_5);
3845
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3846
__Pyx_INCREF(__pyx_v___pyx_PickleError);
3847
__pyx_t_1 = __pyx_v___pyx_PickleError; __pyx_t_6 = NULL;
3848
if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
3849
__pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1);
3850
if (likely(__pyx_t_6)) {
3851
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
3852
__Pyx_INCREF(__pyx_t_6);
3853
__Pyx_INCREF(function);
3854
__Pyx_DECREF_SET(__pyx_t_1, function);
3855
}
3856
}
3857
__pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_6, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5);
3858
__Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
3859
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
3860
if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error)
3861
__Pyx_GOTREF(__pyx_t_4);
3862
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3863
__Pyx_Raise(__pyx_t_4, 0, 0, 0);
3864
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3865
__PYX_ERR(1, 6, __pyx_L1_error)
3866
3867
/* "(tree fragment)":4
3868
* cdef object __pyx_PickleError
3869
* cdef object __pyx_result
3870
* if __pyx_checksum not in (0x865c0c0, 0xde7d1b7, 0x042dc45): # <<<<<<<<<<<<<<
3871
* from pickle import PickleError as __pyx_PickleError
3872
* raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x865c0c0, 0xde7d1b7, 0x042dc45) = (i))" % __pyx_checksum)
3873
*/
3874
}
3875
3876
/* "(tree fragment)":7
3877
* from pickle import PickleError as __pyx_PickleError
3878
* raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x865c0c0, 0xde7d1b7, 0x042dc45) = (i))" % __pyx_checksum)
3879
* __pyx_result = A.__new__(__pyx_type) # <<<<<<<<<<<<<<
3880
* if __pyx_state is not None:
3881
* __pyx_unpickle_A__set_state(<A> __pyx_result, __pyx_state)
3882
*/
3883
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_7numbers_A), __pyx_n_s_new); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 7, __pyx_L1_error)
3884
__Pyx_GOTREF(__pyx_t_1);
3885
__pyx_t_5 = NULL;
3886
if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
3887
__pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
3888
if (likely(__pyx_t_5)) {
3889
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
3890
__Pyx_INCREF(__pyx_t_5);
3891
__Pyx_INCREF(function);
3892
__Pyx_DECREF_SET(__pyx_t_1, function);
3893
}
3894
}
3895
__pyx_t_4 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_5, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v___pyx_type);
3896
__Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
3897
if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 7, __pyx_L1_error)
3898
__Pyx_GOTREF(__pyx_t_4);
3899
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3900
__pyx_v___pyx_result = __pyx_t_4;
3901
__pyx_t_4 = 0;
3902
3903
/* "(tree fragment)":8
3904
* raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x865c0c0, 0xde7d1b7, 0x042dc45) = (i))" % __pyx_checksum)
3905
* __pyx_result = A.__new__(__pyx_type)
3906
* if __pyx_state is not None: # <<<<<<<<<<<<<<
3907
* __pyx_unpickle_A__set_state(<A> __pyx_result, __pyx_state)
3908
* return __pyx_result
3909
*/
3910
__pyx_t_3 = (__pyx_v___pyx_state != Py_None);
3911
__pyx_t_2 = (__pyx_t_3 != 0);
3912
if (__pyx_t_2) {
3913
3914
/* "(tree fragment)":9
3915
* __pyx_result = A.__new__(__pyx_type)
3916
* if __pyx_state is not None:
3917
* __pyx_unpickle_A__set_state(<A> __pyx_result, __pyx_state) # <<<<<<<<<<<<<<
3918
* return __pyx_result
3919
* cdef __pyx_unpickle_A__set_state(A __pyx_result, tuple __pyx_state):
3920
*/
3921
if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 9, __pyx_L1_error)
3922
__pyx_t_4 = __pyx_f_7numbers___pyx_unpickle_A__set_state(((struct __pyx_obj_7numbers_A *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 9, __pyx_L1_error)
3923
__Pyx_GOTREF(__pyx_t_4);
3924
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3925
3926
/* "(tree fragment)":8
3927
* raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x865c0c0, 0xde7d1b7, 0x042dc45) = (i))" % __pyx_checksum)
3928
* __pyx_result = A.__new__(__pyx_type)
3929
* if __pyx_state is not None: # <<<<<<<<<<<<<<
3930
* __pyx_unpickle_A__set_state(<A> __pyx_result, __pyx_state)
3931
* return __pyx_result
3932
*/
3933
}
3934
3935
/* "(tree fragment)":10
3936
* if __pyx_state is not None:
3937
* __pyx_unpickle_A__set_state(<A> __pyx_result, __pyx_state)
3938
* return __pyx_result # <<<<<<<<<<<<<<
3939
* cdef __pyx_unpickle_A__set_state(A __pyx_result, tuple __pyx_state):
3940
* __pyx_result.i = __pyx_state[0]
3941
*/
3942
__Pyx_XDECREF(__pyx_r);
3943
__Pyx_INCREF(__pyx_v___pyx_result);
3944
__pyx_r = __pyx_v___pyx_result;
3945
goto __pyx_L0;
3946
3947
/* "(tree fragment)":1
3948
* def __pyx_unpickle_A(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<<
3949
* cdef object __pyx_PickleError
3950
* cdef object __pyx_result
3951
*/
3952
3953
/* function exit code */
3954
__pyx_L1_error:;
3955
__Pyx_XDECREF(__pyx_t_1);
3956
__Pyx_XDECREF(__pyx_t_4);
3957
__Pyx_XDECREF(__pyx_t_5);
3958
__Pyx_XDECREF(__pyx_t_6);
3959
__Pyx_AddTraceback("numbers.__pyx_unpickle_A", __pyx_clineno, __pyx_lineno, __pyx_filename);
3960
__pyx_r = NULL;
3961
__pyx_L0:;
3962
__Pyx_XDECREF(__pyx_v___pyx_PickleError);
3963
__Pyx_XDECREF(__pyx_v___pyx_result);
3964
__Pyx_XGIVEREF(__pyx_r);
3965
__Pyx_RefNannyFinishContext();
3966
return __pyx_r;
3967
}
3968
3969
/* "(tree fragment)":11
3970
* __pyx_unpickle_A__set_state(<A> __pyx_result, __pyx_state)
3971
* return __pyx_result
3972
* cdef __pyx_unpickle_A__set_state(A __pyx_result, tuple __pyx_state): # <<<<<<<<<<<<<<
3973
* __pyx_result.i = __pyx_state[0]
3974
* if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
3975
*/
3976
3977
static PyObject *__pyx_f_7numbers___pyx_unpickle_A__set_state(struct __pyx_obj_7numbers_A *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
3978
PyObject *__pyx_r = NULL;
3979
__Pyx_RefNannyDeclarations
3980
PyObject *__pyx_t_1 = NULL;
3981
int __pyx_t_2;
3982
int __pyx_t_3;
3983
Py_ssize_t __pyx_t_4;
3984
int __pyx_t_5;
3985
int __pyx_t_6;
3986
PyObject *__pyx_t_7 = NULL;
3987
PyObject *__pyx_t_8 = NULL;
3988
PyObject *__pyx_t_9 = NULL;
3989
int __pyx_lineno = 0;
3990
const char *__pyx_filename = NULL;
3991
int __pyx_clineno = 0;
3992
__Pyx_RefNannySetupContext("__pyx_unpickle_A__set_state", 0);
3993
3994
/* "(tree fragment)":12
3995
* return __pyx_result
3996
* cdef __pyx_unpickle_A__set_state(A __pyx_result, tuple __pyx_state):
3997
* __pyx_result.i = __pyx_state[0] # <<<<<<<<<<<<<<
3998
* if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
3999
* __pyx_result.__dict__.update(__pyx_state[1])
4000
*/
4001
if (unlikely(__pyx_v___pyx_state == Py_None)) {
4002
PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
4003
__PYX_ERR(1, 12, __pyx_L1_error)
4004
}
4005
__pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
4006
__Pyx_GOTREF(__pyx_t_1);
4007
__pyx_t_2 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)
4008
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4009
__pyx_v___pyx_result->i = __pyx_t_2;
4010
4011
/* "(tree fragment)":13
4012
* cdef __pyx_unpickle_A__set_state(A __pyx_result, tuple __pyx_state):
4013
* __pyx_result.i = __pyx_state[0]
4014
* if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'): # <<<<<<<<<<<<<<
4015
* __pyx_result.__dict__.update(__pyx_state[1])
4016
*/
4017
if (unlikely(__pyx_v___pyx_state == Py_None)) {
4018
PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
4019
__PYX_ERR(1, 13, __pyx_L1_error)
4020
}
4021
__pyx_t_4 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
4022
__pyx_t_5 = ((__pyx_t_4 > 1) != 0);
4023
if (__pyx_t_5) {
4024
} else {
4025
__pyx_t_3 = __pyx_t_5;
4026
goto __pyx_L4_bool_binop_done;
4027
}
4028
__pyx_t_5 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
4029
__pyx_t_6 = (__pyx_t_5 != 0);
4030
__pyx_t_3 = __pyx_t_6;
4031
__pyx_L4_bool_binop_done:;
4032
if (__pyx_t_3) {
4033
4034
/* "(tree fragment)":14
4035
* __pyx_result.i = __pyx_state[0]
4036
* if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
4037
* __pyx_result.__dict__.update(__pyx_state[1]) # <<<<<<<<<<<<<<
4038
*/
4039
__pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
4040
__Pyx_GOTREF(__pyx_t_7);
4041
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_update); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 14, __pyx_L1_error)
4042
__Pyx_GOTREF(__pyx_t_8);
4043
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
4044
if (unlikely(__pyx_v___pyx_state == Py_None)) {
4045
PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
4046
__PYX_ERR(1, 14, __pyx_L1_error)
4047
}
4048
__pyx_t_7 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
4049
__Pyx_GOTREF(__pyx_t_7);
4050
__pyx_t_9 = NULL;
4051
if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
4052
__pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
4053
if (likely(__pyx_t_9)) {
4054
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
4055
__Pyx_INCREF(__pyx_t_9);
4056
__Pyx_INCREF(function);
4057
__Pyx_DECREF_SET(__pyx_t_8, function);
4058
}
4059
}
4060
__pyx_t_1 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_9, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_7);
4061
__Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
4062
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
4063
if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 14, __pyx_L1_error)
4064
__Pyx_GOTREF(__pyx_t_1);
4065
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
4066
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4067
4068
/* "(tree fragment)":13
4069
* cdef __pyx_unpickle_A__set_state(A __pyx_result, tuple __pyx_state):
4070
* __pyx_result.i = __pyx_state[0]
4071
* if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'): # <<<<<<<<<<<<<<
4072
* __pyx_result.__dict__.update(__pyx_state[1])
4073
*/
4074
}
4075
4076
/* "(tree fragment)":11
4077
* __pyx_unpickle_A__set_state(<A> __pyx_result, __pyx_state)
4078
* return __pyx_result
4079
* cdef __pyx_unpickle_A__set_state(A __pyx_result, tuple __pyx_state): # <<<<<<<<<<<<<<
4080
* __pyx_result.i = __pyx_state[0]
4081
* if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
4082
*/
4083
4084
/* function exit code */
4085
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
4086
goto __pyx_L0;
4087
__pyx_L1_error:;
4088
__Pyx_XDECREF(__pyx_t_1);
4089
__Pyx_XDECREF(__pyx_t_7);
4090
__Pyx_XDECREF(__pyx_t_8);
4091
__Pyx_XDECREF(__pyx_t_9);
4092
__Pyx_AddTraceback("numbers.__pyx_unpickle_A__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
4093
__pyx_r = 0;
4094
__pyx_L0:;
4095
__Pyx_XGIVEREF(__pyx_r);
4096
__Pyx_RefNannyFinishContext();
4097
return __pyx_r;
4098
}
4099
4100
static PyObject *__pyx_tp_new_7numbers_A(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
4101
PyObject *o;
4102
if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
4103
o = (*t->tp_alloc)(t, 0);
4104
} else {
4105
o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
4106
}
4107
if (unlikely(!o)) return 0;
4108
return o;
4109
}
4110
4111
static void __pyx_tp_dealloc_7numbers_A(PyObject *o) {
4112
#if CYTHON_USE_TP_FINALIZE
4113
if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) {
4114
if (PyObject_CallFinalizerFromDealloc(o)) return;
4115
}
4116
#endif
4117
(*Py_TYPE(o)->tp_free)(o);
4118
}
4119
4120
static PyMethodDef __pyx_methods_7numbers_A[] = {
4121
{"value", (PyCFunction)__pyx_pw_7numbers_1A_3value, METH_NOARGS, 0},
4122
{"__reduce_cython__", (PyCFunction)__pyx_pw_7numbers_1A_7__reduce_cython__, METH_NOARGS, 0},
4123
{"__setstate_cython__", (PyCFunction)__pyx_pw_7numbers_1A_9__setstate_cython__, METH_O, 0},
4124
{0, 0, 0, 0}
4125
};
4126
4127
static PyNumberMethods __pyx_tp_as_number_A = {
4128
__pyx_pw_7numbers_1A_5__add__, /*nb_add*/
4129
0, /*nb_subtract*/
4130
0, /*nb_multiply*/
4131
#if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
4132
0, /*nb_divide*/
4133
#endif
4134
0, /*nb_remainder*/
4135
0, /*nb_divmod*/
4136
0, /*nb_power*/
4137
0, /*nb_negative*/
4138
0, /*nb_positive*/
4139
0, /*nb_absolute*/
4140
0, /*nb_nonzero*/
4141
0, /*nb_invert*/
4142
0, /*nb_lshift*/
4143
0, /*nb_rshift*/
4144
0, /*nb_and*/
4145
0, /*nb_xor*/
4146
0, /*nb_or*/
4147
#if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
4148
0, /*nb_coerce*/
4149
#endif
4150
0, /*nb_int*/
4151
#if PY_MAJOR_VERSION < 3
4152
0, /*nb_long*/
4153
#else
4154
0, /*reserved*/
4155
#endif
4156
0, /*nb_float*/
4157
#if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
4158
0, /*nb_oct*/
4159
#endif
4160
#if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
4161
0, /*nb_hex*/
4162
#endif
4163
0, /*nb_inplace_add*/
4164
0, /*nb_inplace_subtract*/
4165
0, /*nb_inplace_multiply*/
4166
#if PY_MAJOR_VERSION < 3 || (CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03050000)
4167
0, /*nb_inplace_divide*/
4168
#endif
4169
0, /*nb_inplace_remainder*/
4170
0, /*nb_inplace_power*/
4171
0, /*nb_inplace_lshift*/
4172
0, /*nb_inplace_rshift*/
4173
0, /*nb_inplace_and*/
4174
0, /*nb_inplace_xor*/
4175
0, /*nb_inplace_or*/
4176
0, /*nb_floor_divide*/
4177
0, /*nb_true_divide*/
4178
0, /*nb_inplace_floor_divide*/
4179
0, /*nb_inplace_true_divide*/
4180
0, /*nb_index*/
4181
#if PY_VERSION_HEX >= 0x03050000
4182
0, /*nb_matrix_multiply*/
4183
#endif
4184
#if PY_VERSION_HEX >= 0x03050000
4185
0, /*nb_inplace_matrix_multiply*/
4186
#endif
4187
};
4188
4189
static PyTypeObject __pyx_type_7numbers_A = {
4190
PyVarObject_HEAD_INIT(0, 0)
4191
"numbers.A", /*tp_name*/
4192
sizeof(struct __pyx_obj_7numbers_A), /*tp_basicsize*/
4193
0, /*tp_itemsize*/
4194
__pyx_tp_dealloc_7numbers_A, /*tp_dealloc*/
4195
#if PY_VERSION_HEX < 0x030800b4
4196
0, /*tp_print*/
4197
#endif
4198
#if PY_VERSION_HEX >= 0x030800b4
4199
0, /*tp_vectorcall_offset*/
4200
#endif
4201
0, /*tp_getattr*/
4202
0, /*tp_setattr*/
4203
#if PY_MAJOR_VERSION < 3
4204
0, /*tp_compare*/
4205
#endif
4206
#if PY_MAJOR_VERSION >= 3
4207
0, /*tp_as_async*/
4208
#endif
4209
0, /*tp_repr*/
4210
&__pyx_tp_as_number_A, /*tp_as_number*/
4211
0, /*tp_as_sequence*/
4212
0, /*tp_as_mapping*/
4213
0, /*tp_hash*/
4214
0, /*tp_call*/
4215
0, /*tp_str*/
4216
0, /*tp_getattro*/
4217
0, /*tp_setattro*/
4218
0, /*tp_as_buffer*/
4219
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
4220
0, /*tp_doc*/
4221
0, /*tp_traverse*/
4222
0, /*tp_clear*/
4223
0, /*tp_richcompare*/
4224
0, /*tp_weaklistoffset*/
4225
0, /*tp_iter*/
4226
0, /*tp_iternext*/
4227
__pyx_methods_7numbers_A, /*tp_methods*/
4228
0, /*tp_members*/
4229
0, /*tp_getset*/
4230
0, /*tp_base*/
4231
0, /*tp_dict*/
4232
0, /*tp_descr_get*/
4233
0, /*tp_descr_set*/
4234
0, /*tp_dictoffset*/
4235
__pyx_pw_7numbers_1A_1__init__, /*tp_init*/
4236
0, /*tp_alloc*/
4237
__pyx_tp_new_7numbers_A, /*tp_new*/
4238
0, /*tp_free*/
4239
0, /*tp_is_gc*/
4240
0, /*tp_bases*/
4241
0, /*tp_mro*/
4242
0, /*tp_cache*/
4243
0, /*tp_subclasses*/
4244
0, /*tp_weaklist*/
4245
0, /*tp_del*/
4246
0, /*tp_version_tag*/
4247
#if PY_VERSION_HEX >= 0x030400a1
4248
0, /*tp_finalize*/
4249
#endif
4250
#if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
4251
0, /*tp_vectorcall*/
4252
#endif
4253
#if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
4254
0, /*tp_print*/
4255
#endif
4256
#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
4257
0, /*tp_pypy_flags*/
4258
#endif
4259
};
4260
4261
static PyMethodDef __pyx_methods[] = {
4262
{0, 0, 0, 0}
4263
};
4264
4265
#if PY_MAJOR_VERSION >= 3
4266
#if CYTHON_PEP489_MULTI_PHASE_INIT
4267
static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
4268
static int __pyx_pymod_exec_numbers(PyObject* module); /*proto*/
4269
static PyModuleDef_Slot __pyx_moduledef_slots[] = {
4270
{Py_mod_create, (void*)__pyx_pymod_create},
4271
{Py_mod_exec, (void*)__pyx_pymod_exec_numbers},
4272
{0, NULL}
4273
};
4274
#endif
4275
4276
static struct PyModuleDef __pyx_moduledef = {
4277
PyModuleDef_HEAD_INIT,
4278
"numbers",
4279
0, /* m_doc */
4280
#if CYTHON_PEP489_MULTI_PHASE_INIT
4281
0, /* m_size */
4282
#else
4283
-1, /* m_size */
4284
#endif
4285
__pyx_methods /* m_methods */,
4286
#if CYTHON_PEP489_MULTI_PHASE_INIT
4287
__pyx_moduledef_slots, /* m_slots */
4288
#else
4289
NULL, /* m_reload */
4290
#endif
4291
NULL, /* m_traverse */
4292
NULL, /* m_clear */
4293
NULL /* m_free */
4294
};
4295
#endif
4296
#ifndef CYTHON_SMALL_CODE
4297
#if defined(__clang__)
4298
#define CYTHON_SMALL_CODE
4299
#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
4300
#define CYTHON_SMALL_CODE __attribute__((cold))
4301
#else
4302
#define CYTHON_SMALL_CODE
4303
#endif
4304
#endif
4305
4306
static __Pyx_StringTabEntry __pyx_string_tab[] = {
4307
{&__pyx_n_s_A, __pyx_k_A, sizeof(__pyx_k_A), 0, 0, 1, 1},
4308
{&__pyx_kp_s_Incompatible_checksums_0x_x_vs_0, __pyx_k_Incompatible_checksums_0x_x_vs_0, sizeof(__pyx_k_Incompatible_checksums_0x_x_vs_0), 0, 0, 1, 0},
4309
{&__pyx_n_s_PickleError, __pyx_k_PickleError, sizeof(__pyx_k_PickleError), 0, 0, 1, 1},
4310
{&__pyx_n_s_a, __pyx_k_a, sizeof(__pyx_k_a), 0, 0, 1, 1},
4311
{&__pyx_n_s_all, __pyx_k_all, sizeof(__pyx_k_all), 0, 0, 1, 1},
4312
{&__pyx_n_s_b, __pyx_k_b, sizeof(__pyx_k_b), 0, 0, 1, 1},
4313
{&__pyx_n_s_bench, __pyx_k_bench, sizeof(__pyx_k_bench), 0, 0, 1, 1},
4314
{&__pyx_n_s_bench_gcd, __pyx_k_bench_gcd, sizeof(__pyx_k_bench_gcd), 0, 0, 1, 1},
4315
{&__pyx_n_s_bench_inverse_mod, __pyx_k_bench_inverse_mod, sizeof(__pyx_k_bench_inverse_mod), 0, 0, 1, 1},
4316
{&__pyx_n_s_bench_xgcd, __pyx_k_bench_xgcd, sizeof(__pyx_k_bench_xgcd), 0, 0, 1, 1},
4317
{&__pyx_n_s_bench_xgcd_py, __pyx_k_bench_xgcd_py, sizeof(__pyx_k_bench_xgcd_py), 0, 0, 1, 1},
4318
{&__pyx_n_s_c, __pyx_k_c, sizeof(__pyx_k_c), 0, 0, 1, 1},
4319
{&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
4320
{&__pyx_n_s_cx, __pyx_k_cx, sizeof(__pyx_k_cx), 0, 0, 1, 1},
4321
{&__pyx_n_s_cy, __pyx_k_cy, sizeof(__pyx_k_cy), 0, 0, 1, 1},
4322
{&__pyx_n_s_dict, __pyx_k_dict, sizeof(__pyx_k_dict), 0, 0, 1, 1},
4323
{&__pyx_n_s_gcd, __pyx_k_gcd, sizeof(__pyx_k_gcd), 0, 0, 1, 1},
4324
{&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1},
4325
{&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1},
4326
{&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
4327
{&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
4328
{&__pyx_n_s_n, __pyx_k_n, sizeof(__pyx_k_n), 0, 0, 1, 1},
4329
{&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
4330
{&__pyx_n_s_new, __pyx_k_new, sizeof(__pyx_k_new), 0, 0, 1, 1},
4331
{&__pyx_n_s_nt, __pyx_k_nt, sizeof(__pyx_k_nt), 0, 0, 1, 1},
4332
{&__pyx_n_s_numbers, __pyx_k_numbers, sizeof(__pyx_k_numbers), 0, 0, 1, 1},
4333
{&__pyx_kp_s_numbers_pyx, __pyx_k_numbers_pyx, sizeof(__pyx_k_numbers_pyx), 0, 0, 1, 0},
4334
{&__pyx_n_s_operator_add, __pyx_k_operator_add, sizeof(__pyx_k_operator_add), 0, 0, 1, 1},
4335
{&__pyx_n_s_pi, __pyx_k_pi, sizeof(__pyx_k_pi), 0, 0, 1, 1},
4336
{&__pyx_kp_s_pi_10_5, __pyx_k_pi_10_5, sizeof(__pyx_k_pi_10_5), 0, 0, 1, 0},
4337
{&__pyx_n_s_pickle, __pyx_k_pickle, sizeof(__pyx_k_pickle), 0, 0, 1, 1},
4338
{&__pyx_n_s_pyx_PickleError, __pyx_k_pyx_PickleError, sizeof(__pyx_k_pyx_PickleError), 0, 0, 1, 1},
4339
{&__pyx_n_s_pyx_checksum, __pyx_k_pyx_checksum, sizeof(__pyx_k_pyx_checksum), 0, 0, 1, 1},
4340
{&__pyx_n_s_pyx_result, __pyx_k_pyx_result, sizeof(__pyx_k_pyx_result), 0, 0, 1, 1},
4341
{&__pyx_n_s_pyx_state, __pyx_k_pyx_state, sizeof(__pyx_k_pyx_state), 0, 0, 1, 1},
4342
{&__pyx_n_s_pyx_type, __pyx_k_pyx_type, sizeof(__pyx_k_pyx_type), 0, 0, 1, 1},
4343
{&__pyx_n_s_pyx_unpickle_A, __pyx_k_pyx_unpickle_A, sizeof(__pyx_k_pyx_unpickle_A), 0, 0, 1, 1},
4344
{&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
4345
{&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1},
4346
{&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1},
4347
{&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1},
4348
{&__pyx_n_s_register, __pyx_k_register, sizeof(__pyx_k_register), 0, 0, 1, 1},
4349
{&__pyx_n_s_reversed, __pyx_k_reversed, sizeof(__pyx_k_reversed), 0, 0, 1, 1},
4350
{&__pyx_n_s_s, __pyx_k_s, sizeof(__pyx_k_s), 0, 0, 1, 1},
4351
{&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1},
4352
{&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1},
4353
{&__pyx_kp_s_stringsource, __pyx_k_stringsource, sizeof(__pyx_k_stringsource), 0, 0, 1, 0},
4354
{&__pyx_n_s_sum, __pyx_k_sum, sizeof(__pyx_k_sum), 0, 0, 1, 1},
4355
{&__pyx_n_s_sum_loop, __pyx_k_sum_loop, sizeof(__pyx_k_sum_loop), 0, 0, 1, 1},
4356
{&__pyx_n_s_sum_range, __pyx_k_sum_range, sizeof(__pyx_k_sum_range), 0, 0, 1, 1},
4357
{&__pyx_n_s_sum_reversed, __pyx_k_sum_reversed, sizeof(__pyx_k_sum_reversed), 0, 0, 1, 1},
4358
{&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
4359
{&__pyx_n_s_test_pi, __pyx_k_test_pi, sizeof(__pyx_k_test_pi), 0, 0, 1, 1},
4360
{&__pyx_n_s_update, __pyx_k_update, sizeof(__pyx_k_update), 0, 0, 1, 1},
4361
{&__pyx_n_s_value, __pyx_k_value, sizeof(__pyx_k_value), 0, 0, 1, 1},
4362
{&__pyx_n_s_xgcd, __pyx_k_xgcd, sizeof(__pyx_k_xgcd), 0, 0, 1, 1},
4363
{0, 0, 0, 0, 0, 0, 0}
4364
};
4365
static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
4366
__pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 28, __pyx_L1_error)
4367
__pyx_builtin_sum = __Pyx_GetBuiltinName(__pyx_n_s_sum); if (!__pyx_builtin_sum) __PYX_ERR(0, 92, __pyx_L1_error)
4368
__pyx_builtin_reversed = __Pyx_GetBuiltinName(__pyx_n_s_reversed); if (!__pyx_builtin_reversed) __PYX_ERR(0, 100, __pyx_L1_error)
4369
return 0;
4370
__pyx_L1_error:;
4371
return -1;
4372
}
4373
4374
static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
4375
__Pyx_RefNannyDeclarations
4376
__Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
4377
4378
/* "numbers.pyx":25
4379
* def operator_add(int n=100000):
4380
*
4381
* a = A(2) # <<<<<<<<<<<<<<
4382
* b = A(3)
4383
* cdef int i
4384
*/
4385
__pyx_tuple_ = PyTuple_Pack(1, __pyx_int_2); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 25, __pyx_L1_error)
4386
__Pyx_GOTREF(__pyx_tuple_);
4387
__Pyx_GIVEREF(__pyx_tuple_);
4388
4389
/* "numbers.pyx":26
4390
*
4391
* a = A(2)
4392
* b = A(3) # <<<<<<<<<<<<<<
4393
* cdef int i
4394
* for i in range(n):
4395
*/
4396
__pyx_tuple__2 = PyTuple_Pack(1, __pyx_int_3); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 26, __pyx_L1_error)
4397
__Pyx_GOTREF(__pyx_tuple__2);
4398
__Pyx_GIVEREF(__pyx_tuple__2);
4399
4400
/* "(tree fragment)":4
4401
* cdef object __pyx_PickleError
4402
* cdef object __pyx_result
4403
* if __pyx_checksum not in (0x865c0c0, 0xde7d1b7, 0x042dc45): # <<<<<<<<<<<<<<
4404
* from pickle import PickleError as __pyx_PickleError
4405
* raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x865c0c0, 0xde7d1b7, 0x042dc45) = (i))" % __pyx_checksum)
4406
*/
4407
__pyx_tuple__3 = PyTuple_Pack(3, __pyx_int_140886208, __pyx_int_233296311, __pyx_int_4381765); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(1, 4, __pyx_L1_error)
4408
__Pyx_GOTREF(__pyx_tuple__3);
4409
__Pyx_GIVEREF(__pyx_tuple__3);
4410
4411
/* "numbers.pyx":6
4412
* from nt cimport gcd, xgcd_c, inverse_mod
4413
*
4414
* def test_pi(n=100000): # <<<<<<<<<<<<<<
4415
* assert pi(n) == 9592
4416
*
4417
*/
4418
__pyx_tuple__4 = PyTuple_Pack(1, __pyx_n_s_n); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 6, __pyx_L1_error)
4419
__Pyx_GOTREF(__pyx_tuple__4);
4420
__Pyx_GIVEREF(__pyx_tuple__4);
4421
__pyx_codeobj__5 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__4, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_numbers_pyx, __pyx_n_s_test_pi, 6, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__5)) __PYX_ERR(0, 6, __pyx_L1_error)
4422
4423
/* "numbers.pyx":23
4424
* return A((<A>self).i + (<A>right).i)
4425
*
4426
* def operator_add(int n=100000): # <<<<<<<<<<<<<<
4427
*
4428
* a = A(2)
4429
*/
4430
__pyx_tuple__6 = PyTuple_Pack(5, __pyx_n_s_n, __pyx_n_s_a, __pyx_n_s_b, __pyx_n_s_i, __pyx_n_s_c); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 23, __pyx_L1_error)
4431
__Pyx_GOTREF(__pyx_tuple__6);
4432
__Pyx_GIVEREF(__pyx_tuple__6);
4433
__pyx_codeobj__7 = (PyObject*)__Pyx_PyCode_New(1, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__6, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_numbers_pyx, __pyx_n_s_operator_add, 23, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__7)) __PYX_ERR(0, 23, __pyx_L1_error)
4434
4435
/* "numbers.pyx":36
4436
*
4437
*
4438
* def bench_gcd(int n=10**5): # <<<<<<<<<<<<<<
4439
* cdef int s = 0
4440
* cdef int i
4441
*/
4442
__pyx_tuple__8 = PyTuple_Pack(3, __pyx_n_s_n, __pyx_n_s_s, __pyx_n_s_i); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 36, __pyx_L1_error)
4443
__Pyx_GOTREF(__pyx_tuple__8);
4444
__Pyx_GIVEREF(__pyx_tuple__8);
4445
__pyx_codeobj__9 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__8, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_numbers_pyx, __pyx_n_s_bench_gcd, 36, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__9)) __PYX_ERR(0, 36, __pyx_L1_error)
4446
4447
/* "numbers.pyx":48
4448
*
4449
*
4450
* def bench_xgcd_py(n=10**5): # <<<<<<<<<<<<<<
4451
* s = 0
4452
* for i in range(n):
4453
*/
4454
__pyx_tuple__10 = PyTuple_Pack(3, __pyx_n_s_n, __pyx_n_s_s, __pyx_n_s_i); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(0, 48, __pyx_L1_error)
4455
__Pyx_GOTREF(__pyx_tuple__10);
4456
__Pyx_GIVEREF(__pyx_tuple__10);
4457
__pyx_codeobj__11 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__10, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_numbers_pyx, __pyx_n_s_bench_xgcd_py, 48, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__11)) __PYX_ERR(0, 48, __pyx_L1_error)
4458
4459
/* "numbers.pyx":59
4460
*
4461
*
4462
* def bench_xgcd(int n=10**5): # <<<<<<<<<<<<<<
4463
* cdef int s = 0, cx, cy, i
4464
* for i in range(n):
4465
*/
4466
__pyx_tuple__12 = PyTuple_Pack(5, __pyx_n_s_n, __pyx_n_s_s, __pyx_n_s_cx, __pyx_n_s_cy, __pyx_n_s_i); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(0, 59, __pyx_L1_error)
4467
__Pyx_GOTREF(__pyx_tuple__12);
4468
__Pyx_GIVEREF(__pyx_tuple__12);
4469
__pyx_codeobj__13 = (PyObject*)__Pyx_PyCode_New(1, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__12, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_numbers_pyx, __pyx_n_s_bench_xgcd, 59, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__13)) __PYX_ERR(0, 59, __pyx_L1_error)
4470
4471
/* "numbers.pyx":70
4472
*
4473
*
4474
* def bench_inverse_mod(long long n=10**5): # <<<<<<<<<<<<<<
4475
* cdef long long i, s = 0
4476
* for i in range(1, n):
4477
*/
4478
__pyx_tuple__14 = PyTuple_Pack(3, __pyx_n_s_n, __pyx_n_s_i, __pyx_n_s_s); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(0, 70, __pyx_L1_error)
4479
__Pyx_GOTREF(__pyx_tuple__14);
4480
__Pyx_GIVEREF(__pyx_tuple__14);
4481
__pyx_codeobj__15 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__14, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_numbers_pyx, __pyx_n_s_bench_inverse_mod, 70, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__15)) __PYX_ERR(0, 70, __pyx_L1_error)
4482
4483
/* "numbers.pyx":80
4484
*
4485
*
4486
* def sum_loop(int n=1000000): # <<<<<<<<<<<<<<
4487
* cdef int s = 0, i
4488
* for i in range(0, n, 3):
4489
*/
4490
__pyx_tuple__16 = PyTuple_Pack(3, __pyx_n_s_n, __pyx_n_s_s, __pyx_n_s_i); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(0, 80, __pyx_L1_error)
4491
__Pyx_GOTREF(__pyx_tuple__16);
4492
__Pyx_GIVEREF(__pyx_tuple__16);
4493
__pyx_codeobj__17 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__16, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_numbers_pyx, __pyx_n_s_sum_loop, 80, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__17)) __PYX_ERR(0, 80, __pyx_L1_error)
4494
4495
/* "numbers.pyx":91
4496
*
4497
*
4498
* def sum_range(long long n=1000000): # <<<<<<<<<<<<<<
4499
* n = sum(range(0, n, 3))
4500
* assert n == 166666833333
4501
*/
4502
__pyx_tuple__18 = PyTuple_Pack(1, __pyx_n_s_n); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(0, 91, __pyx_L1_error)
4503
__Pyx_GOTREF(__pyx_tuple__18);
4504
__Pyx_GIVEREF(__pyx_tuple__18);
4505
__pyx_codeobj__19 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__18, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_numbers_pyx, __pyx_n_s_sum_range, 91, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__19)) __PYX_ERR(0, 91, __pyx_L1_error)
4506
4507
/* "numbers.pyx":99
4508
*
4509
*
4510
* def sum_reversed(long long n=1000000): # <<<<<<<<<<<<<<
4511
* n = sum(reversed(list(range(0, n, 3))))
4512
* assert n == 166666833333
4513
*/
4514
__pyx_tuple__20 = PyTuple_Pack(1, __pyx_n_s_n); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(0, 99, __pyx_L1_error)
4515
__Pyx_GOTREF(__pyx_tuple__20);
4516
__Pyx_GIVEREF(__pyx_tuple__20);
4517
__pyx_codeobj__21 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__20, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_numbers_pyx, __pyx_n_s_sum_reversed, 99, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__21)) __PYX_ERR(0, 99, __pyx_L1_error)
4518
4519
/* "numbers.pyx":107
4520
*
4521
* if __name__ == '__main__':
4522
* all('numbers') # <<<<<<<<<<<<<<
4523
*/
4524
__pyx_tuple__22 = PyTuple_Pack(1, __pyx_n_s_numbers); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(0, 107, __pyx_L1_error)
4525
__Pyx_GOTREF(__pyx_tuple__22);
4526
__Pyx_GIVEREF(__pyx_tuple__22);
4527
4528
/* "(tree fragment)":1
4529
* def __pyx_unpickle_A(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<<
4530
* cdef object __pyx_PickleError
4531
* cdef object __pyx_result
4532
*/
4533
__pyx_tuple__23 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(1, 1, __pyx_L1_error)
4534
__Pyx_GOTREF(__pyx_tuple__23);
4535
__Pyx_GIVEREF(__pyx_tuple__23);
4536
__pyx_codeobj__24 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__23, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_A, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__24)) __PYX_ERR(1, 1, __pyx_L1_error)
4537
__Pyx_RefNannyFinishContext();
4538
return 0;
4539
__pyx_L1_error:;
4540
__Pyx_RefNannyFinishContext();
4541
return -1;
4542
}
4543
4544
static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
4545
if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
4546
__pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error)
4547
__pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) __PYX_ERR(0, 1, __pyx_L1_error)
4548
__pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) __PYX_ERR(0, 1, __pyx_L1_error)
4549
__pyx_int_5 = PyInt_FromLong(5); if (unlikely(!__pyx_int_5)) __PYX_ERR(0, 1, __pyx_L1_error)
4550
__pyx_int_9592 = PyInt_FromLong(9592); if (unlikely(!__pyx_int_9592)) __PYX_ERR(0, 1, __pyx_L1_error)
4551
__pyx_int_92250 = PyInt_FromLong(92250L); if (unlikely(!__pyx_int_92250)) __PYX_ERR(0, 1, __pyx_L1_error)
4552
__pyx_int_100000 = PyInt_FromLong(100000L); if (unlikely(!__pyx_int_100000)) __PYX_ERR(0, 1, __pyx_L1_error)
4553
__pyx_int_922350 = PyInt_FromLong(922350L); if (unlikely(!__pyx_int_922350)) __PYX_ERR(0, 1, __pyx_L1_error)
4554
__pyx_int_2414484 = PyInt_FromLong(2414484L); if (unlikely(!__pyx_int_2414484)) __PYX_ERR(0, 1, __pyx_L1_error)
4555
__pyx_int_4381765 = PyInt_FromLong(4381765L); if (unlikely(!__pyx_int_4381765)) __PYX_ERR(0, 1, __pyx_L1_error)
4556
__pyx_int_140886208 = PyInt_FromLong(140886208L); if (unlikely(!__pyx_int_140886208)) __PYX_ERR(0, 1, __pyx_L1_error)
4557
__pyx_int_233296311 = PyInt_FromLong(233296311L); if (unlikely(!__pyx_int_233296311)) __PYX_ERR(0, 1, __pyx_L1_error)
4558
__pyx_int_166666833333 = PyInt_FromString((char *)"166666833333", 0, 0); if (unlikely(!__pyx_int_166666833333)) __PYX_ERR(0, 1, __pyx_L1_error)
4559
__pyx_int_53532319533988 = PyInt_FromString((char *)"53532319533988", 0, 0); if (unlikely(!__pyx_int_53532319533988)) __PYX_ERR(0, 1, __pyx_L1_error)
4560
return 0;
4561
__pyx_L1_error:;
4562
return -1;
4563
}
4564
4565
static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/
4566
static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/
4567
static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/
4568
static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/
4569
static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/
4570
static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/
4571
static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/
4572
4573
static int __Pyx_modinit_global_init_code(void) {
4574
__Pyx_RefNannyDeclarations
4575
__Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
4576
/*--- Global init code ---*/
4577
__Pyx_RefNannyFinishContext();
4578
return 0;
4579
}
4580
4581
static int __Pyx_modinit_variable_export_code(void) {
4582
__Pyx_RefNannyDeclarations
4583
__Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
4584
/*--- Variable export code ---*/
4585
__Pyx_RefNannyFinishContext();
4586
return 0;
4587
}
4588
4589
static int __Pyx_modinit_function_export_code(void) {
4590
__Pyx_RefNannyDeclarations
4591
__Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
4592
/*--- Function export code ---*/
4593
__Pyx_RefNannyFinishContext();
4594
return 0;
4595
}
4596
4597
static int __Pyx_modinit_type_init_code(void) {
4598
__Pyx_RefNannyDeclarations
4599
int __pyx_lineno = 0;
4600
const char *__pyx_filename = NULL;
4601
int __pyx_clineno = 0;
4602
__Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
4603
/*--- Type init code ---*/
4604
if (PyType_Ready(&__pyx_type_7numbers_A) < 0) __PYX_ERR(0, 12, __pyx_L1_error)
4605
#if PY_VERSION_HEX < 0x030800B1
4606
__pyx_type_7numbers_A.tp_print = 0;
4607
#endif
4608
if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_7numbers_A.tp_dictoffset && __pyx_type_7numbers_A.tp_getattro == PyObject_GenericGetAttr)) {
4609
__pyx_type_7numbers_A.tp_getattro = __Pyx_PyObject_GenericGetAttr;
4610
}
4611
if (PyObject_SetAttr(__pyx_m, __pyx_n_s_A, (PyObject *)&__pyx_type_7numbers_A) < 0) __PYX_ERR(0, 12, __pyx_L1_error)
4612
if (__Pyx_setup_reduce((PyObject*)&__pyx_type_7numbers_A) < 0) __PYX_ERR(0, 12, __pyx_L1_error)
4613
__pyx_ptype_7numbers_A = &__pyx_type_7numbers_A;
4614
__Pyx_RefNannyFinishContext();
4615
return 0;
4616
__pyx_L1_error:;
4617
__Pyx_RefNannyFinishContext();
4618
return -1;
4619
}
4620
4621
static int __Pyx_modinit_type_import_code(void) {
4622
__Pyx_RefNannyDeclarations
4623
__Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
4624
/*--- Type import code ---*/
4625
__Pyx_RefNannyFinishContext();
4626
return 0;
4627
}
4628
4629
static int __Pyx_modinit_variable_import_code(void) {
4630
__Pyx_RefNannyDeclarations
4631
__Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
4632
/*--- Variable import code ---*/
4633
__Pyx_RefNannyFinishContext();
4634
return 0;
4635
}
4636
4637
static int __Pyx_modinit_function_import_code(void) {
4638
__Pyx_RefNannyDeclarations
4639
PyObject *__pyx_t_1 = NULL;
4640
int __pyx_lineno = 0;
4641
const char *__pyx_filename = NULL;
4642
int __pyx_clineno = 0;
4643
__Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
4644
/*--- Function import code ---*/
4645
__pyx_t_1 = PyImport_ImportModule("nt"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error)
4646
__Pyx_GOTREF(__pyx_t_1);
4647
if (__Pyx_ImportFunction(__pyx_t_1, "gcd", (void (**)(void))&__pyx_f_2nt_gcd, "int (int, int, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4648
if (__Pyx_ImportFunction(__pyx_t_1, "xgcd_c", (void (**)(void))&__pyx_f_2nt_xgcd_c, "int (int, int, int *, int *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4649
if (__Pyx_ImportFunction(__pyx_t_1, "inverse_mod", (void (**)(void))&__pyx_f_2nt_inverse_mod, "int (int, int, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4650
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4651
__Pyx_RefNannyFinishContext();
4652
return 0;
4653
__pyx_L1_error:;
4654
__Pyx_XDECREF(__pyx_t_1);
4655
__Pyx_RefNannyFinishContext();
4656
return -1;
4657
}
4658
4659
4660
#ifndef CYTHON_NO_PYINIT_EXPORT
4661
#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
4662
#elif PY_MAJOR_VERSION < 3
4663
#ifdef __cplusplus
4664
#define __Pyx_PyMODINIT_FUNC extern "C" void
4665
#else
4666
#define __Pyx_PyMODINIT_FUNC void
4667
#endif
4668
#else
4669
#ifdef __cplusplus
4670
#define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
4671
#else
4672
#define __Pyx_PyMODINIT_FUNC PyObject *
4673
#endif
4674
#endif
4675
4676
4677
#if PY_MAJOR_VERSION < 3
4678
__Pyx_PyMODINIT_FUNC initnumbers(void) CYTHON_SMALL_CODE; /*proto*/
4679
__Pyx_PyMODINIT_FUNC initnumbers(void)
4680
#else
4681
__Pyx_PyMODINIT_FUNC PyInit_numbers(void) CYTHON_SMALL_CODE; /*proto*/
4682
__Pyx_PyMODINIT_FUNC PyInit_numbers(void)
4683
#if CYTHON_PEP489_MULTI_PHASE_INIT
4684
{
4685
return PyModuleDef_Init(&__pyx_moduledef);
4686
}
4687
static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
4688
#if PY_VERSION_HEX >= 0x030700A1
4689
static PY_INT64_T main_interpreter_id = -1;
4690
PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
4691
if (main_interpreter_id == -1) {
4692
main_interpreter_id = current_id;
4693
return (unlikely(current_id == -1)) ? -1 : 0;
4694
} else if (unlikely(main_interpreter_id != current_id))
4695
#else
4696
static PyInterpreterState *main_interpreter = NULL;
4697
PyInterpreterState *current_interpreter = PyThreadState_Get()->interp;
4698
if (!main_interpreter) {
4699
main_interpreter = current_interpreter;
4700
} else if (unlikely(main_interpreter != current_interpreter))
4701
#endif
4702
{
4703
PyErr_SetString(
4704
PyExc_ImportError,
4705
"Interpreter change detected - this module can only be loaded into one interpreter per process.");
4706
return -1;
4707
}
4708
return 0;
4709
}
4710
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) {
4711
PyObject *value = PyObject_GetAttrString(spec, from_name);
4712
int result = 0;
4713
if (likely(value)) {
4714
if (allow_none || value != Py_None) {
4715
result = PyDict_SetItemString(moddict, to_name, value);
4716
}
4717
Py_DECREF(value);
4718
} else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
4719
PyErr_Clear();
4720
} else {
4721
result = -1;
4722
}
4723
return result;
4724
}
4725
static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
4726
PyObject *module = NULL, *moddict, *modname;
4727
if (__Pyx_check_single_interpreter())
4728
return NULL;
4729
if (__pyx_m)
4730
return __Pyx_NewRef(__pyx_m);
4731
modname = PyObject_GetAttrString(spec, "name");
4732
if (unlikely(!modname)) goto bad;
4733
module = PyModule_NewObject(modname);
4734
Py_DECREF(modname);
4735
if (unlikely(!module)) goto bad;
4736
moddict = PyModule_GetDict(module);
4737
if (unlikely(!moddict)) goto bad;
4738
if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
4739
if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
4740
if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
4741
if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
4742
return module;
4743
bad:
4744
Py_XDECREF(module);
4745
return NULL;
4746
}
4747
4748
4749
static CYTHON_SMALL_CODE int __pyx_pymod_exec_numbers(PyObject *__pyx_pyinit_module)
4750
#endif
4751
#endif
4752
{
4753
PyObject *__pyx_t_1 = NULL;
4754
PyObject *__pyx_t_2 = NULL;
4755
PyObject *__pyx_t_3 = NULL;
4756
int __pyx_t_4;
4757
int __pyx_lineno = 0;
4758
const char *__pyx_filename = NULL;
4759
int __pyx_clineno = 0;
4760
__Pyx_RefNannyDeclarations
4761
#if CYTHON_PEP489_MULTI_PHASE_INIT
4762
if (__pyx_m) {
4763
if (__pyx_m == __pyx_pyinit_module) return 0;
4764
PyErr_SetString(PyExc_RuntimeError, "Module 'numbers' has already been imported. Re-initialisation is not supported.");
4765
return -1;
4766
}
4767
#elif PY_MAJOR_VERSION >= 3
4768
if (__pyx_m) return __Pyx_NewRef(__pyx_m);
4769
#endif
4770
#if CYTHON_REFNANNY
4771
__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
4772
if (!__Pyx_RefNanny) {
4773
PyErr_Clear();
4774
__Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
4775
if (!__Pyx_RefNanny)
4776
Py_FatalError("failed to import 'refnanny' module");
4777
}
4778
#endif
4779
__Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_numbers(void)", 0);
4780
if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4781
#ifdef __Pxy_PyFrame_Initialize_Offsets
4782
__Pxy_PyFrame_Initialize_Offsets();
4783
#endif
4784
__pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
4785
__pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
4786
__pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
4787
#ifdef __Pyx_CyFunction_USED
4788
if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4789
#endif
4790
#ifdef __Pyx_FusedFunction_USED
4791
if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4792
#endif
4793
#ifdef __Pyx_Coroutine_USED
4794
if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4795
#endif
4796
#ifdef __Pyx_Generator_USED
4797
if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4798
#endif
4799
#ifdef __Pyx_AsyncGen_USED
4800
if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4801
#endif
4802
#ifdef __Pyx_StopAsyncIteration_USED
4803
if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4804
#endif
4805
/*--- Library function declarations ---*/
4806
/*--- Threads initialization code ---*/
4807
#if defined(WITH_THREAD) && PY_VERSION_HEX < 0x030700F0 && defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
4808
PyEval_InitThreads();
4809
#endif
4810
/*--- Module creation code ---*/
4811
#if CYTHON_PEP489_MULTI_PHASE_INIT
4812
__pyx_m = __pyx_pyinit_module;
4813
Py_INCREF(__pyx_m);
4814
#else
4815
#if PY_MAJOR_VERSION < 3
4816
__pyx_m = Py_InitModule4("numbers", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
4817
#else
4818
__pyx_m = PyModule_Create(&__pyx_moduledef);
4819
#endif
4820
if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
4821
#endif
4822
__pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
4823
Py_INCREF(__pyx_d);
4824
__pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
4825
Py_INCREF(__pyx_b);
4826
__pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
4827
Py_INCREF(__pyx_cython_runtime);
4828
if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
4829
/*--- Initialize various global constants etc. ---*/
4830
if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4831
#if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
4832
if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4833
#endif
4834
if (__pyx_module_is_main_numbers) {
4835
if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4836
}
4837
#if PY_MAJOR_VERSION >= 3
4838
{
4839
PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
4840
if (!PyDict_GetItemString(modules, "numbers")) {
4841
if (unlikely(PyDict_SetItemString(modules, "numbers", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
4842
}
4843
}
4844
#endif
4845
/*--- Builtin init code ---*/
4846
if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4847
/*--- Constants init code ---*/
4848
if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4849
/*--- Global type/function init code ---*/
4850
(void)__Pyx_modinit_global_init_code();
4851
(void)__Pyx_modinit_variable_export_code();
4852
(void)__Pyx_modinit_function_export_code();
4853
if (unlikely(__Pyx_modinit_type_init_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
4854
(void)__Pyx_modinit_type_import_code();
4855
(void)__Pyx_modinit_variable_import_code();
4856
if (unlikely(__Pyx_modinit_function_import_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
4857
/*--- Execution code ---*/
4858
#if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
4859
if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4860
#endif
4861
4862
/* "numbers.pyx":1
4863
* from bench import register, all # <<<<<<<<<<<<<<
4864
*
4865
* from nt import xgcd, pi
4866
*/
4867
__pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
4868
__Pyx_GOTREF(__pyx_t_1);
4869
__Pyx_INCREF(__pyx_n_s_register);
4870
__Pyx_GIVEREF(__pyx_n_s_register);
4871
PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_register);
4872
__Pyx_INCREF(__pyx_n_s_all);
4873
__Pyx_GIVEREF(__pyx_n_s_all);
4874
PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_all);
4875
__pyx_t_2 = __Pyx_Import(__pyx_n_s_bench, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error)
4876
__Pyx_GOTREF(__pyx_t_2);
4877
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4878
__pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_register); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
4879
__Pyx_GOTREF(__pyx_t_1);
4880
if (PyDict_SetItem(__pyx_d, __pyx_n_s_register, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4881
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4882
__pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_all); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
4883
__Pyx_GOTREF(__pyx_t_1);
4884
if (PyDict_SetItem(__pyx_d, __pyx_n_s_all, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4885
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4886
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4887
4888
/* "numbers.pyx":3
4889
* from bench import register, all
4890
*
4891
* from nt import xgcd, pi # <<<<<<<<<<<<<<
4892
* from nt cimport gcd, xgcd_c, inverse_mod
4893
*
4894
*/
4895
__pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3, __pyx_L1_error)
4896
__Pyx_GOTREF(__pyx_t_2);
4897
__Pyx_INCREF(__pyx_n_s_xgcd);
4898
__Pyx_GIVEREF(__pyx_n_s_xgcd);
4899
PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_xgcd);
4900
__Pyx_INCREF(__pyx_n_s_pi);
4901
__Pyx_GIVEREF(__pyx_n_s_pi);
4902
PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_pi);
4903
__pyx_t_1 = __Pyx_Import(__pyx_n_s_nt, __pyx_t_2, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3, __pyx_L1_error)
4904
__Pyx_GOTREF(__pyx_t_1);
4905
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4906
__pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_xgcd); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3, __pyx_L1_error)
4907
__Pyx_GOTREF(__pyx_t_2);
4908
if (PyDict_SetItem(__pyx_d, __pyx_n_s_xgcd, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
4909
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4910
__pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_pi); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3, __pyx_L1_error)
4911
__Pyx_GOTREF(__pyx_t_2);
4912
if (PyDict_SetItem(__pyx_d, __pyx_n_s_pi, __pyx_t_2) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
4913
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4914
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4915
4916
/* "numbers.pyx":6
4917
* from nt cimport gcd, xgcd_c, inverse_mod
4918
*
4919
* def test_pi(n=100000): # <<<<<<<<<<<<<<
4920
* assert pi(n) == 9592
4921
*
4922
*/
4923
__pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_7numbers_1test_pi, NULL, __pyx_n_s_numbers); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error)
4924
__Pyx_GOTREF(__pyx_t_1);
4925
if (PyDict_SetItem(__pyx_d, __pyx_n_s_test_pi, __pyx_t_1) < 0) __PYX_ERR(0, 6, __pyx_L1_error)
4926
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4927
4928
/* "numbers.pyx":10
4929
*
4930
*
4931
* register("pi(10**5)", pi) # <<<<<<<<<<<<<<
4932
*
4933
* cdef class A:
4934
*/
4935
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_register); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 10, __pyx_L1_error)
4936
__Pyx_GOTREF(__pyx_t_1);
4937
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_pi); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 10, __pyx_L1_error)
4938
__Pyx_GOTREF(__pyx_t_2);
4939
__pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 10, __pyx_L1_error)
4940
__Pyx_GOTREF(__pyx_t_3);
4941
__Pyx_INCREF(__pyx_kp_s_pi_10_5);
4942
__Pyx_GIVEREF(__pyx_kp_s_pi_10_5);
4943
PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_kp_s_pi_10_5);
4944
__Pyx_GIVEREF(__pyx_t_2);
4945
PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
4946
__pyx_t_2 = 0;
4947
__pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 10, __pyx_L1_error)
4948
__Pyx_GOTREF(__pyx_t_2);
4949
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4950
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4951
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4952
4953
/* "numbers.pyx":23
4954
* return A((<A>self).i + (<A>right).i)
4955
*
4956
* def operator_add(int n=100000): # <<<<<<<<<<<<<<
4957
*
4958
* a = A(2)
4959
*/
4960
__pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_7numbers_3operator_add, NULL, __pyx_n_s_numbers); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 23, __pyx_L1_error)
4961
__Pyx_GOTREF(__pyx_t_2);
4962
if (PyDict_SetItem(__pyx_d, __pyx_n_s_operator_add, __pyx_t_2) < 0) __PYX_ERR(0, 23, __pyx_L1_error)
4963
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4964
4965
/* "numbers.pyx":33
4966
*
4967
*
4968
* register("operator_add", operator_add) # <<<<<<<<<<<<<<
4969
*
4970
*
4971
*/
4972
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_register); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 33, __pyx_L1_error)
4973
__Pyx_GOTREF(__pyx_t_2);
4974
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_operator_add); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 33, __pyx_L1_error)
4975
__Pyx_GOTREF(__pyx_t_3);
4976
__pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 33, __pyx_L1_error)
4977
__Pyx_GOTREF(__pyx_t_1);
4978
__Pyx_INCREF(__pyx_n_s_operator_add);
4979
__Pyx_GIVEREF(__pyx_n_s_operator_add);
4980
PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_operator_add);
4981
__Pyx_GIVEREF(__pyx_t_3);
4982
PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3);
4983
__pyx_t_3 = 0;
4984
__pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 33, __pyx_L1_error)
4985
__Pyx_GOTREF(__pyx_t_3);
4986
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4987
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4988
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4989
4990
/* "numbers.pyx":36
4991
*
4992
*
4993
* def bench_gcd(int n=10**5): # <<<<<<<<<<<<<<
4994
* cdef int s = 0
4995
* cdef int i
4996
*/
4997
__pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_7numbers_5bench_gcd, NULL, __pyx_n_s_numbers); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 36, __pyx_L1_error)
4998
__Pyx_GOTREF(__pyx_t_3);
4999
if (PyDict_SetItem(__pyx_d, __pyx_n_s_bench_gcd, __pyx_t_3) < 0) __PYX_ERR(0, 36, __pyx_L1_error)
5000
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5001
5002
/* "numbers.pyx":45
5003
*
5004
*
5005
* register("gcd", bench_gcd) # <<<<<<<<<<<<<<
5006
*
5007
*
5008
*/
5009
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_register); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 45, __pyx_L1_error)
5010
__Pyx_GOTREF(__pyx_t_3);
5011
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_bench_gcd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 45, __pyx_L1_error)
5012
__Pyx_GOTREF(__pyx_t_1);
5013
__pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 45, __pyx_L1_error)
5014
__Pyx_GOTREF(__pyx_t_2);
5015
__Pyx_INCREF(__pyx_n_s_gcd);
5016
__Pyx_GIVEREF(__pyx_n_s_gcd);
5017
PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_gcd);
5018
__Pyx_GIVEREF(__pyx_t_1);
5019
PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
5020
__pyx_t_1 = 0;
5021
__pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 45, __pyx_L1_error)
5022
__Pyx_GOTREF(__pyx_t_1);
5023
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5024
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5025
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5026
5027
/* "numbers.pyx":48
5028
*
5029
*
5030
* def bench_xgcd_py(n=10**5): # <<<<<<<<<<<<<<
5031
* s = 0
5032
* for i in range(n):
5033
*/
5034
__pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_7numbers_7bench_xgcd_py, NULL, __pyx_n_s_numbers); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 48, __pyx_L1_error)
5035
__Pyx_GOTREF(__pyx_t_1);
5036
if (PyDict_SetItem(__pyx_d, __pyx_n_s_bench_xgcd_py, __pyx_t_1) < 0) __PYX_ERR(0, 48, __pyx_L1_error)
5037
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5038
5039
/* "numbers.pyx":59
5040
*
5041
*
5042
* def bench_xgcd(int n=10**5): # <<<<<<<<<<<<<<
5043
* cdef int s = 0, cx, cy, i
5044
* for i in range(n):
5045
*/
5046
__pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_7numbers_9bench_xgcd, NULL, __pyx_n_s_numbers); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 59, __pyx_L1_error)
5047
__Pyx_GOTREF(__pyx_t_1);
5048
if (PyDict_SetItem(__pyx_d, __pyx_n_s_bench_xgcd, __pyx_t_1) < 0) __PYX_ERR(0, 59, __pyx_L1_error)
5049
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5050
5051
/* "numbers.pyx":67
5052
*
5053
*
5054
* register("xgcd", bench_xgcd) # <<<<<<<<<<<<<<
5055
*
5056
*
5057
*/
5058
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_register); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 67, __pyx_L1_error)
5059
__Pyx_GOTREF(__pyx_t_1);
5060
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_bench_xgcd); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 67, __pyx_L1_error)
5061
__Pyx_GOTREF(__pyx_t_2);
5062
__pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 67, __pyx_L1_error)
5063
__Pyx_GOTREF(__pyx_t_3);
5064
__Pyx_INCREF(__pyx_n_s_xgcd);
5065
__Pyx_GIVEREF(__pyx_n_s_xgcd);
5066
PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_xgcd);
5067
__Pyx_GIVEREF(__pyx_t_2);
5068
PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
5069
__pyx_t_2 = 0;
5070
__pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 67, __pyx_L1_error)
5071
__Pyx_GOTREF(__pyx_t_2);
5072
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5073
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5074
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5075
5076
/* "numbers.pyx":70
5077
*
5078
*
5079
* def bench_inverse_mod(long long n=10**5): # <<<<<<<<<<<<<<
5080
* cdef long long i, s = 0
5081
* for i in range(1, n):
5082
*/
5083
__pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_7numbers_11bench_inverse_mod, NULL, __pyx_n_s_numbers); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 70, __pyx_L1_error)
5084
__Pyx_GOTREF(__pyx_t_2);
5085
if (PyDict_SetItem(__pyx_d, __pyx_n_s_bench_inverse_mod, __pyx_t_2) < 0) __PYX_ERR(0, 70, __pyx_L1_error)
5086
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5087
5088
/* "numbers.pyx":77
5089
*
5090
*
5091
* register("bench_inverse_mod", bench_inverse_mod) # <<<<<<<<<<<<<<
5092
*
5093
*
5094
*/
5095
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_register); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 77, __pyx_L1_error)
5096
__Pyx_GOTREF(__pyx_t_2);
5097
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_bench_inverse_mod); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 77, __pyx_L1_error)
5098
__Pyx_GOTREF(__pyx_t_3);
5099
__pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 77, __pyx_L1_error)
5100
__Pyx_GOTREF(__pyx_t_1);
5101
__Pyx_INCREF(__pyx_n_s_bench_inverse_mod);
5102
__Pyx_GIVEREF(__pyx_n_s_bench_inverse_mod);
5103
PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_bench_inverse_mod);
5104
__Pyx_GIVEREF(__pyx_t_3);
5105
PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3);
5106
__pyx_t_3 = 0;
5107
__pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 77, __pyx_L1_error)
5108
__Pyx_GOTREF(__pyx_t_3);
5109
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5110
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5111
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5112
5113
/* "numbers.pyx":80
5114
*
5115
*
5116
* def sum_loop(int n=1000000): # <<<<<<<<<<<<<<
5117
* cdef int s = 0, i
5118
* for i in range(0, n, 3):
5119
*/
5120
__pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_7numbers_13sum_loop, NULL, __pyx_n_s_numbers); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 80, __pyx_L1_error)
5121
__Pyx_GOTREF(__pyx_t_3);
5122
if (PyDict_SetItem(__pyx_d, __pyx_n_s_sum_loop, __pyx_t_3) < 0) __PYX_ERR(0, 80, __pyx_L1_error)
5123
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5124
5125
/* "numbers.pyx":88
5126
*
5127
*
5128
* register("sum_loop", sum_loop) # <<<<<<<<<<<<<<
5129
*
5130
*
5131
*/
5132
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_register); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 88, __pyx_L1_error)
5133
__Pyx_GOTREF(__pyx_t_3);
5134
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_sum_loop); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 88, __pyx_L1_error)
5135
__Pyx_GOTREF(__pyx_t_1);
5136
__pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 88, __pyx_L1_error)
5137
__Pyx_GOTREF(__pyx_t_2);
5138
__Pyx_INCREF(__pyx_n_s_sum_loop);
5139
__Pyx_GIVEREF(__pyx_n_s_sum_loop);
5140
PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_sum_loop);
5141
__Pyx_GIVEREF(__pyx_t_1);
5142
PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
5143
__pyx_t_1 = 0;
5144
__pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 88, __pyx_L1_error)
5145
__Pyx_GOTREF(__pyx_t_1);
5146
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5147
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5148
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5149
5150
/* "numbers.pyx":91
5151
*
5152
*
5153
* def sum_range(long long n=1000000): # <<<<<<<<<<<<<<
5154
* n = sum(range(0, n, 3))
5155
* assert n == 166666833333
5156
*/
5157
__pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_7numbers_15sum_range, NULL, __pyx_n_s_numbers); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 91, __pyx_L1_error)
5158
__Pyx_GOTREF(__pyx_t_1);
5159
if (PyDict_SetItem(__pyx_d, __pyx_n_s_sum_range, __pyx_t_1) < 0) __PYX_ERR(0, 91, __pyx_L1_error)
5160
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5161
5162
/* "numbers.pyx":96
5163
*
5164
*
5165
* register("sum_range", sum_range) # <<<<<<<<<<<<<<
5166
*
5167
*
5168
*/
5169
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_register); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 96, __pyx_L1_error)
5170
__Pyx_GOTREF(__pyx_t_1);
5171
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_sum_range); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 96, __pyx_L1_error)
5172
__Pyx_GOTREF(__pyx_t_2);
5173
__pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 96, __pyx_L1_error)
5174
__Pyx_GOTREF(__pyx_t_3);
5175
__Pyx_INCREF(__pyx_n_s_sum_range);
5176
__Pyx_GIVEREF(__pyx_n_s_sum_range);
5177
PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_sum_range);
5178
__Pyx_GIVEREF(__pyx_t_2);
5179
PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
5180
__pyx_t_2 = 0;
5181
__pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 96, __pyx_L1_error)
5182
__Pyx_GOTREF(__pyx_t_2);
5183
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5184
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5185
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5186
5187
/* "numbers.pyx":99
5188
*
5189
*
5190
* def sum_reversed(long long n=1000000): # <<<<<<<<<<<<<<
5191
* n = sum(reversed(list(range(0, n, 3))))
5192
* assert n == 166666833333
5193
*/
5194
__pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_7numbers_17sum_reversed, NULL, __pyx_n_s_numbers); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 99, __pyx_L1_error)
5195
__Pyx_GOTREF(__pyx_t_2);
5196
if (PyDict_SetItem(__pyx_d, __pyx_n_s_sum_reversed, __pyx_t_2) < 0) __PYX_ERR(0, 99, __pyx_L1_error)
5197
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5198
5199
/* "numbers.pyx":104
5200
*
5201
*
5202
* register("sum_reversed", sum_reversed) # <<<<<<<<<<<<<<
5203
*
5204
* if __name__ == '__main__':
5205
*/
5206
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_register); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 104, __pyx_L1_error)
5207
__Pyx_GOTREF(__pyx_t_2);
5208
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_sum_reversed); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 104, __pyx_L1_error)
5209
__Pyx_GOTREF(__pyx_t_3);
5210
__pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 104, __pyx_L1_error)
5211
__Pyx_GOTREF(__pyx_t_1);
5212
__Pyx_INCREF(__pyx_n_s_sum_reversed);
5213
__Pyx_GIVEREF(__pyx_n_s_sum_reversed);
5214
PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_sum_reversed);
5215
__Pyx_GIVEREF(__pyx_t_3);
5216
PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3);
5217
__pyx_t_3 = 0;
5218
__pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 104, __pyx_L1_error)
5219
__Pyx_GOTREF(__pyx_t_3);
5220
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5221
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5222
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5223
5224
/* "numbers.pyx":106
5225
* register("sum_reversed", sum_reversed)
5226
*
5227
* if __name__ == '__main__': # <<<<<<<<<<<<<<
5228
* all('numbers')
5229
*/
5230
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 106, __pyx_L1_error)
5231
__Pyx_GOTREF(__pyx_t_3);
5232
__pyx_t_4 = (__Pyx_PyString_Equals(__pyx_t_3, __pyx_n_s_main, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 106, __pyx_L1_error)
5233
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5234
if (__pyx_t_4) {
5235
5236
/* "numbers.pyx":107
5237
*
5238
* if __name__ == '__main__':
5239
* all('numbers') # <<<<<<<<<<<<<<
5240
*/
5241
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_all); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 107, __pyx_L1_error)
5242
__Pyx_GOTREF(__pyx_t_3);
5243
__pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__22, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 107, __pyx_L1_error)
5244
__Pyx_GOTREF(__pyx_t_1);
5245
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5246
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5247
5248
/* "numbers.pyx":106
5249
* register("sum_reversed", sum_reversed)
5250
*
5251
* if __name__ == '__main__': # <<<<<<<<<<<<<<
5252
* all('numbers')
5253
*/
5254
}
5255
5256
/* "(tree fragment)":1
5257
* def __pyx_unpickle_A(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<<
5258
* cdef object __pyx_PickleError
5259
* cdef object __pyx_result
5260
*/
5261
__pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_7numbers_19__pyx_unpickle_A, NULL, __pyx_n_s_numbers); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1, __pyx_L1_error)
5262
__Pyx_GOTREF(__pyx_t_1);
5263
if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_A, __pyx_t_1) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
5264
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5265
5266
/* "numbers.pyx":1
5267
* from bench import register, all # <<<<<<<<<<<<<<
5268
*
5269
* from nt import xgcd, pi
5270
*/
5271
__pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
5272
__Pyx_GOTREF(__pyx_t_1);
5273
if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
5274
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5275
5276
/*--- Wrapped vars code ---*/
5277
5278
goto __pyx_L0;
5279
__pyx_L1_error:;
5280
__Pyx_XDECREF(__pyx_t_1);
5281
__Pyx_XDECREF(__pyx_t_2);
5282
__Pyx_XDECREF(__pyx_t_3);
5283
if (__pyx_m) {
5284
if (__pyx_d) {
5285
__Pyx_AddTraceback("init numbers", __pyx_clineno, __pyx_lineno, __pyx_filename);
5286
}
5287
Py_CLEAR(__pyx_m);
5288
} else if (!PyErr_Occurred()) {
5289
PyErr_SetString(PyExc_ImportError, "init numbers");
5290
}
5291
__pyx_L0:;
5292
__Pyx_RefNannyFinishContext();
5293
#if CYTHON_PEP489_MULTI_PHASE_INIT
5294
return (__pyx_m != NULL) ? 0 : -1;
5295
#elif PY_MAJOR_VERSION >= 3
5296
return __pyx_m;
5297
#else
5298
return;
5299
#endif
5300
}
5301
5302
/* --- Runtime support code --- */
5303
/* Refnanny */
5304
#if CYTHON_REFNANNY
5305
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
5306
PyObject *m = NULL, *p = NULL;
5307
void *r = NULL;
5308
m = PyImport_ImportModule(modname);
5309
if (!m) goto end;
5310
p = PyObject_GetAttrString(m, "RefNannyAPI");
5311
if (!p) goto end;
5312
r = PyLong_AsVoidPtr(p);
5313
end:
5314
Py_XDECREF(p);
5315
Py_XDECREF(m);
5316
return (__Pyx_RefNannyAPIStruct *)r;
5317
}
5318
#endif
5319
5320
/* PyObjectGetAttrStr */
5321
#if CYTHON_USE_TYPE_SLOTS
5322
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
5323
PyTypeObject* tp = Py_TYPE(obj);
5324
if (likely(tp->tp_getattro))
5325
return tp->tp_getattro(obj, attr_name);
5326
#if PY_MAJOR_VERSION < 3
5327
if (likely(tp->tp_getattr))
5328
return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
5329
#endif
5330
return PyObject_GetAttr(obj, attr_name);
5331
}
5332
#endif
5333
5334
/* GetBuiltinName */
5335
static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
5336
PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
5337
if (unlikely(!result)) {
5338
PyErr_Format(PyExc_NameError,
5339
#if PY_MAJOR_VERSION >= 3
5340
"name '%U' is not defined", name);
5341
#else
5342
"name '%.200s' is not defined", PyString_AS_STRING(name));
5343
#endif
5344
}
5345
return result;
5346
}
5347
5348
/* RaiseDoubleKeywords */
5349
static void __Pyx_RaiseDoubleKeywordsError(
5350
const char* func_name,
5351
PyObject* kw_name)
5352
{
5353
PyErr_Format(PyExc_TypeError,
5354
#if PY_MAJOR_VERSION >= 3
5355
"%s() got multiple values for keyword argument '%U'", func_name, kw_name);
5356
#else
5357
"%s() got multiple values for keyword argument '%s'", func_name,
5358
PyString_AsString(kw_name));
5359
#endif
5360
}
5361
5362
/* ParseKeywords */
5363
static int __Pyx_ParseOptionalKeywords(
5364
PyObject *kwds,
5365
PyObject **argnames[],
5366
PyObject *kwds2,
5367
PyObject *values[],
5368
Py_ssize_t num_pos_args,
5369
const char* function_name)
5370
{
5371
PyObject *key = 0, *value = 0;
5372
Py_ssize_t pos = 0;
5373
PyObject*** name;
5374
PyObject*** first_kw_arg = argnames + num_pos_args;
5375
while (PyDict_Next(kwds, &pos, &key, &value)) {
5376
name = first_kw_arg;
5377
while (*name && (**name != key)) name++;
5378
if (*name) {
5379
values[name-argnames] = value;
5380
continue;
5381
}
5382
name = first_kw_arg;
5383
#if PY_MAJOR_VERSION < 3
5384
if (likely(PyString_Check(key))) {
5385
while (*name) {
5386
if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
5387
&& _PyString_Eq(**name, key)) {
5388
values[name-argnames] = value;
5389
break;
5390
}
5391
name++;
5392
}
5393
if (*name) continue;
5394
else {
5395
PyObject*** argname = argnames;
5396
while (argname != first_kw_arg) {
5397
if ((**argname == key) || (
5398
(CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
5399
&& _PyString_Eq(**argname, key))) {
5400
goto arg_passed_twice;
5401
}
5402
argname++;
5403
}
5404
}
5405
} else
5406
#endif
5407
if (likely(PyUnicode_Check(key))) {
5408
while (*name) {
5409
int cmp = (**name == key) ? 0 :
5410
#if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
5411
(__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
5412
#endif
5413
PyUnicode_Compare(**name, key);
5414
if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
5415
if (cmp == 0) {
5416
values[name-argnames] = value;
5417
break;
5418
}
5419
name++;
5420
}
5421
if (*name) continue;
5422
else {
5423
PyObject*** argname = argnames;
5424
while (argname != first_kw_arg) {
5425
int cmp = (**argname == key) ? 0 :
5426
#if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
5427
(__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
5428
#endif
5429
PyUnicode_Compare(**argname, key);
5430
if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
5431
if (cmp == 0) goto arg_passed_twice;
5432
argname++;
5433
}
5434
}
5435
} else
5436
goto invalid_keyword_type;
5437
if (kwds2) {
5438
if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
5439
} else {
5440
goto invalid_keyword;
5441
}
5442
}
5443
return 0;
5444
arg_passed_twice:
5445
__Pyx_RaiseDoubleKeywordsError(function_name, key);
5446
goto bad;
5447
invalid_keyword_type:
5448
PyErr_Format(PyExc_TypeError,
5449
"%.200s() keywords must be strings", function_name);
5450
goto bad;
5451
invalid_keyword:
5452
PyErr_Format(PyExc_TypeError,
5453
#if PY_MAJOR_VERSION < 3
5454
"%.200s() got an unexpected keyword argument '%.200s'",
5455
function_name, PyString_AsString(key));
5456
#else
5457
"%s() got an unexpected keyword argument '%U'",
5458
function_name, key);
5459
#endif
5460
bad:
5461
return -1;
5462
}
5463
5464
/* RaiseArgTupleInvalid */
5465
static void __Pyx_RaiseArgtupleInvalid(
5466
const char* func_name,
5467
int exact,
5468
Py_ssize_t num_min,
5469
Py_ssize_t num_max,
5470
Py_ssize_t num_found)
5471
{
5472
Py_ssize_t num_expected;
5473
const char *more_or_less;
5474
if (num_found < num_min) {
5475
num_expected = num_min;
5476
more_or_less = "at least";
5477
} else {
5478
num_expected = num_max;
5479
more_or_less = "at most";
5480
}
5481
if (exact) {
5482
more_or_less = "exactly";
5483
}
5484
PyErr_Format(PyExc_TypeError,
5485
"%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
5486
func_name, more_or_less, num_expected,
5487
(num_expected == 1) ? "" : "s", num_found);
5488
}
5489
5490
/* PyIntCompare */
5491
static CYTHON_INLINE PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED long inplace) {
5492
if (op1 == op2) {
5493
Py_RETURN_TRUE;
5494
}
5495
#if PY_MAJOR_VERSION < 3
5496
if (likely(PyInt_CheckExact(op1))) {
5497
const long b = intval;
5498
long a = PyInt_AS_LONG(op1);
5499
if (a == b) Py_RETURN_TRUE; else Py_RETURN_FALSE;
5500
}
5501
#endif
5502
#if CYTHON_USE_PYLONG_INTERNALS
5503
if (likely(PyLong_CheckExact(op1))) {
5504
int unequal;
5505
unsigned long uintval;
5506
Py_ssize_t size = Py_SIZE(op1);
5507
const digit* digits = ((PyLongObject*)op1)->ob_digit;
5508
if (intval == 0) {
5509
if (size == 0) Py_RETURN_TRUE; else Py_RETURN_FALSE;
5510
} else if (intval < 0) {
5511
if (size >= 0)
5512
Py_RETURN_FALSE;
5513
intval = -intval;
5514
size = -size;
5515
} else {
5516
if (size <= 0)
5517
Py_RETURN_FALSE;
5518
}
5519
uintval = (unsigned long) intval;
5520
#if PyLong_SHIFT * 4 < SIZEOF_LONG*8
5521
if (uintval >> (PyLong_SHIFT * 4)) {
5522
unequal = (size != 5) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
5523
| (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[4] != ((uintval >> (4 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
5524
} else
5525
#endif
5526
#if PyLong_SHIFT * 3 < SIZEOF_LONG*8
5527
if (uintval >> (PyLong_SHIFT * 3)) {
5528
unequal = (size != 4) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
5529
| (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
5530
} else
5531
#endif
5532
#if PyLong_SHIFT * 2 < SIZEOF_LONG*8
5533
if (uintval >> (PyLong_SHIFT * 2)) {
5534
unequal = (size != 3) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
5535
| (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
5536
} else
5537
#endif
5538
#if PyLong_SHIFT * 1 < SIZEOF_LONG*8
5539
if (uintval >> (PyLong_SHIFT * 1)) {
5540
unequal = (size != 2) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
5541
| (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
5542
} else
5543
#endif
5544
unequal = (size != 1) || (((unsigned long) digits[0]) != (uintval & (unsigned long) PyLong_MASK));
5545
if (unequal == 0) Py_RETURN_TRUE; else Py_RETURN_FALSE;
5546
}
5547
#endif
5548
if (PyFloat_CheckExact(op1)) {
5549
const long b = intval;
5550
double a = PyFloat_AS_DOUBLE(op1);
5551
if ((double)a == (double)b) Py_RETURN_TRUE; else Py_RETURN_FALSE;
5552
}
5553
return (
5554
PyObject_RichCompare(op1, op2, Py_EQ));
5555
}
5556
5557
/* PyDictVersioning */
5558
#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
5559
static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
5560
PyObject *dict = Py_TYPE(obj)->tp_dict;
5561
return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
5562
}
5563
static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
5564
PyObject **dictptr = NULL;
5565
Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
5566
if (offset) {
5567
#if CYTHON_COMPILING_IN_CPYTHON
5568
dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
5569
#else
5570
dictptr = _PyObject_GetDictPtr(obj);
5571
#endif
5572
}
5573
return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
5574
}
5575
static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
5576
PyObject *dict = Py_TYPE(obj)->tp_dict;
5577
if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
5578
return 0;
5579
return obj_dict_version == __Pyx_get_object_dict_version(obj);
5580
}
5581
#endif
5582
5583
/* GetModuleGlobalName */
5584
#if CYTHON_USE_DICT_VERSIONS
5585
static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value)
5586
#else
5587
static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
5588
#endif
5589
{
5590
PyObject *result;
5591
#if !CYTHON_AVOID_BORROWED_REFS
5592
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
5593
result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
5594
__PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
5595
if (likely(result)) {
5596
return __Pyx_NewRef(result);
5597
} else if (unlikely(PyErr_Occurred())) {
5598
return NULL;
5599
}
5600
#else
5601
result = PyDict_GetItem(__pyx_d, name);
5602
__PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
5603
if (likely(result)) {
5604
return __Pyx_NewRef(result);
5605
}
5606
#endif
5607
#else
5608
result = PyObject_GetItem(__pyx_d, name);
5609
__PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
5610
if (likely(result)) {
5611
return __Pyx_NewRef(result);
5612
}
5613
PyErr_Clear();
5614
#endif
5615
return __Pyx_GetBuiltinName(name);
5616
}
5617
5618
/* PyCFunctionFastCall */
5619
#if CYTHON_FAST_PYCCALL
5620
static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
5621
PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
5622
PyCFunction meth = PyCFunction_GET_FUNCTION(func);
5623
PyObject *self = PyCFunction_GET_SELF(func);
5624
int flags = PyCFunction_GET_FLAGS(func);
5625
assert(PyCFunction_Check(func));
5626
assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)));
5627
assert(nargs >= 0);
5628
assert(nargs == 0 || args != NULL);
5629
/* _PyCFunction_FastCallDict() must not be called with an exception set,
5630
because it may clear it (directly or indirectly) and so the
5631
caller loses its exception */
5632
assert(!PyErr_Occurred());
5633
if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
5634
return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL);
5635
} else {
5636
return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs);
5637
}
5638
}
5639
#endif
5640
5641
/* PyFunctionFastCall */
5642
#if CYTHON_FAST_PYCALL
5643
static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
5644
PyObject *globals) {
5645
PyFrameObject *f;
5646
PyThreadState *tstate = __Pyx_PyThreadState_Current;
5647
PyObject **fastlocals;
5648
Py_ssize_t i;
5649
PyObject *result;
5650
assert(globals != NULL);
5651
/* XXX Perhaps we should create a specialized
5652
PyFrame_New() that doesn't take locals, but does
5653
take builtins without sanity checking them.
5654
*/
5655
assert(tstate != NULL);
5656
f = PyFrame_New(tstate, co, globals, NULL);
5657
if (f == NULL) {
5658
return NULL;
5659
}
5660
fastlocals = __Pyx_PyFrame_GetLocalsplus(f);
5661
for (i = 0; i < na; i++) {
5662
Py_INCREF(*args);
5663
fastlocals[i] = *args++;
5664
}
5665
result = PyEval_EvalFrameEx(f,0);
5666
++tstate->recursion_depth;
5667
Py_DECREF(f);
5668
--tstate->recursion_depth;
5669
return result;
5670
}
5671
#if 1 || PY_VERSION_HEX < 0x030600B1
5672
static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) {
5673
PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
5674
PyObject *globals = PyFunction_GET_GLOBALS(func);
5675
PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
5676
PyObject *closure;
5677
#if PY_MAJOR_VERSION >= 3
5678
PyObject *kwdefs;
5679
#endif
5680
PyObject *kwtuple, **k;
5681
PyObject **d;
5682
Py_ssize_t nd;
5683
Py_ssize_t nk;
5684
PyObject *result;
5685
assert(kwargs == NULL || PyDict_Check(kwargs));
5686
nk = kwargs ? PyDict_Size(kwargs) : 0;
5687
if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
5688
return NULL;
5689
}
5690
if (
5691
#if PY_MAJOR_VERSION >= 3
5692
co->co_kwonlyargcount == 0 &&
5693
#endif
5694
likely(kwargs == NULL || nk == 0) &&
5695
co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
5696
if (argdefs == NULL && co->co_argcount == nargs) {
5697
result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
5698
goto done;
5699
}
5700
else if (nargs == 0 && argdefs != NULL
5701
&& co->co_argcount == Py_SIZE(argdefs)) {
5702
/* function called with no arguments, but all parameters have
5703
a default value: use default values as arguments .*/
5704
args = &PyTuple_GET_ITEM(argdefs, 0);
5705
result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
5706
goto done;
5707
}
5708
}
5709
if (kwargs != NULL) {
5710
Py_ssize_t pos, i;
5711
kwtuple = PyTuple_New(2 * nk);
5712
if (kwtuple == NULL) {
5713
result = NULL;
5714
goto done;
5715
}
5716
k = &PyTuple_GET_ITEM(kwtuple, 0);
5717
pos = i = 0;
5718
while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
5719
Py_INCREF(k[i]);
5720
Py_INCREF(k[i+1]);
5721
i += 2;
5722
}
5723
nk = i / 2;
5724
}
5725
else {
5726
kwtuple = NULL;
5727
k = NULL;
5728
}
5729
closure = PyFunction_GET_CLOSURE(func);
5730
#if PY_MAJOR_VERSION >= 3
5731
kwdefs = PyFunction_GET_KW_DEFAULTS(func);
5732
#endif
5733
if (argdefs != NULL) {
5734
d = &PyTuple_GET_ITEM(argdefs, 0);
5735
nd = Py_SIZE(argdefs);
5736
}
5737
else {
5738
d = NULL;
5739
nd = 0;
5740
}
5741
#if PY_MAJOR_VERSION >= 3
5742
result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
5743
args, (int)nargs,
5744
k, (int)nk,
5745
d, (int)nd, kwdefs, closure);
5746
#else
5747
result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
5748
args, (int)nargs,
5749
k, (int)nk,
5750
d, (int)nd, closure);
5751
#endif
5752
Py_XDECREF(kwtuple);
5753
done:
5754
Py_LeaveRecursiveCall();
5755
return result;
5756
}
5757
#endif
5758
#endif
5759
5760
/* PyObjectCall */
5761
#if CYTHON_COMPILING_IN_CPYTHON
5762
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
5763
PyObject *result;
5764
ternaryfunc call = Py_TYPE(func)->tp_call;
5765
if (unlikely(!call))
5766
return PyObject_Call(func, arg, kw);
5767
if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
5768
return NULL;
5769
result = (*call)(func, arg, kw);
5770
Py_LeaveRecursiveCall();
5771
if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
5772
PyErr_SetString(
5773
PyExc_SystemError,
5774
"NULL result without error in PyObject_Call");
5775
}
5776
return result;
5777
}
5778
#endif
5779
5780
/* PyObjectCall2Args */
5781
static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) {
5782
PyObject *args, *result = NULL;
5783
#if CYTHON_FAST_PYCALL
5784
if (PyFunction_Check(function)) {
5785
PyObject *args[2] = {arg1, arg2};
5786
return __Pyx_PyFunction_FastCall(function, args, 2);
5787
}
5788
#endif
5789
#if CYTHON_FAST_PYCCALL
5790
if (__Pyx_PyFastCFunction_Check(function)) {
5791
PyObject *args[2] = {arg1, arg2};
5792
return __Pyx_PyCFunction_FastCall(function, args, 2);
5793
}
5794
#endif
5795
args = PyTuple_New(2);
5796
if (unlikely(!args)) goto done;
5797
Py_INCREF(arg1);
5798
PyTuple_SET_ITEM(args, 0, arg1);
5799
Py_INCREF(arg2);
5800
PyTuple_SET_ITEM(args, 1, arg2);
5801
Py_INCREF(function);
5802
result = __Pyx_PyObject_Call(function, args, NULL);
5803
Py_DECREF(args);
5804
Py_DECREF(function);
5805
done:
5806
return result;
5807
}
5808
5809
/* PyObjectCallMethO */
5810
#if CYTHON_COMPILING_IN_CPYTHON
5811
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
5812
PyObject *self, *result;
5813
PyCFunction cfunc;
5814
cfunc = PyCFunction_GET_FUNCTION(func);
5815
self = PyCFunction_GET_SELF(func);
5816
if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
5817
return NULL;
5818
result = cfunc(self, arg);
5819
Py_LeaveRecursiveCall();
5820
if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
5821
PyErr_SetString(
5822
PyExc_SystemError,
5823
"NULL result without error in PyObject_Call");
5824
}
5825
return result;
5826
}
5827
#endif
5828
5829
/* PyObjectCallOneArg */
5830
#if CYTHON_COMPILING_IN_CPYTHON
5831
static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
5832
PyObject *result;
5833
PyObject *args = PyTuple_New(1);
5834
if (unlikely(!args)) return NULL;
5835
Py_INCREF(arg);
5836
PyTuple_SET_ITEM(args, 0, arg);
5837
result = __Pyx_PyObject_Call(func, args, NULL);
5838
Py_DECREF(args);
5839
return result;
5840
}
5841
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
5842
#if CYTHON_FAST_PYCALL
5843
if (PyFunction_Check(func)) {
5844
return __Pyx_PyFunction_FastCall(func, &arg, 1);
5845
}
5846
#endif
5847
if (likely(PyCFunction_Check(func))) {
5848
if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
5849
return __Pyx_PyObject_CallMethO(func, arg);
5850
#if CYTHON_FAST_PYCCALL
5851
} else if (__Pyx_PyFastCFunction_Check(func)) {
5852
return __Pyx_PyCFunction_FastCall(func, &arg, 1);
5853
#endif
5854
}
5855
}
5856
return __Pyx__PyObject_CallOneArg(func, arg);
5857
}
5858
#else
5859
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
5860
PyObject *result;
5861
PyObject *args = PyTuple_Pack(1, arg);
5862
if (unlikely(!args)) return NULL;
5863
result = __Pyx_PyObject_Call(func, args, NULL);
5864
Py_DECREF(args);
5865
return result;
5866
}
5867
#endif
5868
5869
/* PyErrExceptionMatches */
5870
#if CYTHON_FAST_THREAD_STATE
5871
static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
5872
Py_ssize_t i, n;
5873
n = PyTuple_GET_SIZE(tuple);
5874
#if PY_MAJOR_VERSION >= 3
5875
for (i=0; i<n; i++) {
5876
if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
5877
}
5878
#endif
5879
for (i=0; i<n; i++) {
5880
if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
5881
}
5882
return 0;
5883
}
5884
static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
5885
PyObject *exc_type = tstate->curexc_type;
5886
if (exc_type == err) return 1;
5887
if (unlikely(!exc_type)) return 0;
5888
if (unlikely(PyTuple_Check(err)))
5889
return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
5890
return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
5891
}
5892
#endif
5893
5894
/* PyErrFetchRestore */
5895
#if CYTHON_FAST_THREAD_STATE
5896
static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
5897
PyObject *tmp_type, *tmp_value, *tmp_tb;
5898
tmp_type = tstate->curexc_type;
5899
tmp_value = tstate->curexc_value;
5900
tmp_tb = tstate->curexc_traceback;
5901
tstate->curexc_type = type;
5902
tstate->curexc_value = value;
5903
tstate->curexc_traceback = tb;
5904
Py_XDECREF(tmp_type);
5905
Py_XDECREF(tmp_value);
5906
Py_XDECREF(tmp_tb);
5907
}
5908
static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
5909
*type = tstate->curexc_type;
5910
*value = tstate->curexc_value;
5911
*tb = tstate->curexc_traceback;
5912
tstate->curexc_type = 0;
5913
tstate->curexc_value = 0;
5914
tstate->curexc_traceback = 0;
5915
}
5916
#endif
5917
5918
/* GetAttr */
5919
static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
5920
#if CYTHON_USE_TYPE_SLOTS
5921
#if PY_MAJOR_VERSION >= 3
5922
if (likely(PyUnicode_Check(n)))
5923
#else
5924
if (likely(PyString_Check(n)))
5925
#endif
5926
return __Pyx_PyObject_GetAttrStr(o, n);
5927
#endif
5928
return PyObject_GetAttr(o, n);
5929
}
5930
5931
/* GetAttr3 */
5932
static PyObject *__Pyx_GetAttr3Default(PyObject *d) {
5933
__Pyx_PyThreadState_declare
5934
__Pyx_PyThreadState_assign
5935
if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
5936
return NULL;
5937
__Pyx_PyErr_Clear();
5938
Py_INCREF(d);
5939
return d;
5940
}
5941
static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) {
5942
PyObject *r = __Pyx_GetAttr(o, n);
5943
return (likely(r)) ? r : __Pyx_GetAttr3Default(d);
5944
}
5945
5946
/* None */
5947
static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) {
5948
PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname);
5949
}
5950
5951
/* PyObjectCallNoArg */
5952
#if CYTHON_COMPILING_IN_CPYTHON
5953
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
5954
#if CYTHON_FAST_PYCALL
5955
if (PyFunction_Check(func)) {
5956
return __Pyx_PyFunction_FastCall(func, NULL, 0);
5957
}
5958
#endif
5959
#ifdef __Pyx_CyFunction_USED
5960
if (likely(PyCFunction_Check(func) || __Pyx_CyFunction_Check(func)))
5961
#else
5962
if (likely(PyCFunction_Check(func)))
5963
#endif
5964
{
5965
if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
5966
return __Pyx_PyObject_CallMethO(func, NULL);
5967
}
5968
}
5969
return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
5970
}
5971
#endif
5972
5973
/* PyIntBinop */
5974
#if !CYTHON_COMPILING_IN_PYPY
5975
static PyObject* __Pyx_PyInt_AddCObj(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) {
5976
(void)inplace;
5977
(void)zerodivision_check;
5978
#if PY_MAJOR_VERSION < 3
5979
if (likely(PyInt_CheckExact(op2))) {
5980
const long a = intval;
5981
long x;
5982
long b = PyInt_AS_LONG(op2);
5983
x = (long)((unsigned long)a + b);
5984
if (likely((x^a) >= 0 || (x^b) >= 0))
5985
return PyInt_FromLong(x);
5986
return PyLong_Type.tp_as_number->nb_add(op1, op2);
5987
}
5988
#endif
5989
#if CYTHON_USE_PYLONG_INTERNALS
5990
if (likely(PyLong_CheckExact(op2))) {
5991
const long a = intval;
5992
long b, x;
5993
#ifdef HAVE_LONG_LONG
5994
const PY_LONG_LONG lla = intval;
5995
PY_LONG_LONG llb, llx;
5996
#endif
5997
const digit* digits = ((PyLongObject*)op2)->ob_digit;
5998
const Py_ssize_t size = Py_SIZE(op2);
5999
if (likely(__Pyx_sst_abs(size) <= 1)) {
6000
b = likely(size) ? digits[0] : 0;
6001
if (size == -1) b = -b;
6002
} else {
6003
switch (size) {
6004
case -2:
6005
if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
6006
b = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
6007
break;
6008
#ifdef HAVE_LONG_LONG
6009
} else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
6010
llb = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
6011
goto long_long;
6012
#endif
6013
}
6014
CYTHON_FALLTHROUGH;
6015
case 2:
6016
if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
6017
b = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
6018
break;
6019
#ifdef HAVE_LONG_LONG
6020
} else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
6021
llb = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
6022
goto long_long;
6023
#endif
6024
}
6025
CYTHON_FALLTHROUGH;
6026
case -3:
6027
if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
6028
b = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
6029
break;
6030
#ifdef HAVE_LONG_LONG
6031
} else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
6032
llb = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
6033
goto long_long;
6034
#endif
6035
}
6036
CYTHON_FALLTHROUGH;
6037
case 3:
6038
if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
6039
b = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
6040
break;
6041
#ifdef HAVE_LONG_LONG
6042
} else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
6043
llb = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
6044
goto long_long;
6045
#endif
6046
}
6047
CYTHON_FALLTHROUGH;
6048
case -4:
6049
if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
6050
b = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
6051
break;
6052
#ifdef HAVE_LONG_LONG
6053
} else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
6054
llb = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
6055
goto long_long;
6056
#endif
6057
}
6058
CYTHON_FALLTHROUGH;
6059
case 4:
6060
if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
6061
b = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
6062
break;
6063
#ifdef HAVE_LONG_LONG
6064
} else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
6065
llb = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
6066
goto long_long;
6067
#endif
6068
}
6069
CYTHON_FALLTHROUGH;
6070
default: return PyLong_Type.tp_as_number->nb_add(op1, op2);
6071
}
6072
}
6073
x = a + b;
6074
return PyLong_FromLong(x);
6075
#ifdef HAVE_LONG_LONG
6076
long_long:
6077
llx = lla + llb;
6078
return PyLong_FromLongLong(llx);
6079
#endif
6080
6081
6082
}
6083
#endif
6084
if (PyFloat_CheckExact(op2)) {
6085
const long a = intval;
6086
double b = PyFloat_AS_DOUBLE(op2);
6087
double result;
6088
PyFPE_START_PROTECT("add", return NULL)
6089
result = ((double)a) + (double)b;
6090
PyFPE_END_PROTECT(result)
6091
return PyFloat_FromDouble(result);
6092
}
6093
return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2);
6094
}
6095
#endif
6096
6097
/* GetItemInt */
6098
static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
6099
PyObject *r;
6100
if (!j) return NULL;
6101
r = PyObject_GetItem(o, j);
6102
Py_DECREF(j);
6103
return r;
6104
}
6105
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
6106
CYTHON_NCP_UNUSED int wraparound,
6107
CYTHON_NCP_UNUSED int boundscheck) {
6108
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
6109
Py_ssize_t wrapped_i = i;
6110
if (wraparound & unlikely(i < 0)) {
6111
wrapped_i += PyList_GET_SIZE(o);
6112
}
6113
if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) {
6114
PyObject *r = PyList_GET_ITEM(o, wrapped_i);
6115
Py_INCREF(r);
6116
return r;
6117
}
6118
return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
6119
#else
6120
return PySequence_GetItem(o, i);
6121
#endif
6122
}
6123
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
6124
CYTHON_NCP_UNUSED int wraparound,
6125
CYTHON_NCP_UNUSED int boundscheck) {
6126
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
6127
Py_ssize_t wrapped_i = i;
6128
if (wraparound & unlikely(i < 0)) {
6129
wrapped_i += PyTuple_GET_SIZE(o);
6130
}
6131
if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) {
6132
PyObject *r = PyTuple_GET_ITEM(o, wrapped_i);
6133
Py_INCREF(r);
6134
return r;
6135
}
6136
return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
6137
#else
6138
return PySequence_GetItem(o, i);
6139
#endif
6140
}
6141
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
6142
CYTHON_NCP_UNUSED int wraparound,
6143
CYTHON_NCP_UNUSED int boundscheck) {
6144
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
6145
if (is_list || PyList_CheckExact(o)) {
6146
Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
6147
if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) {
6148
PyObject *r = PyList_GET_ITEM(o, n);
6149
Py_INCREF(r);
6150
return r;
6151
}
6152
}
6153
else if (PyTuple_CheckExact(o)) {
6154
Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
6155
if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) {
6156
PyObject *r = PyTuple_GET_ITEM(o, n);
6157
Py_INCREF(r);
6158
return r;
6159
}
6160
} else {
6161
PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
6162
if (likely(m && m->sq_item)) {
6163
if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
6164
Py_ssize_t l = m->sq_length(o);
6165
if (likely(l >= 0)) {
6166
i += l;
6167
} else {
6168
if (!PyErr_ExceptionMatches(PyExc_OverflowError))
6169
return NULL;
6170
PyErr_Clear();
6171
}
6172
}
6173
return m->sq_item(o, i);
6174
}
6175
}
6176
#else
6177
if (is_list || PySequence_Check(o)) {
6178
return PySequence_GetItem(o, i);
6179
}
6180
#endif
6181
return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
6182
}
6183
6184
/* Import */
6185
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
6186
PyObject *empty_list = 0;
6187
PyObject *module = 0;
6188
PyObject *global_dict = 0;
6189
PyObject *empty_dict = 0;
6190
PyObject *list;
6191
#if PY_MAJOR_VERSION < 3
6192
PyObject *py_import;
6193
py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
6194
if (!py_import)
6195
goto bad;
6196
#endif
6197
if (from_list)
6198
list = from_list;
6199
else {
6200
empty_list = PyList_New(0);
6201
if (!empty_list)
6202
goto bad;
6203
list = empty_list;
6204
}
6205
global_dict = PyModule_GetDict(__pyx_m);
6206
if (!global_dict)
6207
goto bad;
6208
empty_dict = PyDict_New();
6209
if (!empty_dict)
6210
goto bad;
6211
{
6212
#if PY_MAJOR_VERSION >= 3
6213
if (level == -1) {
6214
if ((1) && (strchr(__Pyx_MODULE_NAME, '.'))) {
6215
module = PyImport_ImportModuleLevelObject(
6216
name, global_dict, empty_dict, list, 1);
6217
if (!module) {
6218
if (!PyErr_ExceptionMatches(PyExc_ImportError))
6219
goto bad;
6220
PyErr_Clear();
6221
}
6222
}
6223
level = 0;
6224
}
6225
#endif
6226
if (!module) {
6227
#if PY_MAJOR_VERSION < 3
6228
PyObject *py_level = PyInt_FromLong(level);
6229
if (!py_level)
6230
goto bad;
6231
module = PyObject_CallFunctionObjArgs(py_import,
6232
name, global_dict, empty_dict, list, py_level, (PyObject *)NULL);
6233
Py_DECREF(py_level);
6234
#else
6235
module = PyImport_ImportModuleLevelObject(
6236
name, global_dict, empty_dict, list, level);
6237
#endif
6238
}
6239
}
6240
bad:
6241
#if PY_MAJOR_VERSION < 3
6242
Py_XDECREF(py_import);
6243
#endif
6244
Py_XDECREF(empty_list);
6245
Py_XDECREF(empty_dict);
6246
return module;
6247
}
6248
6249
/* ImportFrom */
6250
static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
6251
PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
6252
if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
6253
PyErr_Format(PyExc_ImportError,
6254
#if PY_MAJOR_VERSION < 3
6255
"cannot import name %.230s", PyString_AS_STRING(name));
6256
#else
6257
"cannot import name %S", name);
6258
#endif
6259
}
6260
return value;
6261
}
6262
6263
/* RaiseException */
6264
#if PY_MAJOR_VERSION < 3
6265
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
6266
CYTHON_UNUSED PyObject *cause) {
6267
__Pyx_PyThreadState_declare
6268
Py_XINCREF(type);
6269
if (!value || value == Py_None)
6270
value = NULL;
6271
else
6272
Py_INCREF(value);
6273
if (!tb || tb == Py_None)
6274
tb = NULL;
6275
else {
6276
Py_INCREF(tb);
6277
if (!PyTraceBack_Check(tb)) {
6278
PyErr_SetString(PyExc_TypeError,
6279
"raise: arg 3 must be a traceback or None");
6280
goto raise_error;
6281
}
6282
}
6283
if (PyType_Check(type)) {
6284
#if CYTHON_COMPILING_IN_PYPY
6285
if (!value) {
6286
Py_INCREF(Py_None);
6287
value = Py_None;
6288
}
6289
#endif
6290
PyErr_NormalizeException(&type, &value, &tb);
6291
} else {
6292
if (value) {
6293
PyErr_SetString(PyExc_TypeError,
6294
"instance exception may not have a separate value");
6295
goto raise_error;
6296
}
6297
value = type;
6298
type = (PyObject*) Py_TYPE(type);
6299
Py_INCREF(type);
6300
if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
6301
PyErr_SetString(PyExc_TypeError,
6302
"raise: exception class must be a subclass of BaseException");
6303
goto raise_error;
6304
}
6305
}
6306
__Pyx_PyThreadState_assign
6307
__Pyx_ErrRestore(type, value, tb);
6308
return;
6309
raise_error:
6310
Py_XDECREF(value);
6311
Py_XDECREF(type);
6312
Py_XDECREF(tb);
6313
return;
6314
}
6315
#else
6316
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
6317
PyObject* owned_instance = NULL;
6318
if (tb == Py_None) {
6319
tb = 0;
6320
} else if (tb && !PyTraceBack_Check(tb)) {
6321
PyErr_SetString(PyExc_TypeError,
6322
"raise: arg 3 must be a traceback or None");
6323
goto bad;
6324
}
6325
if (value == Py_None)
6326
value = 0;
6327
if (PyExceptionInstance_Check(type)) {
6328
if (value) {
6329
PyErr_SetString(PyExc_TypeError,
6330
"instance exception may not have a separate value");
6331
goto bad;
6332
}
6333
value = type;
6334
type = (PyObject*) Py_TYPE(value);
6335
} else if (PyExceptionClass_Check(type)) {
6336
PyObject *instance_class = NULL;
6337
if (value && PyExceptionInstance_Check(value)) {
6338
instance_class = (PyObject*) Py_TYPE(value);
6339
if (instance_class != type) {
6340
int is_subclass = PyObject_IsSubclass(instance_class, type);
6341
if (!is_subclass) {
6342
instance_class = NULL;
6343
} else if (unlikely(is_subclass == -1)) {
6344
goto bad;
6345
} else {
6346
type = instance_class;
6347
}
6348
}
6349
}
6350
if (!instance_class) {
6351
PyObject *args;
6352
if (!value)
6353
args = PyTuple_New(0);
6354
else if (PyTuple_Check(value)) {
6355
Py_INCREF(value);
6356
args = value;
6357
} else
6358
args = PyTuple_Pack(1, value);
6359
if (!args)
6360
goto bad;
6361
owned_instance = PyObject_Call(type, args, NULL);
6362
Py_DECREF(args);
6363
if (!owned_instance)
6364
goto bad;
6365
value = owned_instance;
6366
if (!PyExceptionInstance_Check(value)) {
6367
PyErr_Format(PyExc_TypeError,
6368
"calling %R should have returned an instance of "
6369
"BaseException, not %R",
6370
type, Py_TYPE(value));
6371
goto bad;
6372
}
6373
}
6374
} else {
6375
PyErr_SetString(PyExc_TypeError,
6376
"raise: exception class must be a subclass of BaseException");
6377
goto bad;
6378
}
6379
if (cause) {
6380
PyObject *fixed_cause;
6381
if (cause == Py_None) {
6382
fixed_cause = NULL;
6383
} else if (PyExceptionClass_Check(cause)) {
6384
fixed_cause = PyObject_CallObject(cause, NULL);
6385
if (fixed_cause == NULL)
6386
goto bad;
6387
} else if (PyExceptionInstance_Check(cause)) {
6388
fixed_cause = cause;
6389
Py_INCREF(fixed_cause);
6390
} else {
6391
PyErr_SetString(PyExc_TypeError,
6392
"exception causes must derive from "
6393
"BaseException");
6394
goto bad;
6395
}
6396
PyException_SetCause(value, fixed_cause);
6397
}
6398
PyErr_SetObject(type, value);
6399
if (tb) {
6400
#if CYTHON_COMPILING_IN_PYPY
6401
PyObject *tmp_type, *tmp_value, *tmp_tb;
6402
PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
6403
Py_INCREF(tb);
6404
PyErr_Restore(tmp_type, tmp_value, tb);
6405
Py_XDECREF(tmp_tb);
6406
#else
6407
PyThreadState *tstate = __Pyx_PyThreadState_Current;
6408
PyObject* tmp_tb = tstate->curexc_traceback;
6409
if (tb != tmp_tb) {
6410
Py_INCREF(tb);
6411
tstate->curexc_traceback = tb;
6412
Py_XDECREF(tmp_tb);
6413
}
6414
#endif
6415
}
6416
bad:
6417
Py_XDECREF(owned_instance);
6418
return;
6419
}
6420
#endif
6421
6422
/* HasAttr */
6423
static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) {
6424
PyObject *r;
6425
if (unlikely(!__Pyx_PyBaseString_Check(n))) {
6426
PyErr_SetString(PyExc_TypeError,
6427
"hasattr(): attribute name must be string");
6428
return -1;
6429
}
6430
r = __Pyx_GetAttr(o, n);
6431
if (unlikely(!r)) {
6432
PyErr_Clear();
6433
return 0;
6434
} else {
6435
Py_DECREF(r);
6436
return 1;
6437
}
6438
}
6439
6440
/* PyObject_GenericGetAttrNoDict */
6441
#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
6442
static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
6443
PyErr_Format(PyExc_AttributeError,
6444
#if PY_MAJOR_VERSION >= 3
6445
"'%.50s' object has no attribute '%U'",
6446
tp->tp_name, attr_name);
6447
#else
6448
"'%.50s' object has no attribute '%.400s'",
6449
tp->tp_name, PyString_AS_STRING(attr_name));
6450
#endif
6451
return NULL;
6452
}
6453
static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
6454
PyObject *descr;
6455
PyTypeObject *tp = Py_TYPE(obj);
6456
if (unlikely(!PyString_Check(attr_name))) {
6457
return PyObject_GenericGetAttr(obj, attr_name);
6458
}
6459
assert(!tp->tp_dictoffset);
6460
descr = _PyType_Lookup(tp, attr_name);
6461
if (unlikely(!descr)) {
6462
return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
6463
}
6464
Py_INCREF(descr);
6465
#if PY_MAJOR_VERSION < 3
6466
if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
6467
#endif
6468
{
6469
descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
6470
if (unlikely(f)) {
6471
PyObject *res = f(descr, obj, (PyObject *)tp);
6472
Py_DECREF(descr);
6473
return res;
6474
}
6475
}
6476
return descr;
6477
}
6478
#endif
6479
6480
/* PyObject_GenericGetAttr */
6481
#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
6482
static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) {
6483
if (unlikely(Py_TYPE(obj)->tp_dictoffset)) {
6484
return PyObject_GenericGetAttr(obj, attr_name);
6485
}
6486
return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name);
6487
}
6488
#endif
6489
6490
/* PyObjectGetAttrStrNoError */
6491
static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) {
6492
__Pyx_PyThreadState_declare
6493
__Pyx_PyThreadState_assign
6494
if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
6495
__Pyx_PyErr_Clear();
6496
}
6497
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) {
6498
PyObject *result;
6499
#if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS && PY_VERSION_HEX >= 0x030700B1
6500
PyTypeObject* tp = Py_TYPE(obj);
6501
if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) {
6502
return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1);
6503
}
6504
#endif
6505
result = __Pyx_PyObject_GetAttrStr(obj, attr_name);
6506
if (unlikely(!result)) {
6507
__Pyx_PyObject_GetAttrStr_ClearAttributeError();
6508
}
6509
return result;
6510
}
6511
6512
/* SetupReduce */
6513
static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) {
6514
int ret;
6515
PyObject *name_attr;
6516
name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name);
6517
if (likely(name_attr)) {
6518
ret = PyObject_RichCompareBool(name_attr, name, Py_EQ);
6519
} else {
6520
ret = -1;
6521
}
6522
if (unlikely(ret < 0)) {
6523
PyErr_Clear();
6524
ret = 0;
6525
}
6526
Py_XDECREF(name_attr);
6527
return ret;
6528
}
6529
static int __Pyx_setup_reduce(PyObject* type_obj) {
6530
int ret = 0;
6531
PyObject *object_reduce = NULL;
6532
PyObject *object_getstate = NULL;
6533
PyObject *object_reduce_ex = NULL;
6534
PyObject *reduce = NULL;
6535
PyObject *reduce_ex = NULL;
6536
PyObject *reduce_cython = NULL;
6537
PyObject *setstate = NULL;
6538
PyObject *setstate_cython = NULL;
6539
PyObject *getstate = NULL;
6540
#if CYTHON_USE_PYTYPE_LOOKUP
6541
getstate = _PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate);
6542
#else
6543
getstate = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_getstate);
6544
if (!getstate && PyErr_Occurred()) {
6545
goto __PYX_BAD;
6546
}
6547
#endif
6548
if (getstate) {
6549
#if CYTHON_USE_PYTYPE_LOOKUP
6550
object_getstate = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_getstate);
6551
#else
6552
object_getstate = __Pyx_PyObject_GetAttrStrNoError((PyObject*)&PyBaseObject_Type, __pyx_n_s_getstate);
6553
if (!object_getstate && PyErr_Occurred()) {
6554
goto __PYX_BAD;
6555
}
6556
#endif
6557
if (object_getstate != getstate) {
6558
goto __PYX_GOOD;
6559
}
6560
}
6561
#if CYTHON_USE_PYTYPE_LOOKUP
6562
object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
6563
#else
6564
object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
6565
#endif
6566
reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto __PYX_BAD;
6567
if (reduce_ex == object_reduce_ex) {
6568
#if CYTHON_USE_PYTYPE_LOOKUP
6569
object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
6570
#else
6571
object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
6572
#endif
6573
reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto __PYX_BAD;
6574
if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) {
6575
reduce_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_reduce_cython);
6576
if (likely(reduce_cython)) {
6577
ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
6578
ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
6579
} else if (reduce == object_reduce || PyErr_Occurred()) {
6580
goto __PYX_BAD;
6581
}
6582
setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate);
6583
if (!setstate) PyErr_Clear();
6584
if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) {
6585
setstate_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_setstate_cython);
6586
if (likely(setstate_cython)) {
6587
ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
6588
ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
6589
} else if (!setstate || PyErr_Occurred()) {
6590
goto __PYX_BAD;
6591
}
6592
}
6593
PyType_Modified((PyTypeObject*)type_obj);
6594
}
6595
}
6596
goto __PYX_GOOD;
6597
__PYX_BAD:
6598
if (!PyErr_Occurred())
6599
PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name);
6600
ret = -1;
6601
__PYX_GOOD:
6602
#if !CYTHON_USE_PYTYPE_LOOKUP
6603
Py_XDECREF(object_reduce);
6604
Py_XDECREF(object_reduce_ex);
6605
Py_XDECREF(object_getstate);
6606
Py_XDECREF(getstate);
6607
#endif
6608
Py_XDECREF(reduce);
6609
Py_XDECREF(reduce_ex);
6610
Py_XDECREF(reduce_cython);
6611
Py_XDECREF(setstate);
6612
Py_XDECREF(setstate_cython);
6613
return ret;
6614
}
6615
6616
/* BytesEquals */
6617
static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
6618
#if CYTHON_COMPILING_IN_PYPY
6619
return PyObject_RichCompareBool(s1, s2, equals);
6620
#else
6621
if (s1 == s2) {
6622
return (equals == Py_EQ);
6623
} else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
6624
const char *ps1, *ps2;
6625
Py_ssize_t length = PyBytes_GET_SIZE(s1);
6626
if (length != PyBytes_GET_SIZE(s2))
6627
return (equals == Py_NE);
6628
ps1 = PyBytes_AS_STRING(s1);
6629
ps2 = PyBytes_AS_STRING(s2);
6630
if (ps1[0] != ps2[0]) {
6631
return (equals == Py_NE);
6632
} else if (length == 1) {
6633
return (equals == Py_EQ);
6634
} else {
6635
int result;
6636
#if CYTHON_USE_UNICODE_INTERNALS && (PY_VERSION_HEX < 0x030B0000)
6637
Py_hash_t hash1, hash2;
6638
hash1 = ((PyBytesObject*)s1)->ob_shash;
6639
hash2 = ((PyBytesObject*)s2)->ob_shash;
6640
if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
6641
return (equals == Py_NE);
6642
}
6643
#endif
6644
result = memcmp(ps1, ps2, (size_t)length);
6645
return (equals == Py_EQ) ? (result == 0) : (result != 0);
6646
}
6647
} else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
6648
return (equals == Py_NE);
6649
} else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
6650
return (equals == Py_NE);
6651
} else {
6652
int result;
6653
PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
6654
if (!py_result)
6655
return -1;
6656
result = __Pyx_PyObject_IsTrue(py_result);
6657
Py_DECREF(py_result);
6658
return result;
6659
}
6660
#endif
6661
}
6662
6663
/* UnicodeEquals */
6664
static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
6665
#if CYTHON_COMPILING_IN_PYPY
6666
return PyObject_RichCompareBool(s1, s2, equals);
6667
#else
6668
#if PY_MAJOR_VERSION < 3
6669
PyObject* owned_ref = NULL;
6670
#endif
6671
int s1_is_unicode, s2_is_unicode;
6672
if (s1 == s2) {
6673
goto return_eq;
6674
}
6675
s1_is_unicode = PyUnicode_CheckExact(s1);
6676
s2_is_unicode = PyUnicode_CheckExact(s2);
6677
#if PY_MAJOR_VERSION < 3
6678
if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) {
6679
owned_ref = PyUnicode_FromObject(s2);
6680
if (unlikely(!owned_ref))
6681
return -1;
6682
s2 = owned_ref;
6683
s2_is_unicode = 1;
6684
} else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) {
6685
owned_ref = PyUnicode_FromObject(s1);
6686
if (unlikely(!owned_ref))
6687
return -1;
6688
s1 = owned_ref;
6689
s1_is_unicode = 1;
6690
} else if (((!s2_is_unicode) & (!s1_is_unicode))) {
6691
return __Pyx_PyBytes_Equals(s1, s2, equals);
6692
}
6693
#endif
6694
if (s1_is_unicode & s2_is_unicode) {
6695
Py_ssize_t length;
6696
int kind;
6697
void *data1, *data2;
6698
if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0))
6699
return -1;
6700
length = __Pyx_PyUnicode_GET_LENGTH(s1);
6701
if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) {
6702
goto return_ne;
6703
}
6704
#if CYTHON_USE_UNICODE_INTERNALS
6705
{
6706
Py_hash_t hash1, hash2;
6707
#if CYTHON_PEP393_ENABLED
6708
hash1 = ((PyASCIIObject*)s1)->hash;
6709
hash2 = ((PyASCIIObject*)s2)->hash;
6710
#else
6711
hash1 = ((PyUnicodeObject*)s1)->hash;
6712
hash2 = ((PyUnicodeObject*)s2)->hash;
6713
#endif
6714
if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
6715
goto return_ne;
6716
}
6717
}
6718
#endif
6719
kind = __Pyx_PyUnicode_KIND(s1);
6720
if (kind != __Pyx_PyUnicode_KIND(s2)) {
6721
goto return_ne;
6722
}
6723
data1 = __Pyx_PyUnicode_DATA(s1);
6724
data2 = __Pyx_PyUnicode_DATA(s2);
6725
if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) {
6726
goto return_ne;
6727
} else if (length == 1) {
6728
goto return_eq;
6729
} else {
6730
int result = memcmp(data1, data2, (size_t)(length * kind));
6731
#if PY_MAJOR_VERSION < 3
6732
Py_XDECREF(owned_ref);
6733
#endif
6734
return (equals == Py_EQ) ? (result == 0) : (result != 0);
6735
}
6736
} else if ((s1 == Py_None) & s2_is_unicode) {
6737
goto return_ne;
6738
} else if ((s2 == Py_None) & s1_is_unicode) {
6739
goto return_ne;
6740
} else {
6741
int result;
6742
PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
6743
#if PY_MAJOR_VERSION < 3
6744
Py_XDECREF(owned_ref);
6745
#endif
6746
if (!py_result)
6747
return -1;
6748
result = __Pyx_PyObject_IsTrue(py_result);
6749
Py_DECREF(py_result);
6750
return result;
6751
}
6752
return_eq:
6753
#if PY_MAJOR_VERSION < 3
6754
Py_XDECREF(owned_ref);
6755
#endif
6756
return (equals == Py_EQ);
6757
return_ne:
6758
#if PY_MAJOR_VERSION < 3
6759
Py_XDECREF(owned_ref);
6760
#endif
6761
return (equals == Py_NE);
6762
#endif
6763
}
6764
6765
/* CLineInTraceback */
6766
#ifndef CYTHON_CLINE_IN_TRACEBACK
6767
static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) {
6768
PyObject *use_cline;
6769
PyObject *ptype, *pvalue, *ptraceback;
6770
#if CYTHON_COMPILING_IN_CPYTHON
6771
PyObject **cython_runtime_dict;
6772
#endif
6773
if (unlikely(!__pyx_cython_runtime)) {
6774
return c_line;
6775
}
6776
__Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
6777
#if CYTHON_COMPILING_IN_CPYTHON
6778
cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
6779
if (likely(cython_runtime_dict)) {
6780
__PYX_PY_DICT_LOOKUP_IF_MODIFIED(
6781
use_cline, *cython_runtime_dict,
6782
__Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback))
6783
} else
6784
#endif
6785
{
6786
PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
6787
if (use_cline_obj) {
6788
use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
6789
Py_DECREF(use_cline_obj);
6790
} else {
6791
PyErr_Clear();
6792
use_cline = NULL;
6793
}
6794
}
6795
if (!use_cline) {
6796
c_line = 0;
6797
(void) PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
6798
}
6799
else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
6800
c_line = 0;
6801
}
6802
__Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
6803
return c_line;
6804
}
6805
#endif
6806
6807
/* CodeObjectCache */
6808
static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
6809
int start = 0, mid = 0, end = count - 1;
6810
if (end >= 0 && code_line > entries[end].code_line) {
6811
return count;
6812
}
6813
while (start < end) {
6814
mid = start + (end - start) / 2;
6815
if (code_line < entries[mid].code_line) {
6816
end = mid;
6817
} else if (code_line > entries[mid].code_line) {
6818
start = mid + 1;
6819
} else {
6820
return mid;
6821
}
6822
}
6823
if (code_line <= entries[mid].code_line) {
6824
return mid;
6825
} else {
6826
return mid + 1;
6827
}
6828
}
6829
static PyCodeObject *__pyx_find_code_object(int code_line) {
6830
PyCodeObject* code_object;
6831
int pos;
6832
if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
6833
return NULL;
6834
}
6835
pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
6836
if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
6837
return NULL;
6838
}
6839
code_object = __pyx_code_cache.entries[pos].code_object;
6840
Py_INCREF(code_object);
6841
return code_object;
6842
}
6843
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
6844
int pos, i;
6845
__Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
6846
if (unlikely(!code_line)) {
6847
return;
6848
}
6849
if (unlikely(!entries)) {
6850
entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
6851
if (likely(entries)) {
6852
__pyx_code_cache.entries = entries;
6853
__pyx_code_cache.max_count = 64;
6854
__pyx_code_cache.count = 1;
6855
entries[0].code_line = code_line;
6856
entries[0].code_object = code_object;
6857
Py_INCREF(code_object);
6858
}
6859
return;
6860
}
6861
pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
6862
if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
6863
PyCodeObject* tmp = entries[pos].code_object;
6864
entries[pos].code_object = code_object;
6865
Py_DECREF(tmp);
6866
return;
6867
}
6868
if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
6869
int new_max = __pyx_code_cache.max_count + 64;
6870
entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
6871
__pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry));
6872
if (unlikely(!entries)) {
6873
return;
6874
}
6875
__pyx_code_cache.entries = entries;
6876
__pyx_code_cache.max_count = new_max;
6877
}
6878
for (i=__pyx_code_cache.count; i>pos; i--) {
6879
entries[i] = entries[i-1];
6880
}
6881
entries[pos].code_line = code_line;
6882
entries[pos].code_object = code_object;
6883
__pyx_code_cache.count++;
6884
Py_INCREF(code_object);
6885
}
6886
6887
/* AddTraceback */
6888
#include "compile.h"
6889
#include "frameobject.h"
6890
#include "traceback.h"
6891
#if PY_VERSION_HEX >= 0x030b00a6
6892
#ifndef Py_BUILD_CORE
6893
#define Py_BUILD_CORE 1
6894
#endif
6895
#include "internal/pycore_frame.h"
6896
#endif
6897
static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
6898
const char *funcname, int c_line,
6899
int py_line, const char *filename) {
6900
PyCodeObject *py_code = NULL;
6901
PyObject *py_funcname = NULL;
6902
#if PY_MAJOR_VERSION < 3
6903
PyObject *py_srcfile = NULL;
6904
py_srcfile = PyString_FromString(filename);
6905
if (!py_srcfile) goto bad;
6906
#endif
6907
if (c_line) {
6908
#if PY_MAJOR_VERSION < 3
6909
py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
6910
if (!py_funcname) goto bad;
6911
#else
6912
py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
6913
if (!py_funcname) goto bad;
6914
funcname = PyUnicode_AsUTF8(py_funcname);
6915
if (!funcname) goto bad;
6916
#endif
6917
}
6918
else {
6919
#if PY_MAJOR_VERSION < 3
6920
py_funcname = PyString_FromString(funcname);
6921
if (!py_funcname) goto bad;
6922
#endif
6923
}
6924
#if PY_MAJOR_VERSION < 3
6925
py_code = __Pyx_PyCode_New(
6926
0,
6927
0,
6928
0,
6929
0,
6930
0,
6931
__pyx_empty_bytes, /*PyObject *code,*/
6932
__pyx_empty_tuple, /*PyObject *consts,*/
6933
__pyx_empty_tuple, /*PyObject *names,*/
6934
__pyx_empty_tuple, /*PyObject *varnames,*/
6935
__pyx_empty_tuple, /*PyObject *freevars,*/
6936
__pyx_empty_tuple, /*PyObject *cellvars,*/
6937
py_srcfile, /*PyObject *filename,*/
6938
py_funcname, /*PyObject *name,*/
6939
py_line,
6940
__pyx_empty_bytes /*PyObject *lnotab*/
6941
);
6942
Py_DECREF(py_srcfile);
6943
#else
6944
py_code = PyCode_NewEmpty(filename, funcname, py_line);
6945
#endif
6946
Py_XDECREF(py_funcname); // XDECREF since it's only set on Py3 if cline
6947
return py_code;
6948
bad:
6949
Py_XDECREF(py_funcname);
6950
#if PY_MAJOR_VERSION < 3
6951
Py_XDECREF(py_srcfile);
6952
#endif
6953
return NULL;
6954
}
6955
static void __Pyx_AddTraceback(const char *funcname, int c_line,
6956
int py_line, const char *filename) {
6957
PyCodeObject *py_code = 0;
6958
PyFrameObject *py_frame = 0;
6959
PyThreadState *tstate = __Pyx_PyThreadState_Current;
6960
PyObject *ptype, *pvalue, *ptraceback;
6961
if (c_line) {
6962
c_line = __Pyx_CLineForTraceback(tstate, c_line);
6963
}
6964
py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
6965
if (!py_code) {
6966
__Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
6967
py_code = __Pyx_CreateCodeObjectForTraceback(
6968
funcname, c_line, py_line, filename);
6969
if (!py_code) {
6970
/* If the code object creation fails, then we should clear the
6971
fetched exception references and propagate the new exception */
6972
Py_XDECREF(ptype);
6973
Py_XDECREF(pvalue);
6974
Py_XDECREF(ptraceback);
6975
goto bad;
6976
}
6977
__Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
6978
__pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
6979
}
6980
py_frame = PyFrame_New(
6981
tstate, /*PyThreadState *tstate,*/
6982
py_code, /*PyCodeObject *code,*/
6983
__pyx_d, /*PyObject *globals,*/
6984
0 /*PyObject *locals*/
6985
);
6986
if (!py_frame) goto bad;
6987
__Pyx_PyFrame_SetLineNumber(py_frame, py_line);
6988
PyTraceBack_Here(py_frame);
6989
bad:
6990
Py_XDECREF(py_code);
6991
Py_XDECREF(py_frame);
6992
}
6993
6994
/* CIntFromPyVerify */
6995
#define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
6996
__PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
6997
#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
6998
__PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
6999
#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
7000
{\
7001
func_type value = func_value;\
7002
if (sizeof(target_type) < sizeof(func_type)) {\
7003
if (unlikely(value != (func_type) (target_type) value)) {\
7004
func_type zero = 0;\
7005
if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
7006
return (target_type) -1;\
7007
if (is_unsigned && unlikely(value < zero))\
7008
goto raise_neg_overflow;\
7009
else\
7010
goto raise_overflow;\
7011
}\
7012
}\
7013
return (target_type) value;\
7014
}
7015
7016
/* CIntToPy */
7017
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
7018
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
7019
#pragma GCC diagnostic push
7020
#pragma GCC diagnostic ignored "-Wconversion"
7021
#endif
7022
const int neg_one = (int) -1, const_zero = (int) 0;
7023
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
7024
#pragma GCC diagnostic pop
7025
#endif
7026
const int is_unsigned = neg_one > const_zero;
7027
if (is_unsigned) {
7028
if (sizeof(int) < sizeof(long)) {
7029
return PyInt_FromLong((long) value);
7030
} else if (sizeof(int) <= sizeof(unsigned long)) {
7031
return PyLong_FromUnsignedLong((unsigned long) value);
7032
#ifdef HAVE_LONG_LONG
7033
} else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
7034
return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
7035
#endif
7036
}
7037
} else {
7038
if (sizeof(int) <= sizeof(long)) {
7039
return PyInt_FromLong((long) value);
7040
#ifdef HAVE_LONG_LONG
7041
} else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
7042
return PyLong_FromLongLong((PY_LONG_LONG) value);
7043
#endif
7044
}
7045
}
7046
{
7047
int one = 1; int little = (int)*(unsigned char *)&one;
7048
unsigned char *bytes = (unsigned char *)&value;
7049
return _PyLong_FromByteArray(bytes, sizeof(int),
7050
little, !is_unsigned);
7051
}
7052
}
7053
7054
/* CIntFromPy */
7055
static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
7056
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
7057
#pragma GCC diagnostic push
7058
#pragma GCC diagnostic ignored "-Wconversion"
7059
#endif
7060
const int neg_one = (int) -1, const_zero = (int) 0;
7061
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
7062
#pragma GCC diagnostic pop
7063
#endif
7064
const int is_unsigned = neg_one > const_zero;
7065
#if PY_MAJOR_VERSION < 3
7066
if (likely(PyInt_Check(x))) {
7067
if (sizeof(int) < sizeof(long)) {
7068
__PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
7069
} else {
7070
long val = PyInt_AS_LONG(x);
7071
if (is_unsigned && unlikely(val < 0)) {
7072
goto raise_neg_overflow;
7073
}
7074
return (int) val;
7075
}
7076
} else
7077
#endif
7078
if (likely(PyLong_Check(x))) {
7079
if (is_unsigned) {
7080
#if CYTHON_USE_PYLONG_INTERNALS
7081
const digit* digits = ((PyLongObject*)x)->ob_digit;
7082
switch (Py_SIZE(x)) {
7083
case 0: return (int) 0;
7084
case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
7085
case 2:
7086
if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
7087
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
7088
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7089
} else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
7090
return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
7091
}
7092
}
7093
break;
7094
case 3:
7095
if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
7096
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
7097
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7098
} else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
7099
return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
7100
}
7101
}
7102
break;
7103
case 4:
7104
if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
7105
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
7106
__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])))
7107
} else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
7108
return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
7109
}
7110
}
7111
break;
7112
}
7113
#endif
7114
#if CYTHON_COMPILING_IN_CPYTHON
7115
if (unlikely(Py_SIZE(x) < 0)) {
7116
goto raise_neg_overflow;
7117
}
7118
#else
7119
{
7120
int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
7121
if (unlikely(result < 0))
7122
return (int) -1;
7123
if (unlikely(result == 1))
7124
goto raise_neg_overflow;
7125
}
7126
#endif
7127
if (sizeof(int) <= sizeof(unsigned long)) {
7128
__PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
7129
#ifdef HAVE_LONG_LONG
7130
} else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
7131
__PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
7132
#endif
7133
}
7134
} else {
7135
#if CYTHON_USE_PYLONG_INTERNALS
7136
const digit* digits = ((PyLongObject*)x)->ob_digit;
7137
switch (Py_SIZE(x)) {
7138
case 0: return (int) 0;
7139
case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
7140
case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0])
7141
case -2:
7142
if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
7143
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
7144
__PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7145
} else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
7146
return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
7147
}
7148
}
7149
break;
7150
case 2:
7151
if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
7152
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
7153
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7154
} else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
7155
return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
7156
}
7157
}
7158
break;
7159
case -3:
7160
if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
7161
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
7162
__PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7163
} else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
7164
return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
7165
}
7166
}
7167
break;
7168
case 3:
7169
if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
7170
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
7171
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7172
} else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
7173
return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
7174
}
7175
}
7176
break;
7177
case -4:
7178
if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
7179
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
7180
__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])))
7181
} else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
7182
return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
7183
}
7184
}
7185
break;
7186
case 4:
7187
if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
7188
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
7189
__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])))
7190
} else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
7191
return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
7192
}
7193
}
7194
break;
7195
}
7196
#endif
7197
if (sizeof(int) <= sizeof(long)) {
7198
__PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
7199
#ifdef HAVE_LONG_LONG
7200
} else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
7201
__PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
7202
#endif
7203
}
7204
}
7205
{
7206
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
7207
PyErr_SetString(PyExc_RuntimeError,
7208
"_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
7209
#else
7210
int val;
7211
PyObject *v = __Pyx_PyNumber_IntOrLong(x);
7212
#if PY_MAJOR_VERSION < 3
7213
if (likely(v) && !PyLong_Check(v)) {
7214
PyObject *tmp = v;
7215
v = PyNumber_Long(tmp);
7216
Py_DECREF(tmp);
7217
}
7218
#endif
7219
if (likely(v)) {
7220
int one = 1; int is_little = (int)*(unsigned char *)&one;
7221
unsigned char *bytes = (unsigned char *)&val;
7222
int ret = _PyLong_AsByteArray((PyLongObject *)v,
7223
bytes, sizeof(val),
7224
is_little, !is_unsigned);
7225
Py_DECREF(v);
7226
if (likely(!ret))
7227
return val;
7228
}
7229
#endif
7230
return (int) -1;
7231
}
7232
} else {
7233
int val;
7234
PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
7235
if (!tmp) return (int) -1;
7236
val = __Pyx_PyInt_As_int(tmp);
7237
Py_DECREF(tmp);
7238
return val;
7239
}
7240
raise_overflow:
7241
PyErr_SetString(PyExc_OverflowError,
7242
"value too large to convert to int");
7243
return (int) -1;
7244
raise_neg_overflow:
7245
PyErr_SetString(PyExc_OverflowError,
7246
"can't convert negative value to int");
7247
return (int) -1;
7248
}
7249
7250
/* CIntFromPy */
7251
static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_As_PY_LONG_LONG(PyObject *x) {
7252
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
7253
#pragma GCC diagnostic push
7254
#pragma GCC diagnostic ignored "-Wconversion"
7255
#endif
7256
const PY_LONG_LONG neg_one = (PY_LONG_LONG) -1, const_zero = (PY_LONG_LONG) 0;
7257
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
7258
#pragma GCC diagnostic pop
7259
#endif
7260
const int is_unsigned = neg_one > const_zero;
7261
#if PY_MAJOR_VERSION < 3
7262
if (likely(PyInt_Check(x))) {
7263
if (sizeof(PY_LONG_LONG) < sizeof(long)) {
7264
__PYX_VERIFY_RETURN_INT(PY_LONG_LONG, long, PyInt_AS_LONG(x))
7265
} else {
7266
long val = PyInt_AS_LONG(x);
7267
if (is_unsigned && unlikely(val < 0)) {
7268
goto raise_neg_overflow;
7269
}
7270
return (PY_LONG_LONG) val;
7271
}
7272
} else
7273
#endif
7274
if (likely(PyLong_Check(x))) {
7275
if (is_unsigned) {
7276
#if CYTHON_USE_PYLONG_INTERNALS
7277
const digit* digits = ((PyLongObject*)x)->ob_digit;
7278
switch (Py_SIZE(x)) {
7279
case 0: return (PY_LONG_LONG) 0;
7280
case 1: __PYX_VERIFY_RETURN_INT(PY_LONG_LONG, digit, digits[0])
7281
case 2:
7282
if (8 * sizeof(PY_LONG_LONG) > 1 * PyLong_SHIFT) {
7283
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
7284
__PYX_VERIFY_RETURN_INT(PY_LONG_LONG, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7285
} else if (8 * sizeof(PY_LONG_LONG) >= 2 * PyLong_SHIFT) {
7286
return (PY_LONG_LONG) (((((PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[0]));
7287
}
7288
}
7289
break;
7290
case 3:
7291
if (8 * sizeof(PY_LONG_LONG) > 2 * PyLong_SHIFT) {
7292
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
7293
__PYX_VERIFY_RETURN_INT(PY_LONG_LONG, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7294
} else if (8 * sizeof(PY_LONG_LONG) >= 3 * PyLong_SHIFT) {
7295
return (PY_LONG_LONG) (((((((PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[0]));
7296
}
7297
}
7298
break;
7299
case 4:
7300
if (8 * sizeof(PY_LONG_LONG) > 3 * PyLong_SHIFT) {
7301
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
7302
__PYX_VERIFY_RETURN_INT(PY_LONG_LONG, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7303
} else if (8 * sizeof(PY_LONG_LONG) >= 4 * PyLong_SHIFT) {
7304
return (PY_LONG_LONG) (((((((((PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[0]));
7305
}
7306
}
7307
break;
7308
}
7309
#endif
7310
#if CYTHON_COMPILING_IN_CPYTHON
7311
if (unlikely(Py_SIZE(x) < 0)) {
7312
goto raise_neg_overflow;
7313
}
7314
#else
7315
{
7316
int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
7317
if (unlikely(result < 0))
7318
return (PY_LONG_LONG) -1;
7319
if (unlikely(result == 1))
7320
goto raise_neg_overflow;
7321
}
7322
#endif
7323
if (sizeof(PY_LONG_LONG) <= sizeof(unsigned long)) {
7324
__PYX_VERIFY_RETURN_INT_EXC(PY_LONG_LONG, unsigned long, PyLong_AsUnsignedLong(x))
7325
#ifdef HAVE_LONG_LONG
7326
} else if (sizeof(PY_LONG_LONG) <= sizeof(unsigned PY_LONG_LONG)) {
7327
__PYX_VERIFY_RETURN_INT_EXC(PY_LONG_LONG, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
7328
#endif
7329
}
7330
} else {
7331
#if CYTHON_USE_PYLONG_INTERNALS
7332
const digit* digits = ((PyLongObject*)x)->ob_digit;
7333
switch (Py_SIZE(x)) {
7334
case 0: return (PY_LONG_LONG) 0;
7335
case -1: __PYX_VERIFY_RETURN_INT(PY_LONG_LONG, sdigit, (sdigit) (-(sdigit)digits[0]))
7336
case 1: __PYX_VERIFY_RETURN_INT(PY_LONG_LONG, digit, +digits[0])
7337
case -2:
7338
if (8 * sizeof(PY_LONG_LONG) - 1 > 1 * PyLong_SHIFT) {
7339
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
7340
__PYX_VERIFY_RETURN_INT(PY_LONG_LONG, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7341
} else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
7342
return (PY_LONG_LONG) (((PY_LONG_LONG)-1)*(((((PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[0])));
7343
}
7344
}
7345
break;
7346
case 2:
7347
if (8 * sizeof(PY_LONG_LONG) > 1 * PyLong_SHIFT) {
7348
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
7349
__PYX_VERIFY_RETURN_INT(PY_LONG_LONG, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7350
} else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
7351
return (PY_LONG_LONG) ((((((PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[0])));
7352
}
7353
}
7354
break;
7355
case -3:
7356
if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
7357
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
7358
__PYX_VERIFY_RETURN_INT(PY_LONG_LONG, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7359
} else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
7360
return (PY_LONG_LONG) (((PY_LONG_LONG)-1)*(((((((PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[0])));
7361
}
7362
}
7363
break;
7364
case 3:
7365
if (8 * sizeof(PY_LONG_LONG) > 2 * PyLong_SHIFT) {
7366
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
7367
__PYX_VERIFY_RETURN_INT(PY_LONG_LONG, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7368
} else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
7369
return (PY_LONG_LONG) ((((((((PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[0])));
7370
}
7371
}
7372
break;
7373
case -4:
7374
if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
7375
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
7376
__PYX_VERIFY_RETURN_INT(PY_LONG_LONG, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7377
} else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
7378
return (PY_LONG_LONG) (((PY_LONG_LONG)-1)*(((((((((PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[0])));
7379
}
7380
}
7381
break;
7382
case 4:
7383
if (8 * sizeof(PY_LONG_LONG) > 3 * PyLong_SHIFT) {
7384
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
7385
__PYX_VERIFY_RETURN_INT(PY_LONG_LONG, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7386
} else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
7387
return (PY_LONG_LONG) ((((((((((PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (PY_LONG_LONG)digits[0])));
7388
}
7389
}
7390
break;
7391
}
7392
#endif
7393
if (sizeof(PY_LONG_LONG) <= sizeof(long)) {
7394
__PYX_VERIFY_RETURN_INT_EXC(PY_LONG_LONG, long, PyLong_AsLong(x))
7395
#ifdef HAVE_LONG_LONG
7396
} else if (sizeof(PY_LONG_LONG) <= sizeof(PY_LONG_LONG)) {
7397
__PYX_VERIFY_RETURN_INT_EXC(PY_LONG_LONG, PY_LONG_LONG, PyLong_AsLongLong(x))
7398
#endif
7399
}
7400
}
7401
{
7402
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
7403
PyErr_SetString(PyExc_RuntimeError,
7404
"_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
7405
#else
7406
PY_LONG_LONG val;
7407
PyObject *v = __Pyx_PyNumber_IntOrLong(x);
7408
#if PY_MAJOR_VERSION < 3
7409
if (likely(v) && !PyLong_Check(v)) {
7410
PyObject *tmp = v;
7411
v = PyNumber_Long(tmp);
7412
Py_DECREF(tmp);
7413
}
7414
#endif
7415
if (likely(v)) {
7416
int one = 1; int is_little = (int)*(unsigned char *)&one;
7417
unsigned char *bytes = (unsigned char *)&val;
7418
int ret = _PyLong_AsByteArray((PyLongObject *)v,
7419
bytes, sizeof(val),
7420
is_little, !is_unsigned);
7421
Py_DECREF(v);
7422
if (likely(!ret))
7423
return val;
7424
}
7425
#endif
7426
return (PY_LONG_LONG) -1;
7427
}
7428
} else {
7429
PY_LONG_LONG val;
7430
PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
7431
if (!tmp) return (PY_LONG_LONG) -1;
7432
val = __Pyx_PyInt_As_PY_LONG_LONG(tmp);
7433
Py_DECREF(tmp);
7434
return val;
7435
}
7436
raise_overflow:
7437
PyErr_SetString(PyExc_OverflowError,
7438
"value too large to convert to PY_LONG_LONG");
7439
return (PY_LONG_LONG) -1;
7440
raise_neg_overflow:
7441
PyErr_SetString(PyExc_OverflowError,
7442
"can't convert negative value to PY_LONG_LONG");
7443
return (PY_LONG_LONG) -1;
7444
}
7445
7446
/* CIntFromPy */
7447
static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
7448
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
7449
#pragma GCC diagnostic push
7450
#pragma GCC diagnostic ignored "-Wconversion"
7451
#endif
7452
const long neg_one = (long) -1, const_zero = (long) 0;
7453
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
7454
#pragma GCC diagnostic pop
7455
#endif
7456
const int is_unsigned = neg_one > const_zero;
7457
#if PY_MAJOR_VERSION < 3
7458
if (likely(PyInt_Check(x))) {
7459
if (sizeof(long) < sizeof(long)) {
7460
__PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
7461
} else {
7462
long val = PyInt_AS_LONG(x);
7463
if (is_unsigned && unlikely(val < 0)) {
7464
goto raise_neg_overflow;
7465
}
7466
return (long) val;
7467
}
7468
} else
7469
#endif
7470
if (likely(PyLong_Check(x))) {
7471
if (is_unsigned) {
7472
#if CYTHON_USE_PYLONG_INTERNALS
7473
const digit* digits = ((PyLongObject*)x)->ob_digit;
7474
switch (Py_SIZE(x)) {
7475
case 0: return (long) 0;
7476
case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
7477
case 2:
7478
if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
7479
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
7480
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7481
} else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
7482
return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
7483
}
7484
}
7485
break;
7486
case 3:
7487
if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
7488
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
7489
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7490
} else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
7491
return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
7492
}
7493
}
7494
break;
7495
case 4:
7496
if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
7497
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
7498
__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])))
7499
} else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
7500
return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
7501
}
7502
}
7503
break;
7504
}
7505
#endif
7506
#if CYTHON_COMPILING_IN_CPYTHON
7507
if (unlikely(Py_SIZE(x) < 0)) {
7508
goto raise_neg_overflow;
7509
}
7510
#else
7511
{
7512
int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
7513
if (unlikely(result < 0))
7514
return (long) -1;
7515
if (unlikely(result == 1))
7516
goto raise_neg_overflow;
7517
}
7518
#endif
7519
if (sizeof(long) <= sizeof(unsigned long)) {
7520
__PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
7521
#ifdef HAVE_LONG_LONG
7522
} else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
7523
__PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
7524
#endif
7525
}
7526
} else {
7527
#if CYTHON_USE_PYLONG_INTERNALS
7528
const digit* digits = ((PyLongObject*)x)->ob_digit;
7529
switch (Py_SIZE(x)) {
7530
case 0: return (long) 0;
7531
case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
7532
case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
7533
case -2:
7534
if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
7535
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
7536
__PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7537
} else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
7538
return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
7539
}
7540
}
7541
break;
7542
case 2:
7543
if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
7544
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
7545
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7546
} else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
7547
return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
7548
}
7549
}
7550
break;
7551
case -3:
7552
if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
7553
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
7554
__PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7555
} else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
7556
return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
7557
}
7558
}
7559
break;
7560
case 3:
7561
if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
7562
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
7563
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7564
} else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
7565
return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
7566
}
7567
}
7568
break;
7569
case -4:
7570
if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
7571
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
7572
__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])))
7573
} else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
7574
return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
7575
}
7576
}
7577
break;
7578
case 4:
7579
if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
7580
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
7581
__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])))
7582
} else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
7583
return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
7584
}
7585
}
7586
break;
7587
}
7588
#endif
7589
if (sizeof(long) <= sizeof(long)) {
7590
__PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
7591
#ifdef HAVE_LONG_LONG
7592
} else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
7593
__PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
7594
#endif
7595
}
7596
}
7597
{
7598
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
7599
PyErr_SetString(PyExc_RuntimeError,
7600
"_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
7601
#else
7602
long val;
7603
PyObject *v = __Pyx_PyNumber_IntOrLong(x);
7604
#if PY_MAJOR_VERSION < 3
7605
if (likely(v) && !PyLong_Check(v)) {
7606
PyObject *tmp = v;
7607
v = PyNumber_Long(tmp);
7608
Py_DECREF(tmp);
7609
}
7610
#endif
7611
if (likely(v)) {
7612
int one = 1; int is_little = (int)*(unsigned char *)&one;
7613
unsigned char *bytes = (unsigned char *)&val;
7614
int ret = _PyLong_AsByteArray((PyLongObject *)v,
7615
bytes, sizeof(val),
7616
is_little, !is_unsigned);
7617
Py_DECREF(v);
7618
if (likely(!ret))
7619
return val;
7620
}
7621
#endif
7622
return (long) -1;
7623
}
7624
} else {
7625
long val;
7626
PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
7627
if (!tmp) return (long) -1;
7628
val = __Pyx_PyInt_As_long(tmp);
7629
Py_DECREF(tmp);
7630
return val;
7631
}
7632
raise_overflow:
7633
PyErr_SetString(PyExc_OverflowError,
7634
"value too large to convert to long");
7635
return (long) -1;
7636
raise_neg_overflow:
7637
PyErr_SetString(PyExc_OverflowError,
7638
"can't convert negative value to long");
7639
return (long) -1;
7640
}
7641
7642
/* CIntToPy */
7643
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
7644
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
7645
#pragma GCC diagnostic push
7646
#pragma GCC diagnostic ignored "-Wconversion"
7647
#endif
7648
const long neg_one = (long) -1, const_zero = (long) 0;
7649
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
7650
#pragma GCC diagnostic pop
7651
#endif
7652
const int is_unsigned = neg_one > const_zero;
7653
if (is_unsigned) {
7654
if (sizeof(long) < sizeof(long)) {
7655
return PyInt_FromLong((long) value);
7656
} else if (sizeof(long) <= sizeof(unsigned long)) {
7657
return PyLong_FromUnsignedLong((unsigned long) value);
7658
#ifdef HAVE_LONG_LONG
7659
} else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
7660
return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
7661
#endif
7662
}
7663
} else {
7664
if (sizeof(long) <= sizeof(long)) {
7665
return PyInt_FromLong((long) value);
7666
#ifdef HAVE_LONG_LONG
7667
} else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
7668
return PyLong_FromLongLong((PY_LONG_LONG) value);
7669
#endif
7670
}
7671
}
7672
{
7673
int one = 1; int little = (int)*(unsigned char *)&one;
7674
unsigned char *bytes = (unsigned char *)&value;
7675
return _PyLong_FromByteArray(bytes, sizeof(long),
7676
little, !is_unsigned);
7677
}
7678
}
7679
7680
/* CIntToPy */
7681
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_PY_LONG_LONG(PY_LONG_LONG value) {
7682
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
7683
#pragma GCC diagnostic push
7684
#pragma GCC diagnostic ignored "-Wconversion"
7685
#endif
7686
const PY_LONG_LONG neg_one = (PY_LONG_LONG) -1, const_zero = (PY_LONG_LONG) 0;
7687
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
7688
#pragma GCC diagnostic pop
7689
#endif
7690
const int is_unsigned = neg_one > const_zero;
7691
if (is_unsigned) {
7692
if (sizeof(PY_LONG_LONG) < sizeof(long)) {
7693
return PyInt_FromLong((long) value);
7694
} else if (sizeof(PY_LONG_LONG) <= sizeof(unsigned long)) {
7695
return PyLong_FromUnsignedLong((unsigned long) value);
7696
#ifdef HAVE_LONG_LONG
7697
} else if (sizeof(PY_LONG_LONG) <= sizeof(unsigned PY_LONG_LONG)) {
7698
return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
7699
#endif
7700
}
7701
} else {
7702
if (sizeof(PY_LONG_LONG) <= sizeof(long)) {
7703
return PyInt_FromLong((long) value);
7704
#ifdef HAVE_LONG_LONG
7705
} else if (sizeof(PY_LONG_LONG) <= sizeof(PY_LONG_LONG)) {
7706
return PyLong_FromLongLong((PY_LONG_LONG) value);
7707
#endif
7708
}
7709
}
7710
{
7711
int one = 1; int little = (int)*(unsigned char *)&one;
7712
unsigned char *bytes = (unsigned char *)&value;
7713
return _PyLong_FromByteArray(bytes, sizeof(PY_LONG_LONG),
7714
little, !is_unsigned);
7715
}
7716
}
7717
7718
/* FastTypeChecks */
7719
#if CYTHON_COMPILING_IN_CPYTHON
7720
static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
7721
while (a) {
7722
a = a->tp_base;
7723
if (a == b)
7724
return 1;
7725
}
7726
return b == &PyBaseObject_Type;
7727
}
7728
static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
7729
PyObject *mro;
7730
if (a == b) return 1;
7731
mro = a->tp_mro;
7732
if (likely(mro)) {
7733
Py_ssize_t i, n;
7734
n = PyTuple_GET_SIZE(mro);
7735
for (i = 0; i < n; i++) {
7736
if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
7737
return 1;
7738
}
7739
return 0;
7740
}
7741
return __Pyx_InBases(a, b);
7742
}
7743
#if PY_MAJOR_VERSION == 2
7744
static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
7745
PyObject *exception, *value, *tb;
7746
int res;
7747
__Pyx_PyThreadState_declare
7748
__Pyx_PyThreadState_assign
7749
__Pyx_ErrFetch(&exception, &value, &tb);
7750
res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
7751
if (unlikely(res == -1)) {
7752
PyErr_WriteUnraisable(err);
7753
res = 0;
7754
}
7755
if (!res) {
7756
res = PyObject_IsSubclass(err, exc_type2);
7757
if (unlikely(res == -1)) {
7758
PyErr_WriteUnraisable(err);
7759
res = 0;
7760
}
7761
}
7762
__Pyx_ErrRestore(exception, value, tb);
7763
return res;
7764
}
7765
#else
7766
static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
7767
int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
7768
if (!res) {
7769
res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
7770
}
7771
return res;
7772
}
7773
#endif
7774
static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
7775
Py_ssize_t i, n;
7776
assert(PyExceptionClass_Check(exc_type));
7777
n = PyTuple_GET_SIZE(tuple);
7778
#if PY_MAJOR_VERSION >= 3
7779
for (i=0; i<n; i++) {
7780
if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
7781
}
7782
#endif
7783
for (i=0; i<n; i++) {
7784
PyObject *t = PyTuple_GET_ITEM(tuple, i);
7785
#if PY_MAJOR_VERSION < 3
7786
if (likely(exc_type == t)) return 1;
7787
#endif
7788
if (likely(PyExceptionClass_Check(t))) {
7789
if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
7790
} else {
7791
}
7792
}
7793
return 0;
7794
}
7795
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
7796
if (likely(err == exc_type)) return 1;
7797
if (likely(PyExceptionClass_Check(err))) {
7798
if (likely(PyExceptionClass_Check(exc_type))) {
7799
return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
7800
} else if (likely(PyTuple_Check(exc_type))) {
7801
return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
7802
} else {
7803
}
7804
}
7805
return PyErr_GivenExceptionMatches(err, exc_type);
7806
}
7807
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
7808
assert(PyExceptionClass_Check(exc_type1));
7809
assert(PyExceptionClass_Check(exc_type2));
7810
if (likely(err == exc_type1 || err == exc_type2)) return 1;
7811
if (likely(PyExceptionClass_Check(err))) {
7812
return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
7813
}
7814
return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
7815
}
7816
#endif
7817
7818
/* CheckBinaryVersion */
7819
static int __Pyx_check_binary_version(void) {
7820
char ctversion[5];
7821
int same=1, i, found_dot;
7822
const char* rt_from_call = Py_GetVersion();
7823
PyOS_snprintf(ctversion, 5, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
7824
found_dot = 0;
7825
for (i = 0; i < 4; i++) {
7826
if (!ctversion[i]) {
7827
same = (rt_from_call[i] < '0' || rt_from_call[i] > '9');
7828
break;
7829
}
7830
if (rt_from_call[i] != ctversion[i]) {
7831
same = 0;
7832
break;
7833
}
7834
}
7835
if (!same) {
7836
char rtversion[5] = {'\0'};
7837
char message[200];
7838
for (i=0; i<4; ++i) {
7839
if (rt_from_call[i] == '.') {
7840
if (found_dot) break;
7841
found_dot = 1;
7842
} else if (rt_from_call[i] < '0' || rt_from_call[i] > '9') {
7843
break;
7844
}
7845
rtversion[i] = rt_from_call[i];
7846
}
7847
PyOS_snprintf(message, sizeof(message),
7848
"compiletime version %s of module '%.100s' "
7849
"does not match runtime version %s",
7850
ctversion, __Pyx_MODULE_NAME, rtversion);
7851
return PyErr_WarnEx(NULL, message, 1);
7852
}
7853
return 0;
7854
}
7855
7856
/* FunctionImport */
7857
#ifndef __PYX_HAVE_RT_ImportFunction
7858
#define __PYX_HAVE_RT_ImportFunction
7859
static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
7860
PyObject *d = 0;
7861
PyObject *cobj = 0;
7862
union {
7863
void (*fp)(void);
7864
void *p;
7865
} tmp;
7866
d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
7867
if (!d)
7868
goto bad;
7869
cobj = PyDict_GetItemString(d, funcname);
7870
if (!cobj) {
7871
PyErr_Format(PyExc_ImportError,
7872
"%.200s does not export expected C function %.200s",
7873
PyModule_GetName(module), funcname);
7874
goto bad;
7875
}
7876
#if PY_VERSION_HEX >= 0x02070000
7877
if (!PyCapsule_IsValid(cobj, sig)) {
7878
PyErr_Format(PyExc_TypeError,
7879
"C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
7880
PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj));
7881
goto bad;
7882
}
7883
tmp.p = PyCapsule_GetPointer(cobj, sig);
7884
#else
7885
{const char *desc, *s1, *s2;
7886
desc = (const char *)PyCObject_GetDesc(cobj);
7887
if (!desc)
7888
goto bad;
7889
s1 = desc; s2 = sig;
7890
while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
7891
if (*s1 != *s2) {
7892
PyErr_Format(PyExc_TypeError,
7893
"C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
7894
PyModule_GetName(module), funcname, sig, desc);
7895
goto bad;
7896
}
7897
tmp.p = PyCObject_AsVoidPtr(cobj);}
7898
#endif
7899
*f = tmp.fp;
7900
if (!(*f))
7901
goto bad;
7902
Py_DECREF(d);
7903
return 0;
7904
bad:
7905
Py_XDECREF(d);
7906
return -1;
7907
}
7908
#endif
7909
7910
/* InitStrings */
7911
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
7912
while (t->p) {
7913
#if PY_MAJOR_VERSION < 3
7914
if (t->is_unicode) {
7915
*t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
7916
} else if (t->intern) {
7917
*t->p = PyString_InternFromString(t->s);
7918
} else {
7919
*t->p = PyString_FromStringAndSize(t->s, t->n - 1);
7920
}
7921
#else
7922
if (t->is_unicode | t->is_str) {
7923
if (t->intern) {
7924
*t->p = PyUnicode_InternFromString(t->s);
7925
} else if (t->encoding) {
7926
*t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
7927
} else {
7928
*t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
7929
}
7930
} else {
7931
*t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
7932
}
7933
#endif
7934
if (!*t->p)
7935
return -1;
7936
if (PyObject_Hash(*t->p) == -1)
7937
return -1;
7938
++t;
7939
}
7940
return 0;
7941
}
7942
7943
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
7944
return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
7945
}
7946
static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
7947
Py_ssize_t ignore;
7948
return __Pyx_PyObject_AsStringAndSize(o, &ignore);
7949
}
7950
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
7951
#if !CYTHON_PEP393_ENABLED
7952
static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
7953
char* defenc_c;
7954
PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
7955
if (!defenc) return NULL;
7956
defenc_c = PyBytes_AS_STRING(defenc);
7957
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
7958
{
7959
char* end = defenc_c + PyBytes_GET_SIZE(defenc);
7960
char* c;
7961
for (c = defenc_c; c < end; c++) {
7962
if ((unsigned char) (*c) >= 128) {
7963
PyUnicode_AsASCIIString(o);
7964
return NULL;
7965
}
7966
}
7967
}
7968
#endif
7969
*length = PyBytes_GET_SIZE(defenc);
7970
return defenc_c;
7971
}
7972
#else
7973
static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
7974
if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
7975
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
7976
if (likely(PyUnicode_IS_ASCII(o))) {
7977
*length = PyUnicode_GET_LENGTH(o);
7978
return PyUnicode_AsUTF8(o);
7979
} else {
7980
PyUnicode_AsASCIIString(o);
7981
return NULL;
7982
}
7983
#else
7984
return PyUnicode_AsUTF8AndSize(o, length);
7985
#endif
7986
}
7987
#endif
7988
#endif
7989
static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
7990
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
7991
if (
7992
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
7993
__Pyx_sys_getdefaultencoding_not_ascii &&
7994
#endif
7995
PyUnicode_Check(o)) {
7996
return __Pyx_PyUnicode_AsStringAndSize(o, length);
7997
} else
7998
#endif
7999
#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
8000
if (PyByteArray_Check(o)) {
8001
*length = PyByteArray_GET_SIZE(o);
8002
return PyByteArray_AS_STRING(o);
8003
} else
8004
#endif
8005
{
8006
char* result;
8007
int r = PyBytes_AsStringAndSize(o, &result, length);
8008
if (unlikely(r < 0)) {
8009
return NULL;
8010
} else {
8011
return result;
8012
}
8013
}
8014
}
8015
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
8016
int is_true = x == Py_True;
8017
if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
8018
else return PyObject_IsTrue(x);
8019
}
8020
static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
8021
int retval;
8022
if (unlikely(!x)) return -1;
8023
retval = __Pyx_PyObject_IsTrue(x);
8024
Py_DECREF(x);
8025
return retval;
8026
}
8027
static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
8028
#if PY_MAJOR_VERSION >= 3
8029
if (PyLong_Check(result)) {
8030
if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
8031
"__int__ returned non-int (type %.200s). "
8032
"The ability to return an instance of a strict subclass of int "
8033
"is deprecated, and may be removed in a future version of Python.",
8034
Py_TYPE(result)->tp_name)) {
8035
Py_DECREF(result);
8036
return NULL;
8037
}
8038
return result;
8039
}
8040
#endif
8041
PyErr_Format(PyExc_TypeError,
8042
"__%.4s__ returned non-%.4s (type %.200s)",
8043
type_name, type_name, Py_TYPE(result)->tp_name);
8044
Py_DECREF(result);
8045
return NULL;
8046
}
8047
static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
8048
#if CYTHON_USE_TYPE_SLOTS
8049
PyNumberMethods *m;
8050
#endif
8051
const char *name = NULL;
8052
PyObject *res = NULL;
8053
#if PY_MAJOR_VERSION < 3
8054
if (likely(PyInt_Check(x) || PyLong_Check(x)))
8055
#else
8056
if (likely(PyLong_Check(x)))
8057
#endif
8058
return __Pyx_NewRef(x);
8059
#if CYTHON_USE_TYPE_SLOTS
8060
m = Py_TYPE(x)->tp_as_number;
8061
#if PY_MAJOR_VERSION < 3
8062
if (m && m->nb_int) {
8063
name = "int";
8064
res = m->nb_int(x);
8065
}
8066
else if (m && m->nb_long) {
8067
name = "long";
8068
res = m->nb_long(x);
8069
}
8070
#else
8071
if (likely(m && m->nb_int)) {
8072
name = "int";
8073
res = m->nb_int(x);
8074
}
8075
#endif
8076
#else
8077
if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
8078
res = PyNumber_Int(x);
8079
}
8080
#endif
8081
if (likely(res)) {
8082
#if PY_MAJOR_VERSION < 3
8083
if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
8084
#else
8085
if (unlikely(!PyLong_CheckExact(res))) {
8086
#endif
8087
return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
8088
}
8089
}
8090
else if (!PyErr_Occurred()) {
8091
PyErr_SetString(PyExc_TypeError,
8092
"an integer is required");
8093
}
8094
return res;
8095
}
8096
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
8097
Py_ssize_t ival;
8098
PyObject *x;
8099
#if PY_MAJOR_VERSION < 3
8100
if (likely(PyInt_CheckExact(b))) {
8101
if (sizeof(Py_ssize_t) >= sizeof(long))
8102
return PyInt_AS_LONG(b);
8103
else
8104
return PyInt_AsSsize_t(b);
8105
}
8106
#endif
8107
if (likely(PyLong_CheckExact(b))) {
8108
#if CYTHON_USE_PYLONG_INTERNALS
8109
const digit* digits = ((PyLongObject*)b)->ob_digit;
8110
const Py_ssize_t size = Py_SIZE(b);
8111
if (likely(__Pyx_sst_abs(size) <= 1)) {
8112
ival = likely(size) ? digits[0] : 0;
8113
if (size == -1) ival = -ival;
8114
return ival;
8115
} else {
8116
switch (size) {
8117
case 2:
8118
if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
8119
return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
8120
}
8121
break;
8122
case -2:
8123
if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
8124
return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
8125
}
8126
break;
8127
case 3:
8128
if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
8129
return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
8130
}
8131
break;
8132
case -3:
8133
if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
8134
return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
8135
}
8136
break;
8137
case 4:
8138
if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
8139
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]));
8140
}
8141
break;
8142
case -4:
8143
if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
8144
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]));
8145
}
8146
break;
8147
}
8148
}
8149
#endif
8150
return PyLong_AsSsize_t(b);
8151
}
8152
x = PyNumber_Index(b);
8153
if (!x) return -1;
8154
ival = PyInt_AsSsize_t(x);
8155
Py_DECREF(x);
8156
return ival;
8157
}
8158
static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject* o) {
8159
if (sizeof(Py_hash_t) == sizeof(Py_ssize_t)) {
8160
return (Py_hash_t) __Pyx_PyIndex_AsSsize_t(o);
8161
#if PY_MAJOR_VERSION < 3
8162
} else if (likely(PyInt_CheckExact(o))) {
8163
return PyInt_AS_LONG(o);
8164
#endif
8165
} else {
8166
Py_ssize_t ival;
8167
PyObject *x;
8168
x = PyNumber_Index(o);
8169
if (!x) return -1;
8170
ival = PyInt_AsLong(x);
8171
Py_DECREF(x);
8172
return ival;
8173
}
8174
}
8175
static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
8176
return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
8177
}
8178
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
8179
return PyInt_FromSize_t(ival);
8180
}
8181
8182
8183
#endif /* Py_PYTHON_H */
8184
8185