Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ethen8181
GitHub Repository: ethen8181/machine-learning
Path: blob/master/python/cython/helloworld.c
2574 views
1
/* Generated by Cython 0.25.2 */
2
3
/* BEGIN: Cython Metadata
4
{
5
"distutils": {},
6
"module_name": "helloworld"
7
}
8
END: Cython Metadata */
9
10
#define PY_SSIZE_T_CLEAN
11
#include "Python.h"
12
#ifndef Py_PYTHON_H
13
#error Python headers needed to compile C extensions, please install development version of Python.
14
#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000)
15
#error Cython requires Python 2.6+ or Python 3.2+.
16
#else
17
#define CYTHON_ABI "0_25_2"
18
#include <stddef.h>
19
#ifndef offsetof
20
#define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
21
#endif
22
#if !defined(WIN32) && !defined(MS_WINDOWS)
23
#ifndef __stdcall
24
#define __stdcall
25
#endif
26
#ifndef __cdecl
27
#define __cdecl
28
#endif
29
#ifndef __fastcall
30
#define __fastcall
31
#endif
32
#endif
33
#ifndef DL_IMPORT
34
#define DL_IMPORT(t) t
35
#endif
36
#ifndef DL_EXPORT
37
#define DL_EXPORT(t) t
38
#endif
39
#ifndef HAVE_LONG_LONG
40
#if PY_VERSION_HEX >= 0x03030000 || (PY_MAJOR_VERSION == 2 && PY_VERSION_HEX >= 0x02070000)
41
#define HAVE_LONG_LONG
42
#endif
43
#endif
44
#ifndef PY_LONG_LONG
45
#define PY_LONG_LONG LONG_LONG
46
#endif
47
#ifndef Py_HUGE_VAL
48
#define Py_HUGE_VAL HUGE_VAL
49
#endif
50
#ifdef PYPY_VERSION
51
#define CYTHON_COMPILING_IN_PYPY 1
52
#define CYTHON_COMPILING_IN_PYSTON 0
53
#define CYTHON_COMPILING_IN_CPYTHON 0
54
#undef CYTHON_USE_TYPE_SLOTS
55
#define CYTHON_USE_TYPE_SLOTS 0
56
#undef CYTHON_USE_ASYNC_SLOTS
57
#define CYTHON_USE_ASYNC_SLOTS 0
58
#undef CYTHON_USE_PYLIST_INTERNALS
59
#define CYTHON_USE_PYLIST_INTERNALS 0
60
#undef CYTHON_USE_UNICODE_INTERNALS
61
#define CYTHON_USE_UNICODE_INTERNALS 0
62
#undef CYTHON_USE_UNICODE_WRITER
63
#define CYTHON_USE_UNICODE_WRITER 0
64
#undef CYTHON_USE_PYLONG_INTERNALS
65
#define CYTHON_USE_PYLONG_INTERNALS 0
66
#undef CYTHON_AVOID_BORROWED_REFS
67
#define CYTHON_AVOID_BORROWED_REFS 1
68
#undef CYTHON_ASSUME_SAFE_MACROS
69
#define CYTHON_ASSUME_SAFE_MACROS 0
70
#undef CYTHON_UNPACK_METHODS
71
#define CYTHON_UNPACK_METHODS 0
72
#undef CYTHON_FAST_THREAD_STATE
73
#define CYTHON_FAST_THREAD_STATE 0
74
#undef CYTHON_FAST_PYCALL
75
#define CYTHON_FAST_PYCALL 0
76
#elif defined(PYSTON_VERSION)
77
#define CYTHON_COMPILING_IN_PYPY 0
78
#define CYTHON_COMPILING_IN_PYSTON 1
79
#define CYTHON_COMPILING_IN_CPYTHON 0
80
#ifndef CYTHON_USE_TYPE_SLOTS
81
#define CYTHON_USE_TYPE_SLOTS 1
82
#endif
83
#undef CYTHON_USE_ASYNC_SLOTS
84
#define CYTHON_USE_ASYNC_SLOTS 0
85
#undef CYTHON_USE_PYLIST_INTERNALS
86
#define CYTHON_USE_PYLIST_INTERNALS 0
87
#ifndef CYTHON_USE_UNICODE_INTERNALS
88
#define CYTHON_USE_UNICODE_INTERNALS 1
89
#endif
90
#undef CYTHON_USE_UNICODE_WRITER
91
#define CYTHON_USE_UNICODE_WRITER 0
92
#undef CYTHON_USE_PYLONG_INTERNALS
93
#define CYTHON_USE_PYLONG_INTERNALS 0
94
#ifndef CYTHON_AVOID_BORROWED_REFS
95
#define CYTHON_AVOID_BORROWED_REFS 0
96
#endif
97
#ifndef CYTHON_ASSUME_SAFE_MACROS
98
#define CYTHON_ASSUME_SAFE_MACROS 1
99
#endif
100
#ifndef CYTHON_UNPACK_METHODS
101
#define CYTHON_UNPACK_METHODS 1
102
#endif
103
#undef CYTHON_FAST_THREAD_STATE
104
#define CYTHON_FAST_THREAD_STATE 0
105
#undef CYTHON_FAST_PYCALL
106
#define CYTHON_FAST_PYCALL 0
107
#else
108
#define CYTHON_COMPILING_IN_PYPY 0
109
#define CYTHON_COMPILING_IN_PYSTON 0
110
#define CYTHON_COMPILING_IN_CPYTHON 1
111
#ifndef CYTHON_USE_TYPE_SLOTS
112
#define CYTHON_USE_TYPE_SLOTS 1
113
#endif
114
#if PY_MAJOR_VERSION < 3
115
#undef CYTHON_USE_ASYNC_SLOTS
116
#define CYTHON_USE_ASYNC_SLOTS 0
117
#elif !defined(CYTHON_USE_ASYNC_SLOTS)
118
#define CYTHON_USE_ASYNC_SLOTS 1
119
#endif
120
#if PY_VERSION_HEX < 0x02070000
121
#undef CYTHON_USE_PYLONG_INTERNALS
122
#define CYTHON_USE_PYLONG_INTERNALS 0
123
#elif !defined(CYTHON_USE_PYLONG_INTERNALS)
124
#define CYTHON_USE_PYLONG_INTERNALS 1
125
#endif
126
#ifndef CYTHON_USE_PYLIST_INTERNALS
127
#define CYTHON_USE_PYLIST_INTERNALS 1
128
#endif
129
#ifndef CYTHON_USE_UNICODE_INTERNALS
130
#define CYTHON_USE_UNICODE_INTERNALS 1
131
#endif
132
#if PY_VERSION_HEX < 0x030300F0
133
#undef CYTHON_USE_UNICODE_WRITER
134
#define CYTHON_USE_UNICODE_WRITER 0
135
#elif !defined(CYTHON_USE_UNICODE_WRITER)
136
#define CYTHON_USE_UNICODE_WRITER 1
137
#endif
138
#ifndef CYTHON_AVOID_BORROWED_REFS
139
#define CYTHON_AVOID_BORROWED_REFS 0
140
#endif
141
#ifndef CYTHON_ASSUME_SAFE_MACROS
142
#define CYTHON_ASSUME_SAFE_MACROS 1
143
#endif
144
#ifndef CYTHON_UNPACK_METHODS
145
#define CYTHON_UNPACK_METHODS 1
146
#endif
147
#ifndef CYTHON_FAST_THREAD_STATE
148
#define CYTHON_FAST_THREAD_STATE 1
149
#endif
150
#ifndef CYTHON_FAST_PYCALL
151
#define CYTHON_FAST_PYCALL 1
152
#endif
153
#endif
154
#if !defined(CYTHON_FAST_PYCCALL)
155
#define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
156
#endif
157
#if CYTHON_USE_PYLONG_INTERNALS
158
#include "longintrepr.h"
159
#undef SHIFT
160
#undef BASE
161
#undef MASK
162
#endif
163
#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
164
#define Py_OptimizeFlag 0
165
#endif
166
#define __PYX_BUILD_PY_SSIZE_T "n"
167
#define CYTHON_FORMAT_SSIZE_T "z"
168
#if PY_MAJOR_VERSION < 3
169
#define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
170
#define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
171
PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
172
#define __Pyx_DefaultClassType PyClass_Type
173
#else
174
#define __Pyx_BUILTIN_MODULE_NAME "builtins"
175
#define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
176
PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
177
#define __Pyx_DefaultClassType PyType_Type
178
#endif
179
#ifndef Py_TPFLAGS_CHECKTYPES
180
#define Py_TPFLAGS_CHECKTYPES 0
181
#endif
182
#ifndef Py_TPFLAGS_HAVE_INDEX
183
#define Py_TPFLAGS_HAVE_INDEX 0
184
#endif
185
#ifndef Py_TPFLAGS_HAVE_NEWBUFFER
186
#define Py_TPFLAGS_HAVE_NEWBUFFER 0
187
#endif
188
#ifndef Py_TPFLAGS_HAVE_FINALIZE
189
#define Py_TPFLAGS_HAVE_FINALIZE 0
190
#endif
191
#ifndef METH_FASTCALL
192
#define METH_FASTCALL 0x80
193
typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject **args,
194
Py_ssize_t nargs, PyObject *kwnames);
195
#else
196
#define __Pyx_PyCFunctionFast _PyCFunctionFast
197
#endif
198
#if CYTHON_FAST_PYCCALL
199
#define __Pyx_PyFastCFunction_Check(func)\
200
((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST)))))
201
#else
202
#define __Pyx_PyFastCFunction_Check(func) 0
203
#endif
204
#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
205
#define CYTHON_PEP393_ENABLED 1
206
#define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
207
0 : _PyUnicode_Ready((PyObject *)(op)))
208
#define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
209
#define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
210
#define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
211
#define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
212
#define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
213
#define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
214
#define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch)
215
#define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
216
#else
217
#define CYTHON_PEP393_ENABLED 0
218
#define PyUnicode_1BYTE_KIND 1
219
#define PyUnicode_2BYTE_KIND 2
220
#define PyUnicode_4BYTE_KIND 4
221
#define __Pyx_PyUnicode_READY(op) (0)
222
#define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
223
#define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
224
#define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
225
#define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
226
#define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
227
#define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
228
#define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
229
#define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u))
230
#endif
231
#if CYTHON_COMPILING_IN_PYPY
232
#define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
233
#define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
234
#else
235
#define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
236
#define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
237
PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
238
#endif
239
#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
240
#define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
241
#endif
242
#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
243
#define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
244
#endif
245
#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
246
#define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
247
#endif
248
#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
249
#define PyObject_Malloc(s) PyMem_Malloc(s)
250
#define PyObject_Free(p) PyMem_Free(p)
251
#define PyObject_Realloc(p) PyMem_Realloc(p)
252
#endif
253
#if CYTHON_COMPILING_IN_PYSTON
254
#define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co)
255
#define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
256
#else
257
#define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
258
#define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
259
#endif
260
#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
261
#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
262
#if PY_MAJOR_VERSION >= 3
263
#define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
264
#else
265
#define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
266
#endif
267
#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
268
#define PyObject_ASCII(o) PyObject_Repr(o)
269
#endif
270
#if PY_MAJOR_VERSION >= 3
271
#define PyBaseString_Type PyUnicode_Type
272
#define PyStringObject PyUnicodeObject
273
#define PyString_Type PyUnicode_Type
274
#define PyString_Check PyUnicode_Check
275
#define PyString_CheckExact PyUnicode_CheckExact
276
#endif
277
#if PY_MAJOR_VERSION >= 3
278
#define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
279
#define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
280
#else
281
#define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
282
#define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
283
#endif
284
#ifndef PySet_CheckExact
285
#define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
286
#endif
287
#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
288
#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
289
#if PY_MAJOR_VERSION >= 3
290
#define PyIntObject PyLongObject
291
#define PyInt_Type PyLong_Type
292
#define PyInt_Check(op) PyLong_Check(op)
293
#define PyInt_CheckExact(op) PyLong_CheckExact(op)
294
#define PyInt_FromString PyLong_FromString
295
#define PyInt_FromUnicode PyLong_FromUnicode
296
#define PyInt_FromLong PyLong_FromLong
297
#define PyInt_FromSize_t PyLong_FromSize_t
298
#define PyInt_FromSsize_t PyLong_FromSsize_t
299
#define PyInt_AsLong PyLong_AsLong
300
#define PyInt_AS_LONG PyLong_AS_LONG
301
#define PyInt_AsSsize_t PyLong_AsSsize_t
302
#define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
303
#define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
304
#define PyNumber_Int PyNumber_Long
305
#endif
306
#if PY_MAJOR_VERSION >= 3
307
#define PyBoolObject PyLongObject
308
#endif
309
#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
310
#ifndef PyUnicode_InternFromString
311
#define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
312
#endif
313
#endif
314
#if PY_VERSION_HEX < 0x030200A4
315
typedef long Py_hash_t;
316
#define __Pyx_PyInt_FromHash_t PyInt_FromLong
317
#define __Pyx_PyInt_AsHash_t PyInt_AsLong
318
#else
319
#define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
320
#define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
321
#endif
322
#if PY_MAJOR_VERSION >= 3
323
#define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
324
#else
325
#define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
326
#endif
327
#if CYTHON_USE_ASYNC_SLOTS
328
#if PY_VERSION_HEX >= 0x030500B1
329
#define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
330
#define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
331
#else
332
typedef struct {
333
unaryfunc am_await;
334
unaryfunc am_aiter;
335
unaryfunc am_anext;
336
} __Pyx_PyAsyncMethodsStruct;
337
#define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
338
#endif
339
#else
340
#define __Pyx_PyType_AsAsync(obj) NULL
341
#endif
342
#ifndef CYTHON_RESTRICT
343
#if defined(__GNUC__)
344
#define CYTHON_RESTRICT __restrict__
345
#elif defined(_MSC_VER) && _MSC_VER >= 1400
346
#define CYTHON_RESTRICT __restrict
347
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
348
#define CYTHON_RESTRICT restrict
349
#else
350
#define CYTHON_RESTRICT
351
#endif
352
#endif
353
#ifndef CYTHON_UNUSED
354
# if defined(__GNUC__)
355
# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
356
# define CYTHON_UNUSED __attribute__ ((__unused__))
357
# else
358
# define CYTHON_UNUSED
359
# endif
360
# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
361
# define CYTHON_UNUSED __attribute__ ((__unused__))
362
# else
363
# define CYTHON_UNUSED
364
# endif
365
#endif
366
#ifndef CYTHON_MAYBE_UNUSED_VAR
367
# if defined(__cplusplus)
368
template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
369
# else
370
# define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
371
# endif
372
#endif
373
#ifndef CYTHON_NCP_UNUSED
374
# if CYTHON_COMPILING_IN_CPYTHON
375
# define CYTHON_NCP_UNUSED
376
# else
377
# define CYTHON_NCP_UNUSED CYTHON_UNUSED
378
# endif
379
#endif
380
#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
381
382
#ifndef CYTHON_INLINE
383
#if defined(__clang__)
384
#define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
385
#elif defined(__GNUC__)
386
#define CYTHON_INLINE __inline__
387
#elif defined(_MSC_VER)
388
#define CYTHON_INLINE __inline
389
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
390
#define CYTHON_INLINE inline
391
#else
392
#define CYTHON_INLINE
393
#endif
394
#endif
395
396
#if defined(WIN32) || defined(MS_WINDOWS)
397
#define _USE_MATH_DEFINES
398
#endif
399
#include <math.h>
400
#ifdef NAN
401
#define __PYX_NAN() ((float) NAN)
402
#else
403
static CYTHON_INLINE float __PYX_NAN() {
404
float value;
405
memset(&value, 0xFF, sizeof(value));
406
return value;
407
}
408
#endif
409
#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
410
#define __Pyx_truncl trunc
411
#else
412
#define __Pyx_truncl truncl
413
#endif
414
415
416
#define __PYX_ERR(f_index, lineno, Ln_error) \
417
{ \
418
__pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \
419
}
420
421
#if PY_MAJOR_VERSION >= 3
422
#define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
423
#define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
424
#else
425
#define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
426
#define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
427
#endif
428
429
#ifndef __PYX_EXTERN_C
430
#ifdef __cplusplus
431
#define __PYX_EXTERN_C extern "C"
432
#else
433
#define __PYX_EXTERN_C extern
434
#endif
435
#endif
436
437
#define __PYX_HAVE__helloworld
438
#define __PYX_HAVE_API__helloworld
439
#ifdef _OPENMP
440
#include <omp.h>
441
#endif /* _OPENMP */
442
443
#ifdef PYREX_WITHOUT_ASSERTIONS
444
#define CYTHON_WITHOUT_ASSERTIONS
445
#endif
446
447
typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
448
const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
449
450
#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
451
#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
452
#define __PYX_DEFAULT_STRING_ENCODING ""
453
#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
454
#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
455
#define __Pyx_uchar_cast(c) ((unsigned char)c)
456
#define __Pyx_long_cast(x) ((long)x)
457
#define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
458
(sizeof(type) < sizeof(Py_ssize_t)) ||\
459
(sizeof(type) > sizeof(Py_ssize_t) &&\
460
likely(v < (type)PY_SSIZE_T_MAX ||\
461
v == (type)PY_SSIZE_T_MAX) &&\
462
(!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
463
v == (type)PY_SSIZE_T_MIN))) ||\
464
(sizeof(type) == sizeof(Py_ssize_t) &&\
465
(is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
466
v == (type)PY_SSIZE_T_MAX))) )
467
#if defined (__cplusplus) && __cplusplus >= 201103L
468
#include <cstdlib>
469
#define __Pyx_sst_abs(value) std::abs(value)
470
#elif SIZEOF_INT >= SIZEOF_SIZE_T
471
#define __Pyx_sst_abs(value) abs(value)
472
#elif SIZEOF_LONG >= SIZEOF_SIZE_T
473
#define __Pyx_sst_abs(value) labs(value)
474
#elif defined (_MSC_VER) && defined (_M_X64)
475
#define __Pyx_sst_abs(value) _abs64(value)
476
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
477
#define __Pyx_sst_abs(value) llabs(value)
478
#elif defined (__GNUC__)
479
#define __Pyx_sst_abs(value) __builtin_llabs(value)
480
#else
481
#define __Pyx_sst_abs(value) ((value<0) ? -value : value)
482
#endif
483
static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*);
484
static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
485
#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
486
#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
487
#define __Pyx_PyBytes_FromString PyBytes_FromString
488
#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
489
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
490
#if PY_MAJOR_VERSION < 3
491
#define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
492
#define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
493
#else
494
#define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
495
#define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
496
#endif
497
#define __Pyx_PyObject_AsSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
498
#define __Pyx_PyObject_AsUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
499
#define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
500
#define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
501
#define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
502
#define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s)
503
#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
504
#if PY_MAJOR_VERSION < 3
505
static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u)
506
{
507
const Py_UNICODE *u_end = u;
508
while (*u_end++) ;
509
return (size_t)(u_end - u - 1);
510
}
511
#else
512
#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen
513
#endif
514
#define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
515
#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
516
#define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
517
#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
518
#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
519
#define __Pyx_PyBool_FromLong(b) ((b) ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False))
520
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
521
static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
522
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
523
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
524
#if CYTHON_ASSUME_SAFE_MACROS
525
#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
526
#else
527
#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
528
#endif
529
#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
530
#if PY_MAJOR_VERSION >= 3
531
#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
532
#else
533
#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
534
#endif
535
#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
536
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
537
static int __Pyx_sys_getdefaultencoding_not_ascii;
538
static int __Pyx_init_sys_getdefaultencoding_params(void) {
539
PyObject* sys;
540
PyObject* default_encoding = NULL;
541
PyObject* ascii_chars_u = NULL;
542
PyObject* ascii_chars_b = NULL;
543
const char* default_encoding_c;
544
sys = PyImport_ImportModule("sys");
545
if (!sys) goto bad;
546
default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
547
Py_DECREF(sys);
548
if (!default_encoding) goto bad;
549
default_encoding_c = PyBytes_AsString(default_encoding);
550
if (!default_encoding_c) goto bad;
551
if (strcmp(default_encoding_c, "ascii") == 0) {
552
__Pyx_sys_getdefaultencoding_not_ascii = 0;
553
} else {
554
char ascii_chars[128];
555
int c;
556
for (c = 0; c < 128; c++) {
557
ascii_chars[c] = c;
558
}
559
__Pyx_sys_getdefaultencoding_not_ascii = 1;
560
ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
561
if (!ascii_chars_u) goto bad;
562
ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
563
if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
564
PyErr_Format(
565
PyExc_ValueError,
566
"This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
567
default_encoding_c);
568
goto bad;
569
}
570
Py_DECREF(ascii_chars_u);
571
Py_DECREF(ascii_chars_b);
572
}
573
Py_DECREF(default_encoding);
574
return 0;
575
bad:
576
Py_XDECREF(default_encoding);
577
Py_XDECREF(ascii_chars_u);
578
Py_XDECREF(ascii_chars_b);
579
return -1;
580
}
581
#endif
582
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
583
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
584
#else
585
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
586
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
587
static char* __PYX_DEFAULT_STRING_ENCODING;
588
static int __Pyx_init_sys_getdefaultencoding_params(void) {
589
PyObject* sys;
590
PyObject* default_encoding = NULL;
591
char* default_encoding_c;
592
sys = PyImport_ImportModule("sys");
593
if (!sys) goto bad;
594
default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
595
Py_DECREF(sys);
596
if (!default_encoding) goto bad;
597
default_encoding_c = PyBytes_AsString(default_encoding);
598
if (!default_encoding_c) goto bad;
599
__PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c));
600
if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
601
strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
602
Py_DECREF(default_encoding);
603
return 0;
604
bad:
605
Py_XDECREF(default_encoding);
606
return -1;
607
}
608
#endif
609
#endif
610
611
612
/* Test for GCC > 2.95 */
613
#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
614
#define likely(x) __builtin_expect(!!(x), 1)
615
#define unlikely(x) __builtin_expect(!!(x), 0)
616
#else /* !__GNUC__ or GCC < 2.95 */
617
#define likely(x) (x)
618
#define unlikely(x) (x)
619
#endif /* __GNUC__ */
620
621
static PyObject *__pyx_m;
622
static PyObject *__pyx_d;
623
static PyObject *__pyx_b;
624
static PyObject *__pyx_empty_tuple;
625
static PyObject *__pyx_empty_bytes;
626
static PyObject *__pyx_empty_unicode;
627
static int __pyx_lineno;
628
static int __pyx_clineno = 0;
629
static const char * __pyx_cfilenm= __FILE__;
630
static const char *__pyx_filename;
631
632
633
static const char *__pyx_f[] = {
634
"helloworld.pyx",
635
};
636
637
/*--- Type declarations ---*/
638
639
/* --- Runtime support code (head) --- */
640
/* Refnanny.proto */
641
#ifndef CYTHON_REFNANNY
642
#define CYTHON_REFNANNY 0
643
#endif
644
#if CYTHON_REFNANNY
645
typedef struct {
646
void (*INCREF)(void*, PyObject*, int);
647
void (*DECREF)(void*, PyObject*, int);
648
void (*GOTREF)(void*, PyObject*, int);
649
void (*GIVEREF)(void*, PyObject*, int);
650
void* (*SetupContext)(const char*, int, const char*);
651
void (*FinishContext)(void**);
652
} __Pyx_RefNannyAPIStruct;
653
static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
654
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
655
#define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
656
#ifdef WITH_THREAD
657
#define __Pyx_RefNannySetupContext(name, acquire_gil)\
658
if (acquire_gil) {\
659
PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
660
__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
661
PyGILState_Release(__pyx_gilstate_save);\
662
} else {\
663
__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
664
}
665
#else
666
#define __Pyx_RefNannySetupContext(name, acquire_gil)\
667
__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
668
#endif
669
#define __Pyx_RefNannyFinishContext()\
670
__Pyx_RefNanny->FinishContext(&__pyx_refnanny)
671
#define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
672
#define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
673
#define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
674
#define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
675
#define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
676
#define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
677
#define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
678
#define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
679
#else
680
#define __Pyx_RefNannyDeclarations
681
#define __Pyx_RefNannySetupContext(name, acquire_gil)
682
#define __Pyx_RefNannyFinishContext()
683
#define __Pyx_INCREF(r) Py_INCREF(r)
684
#define __Pyx_DECREF(r) Py_DECREF(r)
685
#define __Pyx_GOTREF(r)
686
#define __Pyx_GIVEREF(r)
687
#define __Pyx_XINCREF(r) Py_XINCREF(r)
688
#define __Pyx_XDECREF(r) Py_XDECREF(r)
689
#define __Pyx_XGOTREF(r)
690
#define __Pyx_XGIVEREF(r)
691
#endif
692
#define __Pyx_XDECREF_SET(r, v) do {\
693
PyObject *tmp = (PyObject *) r;\
694
r = v; __Pyx_XDECREF(tmp);\
695
} while (0)
696
#define __Pyx_DECREF_SET(r, v) do {\
697
PyObject *tmp = (PyObject *) r;\
698
r = v; __Pyx_DECREF(tmp);\
699
} while (0)
700
#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
701
#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
702
703
/* CodeObjectCache.proto */
704
typedef struct {
705
PyCodeObject* code_object;
706
int code_line;
707
} __Pyx_CodeObjectCacheEntry;
708
struct __Pyx_CodeObjectCache {
709
int count;
710
int max_count;
711
__Pyx_CodeObjectCacheEntry* entries;
712
};
713
static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
714
static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
715
static PyCodeObject *__pyx_find_code_object(int code_line);
716
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
717
718
/* AddTraceback.proto */
719
static void __Pyx_AddTraceback(const char *funcname, int c_line,
720
int py_line, const char *filename);
721
722
/* Print.proto */
723
static int __Pyx_Print(PyObject*, PyObject *, int);
724
#if CYTHON_COMPILING_IN_PYPY || PY_MAJOR_VERSION >= 3
725
static PyObject* __pyx_print = 0;
726
static PyObject* __pyx_print_kwargs = 0;
727
#endif
728
729
/* PrintOne.proto */
730
static int __Pyx_PrintOne(PyObject* stream, PyObject *o);
731
732
/* CIntToPy.proto */
733
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
734
735
/* CIntFromPy.proto */
736
static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
737
738
/* CIntFromPy.proto */
739
static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
740
741
/* CheckBinaryVersion.proto */
742
static int __Pyx_check_binary_version(void);
743
744
/* InitStrings.proto */
745
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
746
747
748
/* Module declarations from 'helloworld' */
749
#define __Pyx_MODULE_NAME "helloworld"
750
int __pyx_module_is_main_helloworld = 0;
751
752
/* Implementation of 'helloworld' */
753
static const char __pyx_k_end[] = "end";
754
static const char __pyx_k_file[] = "file";
755
static const char __pyx_k_main[] = "__main__";
756
static const char __pyx_k_test[] = "__test__";
757
static const char __pyx_k_hello[] = "hello";
758
static const char __pyx_k_print[] = "print";
759
static const char __pyx_k_helloworld[] = "helloworld";
760
static const char __pyx_k_Hello_World[] = "Hello, World!";
761
static const char __pyx_k_Users_ethen_machine_learning_py[] = "/Users/ethen/machine-learning/python/cython/helloworld.pyx";
762
static PyObject *__pyx_kp_s_Hello_World;
763
static PyObject *__pyx_kp_s_Users_ethen_machine_learning_py;
764
static PyObject *__pyx_n_s_end;
765
static PyObject *__pyx_n_s_file;
766
static PyObject *__pyx_n_s_hello;
767
static PyObject *__pyx_n_s_helloworld;
768
static PyObject *__pyx_n_s_main;
769
static PyObject *__pyx_n_s_print;
770
static PyObject *__pyx_n_s_test;
771
static PyObject *__pyx_pf_10helloworld_hello(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
772
static PyObject *__pyx_codeobj_;
773
774
/* "helloworld.pyx":2
775
* # cython hello world
776
* def hello(): # <<<<<<<<<<<<<<
777
* print('Hello, World!')
778
*/
779
780
/* Python wrapper */
781
static PyObject *__pyx_pw_10helloworld_1hello(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
782
static PyMethodDef __pyx_mdef_10helloworld_1hello = {"hello", (PyCFunction)__pyx_pw_10helloworld_1hello, METH_NOARGS, 0};
783
static PyObject *__pyx_pw_10helloworld_1hello(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
784
PyObject *__pyx_r = 0;
785
__Pyx_RefNannyDeclarations
786
__Pyx_RefNannySetupContext("hello (wrapper)", 0);
787
__pyx_r = __pyx_pf_10helloworld_hello(__pyx_self);
788
789
/* function exit code */
790
__Pyx_RefNannyFinishContext();
791
return __pyx_r;
792
}
793
794
static PyObject *__pyx_pf_10helloworld_hello(CYTHON_UNUSED PyObject *__pyx_self) {
795
PyObject *__pyx_r = NULL;
796
__Pyx_RefNannyDeclarations
797
__Pyx_RefNannySetupContext("hello", 0);
798
799
/* "helloworld.pyx":3
800
* # cython hello world
801
* def hello():
802
* print('Hello, World!') # <<<<<<<<<<<<<<
803
*/
804
if (__Pyx_PrintOne(0, __pyx_kp_s_Hello_World) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
805
806
/* "helloworld.pyx":2
807
* # cython hello world
808
* def hello(): # <<<<<<<<<<<<<<
809
* print('Hello, World!')
810
*/
811
812
/* function exit code */
813
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
814
goto __pyx_L0;
815
__pyx_L1_error:;
816
__Pyx_AddTraceback("helloworld.hello", __pyx_clineno, __pyx_lineno, __pyx_filename);
817
__pyx_r = NULL;
818
__pyx_L0:;
819
__Pyx_XGIVEREF(__pyx_r);
820
__Pyx_RefNannyFinishContext();
821
return __pyx_r;
822
}
823
824
static PyMethodDef __pyx_methods[] = {
825
{0, 0, 0, 0}
826
};
827
828
#if PY_MAJOR_VERSION >= 3
829
static struct PyModuleDef __pyx_moduledef = {
830
#if PY_VERSION_HEX < 0x03020000
831
{ PyObject_HEAD_INIT(NULL) NULL, 0, NULL },
832
#else
833
PyModuleDef_HEAD_INIT,
834
#endif
835
"helloworld",
836
0, /* m_doc */
837
-1, /* m_size */
838
__pyx_methods /* m_methods */,
839
NULL, /* m_reload */
840
NULL, /* m_traverse */
841
NULL, /* m_clear */
842
NULL /* m_free */
843
};
844
#endif
845
846
static __Pyx_StringTabEntry __pyx_string_tab[] = {
847
{&__pyx_kp_s_Hello_World, __pyx_k_Hello_World, sizeof(__pyx_k_Hello_World), 0, 0, 1, 0},
848
{&__pyx_kp_s_Users_ethen_machine_learning_py, __pyx_k_Users_ethen_machine_learning_py, sizeof(__pyx_k_Users_ethen_machine_learning_py), 0, 0, 1, 0},
849
{&__pyx_n_s_end, __pyx_k_end, sizeof(__pyx_k_end), 0, 0, 1, 1},
850
{&__pyx_n_s_file, __pyx_k_file, sizeof(__pyx_k_file), 0, 0, 1, 1},
851
{&__pyx_n_s_hello, __pyx_k_hello, sizeof(__pyx_k_hello), 0, 0, 1, 1},
852
{&__pyx_n_s_helloworld, __pyx_k_helloworld, sizeof(__pyx_k_helloworld), 0, 0, 1, 1},
853
{&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
854
{&__pyx_n_s_print, __pyx_k_print, sizeof(__pyx_k_print), 0, 0, 1, 1},
855
{&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
856
{0, 0, 0, 0, 0, 0, 0}
857
};
858
static int __Pyx_InitCachedBuiltins(void) {
859
return 0;
860
}
861
862
static int __Pyx_InitCachedConstants(void) {
863
__Pyx_RefNannyDeclarations
864
__Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
865
866
/* "helloworld.pyx":2
867
* # cython hello world
868
* def hello(): # <<<<<<<<<<<<<<
869
* print('Hello, World!')
870
*/
871
__pyx_codeobj_ = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_ethen_machine_learning_py, __pyx_n_s_hello, 2, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj_)) __PYX_ERR(0, 2, __pyx_L1_error)
872
__Pyx_RefNannyFinishContext();
873
return 0;
874
__pyx_L1_error:;
875
__Pyx_RefNannyFinishContext();
876
return -1;
877
}
878
879
static int __Pyx_InitGlobals(void) {
880
if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
881
return 0;
882
__pyx_L1_error:;
883
return -1;
884
}
885
886
#if PY_MAJOR_VERSION < 3
887
PyMODINIT_FUNC inithelloworld(void); /*proto*/
888
PyMODINIT_FUNC inithelloworld(void)
889
#else
890
PyMODINIT_FUNC PyInit_helloworld(void); /*proto*/
891
PyMODINIT_FUNC PyInit_helloworld(void)
892
#endif
893
{
894
PyObject *__pyx_t_1 = NULL;
895
__Pyx_RefNannyDeclarations
896
#if CYTHON_REFNANNY
897
__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
898
if (!__Pyx_RefNanny) {
899
PyErr_Clear();
900
__Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
901
if (!__Pyx_RefNanny)
902
Py_FatalError("failed to import 'refnanny' module");
903
}
904
#endif
905
__Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_helloworld(void)", 0);
906
if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
907
__pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
908
__pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
909
__pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
910
#ifdef __Pyx_CyFunction_USED
911
if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
912
#endif
913
#ifdef __Pyx_FusedFunction_USED
914
if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
915
#endif
916
#ifdef __Pyx_Coroutine_USED
917
if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
918
#endif
919
#ifdef __Pyx_Generator_USED
920
if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
921
#endif
922
#ifdef __Pyx_StopAsyncIteration_USED
923
if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
924
#endif
925
/*--- Library function declarations ---*/
926
/*--- Threads initialization code ---*/
927
#if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
928
#ifdef WITH_THREAD /* Python build with threading support? */
929
PyEval_InitThreads();
930
#endif
931
#endif
932
/*--- Module creation code ---*/
933
#if PY_MAJOR_VERSION < 3
934
__pyx_m = Py_InitModule4("helloworld", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
935
#else
936
__pyx_m = PyModule_Create(&__pyx_moduledef);
937
#endif
938
if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
939
__pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
940
Py_INCREF(__pyx_d);
941
__pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
942
#if CYTHON_COMPILING_IN_PYPY
943
Py_INCREF(__pyx_b);
944
#endif
945
if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
946
/*--- Initialize various global constants etc. ---*/
947
if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
948
#if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
949
if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
950
#endif
951
if (__pyx_module_is_main_helloworld) {
952
if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
953
}
954
#if PY_MAJOR_VERSION >= 3
955
{
956
PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
957
if (!PyDict_GetItemString(modules, "helloworld")) {
958
if (unlikely(PyDict_SetItemString(modules, "helloworld", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
959
}
960
}
961
#endif
962
/*--- Builtin init code ---*/
963
if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
964
/*--- Constants init code ---*/
965
if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
966
/*--- Global init code ---*/
967
/*--- Variable export code ---*/
968
/*--- Function export code ---*/
969
/*--- Type init code ---*/
970
/*--- Type import code ---*/
971
/*--- Variable import code ---*/
972
/*--- Function import code ---*/
973
/*--- Execution code ---*/
974
#if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
975
if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
976
#endif
977
978
/* "helloworld.pyx":2
979
* # cython hello world
980
* def hello(): # <<<<<<<<<<<<<<
981
* print('Hello, World!')
982
*/
983
__pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_10helloworld_1hello, NULL, __pyx_n_s_helloworld); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2, __pyx_L1_error)
984
__Pyx_GOTREF(__pyx_t_1);
985
if (PyDict_SetItem(__pyx_d, __pyx_n_s_hello, __pyx_t_1) < 0) __PYX_ERR(0, 2, __pyx_L1_error)
986
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
987
988
/* "helloworld.pyx":1
989
* # cython hello world # <<<<<<<<<<<<<<
990
* def hello():
991
* print('Hello, World!')
992
*/
993
__pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
994
__Pyx_GOTREF(__pyx_t_1);
995
if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
996
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
997
998
/*--- Wrapped vars code ---*/
999
1000
goto __pyx_L0;
1001
__pyx_L1_error:;
1002
__Pyx_XDECREF(__pyx_t_1);
1003
if (__pyx_m) {
1004
if (__pyx_d) {
1005
__Pyx_AddTraceback("init helloworld", __pyx_clineno, __pyx_lineno, __pyx_filename);
1006
}
1007
Py_DECREF(__pyx_m); __pyx_m = 0;
1008
} else if (!PyErr_Occurred()) {
1009
PyErr_SetString(PyExc_ImportError, "init helloworld");
1010
}
1011
__pyx_L0:;
1012
__Pyx_RefNannyFinishContext();
1013
#if PY_MAJOR_VERSION < 3
1014
return;
1015
#else
1016
return __pyx_m;
1017
#endif
1018
}
1019
1020
/* --- Runtime support code --- */
1021
/* Refnanny */
1022
#if CYTHON_REFNANNY
1023
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
1024
PyObject *m = NULL, *p = NULL;
1025
void *r = NULL;
1026
m = PyImport_ImportModule((char *)modname);
1027
if (!m) goto end;
1028
p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
1029
if (!p) goto end;
1030
r = PyLong_AsVoidPtr(p);
1031
end:
1032
Py_XDECREF(p);
1033
Py_XDECREF(m);
1034
return (__Pyx_RefNannyAPIStruct *)r;
1035
}
1036
#endif
1037
1038
/* CodeObjectCache */
1039
static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
1040
int start = 0, mid = 0, end = count - 1;
1041
if (end >= 0 && code_line > entries[end].code_line) {
1042
return count;
1043
}
1044
while (start < end) {
1045
mid = start + (end - start) / 2;
1046
if (code_line < entries[mid].code_line) {
1047
end = mid;
1048
} else if (code_line > entries[mid].code_line) {
1049
start = mid + 1;
1050
} else {
1051
return mid;
1052
}
1053
}
1054
if (code_line <= entries[mid].code_line) {
1055
return mid;
1056
} else {
1057
return mid + 1;
1058
}
1059
}
1060
static PyCodeObject *__pyx_find_code_object(int code_line) {
1061
PyCodeObject* code_object;
1062
int pos;
1063
if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
1064
return NULL;
1065
}
1066
pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
1067
if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
1068
return NULL;
1069
}
1070
code_object = __pyx_code_cache.entries[pos].code_object;
1071
Py_INCREF(code_object);
1072
return code_object;
1073
}
1074
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
1075
int pos, i;
1076
__Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
1077
if (unlikely(!code_line)) {
1078
return;
1079
}
1080
if (unlikely(!entries)) {
1081
entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
1082
if (likely(entries)) {
1083
__pyx_code_cache.entries = entries;
1084
__pyx_code_cache.max_count = 64;
1085
__pyx_code_cache.count = 1;
1086
entries[0].code_line = code_line;
1087
entries[0].code_object = code_object;
1088
Py_INCREF(code_object);
1089
}
1090
return;
1091
}
1092
pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
1093
if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
1094
PyCodeObject* tmp = entries[pos].code_object;
1095
entries[pos].code_object = code_object;
1096
Py_DECREF(tmp);
1097
return;
1098
}
1099
if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
1100
int new_max = __pyx_code_cache.max_count + 64;
1101
entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
1102
__pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry));
1103
if (unlikely(!entries)) {
1104
return;
1105
}
1106
__pyx_code_cache.entries = entries;
1107
__pyx_code_cache.max_count = new_max;
1108
}
1109
for (i=__pyx_code_cache.count; i>pos; i--) {
1110
entries[i] = entries[i-1];
1111
}
1112
entries[pos].code_line = code_line;
1113
entries[pos].code_object = code_object;
1114
__pyx_code_cache.count++;
1115
Py_INCREF(code_object);
1116
}
1117
1118
/* AddTraceback */
1119
#include "compile.h"
1120
#include "frameobject.h"
1121
#include "traceback.h"
1122
static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
1123
const char *funcname, int c_line,
1124
int py_line, const char *filename) {
1125
PyCodeObject *py_code = 0;
1126
PyObject *py_srcfile = 0;
1127
PyObject *py_funcname = 0;
1128
#if PY_MAJOR_VERSION < 3
1129
py_srcfile = PyString_FromString(filename);
1130
#else
1131
py_srcfile = PyUnicode_FromString(filename);
1132
#endif
1133
if (!py_srcfile) goto bad;
1134
if (c_line) {
1135
#if PY_MAJOR_VERSION < 3
1136
py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
1137
#else
1138
py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
1139
#endif
1140
}
1141
else {
1142
#if PY_MAJOR_VERSION < 3
1143
py_funcname = PyString_FromString(funcname);
1144
#else
1145
py_funcname = PyUnicode_FromString(funcname);
1146
#endif
1147
}
1148
if (!py_funcname) goto bad;
1149
py_code = __Pyx_PyCode_New(
1150
0,
1151
0,
1152
0,
1153
0,
1154
0,
1155
__pyx_empty_bytes, /*PyObject *code,*/
1156
__pyx_empty_tuple, /*PyObject *consts,*/
1157
__pyx_empty_tuple, /*PyObject *names,*/
1158
__pyx_empty_tuple, /*PyObject *varnames,*/
1159
__pyx_empty_tuple, /*PyObject *freevars,*/
1160
__pyx_empty_tuple, /*PyObject *cellvars,*/
1161
py_srcfile, /*PyObject *filename,*/
1162
py_funcname, /*PyObject *name,*/
1163
py_line,
1164
__pyx_empty_bytes /*PyObject *lnotab*/
1165
);
1166
Py_DECREF(py_srcfile);
1167
Py_DECREF(py_funcname);
1168
return py_code;
1169
bad:
1170
Py_XDECREF(py_srcfile);
1171
Py_XDECREF(py_funcname);
1172
return NULL;
1173
}
1174
static void __Pyx_AddTraceback(const char *funcname, int c_line,
1175
int py_line, const char *filename) {
1176
PyCodeObject *py_code = 0;
1177
PyFrameObject *py_frame = 0;
1178
py_code = __pyx_find_code_object(c_line ? c_line : py_line);
1179
if (!py_code) {
1180
py_code = __Pyx_CreateCodeObjectForTraceback(
1181
funcname, c_line, py_line, filename);
1182
if (!py_code) goto bad;
1183
__pyx_insert_code_object(c_line ? c_line : py_line, py_code);
1184
}
1185
py_frame = PyFrame_New(
1186
PyThreadState_GET(), /*PyThreadState *tstate,*/
1187
py_code, /*PyCodeObject *code,*/
1188
__pyx_d, /*PyObject *globals,*/
1189
0 /*PyObject *locals*/
1190
);
1191
if (!py_frame) goto bad;
1192
__Pyx_PyFrame_SetLineNumber(py_frame, py_line);
1193
PyTraceBack_Here(py_frame);
1194
bad:
1195
Py_XDECREF(py_code);
1196
Py_XDECREF(py_frame);
1197
}
1198
1199
/* Print */
1200
#if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION < 3
1201
static PyObject *__Pyx_GetStdout(void) {
1202
PyObject *f = PySys_GetObject((char *)"stdout");
1203
if (!f) {
1204
PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout");
1205
}
1206
return f;
1207
}
1208
static int __Pyx_Print(PyObject* f, PyObject *arg_tuple, int newline) {
1209
int i;
1210
if (!f) {
1211
if (!(f = __Pyx_GetStdout()))
1212
return -1;
1213
}
1214
Py_INCREF(f);
1215
for (i=0; i < PyTuple_GET_SIZE(arg_tuple); i++) {
1216
PyObject* v;
1217
if (PyFile_SoftSpace(f, 1)) {
1218
if (PyFile_WriteString(" ", f) < 0)
1219
goto error;
1220
}
1221
v = PyTuple_GET_ITEM(arg_tuple, i);
1222
if (PyFile_WriteObject(v, f, Py_PRINT_RAW) < 0)
1223
goto error;
1224
if (PyString_Check(v)) {
1225
char *s = PyString_AsString(v);
1226
Py_ssize_t len = PyString_Size(v);
1227
if (len > 0) {
1228
switch (s[len-1]) {
1229
case ' ': break;
1230
case '\f': case '\r': case '\n': case '\t': case '\v':
1231
PyFile_SoftSpace(f, 0);
1232
break;
1233
default: break;
1234
}
1235
}
1236
}
1237
}
1238
if (newline) {
1239
if (PyFile_WriteString("\n", f) < 0)
1240
goto error;
1241
PyFile_SoftSpace(f, 0);
1242
}
1243
Py_DECREF(f);
1244
return 0;
1245
error:
1246
Py_DECREF(f);
1247
return -1;
1248
}
1249
#else
1250
static int __Pyx_Print(PyObject* stream, PyObject *arg_tuple, int newline) {
1251
PyObject* kwargs = 0;
1252
PyObject* result = 0;
1253
PyObject* end_string;
1254
if (unlikely(!__pyx_print)) {
1255
__pyx_print = PyObject_GetAttr(__pyx_b, __pyx_n_s_print);
1256
if (!__pyx_print)
1257
return -1;
1258
}
1259
if (stream) {
1260
kwargs = PyDict_New();
1261
if (unlikely(!kwargs))
1262
return -1;
1263
if (unlikely(PyDict_SetItem(kwargs, __pyx_n_s_file, stream) < 0))
1264
goto bad;
1265
if (!newline) {
1266
end_string = PyUnicode_FromStringAndSize(" ", 1);
1267
if (unlikely(!end_string))
1268
goto bad;
1269
if (PyDict_SetItem(kwargs, __pyx_n_s_end, end_string) < 0) {
1270
Py_DECREF(end_string);
1271
goto bad;
1272
}
1273
Py_DECREF(end_string);
1274
}
1275
} else if (!newline) {
1276
if (unlikely(!__pyx_print_kwargs)) {
1277
__pyx_print_kwargs = PyDict_New();
1278
if (unlikely(!__pyx_print_kwargs))
1279
return -1;
1280
end_string = PyUnicode_FromStringAndSize(" ", 1);
1281
if (unlikely(!end_string))
1282
return -1;
1283
if (PyDict_SetItem(__pyx_print_kwargs, __pyx_n_s_end, end_string) < 0) {
1284
Py_DECREF(end_string);
1285
return -1;
1286
}
1287
Py_DECREF(end_string);
1288
}
1289
kwargs = __pyx_print_kwargs;
1290
}
1291
result = PyObject_Call(__pyx_print, arg_tuple, kwargs);
1292
if (unlikely(kwargs) && (kwargs != __pyx_print_kwargs))
1293
Py_DECREF(kwargs);
1294
if (!result)
1295
return -1;
1296
Py_DECREF(result);
1297
return 0;
1298
bad:
1299
if (kwargs != __pyx_print_kwargs)
1300
Py_XDECREF(kwargs);
1301
return -1;
1302
}
1303
#endif
1304
1305
/* PrintOne */
1306
#if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION < 3
1307
static int __Pyx_PrintOne(PyObject* f, PyObject *o) {
1308
if (!f) {
1309
if (!(f = __Pyx_GetStdout()))
1310
return -1;
1311
}
1312
Py_INCREF(f);
1313
if (PyFile_SoftSpace(f, 0)) {
1314
if (PyFile_WriteString(" ", f) < 0)
1315
goto error;
1316
}
1317
if (PyFile_WriteObject(o, f, Py_PRINT_RAW) < 0)
1318
goto error;
1319
if (PyFile_WriteString("\n", f) < 0)
1320
goto error;
1321
Py_DECREF(f);
1322
return 0;
1323
error:
1324
Py_DECREF(f);
1325
return -1;
1326
/* the line below is just to avoid C compiler
1327
* warnings about unused functions */
1328
return __Pyx_Print(f, NULL, 0);
1329
}
1330
#else
1331
static int __Pyx_PrintOne(PyObject* stream, PyObject *o) {
1332
int res;
1333
PyObject* arg_tuple = PyTuple_Pack(1, o);
1334
if (unlikely(!arg_tuple))
1335
return -1;
1336
res = __Pyx_Print(stream, arg_tuple, 1);
1337
Py_DECREF(arg_tuple);
1338
return res;
1339
}
1340
#endif
1341
1342
/* CIntToPy */
1343
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
1344
const long neg_one = (long) -1, const_zero = (long) 0;
1345
const int is_unsigned = neg_one > const_zero;
1346
if (is_unsigned) {
1347
if (sizeof(long) < sizeof(long)) {
1348
return PyInt_FromLong((long) value);
1349
} else if (sizeof(long) <= sizeof(unsigned long)) {
1350
return PyLong_FromUnsignedLong((unsigned long) value);
1351
#ifdef HAVE_LONG_LONG
1352
} else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
1353
return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
1354
#endif
1355
}
1356
} else {
1357
if (sizeof(long) <= sizeof(long)) {
1358
return PyInt_FromLong((long) value);
1359
#ifdef HAVE_LONG_LONG
1360
} else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
1361
return PyLong_FromLongLong((PY_LONG_LONG) value);
1362
#endif
1363
}
1364
}
1365
{
1366
int one = 1; int little = (int)*(unsigned char *)&one;
1367
unsigned char *bytes = (unsigned char *)&value;
1368
return _PyLong_FromByteArray(bytes, sizeof(long),
1369
little, !is_unsigned);
1370
}
1371
}
1372
1373
/* CIntFromPyVerify */
1374
#define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
1375
__PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
1376
#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
1377
__PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
1378
#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
1379
{\
1380
func_type value = func_value;\
1381
if (sizeof(target_type) < sizeof(func_type)) {\
1382
if (unlikely(value != (func_type) (target_type) value)) {\
1383
func_type zero = 0;\
1384
if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
1385
return (target_type) -1;\
1386
if (is_unsigned && unlikely(value < zero))\
1387
goto raise_neg_overflow;\
1388
else\
1389
goto raise_overflow;\
1390
}\
1391
}\
1392
return (target_type) value;\
1393
}
1394
1395
/* CIntFromPy */
1396
static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
1397
const long neg_one = (long) -1, const_zero = (long) 0;
1398
const int is_unsigned = neg_one > const_zero;
1399
#if PY_MAJOR_VERSION < 3
1400
if (likely(PyInt_Check(x))) {
1401
if (sizeof(long) < sizeof(long)) {
1402
__PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
1403
} else {
1404
long val = PyInt_AS_LONG(x);
1405
if (is_unsigned && unlikely(val < 0)) {
1406
goto raise_neg_overflow;
1407
}
1408
return (long) val;
1409
}
1410
} else
1411
#endif
1412
if (likely(PyLong_Check(x))) {
1413
if (is_unsigned) {
1414
#if CYTHON_USE_PYLONG_INTERNALS
1415
const digit* digits = ((PyLongObject*)x)->ob_digit;
1416
switch (Py_SIZE(x)) {
1417
case 0: return (long) 0;
1418
case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
1419
case 2:
1420
if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
1421
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
1422
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
1423
} else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
1424
return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
1425
}
1426
}
1427
break;
1428
case 3:
1429
if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
1430
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
1431
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
1432
} else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
1433
return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
1434
}
1435
}
1436
break;
1437
case 4:
1438
if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
1439
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
1440
__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])))
1441
} else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
1442
return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
1443
}
1444
}
1445
break;
1446
}
1447
#endif
1448
#if CYTHON_COMPILING_IN_CPYTHON
1449
if (unlikely(Py_SIZE(x) < 0)) {
1450
goto raise_neg_overflow;
1451
}
1452
#else
1453
{
1454
int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
1455
if (unlikely(result < 0))
1456
return (long) -1;
1457
if (unlikely(result == 1))
1458
goto raise_neg_overflow;
1459
}
1460
#endif
1461
if (sizeof(long) <= sizeof(unsigned long)) {
1462
__PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
1463
#ifdef HAVE_LONG_LONG
1464
} else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
1465
__PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
1466
#endif
1467
}
1468
} else {
1469
#if CYTHON_USE_PYLONG_INTERNALS
1470
const digit* digits = ((PyLongObject*)x)->ob_digit;
1471
switch (Py_SIZE(x)) {
1472
case 0: return (long) 0;
1473
case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
1474
case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
1475
case -2:
1476
if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
1477
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
1478
__PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
1479
} else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
1480
return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
1481
}
1482
}
1483
break;
1484
case 2:
1485
if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
1486
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
1487
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
1488
} else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
1489
return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
1490
}
1491
}
1492
break;
1493
case -3:
1494
if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
1495
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
1496
__PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
1497
} else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
1498
return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
1499
}
1500
}
1501
break;
1502
case 3:
1503
if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
1504
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
1505
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
1506
} else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
1507
return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
1508
}
1509
}
1510
break;
1511
case -4:
1512
if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
1513
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
1514
__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])))
1515
} else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
1516
return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
1517
}
1518
}
1519
break;
1520
case 4:
1521
if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
1522
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
1523
__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])))
1524
} else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
1525
return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
1526
}
1527
}
1528
break;
1529
}
1530
#endif
1531
if (sizeof(long) <= sizeof(long)) {
1532
__PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
1533
#ifdef HAVE_LONG_LONG
1534
} else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
1535
__PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
1536
#endif
1537
}
1538
}
1539
{
1540
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
1541
PyErr_SetString(PyExc_RuntimeError,
1542
"_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
1543
#else
1544
long val;
1545
PyObject *v = __Pyx_PyNumber_IntOrLong(x);
1546
#if PY_MAJOR_VERSION < 3
1547
if (likely(v) && !PyLong_Check(v)) {
1548
PyObject *tmp = v;
1549
v = PyNumber_Long(tmp);
1550
Py_DECREF(tmp);
1551
}
1552
#endif
1553
if (likely(v)) {
1554
int one = 1; int is_little = (int)*(unsigned char *)&one;
1555
unsigned char *bytes = (unsigned char *)&val;
1556
int ret = _PyLong_AsByteArray((PyLongObject *)v,
1557
bytes, sizeof(val),
1558
is_little, !is_unsigned);
1559
Py_DECREF(v);
1560
if (likely(!ret))
1561
return val;
1562
}
1563
#endif
1564
return (long) -1;
1565
}
1566
} else {
1567
long val;
1568
PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
1569
if (!tmp) return (long) -1;
1570
val = __Pyx_PyInt_As_long(tmp);
1571
Py_DECREF(tmp);
1572
return val;
1573
}
1574
raise_overflow:
1575
PyErr_SetString(PyExc_OverflowError,
1576
"value too large to convert to long");
1577
return (long) -1;
1578
raise_neg_overflow:
1579
PyErr_SetString(PyExc_OverflowError,
1580
"can't convert negative value to long");
1581
return (long) -1;
1582
}
1583
1584
/* CIntFromPy */
1585
static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
1586
const int neg_one = (int) -1, const_zero = (int) 0;
1587
const int is_unsigned = neg_one > const_zero;
1588
#if PY_MAJOR_VERSION < 3
1589
if (likely(PyInt_Check(x))) {
1590
if (sizeof(int) < sizeof(long)) {
1591
__PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
1592
} else {
1593
long val = PyInt_AS_LONG(x);
1594
if (is_unsigned && unlikely(val < 0)) {
1595
goto raise_neg_overflow;
1596
}
1597
return (int) val;
1598
}
1599
} else
1600
#endif
1601
if (likely(PyLong_Check(x))) {
1602
if (is_unsigned) {
1603
#if CYTHON_USE_PYLONG_INTERNALS
1604
const digit* digits = ((PyLongObject*)x)->ob_digit;
1605
switch (Py_SIZE(x)) {
1606
case 0: return (int) 0;
1607
case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
1608
case 2:
1609
if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
1610
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
1611
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
1612
} else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
1613
return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
1614
}
1615
}
1616
break;
1617
case 3:
1618
if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
1619
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
1620
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
1621
} else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
1622
return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
1623
}
1624
}
1625
break;
1626
case 4:
1627
if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
1628
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
1629
__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])))
1630
} else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
1631
return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
1632
}
1633
}
1634
break;
1635
}
1636
#endif
1637
#if CYTHON_COMPILING_IN_CPYTHON
1638
if (unlikely(Py_SIZE(x) < 0)) {
1639
goto raise_neg_overflow;
1640
}
1641
#else
1642
{
1643
int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
1644
if (unlikely(result < 0))
1645
return (int) -1;
1646
if (unlikely(result == 1))
1647
goto raise_neg_overflow;
1648
}
1649
#endif
1650
if (sizeof(int) <= sizeof(unsigned long)) {
1651
__PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
1652
#ifdef HAVE_LONG_LONG
1653
} else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
1654
__PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
1655
#endif
1656
}
1657
} else {
1658
#if CYTHON_USE_PYLONG_INTERNALS
1659
const digit* digits = ((PyLongObject*)x)->ob_digit;
1660
switch (Py_SIZE(x)) {
1661
case 0: return (int) 0;
1662
case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
1663
case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0])
1664
case -2:
1665
if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
1666
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
1667
__PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
1668
} else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
1669
return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
1670
}
1671
}
1672
break;
1673
case 2:
1674
if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
1675
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
1676
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
1677
} else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
1678
return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
1679
}
1680
}
1681
break;
1682
case -3:
1683
if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
1684
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
1685
__PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
1686
} else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
1687
return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
1688
}
1689
}
1690
break;
1691
case 3:
1692
if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
1693
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
1694
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
1695
} else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
1696
return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
1697
}
1698
}
1699
break;
1700
case -4:
1701
if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
1702
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
1703
__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])))
1704
} else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
1705
return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
1706
}
1707
}
1708
break;
1709
case 4:
1710
if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
1711
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
1712
__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])))
1713
} else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
1714
return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
1715
}
1716
}
1717
break;
1718
}
1719
#endif
1720
if (sizeof(int) <= sizeof(long)) {
1721
__PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
1722
#ifdef HAVE_LONG_LONG
1723
} else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
1724
__PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
1725
#endif
1726
}
1727
}
1728
{
1729
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
1730
PyErr_SetString(PyExc_RuntimeError,
1731
"_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
1732
#else
1733
int val;
1734
PyObject *v = __Pyx_PyNumber_IntOrLong(x);
1735
#if PY_MAJOR_VERSION < 3
1736
if (likely(v) && !PyLong_Check(v)) {
1737
PyObject *tmp = v;
1738
v = PyNumber_Long(tmp);
1739
Py_DECREF(tmp);
1740
}
1741
#endif
1742
if (likely(v)) {
1743
int one = 1; int is_little = (int)*(unsigned char *)&one;
1744
unsigned char *bytes = (unsigned char *)&val;
1745
int ret = _PyLong_AsByteArray((PyLongObject *)v,
1746
bytes, sizeof(val),
1747
is_little, !is_unsigned);
1748
Py_DECREF(v);
1749
if (likely(!ret))
1750
return val;
1751
}
1752
#endif
1753
return (int) -1;
1754
}
1755
} else {
1756
int val;
1757
PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
1758
if (!tmp) return (int) -1;
1759
val = __Pyx_PyInt_As_int(tmp);
1760
Py_DECREF(tmp);
1761
return val;
1762
}
1763
raise_overflow:
1764
PyErr_SetString(PyExc_OverflowError,
1765
"value too large to convert to int");
1766
return (int) -1;
1767
raise_neg_overflow:
1768
PyErr_SetString(PyExc_OverflowError,
1769
"can't convert negative value to int");
1770
return (int) -1;
1771
}
1772
1773
/* CheckBinaryVersion */
1774
static int __Pyx_check_binary_version(void) {
1775
char ctversion[4], rtversion[4];
1776
PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
1777
PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
1778
if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
1779
char message[200];
1780
PyOS_snprintf(message, sizeof(message),
1781
"compiletime version %s of module '%.100s' "
1782
"does not match runtime version %s",
1783
ctversion, __Pyx_MODULE_NAME, rtversion);
1784
return PyErr_WarnEx(NULL, message, 1);
1785
}
1786
return 0;
1787
}
1788
1789
/* InitStrings */
1790
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
1791
while (t->p) {
1792
#if PY_MAJOR_VERSION < 3
1793
if (t->is_unicode) {
1794
*t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
1795
} else if (t->intern) {
1796
*t->p = PyString_InternFromString(t->s);
1797
} else {
1798
*t->p = PyString_FromStringAndSize(t->s, t->n - 1);
1799
}
1800
#else
1801
if (t->is_unicode | t->is_str) {
1802
if (t->intern) {
1803
*t->p = PyUnicode_InternFromString(t->s);
1804
} else if (t->encoding) {
1805
*t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
1806
} else {
1807
*t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
1808
}
1809
} else {
1810
*t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
1811
}
1812
#endif
1813
if (!*t->p)
1814
return -1;
1815
++t;
1816
}
1817
return 0;
1818
}
1819
1820
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
1821
return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
1822
}
1823
static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) {
1824
Py_ssize_t ignore;
1825
return __Pyx_PyObject_AsStringAndSize(o, &ignore);
1826
}
1827
static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
1828
#if CYTHON_COMPILING_IN_CPYTHON && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
1829
if (
1830
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
1831
__Pyx_sys_getdefaultencoding_not_ascii &&
1832
#endif
1833
PyUnicode_Check(o)) {
1834
#if PY_VERSION_HEX < 0x03030000
1835
char* defenc_c;
1836
PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
1837
if (!defenc) return NULL;
1838
defenc_c = PyBytes_AS_STRING(defenc);
1839
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
1840
{
1841
char* end = defenc_c + PyBytes_GET_SIZE(defenc);
1842
char* c;
1843
for (c = defenc_c; c < end; c++) {
1844
if ((unsigned char) (*c) >= 128) {
1845
PyUnicode_AsASCIIString(o);
1846
return NULL;
1847
}
1848
}
1849
}
1850
#endif
1851
*length = PyBytes_GET_SIZE(defenc);
1852
return defenc_c;
1853
#else
1854
if (__Pyx_PyUnicode_READY(o) == -1) return NULL;
1855
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
1856
if (PyUnicode_IS_ASCII(o)) {
1857
*length = PyUnicode_GET_LENGTH(o);
1858
return PyUnicode_AsUTF8(o);
1859
} else {
1860
PyUnicode_AsASCIIString(o);
1861
return NULL;
1862
}
1863
#else
1864
return PyUnicode_AsUTF8AndSize(o, length);
1865
#endif
1866
#endif
1867
} else
1868
#endif
1869
#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
1870
if (PyByteArray_Check(o)) {
1871
*length = PyByteArray_GET_SIZE(o);
1872
return PyByteArray_AS_STRING(o);
1873
} else
1874
#endif
1875
{
1876
char* result;
1877
int r = PyBytes_AsStringAndSize(o, &result, length);
1878
if (unlikely(r < 0)) {
1879
return NULL;
1880
} else {
1881
return result;
1882
}
1883
}
1884
}
1885
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
1886
int is_true = x == Py_True;
1887
if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
1888
else return PyObject_IsTrue(x);
1889
}
1890
static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
1891
#if CYTHON_USE_TYPE_SLOTS
1892
PyNumberMethods *m;
1893
#endif
1894
const char *name = NULL;
1895
PyObject *res = NULL;
1896
#if PY_MAJOR_VERSION < 3
1897
if (PyInt_Check(x) || PyLong_Check(x))
1898
#else
1899
if (PyLong_Check(x))
1900
#endif
1901
return __Pyx_NewRef(x);
1902
#if CYTHON_USE_TYPE_SLOTS
1903
m = Py_TYPE(x)->tp_as_number;
1904
#if PY_MAJOR_VERSION < 3
1905
if (m && m->nb_int) {
1906
name = "int";
1907
res = PyNumber_Int(x);
1908
}
1909
else if (m && m->nb_long) {
1910
name = "long";
1911
res = PyNumber_Long(x);
1912
}
1913
#else
1914
if (m && m->nb_int) {
1915
name = "int";
1916
res = PyNumber_Long(x);
1917
}
1918
#endif
1919
#else
1920
res = PyNumber_Int(x);
1921
#endif
1922
if (res) {
1923
#if PY_MAJOR_VERSION < 3
1924
if (!PyInt_Check(res) && !PyLong_Check(res)) {
1925
#else
1926
if (!PyLong_Check(res)) {
1927
#endif
1928
PyErr_Format(PyExc_TypeError,
1929
"__%.4s__ returned non-%.4s (type %.200s)",
1930
name, name, Py_TYPE(res)->tp_name);
1931
Py_DECREF(res);
1932
return NULL;
1933
}
1934
}
1935
else if (!PyErr_Occurred()) {
1936
PyErr_SetString(PyExc_TypeError,
1937
"an integer is required");
1938
}
1939
return res;
1940
}
1941
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
1942
Py_ssize_t ival;
1943
PyObject *x;
1944
#if PY_MAJOR_VERSION < 3
1945
if (likely(PyInt_CheckExact(b))) {
1946
if (sizeof(Py_ssize_t) >= sizeof(long))
1947
return PyInt_AS_LONG(b);
1948
else
1949
return PyInt_AsSsize_t(x);
1950
}
1951
#endif
1952
if (likely(PyLong_CheckExact(b))) {
1953
#if CYTHON_USE_PYLONG_INTERNALS
1954
const digit* digits = ((PyLongObject*)b)->ob_digit;
1955
const Py_ssize_t size = Py_SIZE(b);
1956
if (likely(__Pyx_sst_abs(size) <= 1)) {
1957
ival = likely(size) ? digits[0] : 0;
1958
if (size == -1) ival = -ival;
1959
return ival;
1960
} else {
1961
switch (size) {
1962
case 2:
1963
if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
1964
return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
1965
}
1966
break;
1967
case -2:
1968
if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
1969
return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
1970
}
1971
break;
1972
case 3:
1973
if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
1974
return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
1975
}
1976
break;
1977
case -3:
1978
if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
1979
return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
1980
}
1981
break;
1982
case 4:
1983
if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
1984
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]));
1985
}
1986
break;
1987
case -4:
1988
if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
1989
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]));
1990
}
1991
break;
1992
}
1993
}
1994
#endif
1995
return PyLong_AsSsize_t(b);
1996
}
1997
x = PyNumber_Index(b);
1998
if (!x) return -1;
1999
ival = PyInt_AsSsize_t(x);
2000
Py_DECREF(x);
2001
return ival;
2002
}
2003
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
2004
return PyInt_FromSize_t(ival);
2005
}
2006
2007
2008
#endif /* Py_PYTHON_H */
2009
2010