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