Debian Codegraph @

pymusic/pybuffer.cpp

raw
1 /* Generated by Cython 0.29.32 */
2
3 /* BEGIN: Cython Metadata
4 {
5 "distutils": {
6 "depends": [
7 "mpi_compat.h",
8 "music/pymusic_c.h"
9 ],
10 "language": "c++",
11 "name": "pybuffer",
12 "sources": [
13 "pybuffer.pyx"
14 ]
15 },
16 "module_name": "pybuffer"
17 }
18 END: Cython Metadata */
19
20 #ifndef PY_SSIZE_T_CLEAN
21 #define PY_SSIZE_T_CLEAN
22 #endif /* PY_SSIZE_T_CLEAN */
23 #include "Python.h"
24 #ifndef Py_PYTHON_H
25 #error Python headers needed to compile C extensions, please install development version of Python.
26 #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
27 #error Cython requires Python 2.6+ or Python 3.3+.
28 #else
29 #define CYTHON_ABI "0_29_32"
30 #define CYTHON_HEX_VERSION 0x001D20F0
31 #define CYTHON_FUTURE_DIVISION 0
32 #include <stddef.h>
33 #ifndef offsetof
34 #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
35 #endif
36 #if !defined(WIN32) && !defined(MS_WINDOWS)
37 #ifndef __stdcall
38 #define __stdcall
39 #endif
40 #ifndef __cdecl
41 #define __cdecl
42 #endif
43 #ifndef __fastcall
44 #define __fastcall
45 #endif
46 #endif
47 #ifndef DL_IMPORT
48 #define DL_IMPORT(t) t
49 #endif
50 #ifndef DL_EXPORT
51 #define DL_EXPORT(t) t
52 #endif
53 #define __PYX_COMMA ,
54 #ifndef HAVE_LONG_LONG
55 #if PY_VERSION_HEX >= 0x02070000
56 #define HAVE_LONG_LONG
57 #endif
58 #endif
59 #ifndef PY_LONG_LONG
60 #define PY_LONG_LONG LONG_LONG
61 #endif
62 #ifndef Py_HUGE_VAL
63 #define Py_HUGE_VAL HUGE_VAL
64 #endif
65 #ifdef PYPY_VERSION
66 #define CYTHON_COMPILING_IN_PYPY 1
67 #define CYTHON_COMPILING_IN_PYSTON 0
68 #define CYTHON_COMPILING_IN_CPYTHON 0
69 #define CYTHON_COMPILING_IN_NOGIL 0
70 #undef CYTHON_USE_TYPE_SLOTS
71 #define CYTHON_USE_TYPE_SLOTS 0
72 #undef CYTHON_USE_PYTYPE_LOOKUP
73 #define CYTHON_USE_PYTYPE_LOOKUP 0
74 #if PY_VERSION_HEX < 0x03050000
75 #undef CYTHON_USE_ASYNC_SLOTS
76 #define CYTHON_USE_ASYNC_SLOTS 0
77 #elif !defined(CYTHON_USE_ASYNC_SLOTS)
78 #define CYTHON_USE_ASYNC_SLOTS 1
79 #endif
80 #undef CYTHON_USE_PYLIST_INTERNALS
81 #define CYTHON_USE_PYLIST_INTERNALS 0
82 #undef CYTHON_USE_UNICODE_INTERNALS
83 #define CYTHON_USE_UNICODE_INTERNALS 0
84 #undef CYTHON_USE_UNICODE_WRITER
85 #define CYTHON_USE_UNICODE_WRITER 0
86 #undef CYTHON_USE_PYLONG_INTERNALS
87 #define CYTHON_USE_PYLONG_INTERNALS 0
88 #undef CYTHON_AVOID_BORROWED_REFS
89 #define CYTHON_AVOID_BORROWED_REFS 1
90 #undef CYTHON_ASSUME_SAFE_MACROS
91 #define CYTHON_ASSUME_SAFE_MACROS 0
92 #undef CYTHON_UNPACK_METHODS
93 #define CYTHON_UNPACK_METHODS 0
94 #undef CYTHON_FAST_THREAD_STATE
95 #define CYTHON_FAST_THREAD_STATE 0
96 #undef CYTHON_FAST_PYCALL
97 #define CYTHON_FAST_PYCALL 0
98 #undef CYTHON_PEP489_MULTI_PHASE_INIT
99 #define CYTHON_PEP489_MULTI_PHASE_INIT 0
100 #undef CYTHON_USE_TP_FINALIZE
101 #define CYTHON_USE_TP_FINALIZE 0
102 #undef CYTHON_USE_DICT_VERSIONS
103 #define CYTHON_USE_DICT_VERSIONS 0
104 #undef CYTHON_USE_EXC_INFO_STACK
105 #define CYTHON_USE_EXC_INFO_STACK 0
106 #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
107 #define CYTHON_UPDATE_DESCRIPTOR_DOC (PYPY_VERSION_HEX >= 0x07030900)
108 #endif
109 #elif defined(PYSTON_VERSION)
110 #define CYTHON_COMPILING_IN_PYPY 0
111 #define CYTHON_COMPILING_IN_PYSTON 1
112 #define CYTHON_COMPILING_IN_CPYTHON 0
113 #define CYTHON_COMPILING_IN_NOGIL 0
114 #ifndef CYTHON_USE_TYPE_SLOTS
115 #define CYTHON_USE_TYPE_SLOTS 1
116 #endif
117 #undef CYTHON_USE_PYTYPE_LOOKUP
118 #define CYTHON_USE_PYTYPE_LOOKUP 0
119 #undef CYTHON_USE_ASYNC_SLOTS
120 #define CYTHON_USE_ASYNC_SLOTS 0
121 #undef CYTHON_USE_PYLIST_INTERNALS
122 #define CYTHON_USE_PYLIST_INTERNALS 0
123 #ifndef CYTHON_USE_UNICODE_INTERNALS
124 #define CYTHON_USE_UNICODE_INTERNALS 1
125 #endif
126 #undef CYTHON_USE_UNICODE_WRITER
127 #define CYTHON_USE_UNICODE_WRITER 0
128 #undef CYTHON_USE_PYLONG_INTERNALS
129 #define CYTHON_USE_PYLONG_INTERNALS 0
130 #ifndef CYTHON_AVOID_BORROWED_REFS
131 #define CYTHON_AVOID_BORROWED_REFS 0
132 #endif
133 #ifndef CYTHON_ASSUME_SAFE_MACROS
134 #define CYTHON_ASSUME_SAFE_MACROS 1
135 #endif
136 #ifndef CYTHON_UNPACK_METHODS
137 #define CYTHON_UNPACK_METHODS 1
138 #endif
139 #undef CYTHON_FAST_THREAD_STATE
140 #define CYTHON_FAST_THREAD_STATE 0
141 #undef CYTHON_FAST_PYCALL
142 #define CYTHON_FAST_PYCALL 0
143 #undef CYTHON_PEP489_MULTI_PHASE_INIT
144 #define CYTHON_PEP489_MULTI_PHASE_INIT 0
145 #undef CYTHON_USE_TP_FINALIZE
146 #define CYTHON_USE_TP_FINALIZE 0
147 #undef CYTHON_USE_DICT_VERSIONS
148 #define CYTHON_USE_DICT_VERSIONS 0
149 #undef CYTHON_USE_EXC_INFO_STACK
150 #define CYTHON_USE_EXC_INFO_STACK 0
151 #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
152 #define CYTHON_UPDATE_DESCRIPTOR_DOC 0
153 #endif
154 #elif defined(PY_NOGIL)
155 #define CYTHON_COMPILING_IN_PYPY 0
156 #define CYTHON_COMPILING_IN_PYSTON 0
157 #define CYTHON_COMPILING_IN_CPYTHON 0
158 #define CYTHON_COMPILING_IN_NOGIL 1
159 #ifndef CYTHON_USE_TYPE_SLOTS
160 #define CYTHON_USE_TYPE_SLOTS 1
161 #endif
162 #undef CYTHON_USE_PYTYPE_LOOKUP
163 #define CYTHON_USE_PYTYPE_LOOKUP 0
164 #ifndef CYTHON_USE_ASYNC_SLOTS
165 #define CYTHON_USE_ASYNC_SLOTS 1
166 #endif
167 #undef CYTHON_USE_PYLIST_INTERNALS
168 #define CYTHON_USE_PYLIST_INTERNALS 0
169 #ifndef CYTHON_USE_UNICODE_INTERNALS
170 #define CYTHON_USE_UNICODE_INTERNALS 1
171 #endif
172 #undef CYTHON_USE_UNICODE_WRITER
173 #define CYTHON_USE_UNICODE_WRITER 0
174 #undef CYTHON_USE_PYLONG_INTERNALS
175 #define CYTHON_USE_PYLONG_INTERNALS 0
176 #ifndef CYTHON_AVOID_BORROWED_REFS
177 #define CYTHON_AVOID_BORROWED_REFS 0
178 #endif
179 #ifndef CYTHON_ASSUME_SAFE_MACROS
180 #define CYTHON_ASSUME_SAFE_MACROS 1
181 #endif
182 #ifndef CYTHON_UNPACK_METHODS
183 #define CYTHON_UNPACK_METHODS 1
184 #endif
185 #undef CYTHON_FAST_THREAD_STATE
186 #define CYTHON_FAST_THREAD_STATE 0
187 #undef CYTHON_FAST_PYCALL
188 #define CYTHON_FAST_PYCALL 0
189 #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
190 #define CYTHON_PEP489_MULTI_PHASE_INIT 1
191 #endif
192 #ifndef CYTHON_USE_TP_FINALIZE
193 #define CYTHON_USE_TP_FINALIZE 1
194 #endif
195 #undef CYTHON_USE_DICT_VERSIONS
196 #define CYTHON_USE_DICT_VERSIONS 0
197 #undef CYTHON_USE_EXC_INFO_STACK
198 #define CYTHON_USE_EXC_INFO_STACK 0
199 #else
200 #define CYTHON_COMPILING_IN_PYPY 0
201 #define CYTHON_COMPILING_IN_PYSTON 0
202 #define CYTHON_COMPILING_IN_CPYTHON 1
203 #define CYTHON_COMPILING_IN_NOGIL 0
204 #ifndef CYTHON_USE_TYPE_SLOTS
205 #define CYTHON_USE_TYPE_SLOTS 1
206 #endif
207 #if PY_VERSION_HEX < 0x02070000
208 #undef CYTHON_USE_PYTYPE_LOOKUP
209 #define CYTHON_USE_PYTYPE_LOOKUP 0
210 #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
211 #define CYTHON_USE_PYTYPE_LOOKUP 1
212 #endif
213 #if PY_MAJOR_VERSION < 3
214 #undef CYTHON_USE_ASYNC_SLOTS
215 #define CYTHON_USE_ASYNC_SLOTS 0
216 #elif !defined(CYTHON_USE_ASYNC_SLOTS)
217 #define CYTHON_USE_ASYNC_SLOTS 1
218 #endif
219 #if PY_VERSION_HEX < 0x02070000
220 #undef CYTHON_USE_PYLONG_INTERNALS
221 #define CYTHON_USE_PYLONG_INTERNALS 0
222 #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
223 #define CYTHON_USE_PYLONG_INTERNALS 1
224 #endif
225 #ifndef CYTHON_USE_PYLIST_INTERNALS
226 #define CYTHON_USE_PYLIST_INTERNALS 1
227 #endif
228 #ifndef CYTHON_USE_UNICODE_INTERNALS
229 #define CYTHON_USE_UNICODE_INTERNALS 1
230 #endif
231 #if PY_VERSION_HEX < 0x030300F0 || PY_VERSION_HEX >= 0x030B00A2
232 #undef CYTHON_USE_UNICODE_WRITER
233 #define CYTHON_USE_UNICODE_WRITER 0
234 #elif !defined(CYTHON_USE_UNICODE_WRITER)
235 #define CYTHON_USE_UNICODE_WRITER 1
236 #endif
237 #ifndef CYTHON_AVOID_BORROWED_REFS
238 #define CYTHON_AVOID_BORROWED_REFS 0
239 #endif
240 #ifndef CYTHON_ASSUME_SAFE_MACROS
241 #define CYTHON_ASSUME_SAFE_MACROS 1
242 #endif
243 #ifndef CYTHON_UNPACK_METHODS
244 #define CYTHON_UNPACK_METHODS 1
245 #endif
246 #if PY_VERSION_HEX >= 0x030B00A4
247 #undef CYTHON_FAST_THREAD_STATE
248 #define CYTHON_FAST_THREAD_STATE 0
249 #elif !defined(CYTHON_FAST_THREAD_STATE)
250 #define CYTHON_FAST_THREAD_STATE 1
251 #endif
252 #ifndef CYTHON_FAST_PYCALL
253 #define CYTHON_FAST_PYCALL (PY_VERSION_HEX < 0x030A0000)
254 #endif
255 #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
256 #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000)
257 #endif
258 #ifndef CYTHON_USE_TP_FINALIZE
259 #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
260 #endif
261 #ifndef CYTHON_USE_DICT_VERSIONS
262 #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1)
263 #endif
264 #if PY_VERSION_HEX >= 0x030B00A4
265 #undef CYTHON_USE_EXC_INFO_STACK
266 #define CYTHON_USE_EXC_INFO_STACK 0
267 #elif !defined(CYTHON_USE_EXC_INFO_STACK)
268 #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3)
269 #endif
270 #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
271 #define CYTHON_UPDATE_DESCRIPTOR_DOC 1
272 #endif
273 #endif
274 #if !defined(CYTHON_FAST_PYCCALL)
275 #define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
276 #endif
277 #if CYTHON_USE_PYLONG_INTERNALS
278 #if PY_MAJOR_VERSION < 3
279 #include "longintrepr.h"
280 #endif
281 #undef SHIFT
282 #undef BASE
283 #undef MASK
284 #ifdef SIZEOF_VOID_P
285 enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) };
286 #endif
287 #endif
288 #ifndef __has_attribute
289 #define __has_attribute(x) 0
290 #endif
291 #ifndef __has_cpp_attribute
292 #define __has_cpp_attribute(x) 0
293 #endif
294 #ifndef CYTHON_RESTRICT
295 #if defined(__GNUC__)
296 #define CYTHON_RESTRICT __restrict__
297 #elif defined(_MSC_VER) && _MSC_VER >= 1400
298 #define CYTHON_RESTRICT __restrict
299 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
300 #define CYTHON_RESTRICT restrict
301 #else
302 #define CYTHON_RESTRICT
303 #endif
304 #endif
305 #ifndef CYTHON_UNUSED
306 # if defined(__GNUC__)
307 # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
308 # define CYTHON_UNUSED __attribute__ ((__unused__))
309 # else
310 # define CYTHON_UNUSED
311 # endif
312 # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
313 # define CYTHON_UNUSED __attribute__ ((__unused__))
314 # else
315 # define CYTHON_UNUSED
316 # endif
317 #endif
318 #ifndef CYTHON_MAYBE_UNUSED_VAR
319 # if defined(__cplusplus)
320 template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
321 # else
322 # define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
323 # endif
324 #endif
325 #ifndef CYTHON_NCP_UNUSED
326 # if CYTHON_COMPILING_IN_CPYTHON
327 # define CYTHON_NCP_UNUSED
328 # else
329 # define CYTHON_NCP_UNUSED CYTHON_UNUSED
330 # endif
331 #endif
332 #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
333 #ifdef _MSC_VER
334 #ifndef _MSC_STDINT_H_
335 #if _MSC_VER < 1300
336 typedef unsigned char uint8_t;
337 typedef unsigned int uint32_t;
338 #else
339 typedef unsigned __int8 uint8_t;
340 typedef unsigned __int32 uint32_t;
341 #endif
342 #endif
343 #else
344 #include <stdint.h>
345 #endif
346 #ifndef CYTHON_FALLTHROUGH
347 #if defined(__cplusplus) && __cplusplus >= 201103L
348 #if __has_cpp_attribute(fallthrough)
349 #define CYTHON_FALLTHROUGH [[fallthrough]]
350 #elif __has_cpp_attribute(clang::fallthrough)
351 #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
352 #elif __has_cpp_attribute(gnu::fallthrough)
353 #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
354 #endif
355 #endif
356 #ifndef CYTHON_FALLTHROUGH
357 #if __has_attribute(fallthrough)
358 #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
359 #else
360 #define CYTHON_FALLTHROUGH
361 #endif
362 #endif
363 #if defined(__clang__ ) && defined(__apple_build_version__)
364 #if __apple_build_version__ < 7000000
365 #undef CYTHON_FALLTHROUGH
366 #define CYTHON_FALLTHROUGH
367 #endif
368 #endif
369 #endif
370
371 #ifndef __cplusplus
372 #error "Cython files generated with the C++ option must be compiled with a C++ compiler."
373 #endif
374 #ifndef CYTHON_INLINE
375 #if defined(__clang__)
376 #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
377 #else
378 #define CYTHON_INLINE inline
379 #endif
380 #endif
381 template<typename T>
382 void __Pyx_call_destructor(T& x) {
383 x.~T();
384 }
385 template<typename T>
386 class __Pyx_FakeReference {
387 public:
388 __Pyx_FakeReference() : ptr(NULL) { }
389 __Pyx_FakeReference(const T& ref) : ptr(const_cast<T*>(&ref)) { }
390 T *operator->() { return ptr; }
391 T *operator&() { return ptr; }
392 operator T&() { return *ptr; }
393 template<typename U> bool operator ==(U other) { return *ptr == other; }
394 template<typename U> bool operator !=(U other) { return *ptr != other; }
395 private:
396 T *ptr;
397 };
398
399 #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
400 #define Py_OptimizeFlag 0
401 #endif
402 #define __PYX_BUILD_PY_SSIZE_T "n"
403 #define CYTHON_FORMAT_SSIZE_T "z"
404 #if PY_MAJOR_VERSION < 3
405 #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
406 #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
407 PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
408 #define __Pyx_DefaultClassType PyClass_Type
409 #else
410 #define __Pyx_BUILTIN_MODULE_NAME "builtins"
411 #define __Pyx_DefaultClassType PyType_Type
412 #if PY_VERSION_HEX >= 0x030B00A1
413 static CYTHON_INLINE PyCodeObject* __Pyx_PyCode_New(int a, int k, int l, int s, int f,
414 PyObject *code, PyObject *c, PyObject* n, PyObject *v,
415 PyObject *fv, PyObject *cell, PyObject* fn,
416 PyObject *name, int fline, PyObject *lnos) {
417 PyObject *kwds=NULL, *argcount=NULL, *posonlyargcount=NULL, *kwonlyargcount=NULL;
418 PyObject *nlocals=NULL, *stacksize=NULL, *flags=NULL, *replace=NULL, *call_result=NULL, *empty=NULL;
419 const char *fn_cstr=NULL;
420 const char *name_cstr=NULL;
421 PyCodeObject* co=NULL;
422 PyObject *type, *value, *traceback;
423 PyErr_Fetch(&type, &value, &traceback);
424 if (!(kwds=PyDict_New())) goto end;
425 if (!(argcount=PyLong_FromLong(a))) goto end;
426 if (PyDict_SetItemString(kwds, "co_argcount", argcount) != 0) goto end;
427 if (!(posonlyargcount=PyLong_FromLong(0))) goto end;
428 if (PyDict_SetItemString(kwds, "co_posonlyargcount", posonlyargcount) != 0) goto end;
429 if (!(kwonlyargcount=PyLong_FromLong(k))) goto end;
430 if (PyDict_SetItemString(kwds, "co_kwonlyargcount", kwonlyargcount) != 0) goto end;
431 if (!(nlocals=PyLong_FromLong(l))) goto end;
432 if (PyDict_SetItemString(kwds, "co_nlocals", nlocals) != 0) goto end;
433 if (!(stacksize=PyLong_FromLong(s))) goto end;
434 if (PyDict_SetItemString(kwds, "co_stacksize", stacksize) != 0) goto end;
435 if (!(flags=PyLong_FromLong(f))) goto end;
436 if (PyDict_SetItemString(kwds, "co_flags", flags) != 0) goto end;
437 if (PyDict_SetItemString(kwds, "co_code", code) != 0) goto end;
438 if (PyDict_SetItemString(kwds, "co_consts", c) != 0) goto end;
439 if (PyDict_SetItemString(kwds, "co_names", n) != 0) goto end;
440 if (PyDict_SetItemString(kwds, "co_varnames", v) != 0) goto end;
441 if (PyDict_SetItemString(kwds, "co_freevars", fv) != 0) goto end;
442 if (PyDict_SetItemString(kwds, "co_cellvars", cell) != 0) goto end;
443 if (PyDict_SetItemString(kwds, "co_linetable", lnos) != 0) goto end;
444 if (!(fn_cstr=PyUnicode_AsUTF8AndSize(fn, NULL))) goto end;
445 if (!(name_cstr=PyUnicode_AsUTF8AndSize(name, NULL))) goto end;
446 if (!(co = PyCode_NewEmpty(fn_cstr, name_cstr, fline))) goto end;
447 if (!(replace = PyObject_GetAttrString((PyObject*)co, "replace"))) goto cleanup_code_too;
448 if (!(empty = PyTuple_New(0))) goto cleanup_code_too; // unfortunately __pyx_empty_tuple isn't available here
449 if (!(call_result = PyObject_Call(replace, empty, kwds))) goto cleanup_code_too;
450 Py_XDECREF((PyObject*)co);
451 co = (PyCodeObject*)call_result;
452 call_result = NULL;
453 if (0) {
454 cleanup_code_too:
455 Py_XDECREF((PyObject*)co);
456 co = NULL;
457 }
458 end:
459 Py_XDECREF(kwds);
460 Py_XDECREF(argcount);
461 Py_XDECREF(posonlyargcount);
462 Py_XDECREF(kwonlyargcount);
463 Py_XDECREF(nlocals);
464 Py_XDECREF(stacksize);
465 Py_XDECREF(replace);
466 Py_XDECREF(call_result);
467 Py_XDECREF(empty);
468 if (type) {
469 PyErr_Restore(type, value, traceback);
470 }
471 return co;
472 }
473 #else
474 #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
475 PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
476 #endif
477 #define __Pyx_DefaultClassType PyType_Type
478 #endif
479 #ifndef Py_TPFLAGS_CHECKTYPES
480 #define Py_TPFLAGS_CHECKTYPES 0
481 #endif
482 #ifndef Py_TPFLAGS_HAVE_INDEX
483 #define Py_TPFLAGS_HAVE_INDEX 0
484 #endif
485 #ifndef Py_TPFLAGS_HAVE_NEWBUFFER
486 #define Py_TPFLAGS_HAVE_NEWBUFFER 0
487 #endif
488 #ifndef Py_TPFLAGS_HAVE_FINALIZE
489 #define Py_TPFLAGS_HAVE_FINALIZE 0
490 #endif
491 #ifndef METH_STACKLESS
492 #define METH_STACKLESS 0
493 #endif
494 #if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
495 #ifndef METH_FASTCALL
496 #define METH_FASTCALL 0x80
497 #endif
498 typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
499 typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
500 Py_ssize_t nargs, PyObject *kwnames);
501 #else
502 #define __Pyx_PyCFunctionFast _PyCFunctionFast
503 #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
504 #endif
505 #if CYTHON_FAST_PYCCALL
506 #define __Pyx_PyFastCFunction_Check(func)\
507 ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)))))
508 #else
509 #define __Pyx_PyFastCFunction_Check(func) 0
510 #endif
511 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
512 #define PyObject_Malloc(s) PyMem_Malloc(s)
513 #define PyObject_Free(p) PyMem_Free(p)
514 #define PyObject_Realloc(p) PyMem_Realloc(p)
515 #endif
516 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1
517 #define PyMem_RawMalloc(n) PyMem_Malloc(n)
518 #define PyMem_RawRealloc(p, n) PyMem_Realloc(p, n)
519 #define PyMem_RawFree(p) PyMem_Free(p)
520 #endif
521 #if CYTHON_COMPILING_IN_PYSTON
522 #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co)
523 #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
524 #else
525 #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
526 #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
527 #endif
528 #if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
529 #define __Pyx_PyThreadState_Current PyThreadState_GET()
530 #elif PY_VERSION_HEX >= 0x03060000
531 #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
532 #elif PY_VERSION_HEX >= 0x03000000
533 #define __Pyx_PyThreadState_Current PyThreadState_GET()
534 #else
535 #define __Pyx_PyThreadState_Current _PyThreadState_Current
536 #endif
537 #if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
538 #include "pythread.h"
539 #define Py_tss_NEEDS_INIT 0
540 typedef int Py_tss_t;
541 static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
542 *key = PyThread_create_key();
543 return 0;
544 }
545 static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
546 Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
547 *key = Py_tss_NEEDS_INIT;
548 return key;
549 }
550 static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
551 PyObject_Free(key);
552 }
553 static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
554 return *key != Py_tss_NEEDS_INIT;
555 }
556 static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
557 PyThread_delete_key(*key);
558 *key = Py_tss_NEEDS_INIT;
559 }
560 static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
561 return PyThread_set_key_value(*key, value);
562 }
563 static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
564 return PyThread_get_key_value(*key);
565 }
566 #endif
567 #if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
568 #define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
569 #else
570 #define __Pyx_PyDict_NewPresized(n) PyDict_New()
571 #endif
572 #if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
573 #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
574 #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
575 #else
576 #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
577 #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
578 #endif
579 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
580 #define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
581 #else
582 #define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name)
583 #endif
584 #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
585 #define CYTHON_PEP393_ENABLED 1
586 #if defined(PyUnicode_IS_READY)
587 #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
588 0 : _PyUnicode_Ready((PyObject *)(op)))
589 #else
590 #define __Pyx_PyUnicode_READY(op) (0)
591 #endif
592 #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
593 #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
594 #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
595 #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
596 #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
597 #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
598 #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch)
599 #if defined(PyUnicode_IS_READY) && defined(PyUnicode_GET_SIZE)
600 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03090000
601 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : ((PyCompactUnicodeObject *)(u))->wstr_length))
602 #else
603 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
604 #endif
605 #else
606 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_LENGTH(u))
607 #endif
608 #else
609 #define CYTHON_PEP393_ENABLED 0
610 #define PyUnicode_1BYTE_KIND 1
611 #define PyUnicode_2BYTE_KIND 2
612 #define PyUnicode_4BYTE_KIND 4
613 #define __Pyx_PyUnicode_READY(op) (0)
614 #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
615 #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
616 #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
617 #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
618 #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
619 #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
620 #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
621 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u))
622 #endif
623 #if CYTHON_COMPILING_IN_PYPY
624 #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
625 #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
626 #else
627 #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
628 #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
629 PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
630 #endif
631 #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
632 #define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
633 #endif
634 #if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
635 #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
636 #endif
637 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
638 #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
639 #endif
640 #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))
641 #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
642 #if PY_MAJOR_VERSION >= 3
643 #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
644 #else
645 #define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
646 #endif
647 #if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
648 #define PyObject_ASCII(o) PyObject_Repr(o)
649 #endif
650 #if PY_MAJOR_VERSION >= 3
651 #define PyBaseString_Type PyUnicode_Type
652 #define PyStringObject PyUnicodeObject
653 #define PyString_Type PyUnicode_Type
654 #define PyString_Check PyUnicode_Check
655 #define PyString_CheckExact PyUnicode_CheckExact
656 #ifndef PyObject_Unicode
657 #define PyObject_Unicode PyObject_Str
658 #endif
659 #endif
660 #if PY_MAJOR_VERSION >= 3
661 #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
662 #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
663 #else
664 #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
665 #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
666 #endif
667 #ifndef PySet_CheckExact
668 #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
669 #endif
670 #if PY_VERSION_HEX >= 0x030900A4
671 #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt)
672 #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size)
673 #else
674 #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt)
675 #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size)
676 #endif
677 #if CYTHON_ASSUME_SAFE_MACROS
678 #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq)
679 #else
680 #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq)
681 #endif
682 #if PY_MAJOR_VERSION >= 3
683 #define PyIntObject PyLongObject
684 #define PyInt_Type PyLong_Type
685 #define PyInt_Check(op) PyLong_Check(op)
686 #define PyInt_CheckExact(op) PyLong_CheckExact(op)
687 #define PyInt_FromString PyLong_FromString
688 #define PyInt_FromUnicode PyLong_FromUnicode
689 #define PyInt_FromLong PyLong_FromLong
690 #define PyInt_FromSize_t PyLong_FromSize_t
691 #define PyInt_FromSsize_t PyLong_FromSsize_t
692 #define PyInt_AsLong PyLong_AsLong
693 #define PyInt_AS_LONG PyLong_AS_LONG
694 #define PyInt_AsSsize_t PyLong_AsSsize_t
695 #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
696 #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
697 #define PyNumber_Int PyNumber_Long
698 #endif
699 #if PY_MAJOR_VERSION >= 3
700 #define PyBoolObject PyLongObject
701 #endif
702 #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
703 #ifndef PyUnicode_InternFromString
704 #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
705 #endif
706 #endif
707 #if PY_VERSION_HEX < 0x030200A4
708 typedef long Py_hash_t;
709 #define __Pyx_PyInt_FromHash_t PyInt_FromLong
710 #define __Pyx_PyInt_AsHash_t __Pyx_PyIndex_AsHash_t
711 #else
712 #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
713 #define __Pyx_PyInt_AsHash_t __Pyx_PyIndex_AsSsize_t
714 #endif
715 #if PY_MAJOR_VERSION >= 3
716 #define __Pyx_PyMethod_New(func, self, klass) ((self) ? ((void)(klass), PyMethod_New(func, self)) : __Pyx_NewRef(func))
717 #else
718 #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
719 #endif
720 #if CYTHON_USE_ASYNC_SLOTS
721 #if PY_VERSION_HEX >= 0x030500B1
722 #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
723 #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
724 #else
725 #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
726 #endif
727 #else
728 #define __Pyx_PyType_AsAsync(obj) NULL
729 #endif
730 #ifndef __Pyx_PyAsyncMethodsStruct
731 typedef struct {
732 unaryfunc am_await;
733 unaryfunc am_aiter;
734 unaryfunc am_anext;
735 } __Pyx_PyAsyncMethodsStruct;
736 #endif
737
738 #if defined(_WIN32) || defined(WIN32) || defined(MS_WINDOWS)
739 #if !defined(_USE_MATH_DEFINES)
740 #define _USE_MATH_DEFINES
741 #endif
742 #endif
743 #include <math.h>
744 #ifdef NAN
745 #define __PYX_NAN() ((float) NAN)
746 #else
747 static CYTHON_INLINE float __PYX_NAN() {
748 float value;
749 memset(&value, 0xFF, sizeof(value));
750 return value;
751 }
752 #endif
753 #if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
754 #define __Pyx_truncl trunc
755 #else
756 #define __Pyx_truncl truncl
757 #endif
758
759 #define __PYX_MARK_ERR_POS(f_index, lineno) \
760 { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; }
761 #define __PYX_ERR(f_index, lineno, Ln_error) \
762 { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; }
763
764 #ifndef __PYX_EXTERN_C
765 #ifdef __cplusplus
766 #define __PYX_EXTERN_C extern "C"
767 #else
768 #define __PYX_EXTERN_C extern
769 #endif
770 #endif
771
772 #define __PYX_HAVE__pybuffer
773 #define __PYX_HAVE_API__pybuffer
774 /* Early includes */
775 #include "mpi_compat.h"
776 #include "mpi.h"
777 #include "music/pymusic_c.h"
778 #include <string.h>
779 #include <stdio.h>
780 #include <stdlib.h>
781 #ifdef _OPENMP
782 #include <omp.h>
783 #endif /* _OPENMP */
784
785 #if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
786 #define CYTHON_WITHOUT_ASSERTIONS
787 #endif
788
789 typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
790 const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
791
792 #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
793 #define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0
794 #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8)
795 #define __PYX_DEFAULT_STRING_ENCODING ""
796 #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
797 #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
798 #define __Pyx_uchar_cast(c) ((unsigned char)c)
799 #define __Pyx_long_cast(x) ((long)x)
800 #define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
801 (sizeof(type) < sizeof(Py_ssize_t)) ||\
802 (sizeof(type) > sizeof(Py_ssize_t) &&\
803 likely(v < (type)PY_SSIZE_T_MAX ||\
804 v == (type)PY_SSIZE_T_MAX) &&\
805 (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
806 v == (type)PY_SSIZE_T_MIN))) ||\
807 (sizeof(type) == sizeof(Py_ssize_t) &&\
808 (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
809 v == (type)PY_SSIZE_T_MAX))) )
810 static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
811 return (size_t) i < (size_t) limit;
812 }
813 #if defined (__cplusplus) && __cplusplus >= 201103L
814 #include <cstdlib>
815 #define __Pyx_sst_abs(value) std::abs(value)
816 #elif SIZEOF_INT >= SIZEOF_SIZE_T
817 #define __Pyx_sst_abs(value) abs(value)
818 #elif SIZEOF_LONG >= SIZEOF_SIZE_T
819 #define __Pyx_sst_abs(value) labs(value)
820 #elif defined (_MSC_VER)
821 #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
822 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
823 #define __Pyx_sst_abs(value) llabs(value)
824 #elif defined (__GNUC__)
825 #define __Pyx_sst_abs(value) __builtin_llabs(value)
826 #else
827 #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
828 #endif
829 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
830 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
831 #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
832 #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
833 #define __Pyx_PyBytes_FromString PyBytes_FromString
834 #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
835 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
836 #if PY_MAJOR_VERSION < 3
837 #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
838 #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
839 #else
840 #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
841 #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
842 #endif
843 #define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s))
844 #define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s))
845 #define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s))
846 #define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s))
847 #define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s))
848 #define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s))
849 #define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s))
850 #define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
851 #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
852 #define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s))
853 #define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s))
854 #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
855 #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
856 #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
857 #define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s)
858 #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
859 static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
860 const Py_UNICODE *u_end = u;
861 while (*u_end++) ;
862 return (size_t)(u_end - u - 1);
863 }
864 #define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
865 #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
866 #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
867 #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
868 #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
869 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
870 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
871 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
872 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
873 #define __Pyx_PySequence_Tuple(obj)\
874 (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
875 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
876 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
877 static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject*);
878 #if CYTHON_ASSUME_SAFE_MACROS
879 #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
880 #else
881 #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
882 #endif
883 #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
884 #if PY_MAJOR_VERSION >= 3
885 #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
886 #else
887 #define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
888 #endif
889 #define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
890 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
891 static int __Pyx_sys_getdefaultencoding_not_ascii;
892 static int __Pyx_init_sys_getdefaultencoding_params(void) {
893 PyObject* sys;
894 PyObject* default_encoding = NULL;
895 PyObject* ascii_chars_u = NULL;
896 PyObject* ascii_chars_b = NULL;
897 const char* default_encoding_c;
898 sys = PyImport_ImportModule("sys");
899 if (!sys) goto bad;
900 default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
901 Py_DECREF(sys);
902 if (!default_encoding) goto bad;
903 default_encoding_c = PyBytes_AsString(default_encoding);
904 if (!default_encoding_c) goto bad;
905 if (strcmp(default_encoding_c, "ascii") == 0) {
906 __Pyx_sys_getdefaultencoding_not_ascii = 0;
907 } else {
908 char ascii_chars[128];
909 int c;
910 for (c = 0; c < 128; c++) {
911 ascii_chars[c] = c;
912 }
913 __Pyx_sys_getdefaultencoding_not_ascii = 1;
914 ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
915 if (!ascii_chars_u) goto bad;
916 ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
917 if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
918 PyErr_Format(
919 PyExc_ValueError,
920 "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
921 default_encoding_c);
922 goto bad;
923 }
924 Py_DECREF(ascii_chars_u);
925 Py_DECREF(ascii_chars_b);
926 }
927 Py_DECREF(default_encoding);
928 return 0;
929 bad:
930 Py_XDECREF(default_encoding);
931 Py_XDECREF(ascii_chars_u);
932 Py_XDECREF(ascii_chars_b);
933 return -1;
934 }
935 #endif
936 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
937 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
938 #else
939 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
940 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
941 static char* __PYX_DEFAULT_STRING_ENCODING;
942 static int __Pyx_init_sys_getdefaultencoding_params(void) {
943 PyObject* sys;
944 PyObject* default_encoding = NULL;
945 char* default_encoding_c;
946 sys = PyImport_ImportModule("sys");
947 if (!sys) goto bad;
948 default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
949 Py_DECREF(sys);
950 if (!default_encoding) goto bad;
951 default_encoding_c = PyBytes_AsString(default_encoding);
952 if (!default_encoding_c) goto bad;
953 __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1);
954 if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
955 strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
956 Py_DECREF(default_encoding);
957 return 0;
958 bad:
959 Py_XDECREF(default_encoding);
960 return -1;
961 }
962 #endif
963 #endif
964
965
966 /* Test for GCC > 2.95 */
967 #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
968 #define likely(x) __builtin_expect(!!(x), 1)
969 #define unlikely(x) __builtin_expect(!!(x), 0)
970 #else /* !__GNUC__ or GCC < 2.95 */
971 #define likely(x) (x)
972 #define unlikely(x) (x)
973 #endif /* __GNUC__ */
974 static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
975
976 static PyObject *__pyx_m = NULL;
977 static PyObject *__pyx_d;
978 static PyObject *__pyx_b;
979 static PyObject *__pyx_cython_runtime = NULL;
980 static PyObject *__pyx_empty_tuple;
981 static PyObject *__pyx_empty_bytes;
982 static PyObject *__pyx_empty_unicode;
983 static int __pyx_lineno;
984 static int __pyx_clineno = 0;
985 static const char * __pyx_cfilenm= __FILE__;
986 static const char *__pyx_filename;
987
988
989 static const char *__pyx_f[] = {
990 "pybuffer.pyx",
991 "stringsource",
992 "MPI.pxd",
993 "type.pxd",
994 };
995
996 /*--- Type declarations ---*/
997 struct PyMPIDatatypeObject;
998 struct PyMPIStatusObject;
999 struct PyMPIRequestObject;
1000 struct PyMPIPrequestObject;
1001 struct PyMPIGrequestObject;
1002 struct PyMPIMessageObject;
1003 struct PyMPIOpObject;
1004 struct PyMPIGroupObject;
1005 struct PyMPIInfoObject;
1006 struct PyMPIErrhandlerObject;
1007 struct PyMPICommObject;
1008 struct PyMPIIntracommObject;
1009 struct PyMPITopocommObject;
1010 struct PyMPICartcommObject;
1011 struct PyMPIGraphcommObject;
1012 struct PyMPIDistgraphcommObject;
1013 struct PyMPIIntercommObject;
1014 struct PyMPIWinObject;
1015 struct PyMPIFileObject;
1016 struct __pyx_obj_8pybuffer_Buffer;
1017
1018 /* "mpi4py/MPI.pxd":28
1019 * ctypedef MPI_Count Count "MPI_Count"
1020 *
1021 * ctypedef public api class Datatype [ # <<<<<<<<<<<<<<
1022 * type PyMPIDatatype_Type,
1023 * object PyMPIDatatypeObject,
1024 */
1025 struct PyMPIDatatypeObject {
1026 PyObject_HEAD
1027 MPI_Datatype ob_mpi;
1028 unsigned int flags;
1029 PyObject *__weakref__;
1030 };
1031 typedef struct PyMPIDatatypeObject PyMPIDatatypeObject;
1032
1033 __PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyMPIDatatype_Type;
1034
1035 /* "mpi4py/MPI.pxd":36
1036 * cdef object __weakref__
1037 *
1038 * ctypedef public api class Status [ # <<<<<<<<<<<<<<
1039 * type PyMPIStatus_Type,
1040 * object PyMPIStatusObject,
1041 */
1042 struct PyMPIStatusObject {
1043 PyObject_HEAD
1044 MPI_Status ob_mpi;
1045 unsigned int flags;
1046 PyObject *__weakref__;
1047 };
1048 typedef struct PyMPIStatusObject PyMPIStatusObject;
1049
1050 __PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyMPIStatus_Type;
1051
1052 /* "mpi4py/MPI.pxd":44
1053 * cdef object __weakref__
1054 *
1055 * ctypedef public api class Request [ # <<<<<<<<<<<<<<
1056 * type PyMPIRequest_Type,
1057 * object PyMPIRequestObject,
1058 */
1059 struct PyMPIRequestObject {
1060 PyObject_HEAD
1061 MPI_Request ob_mpi;
1062 unsigned int flags;
1063 PyObject *__weakref__;
1064 PyObject *ob_buf;
1065 };
1066 typedef struct PyMPIRequestObject PyMPIRequestObject;
1067
1068 __PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyMPIRequest_Type;
1069
1070 /* "mpi4py/MPI.pxd":53
1071 * cdef object ob_buf
1072 *
1073 * ctypedef public api class Prequest(Request) [ # <<<<<<<<<<<<<<
1074 * type PyMPIPrequest_Type,
1075 * object PyMPIPrequestObject,
1076 */
1077 struct PyMPIPrequestObject {
1078 struct PyMPIRequestObject __pyx_base;
1079 };
1080 typedef struct PyMPIPrequestObject PyMPIPrequestObject;
1081
1082 __PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyMPIPrequest_Type;
1083
1084 /* "mpi4py/MPI.pxd":59
1085 * pass
1086 *
1087 * ctypedef public api class Grequest(Request) [ # <<<<<<<<<<<<<<
1088 * type PyMPIGrequest_Type,
1089 * object PyMPIGrequestObject,
1090 */
1091 struct PyMPIGrequestObject {
1092 struct PyMPIRequestObject __pyx_base;
1093 MPI_Request ob_grequest;
1094 };
1095 typedef struct PyMPIGrequestObject PyMPIGrequestObject;
1096
1097 __PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyMPIGrequest_Type;
1098
1099 /* "mpi4py/MPI.pxd":65
1100 * cdef MPI_Request ob_grequest
1101 *
1102 * ctypedef public api class Message [ # <<<<<<<<<<<<<<
1103 * type PyMPIMessage_Type,
1104 * object PyMPIMessageObject,
1105 */
1106 struct PyMPIMessageObject {
1107 PyObject_HEAD
1108 MPI_Message ob_mpi;
1109 unsigned int flags;
1110 PyObject *__weakref__;
1111 PyObject *ob_buf;
1112 };
1113 typedef struct PyMPIMessageObject PyMPIMessageObject;
1114
1115 __PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyMPIMessage_Type;
1116
1117 /* "mpi4py/MPI.pxd":74
1118 * cdef object ob_buf
1119 *
1120 * ctypedef public api class Op [ # <<<<<<<<<<<<<<
1121 * type PyMPIOp_Type,
1122 * object PyMPIOpObject,
1123 */
1124 struct PyMPIOpObject {
1125 PyObject_HEAD
1126 MPI_Op ob_mpi;
1127 unsigned int flags;
1128 PyObject *__weakref__;
1129 PyObject *(*ob_func)(PyObject *, PyObject *);
1130 int ob_usrid;
1131 };
1132 typedef struct PyMPIOpObject PyMPIOpObject;
1133
1134 __PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyMPIOp_Type;
1135
1136 /* "mpi4py/MPI.pxd":84
1137 * cdef int ob_usrid
1138 *
1139 * ctypedef public api class Group [ # <<<<<<<<<<<<<<
1140 * type PyMPIGroup_Type,
1141 * object PyMPIGroupObject,
1142 */
1143 struct PyMPIGroupObject {
1144 PyObject_HEAD
1145 MPI_Group ob_mpi;
1146 unsigned int flags;
1147 PyObject *__weakref__;
1148 };
1149 typedef struct PyMPIGroupObject PyMPIGroupObject;
1150
1151 __PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyMPIGroup_Type;
1152
1153 /* "mpi4py/MPI.pxd":92
1154 * cdef object __weakref__
1155 *
1156 * ctypedef public api class Info [ # <<<<<<<<<<<<<<
1157 * type PyMPIInfo_Type,
1158 * object PyMPIInfoObject,
1159 */
1160 struct PyMPIInfoObject {
1161 PyObject_HEAD
1162 MPI_Info ob_mpi;
1163 unsigned int flags;
1164 PyObject *__weakref__;
1165 };
1166 typedef struct PyMPIInfoObject PyMPIInfoObject;
1167
1168 __PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyMPIInfo_Type;
1169
1170 /* "mpi4py/MPI.pxd":100
1171 * cdef object __weakref__
1172 *
1173 * ctypedef public api class Errhandler [ # <<<<<<<<<<<<<<
1174 * type PyMPIErrhandler_Type,
1175 * object PyMPIErrhandlerObject,
1176 */
1177 struct PyMPIErrhandlerObject {
1178 PyObject_HEAD
1179 MPI_Errhandler ob_mpi;
1180 unsigned int flags;
1181 PyObject *__weakref__;
1182 };
1183 typedef struct PyMPIErrhandlerObject PyMPIErrhandlerObject;
1184
1185 __PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyMPIErrhandler_Type;
1186
1187 /* "mpi4py/MPI.pxd":108
1188 * cdef object __weakref__
1189 *
1190 * ctypedef public api class Comm [ # <<<<<<<<<<<<<<
1191 * type PyMPIComm_Type,
1192 * object PyMPICommObject,
1193 */
1194 struct PyMPICommObject {
1195 PyObject_HEAD
1196 MPI_Comm ob_mpi;
1197 unsigned int flags;
1198 PyObject *__weakref__;
1199 };
1200 typedef struct PyMPICommObject PyMPICommObject;
1201
1202 __PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyMPIComm_Type;
1203
1204 /* "mpi4py/MPI.pxd":116
1205 * cdef object __weakref__
1206 *
1207 * ctypedef public api class Intracomm(Comm) [ # <<<<<<<<<<<<<<
1208 * type PyMPIIntracomm_Type,
1209 * object PyMPIIntracommObject,
1210 */
1211 struct PyMPIIntracommObject {
1212 struct PyMPICommObject __pyx_base;
1213 };
1214 typedef struct PyMPIIntracommObject PyMPIIntracommObject;
1215
1216 __PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyMPIIntracomm_Type;
1217
1218 /* "mpi4py/MPI.pxd":122
1219 * pass
1220 *
1221 * ctypedef public api class Topocomm(Intracomm) [ # <<<<<<<<<<<<<<
1222 * type PyMPITopocomm_Type,
1223 * object PyMPITopocommObject,
1224 */
1225 struct PyMPITopocommObject {
1226 struct PyMPIIntracommObject __pyx_base;
1227 };
1228 typedef struct PyMPITopocommObject PyMPITopocommObject;
1229
1230 __PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyMPITopocomm_Type;
1231
1232 /* "mpi4py/MPI.pxd":128
1233 * pass
1234 *
1235 * ctypedef public api class Cartcomm(Topocomm) [ # <<<<<<<<<<<<<<
1236 * type PyMPICartcomm_Type,
1237 * object PyMPICartcommObject,
1238 */
1239 struct PyMPICartcommObject {
1240 struct PyMPITopocommObject __pyx_base;
1241 };
1242 typedef struct PyMPICartcommObject PyMPICartcommObject;
1243
1244 __PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyMPICartcomm_Type;
1245
1246 /* "mpi4py/MPI.pxd":134
1247 * pass
1248 *
1249 * ctypedef public api class Graphcomm(Topocomm) [ # <<<<<<<<<<<<<<
1250 * type PyMPIGraphcomm_Type,
1251 * object PyMPIGraphcommObject,
1252 */
1253 struct PyMPIGraphcommObject {
1254 struct PyMPITopocommObject __pyx_base;
1255 };
1256 typedef struct PyMPIGraphcommObject PyMPIGraphcommObject;
1257
1258 __PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyMPIGraphcomm_Type;
1259
1260 /* "mpi4py/MPI.pxd":140
1261 * pass
1262 *
1263 * ctypedef public api class Distgraphcomm(Topocomm) [ # <<<<<<<<<<<<<<
1264 * type PyMPIDistgraphcomm_Type,
1265 * object PyMPIDistgraphcommObject,
1266 */
1267 struct PyMPIDistgraphcommObject {
1268 struct PyMPITopocommObject __pyx_base;
1269 };
1270 typedef struct PyMPIDistgraphcommObject PyMPIDistgraphcommObject;
1271
1272 __PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyMPIDistgraphcomm_Type;
1273
1274 /* "mpi4py/MPI.pxd":146
1275 * pass
1276 *
1277 * ctypedef public api class Intercomm(Comm) [ # <<<<<<<<<<<<<<
1278 * type PyMPIIntercomm_Type,
1279 * object PyMPIIntercommObject,
1280 */
1281 struct PyMPIIntercommObject {
1282 struct PyMPICommObject __pyx_base;
1283 };
1284 typedef struct PyMPIIntercommObject PyMPIIntercommObject;
1285
1286 __PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyMPIIntercomm_Type;
1287
1288 /* "mpi4py/MPI.pxd":152
1289 * pass
1290 *
1291 * ctypedef public api class Win [ # <<<<<<<<<<<<<<
1292 * type PyMPIWin_Type,
1293 * object PyMPIWinObject,
1294 */
1295 struct PyMPIWinObject {
1296 PyObject_HEAD
1297 MPI_Win ob_mpi;
1298 unsigned int flags;
1299 PyObject *__weakref__;
1300 PyObject *ob_mem;
1301 };
1302 typedef struct PyMPIWinObject PyMPIWinObject;
1303
1304 __PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyMPIWin_Type;
1305
1306 /* "mpi4py/MPI.pxd":161
1307 * cdef object ob_mem
1308 *
1309 * ctypedef public api class File [ # <<<<<<<<<<<<<<
1310 * type PyMPIFile_Type,
1311 * object PyMPIFileObject,
1312 */
1313 struct PyMPIFileObject {
1314 PyObject_HEAD
1315 MPI_File ob_mpi;
1316 unsigned int flags;
1317 PyObject *__weakref__;
1318 };
1319 typedef struct PyMPIFileObject PyMPIFileObject;
1320
1321 __PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyMPIFile_Type;
1322
1323 /* "pybuffer.pxd":49
1324 * int PyBuffer_FillInfo(Py_buffer*, object, void*, Py_ssize_t, bint, int) except -1
1325 *
1326 * cdef class Buffer(object): # <<<<<<<<<<<<<<
1327 * cdef Py_buffer pybuf
1328 * cdef MPI.Datatype dtype
1329 */
1330 struct __pyx_obj_8pybuffer_Buffer {
1331 PyObject_HEAD
1332 Py_buffer pybuf;
1333 struct PyMPIDatatypeObject *dtype;
1334 Py_ssize_t items;
1335 };
1336
1337
1338 /* --- Runtime support code (head) --- */
1339 /* Refnanny.proto */
1340 #ifndef CYTHON_REFNANNY
1341 #define CYTHON_REFNANNY 0
1342 #endif
1343 #if CYTHON_REFNANNY
1344 typedef struct {
1345 void (*INCREF)(void*, PyObject*, int);
1346 void (*DECREF)(void*, PyObject*, int);
1347 void (*GOTREF)(void*, PyObject*, int);
1348 void (*GIVEREF)(void*, PyObject*, int);
1349 void* (*SetupContext)(const char*, int, const char*);
1350 void (*FinishContext)(void**);
1351 } __Pyx_RefNannyAPIStruct;
1352 static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
1353 static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
1354 #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
1355 #ifdef WITH_THREAD
1356 #define __Pyx_RefNannySetupContext(name, acquire_gil)\
1357 if (acquire_gil) {\
1358 PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
1359 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
1360 PyGILState_Release(__pyx_gilstate_save);\
1361 } else {\
1362 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
1363 }
1364 #else
1365 #define __Pyx_RefNannySetupContext(name, acquire_gil)\
1366 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
1367 #endif
1368 #define __Pyx_RefNannyFinishContext()\
1369 __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
1370 #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1371 #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1372 #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1373 #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1374 #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
1375 #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
1376 #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
1377 #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
1378 #else
1379 #define __Pyx_RefNannyDeclarations
1380 #define __Pyx_RefNannySetupContext(name, acquire_gil)
1381 #define __Pyx_RefNannyFinishContext()
1382 #define __Pyx_INCREF(r) Py_INCREF(r)
1383 #define __Pyx_DECREF(r) Py_DECREF(r)
1384 #define __Pyx_GOTREF(r)
1385 #define __Pyx_GIVEREF(r)
1386 #define __Pyx_XINCREF(r) Py_XINCREF(r)
1387 #define __Pyx_XDECREF(r) Py_XDECREF(r)
1388 #define __Pyx_XGOTREF(r)
1389 #define __Pyx_XGIVEREF(r)
1390 #endif
1391 #define __Pyx_XDECREF_SET(r, v) do {\
1392 PyObject *tmp = (PyObject *) r;\
1393 r = v; __Pyx_XDECREF(tmp);\
1394 } while (0)
1395 #define __Pyx_DECREF_SET(r, v) do {\
1396 PyObject *tmp = (PyObject *) r;\
1397 r = v; __Pyx_DECREF(tmp);\
1398 } while (0)
1399 #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
1400 #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
1401
1402 /* PyObjectGetAttrStr.proto */
1403 #if CYTHON_USE_TYPE_SLOTS
1404 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
1405 #else
1406 #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
1407 #endif
1408
1409 /* GetBuiltinName.proto */
1410 static PyObject *__Pyx_GetBuiltinName(PyObject *name);
1411
1412 /* GetTopmostException.proto */
1413 #if CYTHON_USE_EXC_INFO_STACK
1414 static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate);
1415 #endif
1416
1417 /* PyThreadStateGet.proto */
1418 #if CYTHON_FAST_THREAD_STATE
1419 #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
1420 #define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current;
1421 #define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type
1422 #else
1423 #define __Pyx_PyThreadState_declare
1424 #define __Pyx_PyThreadState_assign
1425 #define __Pyx_PyErr_Occurred() PyErr_Occurred()
1426 #endif
1427
1428 /* SaveResetException.proto */
1429 #if CYTHON_FAST_THREAD_STATE
1430 #define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
1431 static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1432 #define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
1433 static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
1434 #else
1435 #define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb)
1436 #define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb)
1437 #endif
1438
1439 /* PyErrExceptionMatches.proto */
1440 #if CYTHON_FAST_THREAD_STATE
1441 #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
1442 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
1443 #else
1444 #define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err)
1445 #endif
1446
1447 /* PyErrFetchRestore.proto */
1448 #if CYTHON_FAST_THREAD_STATE
1449 #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
1450 #define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
1451 #define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
1452 #define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
1453 #define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
1454 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
1455 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1456 #if CYTHON_COMPILING_IN_CPYTHON
1457 #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
1458 #else
1459 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
1460 #endif
1461 #else
1462 #define __Pyx_PyErr_Clear() PyErr_Clear()
1463 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
1464 #define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
1465 #define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
1466 #define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb)
1467 #define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb)
1468 #define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
1469 #define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
1470 #endif
1471
1472 /* RaiseDoubleKeywords.proto */
1473 static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
1474
1475 /* ParseKeywords.proto */
1476 static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
1477 PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
1478 const char* function_name);
1479
1480 /* RaiseArgTupleInvalid.proto */
1481 static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
1482 Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
1483
1484 /* PyObjectCall.proto */
1485 #if CYTHON_COMPILING_IN_CPYTHON
1486 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
1487 #else
1488 #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
1489 #endif
1490
1491 /* RaiseException.proto */
1492 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
1493
1494 /* DictGetItem.proto */
1495 #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
1496 static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key);
1497 #define __Pyx_PyObject_Dict_GetItem(obj, name)\
1498 (likely(PyDict_CheckExact(obj)) ?\
1499 __Pyx_PyDict_GetItem(obj, name) : PyObject_GetItem(obj, name))
1500 #else
1501 #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key)
1502 #define __Pyx_PyObject_Dict_GetItem(obj, name) PyObject_GetItem(obj, name)
1503 #endif
1504
1505 /* ExtTypeTest.proto */
1506 static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type);
1507
1508 /* DivInt[Py_ssize_t].proto */
1509 static CYTHON_INLINE Py_ssize_t __Pyx_div_Py_ssize_t(Py_ssize_t, Py_ssize_t);
1510
1511 /* UnaryNegOverflows.proto */
1512 #define UNARY_NEG_WOULD_OVERFLOW(x)\
1513 (((x) < 0) & ((unsigned long)(x) == 0-(unsigned long)(x)))
1514
1515 /* PyObject_GenericGetAttrNoDict.proto */
1516 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
1517 static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
1518 #else
1519 #define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
1520 #endif
1521
1522 /* PyObject_GenericGetAttr.proto */
1523 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
1524 static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name);
1525 #else
1526 #define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr
1527 #endif
1528
1529 /* PyObjectGetAttrStrNoError.proto */
1530 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name);
1531
1532 /* SetupReduce.proto */
1533 static int __Pyx_setup_reduce(PyObject* type_obj);
1534
1535 /* TypeImport.proto */
1536 #ifndef __PYX_HAVE_RT_ImportType_proto
1537 #define __PYX_HAVE_RT_ImportType_proto
1538 enum __Pyx_ImportType_CheckSize {
1539 __Pyx_ImportType_CheckSize_Error = 0,
1540 __Pyx_ImportType_CheckSize_Warn = 1,
1541 __Pyx_ImportType_CheckSize_Ignore = 2
1542 };
1543 static PyTypeObject *__Pyx_ImportType(PyObject* module, const char *module_name, const char *class_name, size_t size, enum __Pyx_ImportType_CheckSize check_size);
1544 #endif
1545
1546 /* Import.proto */
1547 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
1548
1549 /* ImportFrom.proto */
1550 static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
1551
1552 /* PyDictVersioning.proto */
1553 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
1554 #define __PYX_DICT_VERSION_INIT ((PY_UINT64_T) -1)
1555 #define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag)
1556 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
1557 (version_var) = __PYX_GET_DICT_VERSION(dict);\
1558 (cache_var) = (value);
1559 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
1560 static PY_UINT64_T __pyx_dict_version = 0;\
1561 static PyObject *__pyx_dict_cached_value = NULL;\
1562 if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
1563 (VAR) = __pyx_dict_cached_value;\
1564 } else {\
1565 (VAR) = __pyx_dict_cached_value = (LOOKUP);\
1566 __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
1567 }\
1568 }
1569 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj);
1570 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj);
1571 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version);
1572 #else
1573 #define __PYX_GET_DICT_VERSION(dict) (0)
1574 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
1575 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) (VAR) = (LOOKUP);
1576 #endif
1577
1578 /* GetModuleGlobalName.proto */
1579 #if CYTHON_USE_DICT_VERSIONS
1580 #define __Pyx_GetModuleGlobalName(var, name) {\
1581 static PY_UINT64_T __pyx_dict_version = 0;\
1582 static PyObject *__pyx_dict_cached_value = NULL;\
1583 (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\
1584 (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\
1585 __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
1586 }
1587 #define __Pyx_GetModuleGlobalNameUncached(var, name) {\
1588 PY_UINT64_T __pyx_dict_version;\
1589 PyObject *__pyx_dict_cached_value;\
1590 (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
1591 }
1592 static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value);
1593 #else
1594 #define __Pyx_GetModuleGlobalName(var, name) (var) = __Pyx__GetModuleGlobalName(name)
1595 #define __Pyx_GetModuleGlobalNameUncached(var, name) (var) = __Pyx__GetModuleGlobalName(name)
1596 static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name);
1597 #endif
1598
1599 /* CLineInTraceback.proto */
1600 #ifdef CYTHON_CLINE_IN_TRACEBACK
1601 #define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
1602 #else
1603 static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
1604 #endif
1605
1606 /* CodeObjectCache.proto */
1607 typedef struct {
1608 PyCodeObject* code_object;
1609 int code_line;
1610 } __Pyx_CodeObjectCacheEntry;
1611 struct __Pyx_CodeObjectCache {
1612 int count;
1613 int max_count;
1614 __Pyx_CodeObjectCacheEntry* entries;
1615 };
1616 static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
1617 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
1618 static PyCodeObject *__pyx_find_code_object(int code_line);
1619 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
1620
1621 /* AddTraceback.proto */
1622 static void __Pyx_AddTraceback(const char *funcname, int c_line,
1623 int py_line, const char *filename);
1624
1625 /* GCCDiagnostics.proto */
1626 #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
1627 #define __Pyx_HAS_GCC_DIAGNOSTIC
1628 #endif
1629
1630 /* CIntToPy.proto */
1631 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
1632
1633 /* CIntFromPy.proto */
1634 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
1635
1636 /* CIntFromPy.proto */
1637 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
1638
1639 /* FastTypeChecks.proto */
1640 #if CYTHON_COMPILING_IN_CPYTHON
1641 #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
1642 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
1643 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
1644 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
1645 #else
1646 #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
1647 #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
1648 #define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
1649 #endif
1650 #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
1651
1652 /* CheckBinaryVersion.proto */
1653 static int __Pyx_check_binary_version(void);
1654
1655 /* InitStrings.proto */
1656 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
1657
1658
1659 /* Module declarations from 'mpi4py.libmpi' */
1660
1661 /* Module declarations from 'mpi4py.MPI' */
1662 static PyTypeObject *__pyx_ptype_6mpi4py_3MPI_Datatype = 0;
1663 static PyTypeObject *__pyx_ptype_6mpi4py_3MPI_Status = 0;
1664 static PyTypeObject *__pyx_ptype_6mpi4py_3MPI_Request = 0;
1665 static PyTypeObject *__pyx_ptype_6mpi4py_3MPI_Prequest = 0;
1666 static PyTypeObject *__pyx_ptype_6mpi4py_3MPI_Grequest = 0;
1667 static PyTypeObject *__pyx_ptype_6mpi4py_3MPI_Message = 0;
1668 static PyTypeObject *__pyx_ptype_6mpi4py_3MPI_Op = 0;
1669 static PyTypeObject *__pyx_ptype_6mpi4py_3MPI_Group = 0;
1670 static PyTypeObject *__pyx_ptype_6mpi4py_3MPI_Info = 0;
1671 static PyTypeObject *__pyx_ptype_6mpi4py_3MPI_Errhandler = 0;
1672 static PyTypeObject *__pyx_ptype_6mpi4py_3MPI_Comm = 0;
1673 static PyTypeObject *__pyx_ptype_6mpi4py_3MPI_Intracomm = 0;
1674 static PyTypeObject *__pyx_ptype_6mpi4py_3MPI_Topocomm = 0;
1675 static PyTypeObject *__pyx_ptype_6mpi4py_3MPI_Cartcomm = 0;
1676 static PyTypeObject *__pyx_ptype_6mpi4py_3MPI_Graphcomm = 0;
1677 static PyTypeObject *__pyx_ptype_6mpi4py_3MPI_Distgraphcomm = 0;
1678 static PyTypeObject *__pyx_ptype_6mpi4py_3MPI_Intercomm = 0;
1679 static PyTypeObject *__pyx_ptype_6mpi4py_3MPI_Win = 0;
1680 static PyTypeObject *__pyx_ptype_6mpi4py_3MPI_File = 0;
1681
1682 /* Module declarations from 'libc.string' */
1683
1684 /* Module declarations from 'libc.stdio' */
1685
1686 /* Module declarations from '__builtin__' */
1687
1688 /* Module declarations from 'cpython.type' */
1689 static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0;
1690
1691 /* Module declarations from 'cpython' */
1692
1693 /* Module declarations from 'cpython.object' */
1694
1695 /* Module declarations from 'cpython.ref' */
1696
1697 /* Module declarations from 'libc.stdlib' */
1698
1699 /* Module declarations from 'pybuffer' */
1700 static PyTypeObject *__pyx_ptype_8pybuffer_Buffer = 0;
1701 static PyObject *__pyx_v_8pybuffer_TypeDict = 0;
1702 static int __pyx_v_8pybuffer_bufflags;
1703 static PyObject *__pyx_f_8pybuffer_getformat(Py_buffer *); /*proto*/
1704 #define __Pyx_MODULE_NAME "pybuffer"
1705 extern int __pyx_module_is_main_pybuffer;
1706 int __pyx_module_is_main_pybuffer = 0;
1707
1708 /* Implementation of 'pybuffer' */
1709 static PyObject *__pyx_builtin_AttributeError;
1710 static PyObject *__pyx_builtin_TypeError;
1711 static const char __pyx_k_B[] = "B";
1712 static const char __pyx_k_D[] = "D";
1713 static const char __pyx_k_F[] = "F";
1714 static const char __pyx_k_G[] = "G";
1715 static const char __pyx_k_H[] = "H";
1716 static const char __pyx_k_I[] = "I";
1717 static const char __pyx_k_L[] = "L";
1718 static const char __pyx_k_Q[] = "Q";
1719 static const char __pyx_k_b[] = "b";
1720 static const char __pyx_k_c[] = "c";
1721 static const char __pyx_k_d[] = "d";
1722 static const char __pyx_k_f[] = "f";
1723 static const char __pyx_k_g[] = "g";
1724 static const char __pyx_k_h[] = "h";
1725 static const char __pyx_k_i[] = "i";
1726 static const char __pyx_k_l[] = "l";
1727 static const char __pyx_k_p[] = "p";
1728 static const char __pyx_k_q[] = "q";
1729 static const char __pyx_k_Zd[] = "Zd";
1730 static const char __pyx_k_Zf[] = "Zf";
1731 static const char __pyx_k_Zg[] = "Zg";
1732 static const char __pyx_k__4[] = "?";
1733 static const char __pyx_k_INT[] = "INT";
1734 static const char __pyx_k_MPI[] = "MPI";
1735 static const char __pyx_k_AINT[] = "AINT";
1736 static const char __pyx_k_CHAR[] = "CHAR";
1737 static const char __pyx_k_LONG[] = "LONG";
1738 static const char __pyx_k_char[] = "char";
1739 static const char __pyx_k_data[] = "data";
1740 static const char __pyx_k_main[] = "__main__";
1741 static const char __pyx_k_name[] = "__name__";
1742 static const char __pyx_k_test[] = "__test__";
1743 static const char __pyx_k_FLOAT[] = "FLOAT";
1744 static const char __pyx_k_SHORT[] = "SHORT";
1745 static const char __pyx_k_dtype[] = "dtype";
1746 static const char __pyx_k_Buffer[] = "Buffer";
1747 static const char __pyx_k_C_BOOL[] = "C_BOOL";
1748 static const char __pyx_k_DOUBLE[] = "DOUBLE";
1749 static const char __pyx_k_import[] = "__import__";
1750 static const char __pyx_k_mpi4py[] = "mpi4py";
1751 static const char __pyx_k_reduce[] = "__reduce__";
1752 static const char __pyx_k_UNSIGNED[] = "UNSIGNED";
1753 static const char __pyx_k_getstate[] = "__getstate__";
1754 static const char __pyx_k_setstate[] = "__setstate__";
1755 static const char __pyx_k_typecode[] = "typecode";
1756 static const char __pyx_k_LONG_LONG[] = "LONG_LONG";
1757 static const char __pyx_k_TypeError[] = "TypeError";
1758 static const char __pyx_k_reduce_ex[] = "__reduce_ex__";
1759 static const char __pyx_k_LONG_DOUBLE[] = "LONG_DOUBLE";
1760 static const char __pyx_k_SIGNED_CHAR[] = "SIGNED_CHAR";
1761 static const char __pyx_k_UNSIGNED_CHAR[] = "UNSIGNED_CHAR";
1762 static const char __pyx_k_UNSIGNED_LONG[] = "UNSIGNED_LONG";
1763 static const char __pyx_k_reduce_cython[] = "__reduce_cython__";
1764 static const char __pyx_k_AttributeError[] = "AttributeError";
1765 static const char __pyx_k_UNSIGNED_SHORT[] = "UNSIGNED_SHORT";
1766 static const char __pyx_k_C_FLOAT_COMPLEX[] = "C_FLOAT_COMPLEX";
1767 static const char __pyx_k_setstate_cython[] = "__setstate_cython__";
1768 static const char __pyx_k_C_DOUBLE_COMPLEX[] = "C_DOUBLE_COMPLEX";
1769 static const char __pyx_k_UNSIGNED_LONG_LONG[] = "UNSIGNED_LONG_LONG";
1770 static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
1771 static const char __pyx_k_C_LONG_DOUBLE_COMPLEX[] = "C_LONG_DOUBLE_COMPLEX";
1772 static const char __pyx_k_no_default___reduce___due_to_non[] = "no default __reduce__ due to non-trivial __cinit__";
1773 static const char __pyx_k_object_does_not_present_buffer_i[] = "object does not present buffer interface";
1774 static PyObject *__pyx_n_s_AINT;
1775 static PyObject *__pyx_n_s_AttributeError;
1776 static PyObject *__pyx_n_s_B;
1777 static PyObject *__pyx_n_s_Buffer;
1778 static PyObject *__pyx_n_s_CHAR;
1779 static PyObject *__pyx_n_s_C_BOOL;
1780 static PyObject *__pyx_n_s_C_DOUBLE_COMPLEX;
1781 static PyObject *__pyx_n_s_C_FLOAT_COMPLEX;
1782 static PyObject *__pyx_n_s_C_LONG_DOUBLE_COMPLEX;
1783 static PyObject *__pyx_n_s_D;
1784 static PyObject *__pyx_n_s_DOUBLE;
1785 static PyObject *__pyx_n_s_F;
1786 static PyObject *__pyx_n_s_FLOAT;
1787 static PyObject *__pyx_n_s_G;
1788 static PyObject *__pyx_n_s_H;
1789 static PyObject *__pyx_n_s_I;
1790 static PyObject *__pyx_n_s_INT;
1791 static PyObject *__pyx_n_s_L;
1792 static PyObject *__pyx_n_s_LONG;
1793 static PyObject *__pyx_n_s_LONG_DOUBLE;
1794 static PyObject *__pyx_n_s_LONG_LONG;
1795 static PyObject *__pyx_n_s_MPI;
1796 static PyObject *__pyx_n_s_Q;
1797 static PyObject *__pyx_n_s_SHORT;
1798 static PyObject *__pyx_n_s_SIGNED_CHAR;
1799 static PyObject *__pyx_n_s_TypeError;
1800 static PyObject *__pyx_n_s_UNSIGNED;
1801 static PyObject *__pyx_n_s_UNSIGNED_CHAR;
1802 static PyObject *__pyx_n_s_UNSIGNED_LONG;
1803 static PyObject *__pyx_n_s_UNSIGNED_LONG_LONG;
1804 static PyObject *__pyx_n_s_UNSIGNED_SHORT;
1805 static PyObject *__pyx_n_s_Zd;
1806 static PyObject *__pyx_n_s_Zf;
1807 static PyObject *__pyx_n_s_Zg;
1808 static PyObject *__pyx_kp_s__4;
1809 static PyObject *__pyx_n_s_b;
1810 static PyObject *__pyx_n_s_c;
1811 static PyObject *__pyx_n_s_char;
1812 static PyObject *__pyx_n_s_cline_in_traceback;
1813 static PyObject *__pyx_n_s_d;
1814 static PyObject *__pyx_n_s_data;
1815 static PyObject *__pyx_n_s_dtype;
1816 static PyObject *__pyx_n_s_f;
1817 static PyObject *__pyx_n_s_g;
1818 static PyObject *__pyx_n_s_getstate;
1819 static PyObject *__pyx_n_s_h;
1820 static PyObject *__pyx_n_s_i;
1821 static PyObject *__pyx_n_s_import;
1822 static PyObject *__pyx_n_s_l;
1823 static PyObject *__pyx_n_s_main;
1824 static PyObject *__pyx_n_s_mpi4py;
1825 static PyObject *__pyx_n_s_name;
1826 static PyObject *__pyx_kp_s_no_default___reduce___due_to_non;
1827 static PyObject *__pyx_kp_s_object_does_not_present_buffer_i;
1828 static PyObject *__pyx_n_s_p;
1829 static PyObject *__pyx_n_s_q;
1830 static PyObject *__pyx_n_s_reduce;
1831 static PyObject *__pyx_n_s_reduce_cython;
1832 static PyObject *__pyx_n_s_reduce_ex;
1833 static PyObject *__pyx_n_s_setstate;
1834 static PyObject *__pyx_n_s_setstate_cython;
1835 static PyObject *__pyx_n_s_test;
1836 static PyObject *__pyx_n_s_typecode;
1837 static int __pyx_pf_8pybuffer_6Buffer___cinit__(struct __pyx_obj_8pybuffer_Buffer *__pyx_v_self, PyObject *__pyx_v_data); /* proto */
1838 static void __pyx_pf_8pybuffer_6Buffer_2__dealloc__(struct __pyx_obj_8pybuffer_Buffer *__pyx_v_self); /* proto */
1839 static PyObject *__pyx_pf_8pybuffer_6Buffer_4__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_8pybuffer_Buffer *__pyx_v_self); /* proto */
1840 static PyObject *__pyx_pf_8pybuffer_6Buffer_6__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_8pybuffer_Buffer *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
1841 static PyObject *__pyx_tp_new_8pybuffer_Buffer(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
1842 static PyObject *__pyx_tuple_;
1843 static PyObject *__pyx_tuple__2;
1844 static PyObject *__pyx_tuple__3;
1845 /* Late includes */
1846
1847 /* "pybuffer.pyx":39
1848 * }
1849 *
1850 * cdef object getformat(Py_buffer* pybuf): # <<<<<<<<<<<<<<
1851 * cdef object obj = <object> pybuf.obj
1852 *
1853 */
1854
1855 static PyObject *__pyx_f_8pybuffer_getformat(Py_buffer *__pyx_v_pybuf) {
1856 PyObject *__pyx_v_obj = 0;
1857 PyObject *__pyx_r = NULL;
1858 __Pyx_RefNannyDeclarations
1859 PyObject *__pyx_t_1 = NULL;
1860 PyObject *__pyx_t_2 = NULL;
1861 PyObject *__pyx_t_3 = NULL;
1862 PyObject *__pyx_t_4 = NULL;
1863 PyObject *__pyx_t_5 = NULL;
1864 int __pyx_t_6;
1865 int __pyx_t_7;
1866 int __pyx_lineno = 0;
1867 const char *__pyx_filename = NULL;
1868 int __pyx_clineno = 0;
1869 __Pyx_RefNannySetupContext("getformat", 0);
1870
1871 /* "pybuffer.pyx":40
1872 *
1873 * cdef object getformat(Py_buffer* pybuf):
1874 * cdef object obj = <object> pybuf.obj # <<<<<<<<<<<<<<
1875 *
1876 * # numpy.ndarray
1877 */
1878 __pyx_t_1 = ((PyObject *)__pyx_v_pybuf->obj);
1879 __Pyx_INCREF(__pyx_t_1);
1880 __pyx_v_obj = __pyx_t_1;
1881 __pyx_t_1 = 0;
1882
1883 /* "pybuffer.pyx":43
1884 *
1885 * # numpy.ndarray
1886 * try: return obj.dtype.char # <<<<<<<<<<<<<<
1887 * except (AttributeError, TypeError): pass
1888 *
1889 */
1890 {
1891 __Pyx_PyThreadState_declare
1892 __Pyx_PyThreadState_assign
1893 __Pyx_ExceptionSave(&__pyx_t_2, &__pyx_t_3, &__pyx_t_4);
1894 __Pyx_XGOTREF(__pyx_t_2);
1895 __Pyx_XGOTREF(__pyx_t_3);
1896 __Pyx_XGOTREF(__pyx_t_4);
1897 /*try:*/ {
1898 __Pyx_XDECREF(__pyx_r);
1899 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_dtype); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 43, __pyx_L3_error)
1900 __Pyx_GOTREF(__pyx_t_1);
1901 __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_char); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 43, __pyx_L3_error)
1902 __Pyx_GOTREF(__pyx_t_5);
1903 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1904 __pyx_r = __pyx_t_5;
1905 __pyx_t_5 = 0;
1906 goto __pyx_L7_try_return;
1907 }
1908 __pyx_L3_error:;
1909 __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
1910 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
1911
1912 /* "pybuffer.pyx":44
1913 * # numpy.ndarray
1914 * try: return obj.dtype.char
1915 * except (AttributeError, TypeError): pass # <<<<<<<<<<<<<<
1916 *
1917 * # array.array
1918 */
1919 __pyx_t_6 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_AttributeError) || __Pyx_PyErr_ExceptionMatches(__pyx_builtin_TypeError);
1920 if (__pyx_t_6) {
1921 __Pyx_ErrRestore(0,0,0);
1922 goto __pyx_L4_exception_handled;
1923 }
1924 goto __pyx_L5_except_error;
1925 __pyx_L5_except_error:;
1926
1927 /* "pybuffer.pyx":43
1928 *
1929 * # numpy.ndarray
1930 * try: return obj.dtype.char # <<<<<<<<<<<<<<
1931 * except (AttributeError, TypeError): pass
1932 *
1933 */
1934 __Pyx_XGIVEREF(__pyx_t_2);
1935 __Pyx_XGIVEREF(__pyx_t_3);
1936 __Pyx_XGIVEREF(__pyx_t_4);
1937 __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
1938 goto __pyx_L1_error;
1939 __pyx_L7_try_return:;
1940 __Pyx_XGIVEREF(__pyx_t_2);
1941 __Pyx_XGIVEREF(__pyx_t_3);
1942 __Pyx_XGIVEREF(__pyx_t_4);
1943 __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
1944 goto __pyx_L0;
1945 __pyx_L4_exception_handled:;
1946 __Pyx_XGIVEREF(__pyx_t_2);
1947 __Pyx_XGIVEREF(__pyx_t_3);
1948 __Pyx_XGIVEREF(__pyx_t_4);
1949 __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
1950 }
1951
1952 /* "pybuffer.pyx":47
1953 *
1954 * # array.array
1955 * try: return obj.typecode # <<<<<<<<<<<<<<
1956 * except (AttributeError, TypeError): pass
1957 *
1958 */
1959 {
1960 __Pyx_PyThreadState_declare
1961 __Pyx_PyThreadState_assign
1962 __Pyx_ExceptionSave(&__pyx_t_4, &__pyx_t_3, &__pyx_t_2);
1963 __Pyx_XGOTREF(__pyx_t_4);
1964 __Pyx_XGOTREF(__pyx_t_3);
1965 __Pyx_XGOTREF(__pyx_t_2);
1966 /*try:*/ {
1967 __Pyx_XDECREF(__pyx_r);
1968 __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_typecode); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 47, __pyx_L9_error)
1969 __Pyx_GOTREF(__pyx_t_5);
1970 __pyx_r = __pyx_t_5;
1971 __pyx_t_5 = 0;
1972 goto __pyx_L13_try_return;
1973 }
1974 __pyx_L9_error:;
1975 __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
1976 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
1977
1978 /* "pybuffer.pyx":48
1979 * # array.array
1980 * try: return obj.typecode
1981 * except (AttributeError, TypeError): pass # <<<<<<<<<<<<<<
1982 *
1983 * if pybuf.format is NULL: return "B"
1984 */
1985 __pyx_t_6 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_AttributeError) || __Pyx_PyErr_ExceptionMatches(__pyx_builtin_TypeError);
1986 if (__pyx_t_6) {
1987 __Pyx_ErrRestore(0,0,0);
1988 goto __pyx_L10_exception_handled;
1989 }
1990 goto __pyx_L11_except_error;
1991 __pyx_L11_except_error:;
1992
1993 /* "pybuffer.pyx":47
1994 *
1995 * # array.array
1996 * try: return obj.typecode # <<<<<<<<<<<<<<
1997 * except (AttributeError, TypeError): pass
1998 *
1999 */
2000 __Pyx_XGIVEREF(__pyx_t_4);
2001 __Pyx_XGIVEREF(__pyx_t_3);
2002 __Pyx_XGIVEREF(__pyx_t_2);
2003 __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_3, __pyx_t_2);
2004 goto __pyx_L1_error;
2005 __pyx_L13_try_return:;
2006 __Pyx_XGIVEREF(__pyx_t_4);
2007 __Pyx_XGIVEREF(__pyx_t_3);
2008 __Pyx_XGIVEREF(__pyx_t_2);
2009 __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_3, __pyx_t_2);
2010 goto __pyx_L0;
2011 __pyx_L10_exception_handled:;
2012 __Pyx_XGIVEREF(__pyx_t_4);
2013 __Pyx_XGIVEREF(__pyx_t_3);
2014 __Pyx_XGIVEREF(__pyx_t_2);
2015 __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_3, __pyx_t_2);
2016 }
2017
2018 /* "pybuffer.pyx":50
2019 * except (AttributeError, TypeError): pass
2020 *
2021 * if pybuf.format is NULL: return "B" # <<<<<<<<<<<<<<
2022 * return PyUnicodeString_FromString(pybuf.format)
2023 *
2024 */
2025 __pyx_t_7 = ((__pyx_v_pybuf->format == NULL) != 0);
2026 if (__pyx_t_7) {
2027 __Pyx_XDECREF(__pyx_r);
2028 __Pyx_INCREF(__pyx_n_s_B);
2029 __pyx_r = __pyx_n_s_B;
2030 goto __pyx_L0;
2031 }
2032
2033 /* "pybuffer.pyx":51
2034 *
2035 * if pybuf.format is NULL: return "B"
2036 * return PyUnicodeString_FromString(pybuf.format) # <<<<<<<<<<<<<<
2037 *
2038 * cdef int bufflags = PyBUF_ANY_CONTIGUOUS | PyBUF_WRITABLE | PyBUF_FORMAT
2039 */
2040 __Pyx_XDECREF(__pyx_r);
2041 __pyx_t_5 = PyUnicodeString_FromString(__pyx_v_pybuf->format); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 51, __pyx_L1_error)
2042 __Pyx_GOTREF(__pyx_t_5);
2043 __pyx_r = __pyx_t_5;
2044 __pyx_t_5 = 0;
2045 goto __pyx_L0;
2046
2047 /* "pybuffer.pyx":39
2048 * }
2049 *
2050 * cdef object getformat(Py_buffer* pybuf): # <<<<<<<<<<<<<<
2051 * cdef object obj = <object> pybuf.obj
2052 *
2053 */
2054
2055 /* function exit code */
2056 __pyx_L1_error:;
2057 __Pyx_XDECREF(__pyx_t_1);
2058 __Pyx_XDECREF(__pyx_t_5);
2059 __Pyx_AddTraceback("pybuffer.getformat", __pyx_clineno, __pyx_lineno, __pyx_filename);
2060 __pyx_r = 0;
2061 __pyx_L0:;
2062 __Pyx_XDECREF(__pyx_v_obj);
2063 __Pyx_XGIVEREF(__pyx_r);
2064 __Pyx_RefNannyFinishContext();
2065 return __pyx_r;
2066 }
2067
2068 /* "pybuffer.pyx":56
2069 *
2070 * cdef class Buffer(object):
2071 * def __cinit__(self, object data): # <<<<<<<<<<<<<<
2072 * if not PyObject_CheckBuffer(data):
2073 * raise TypeError("object does not present buffer interface")
2074 */
2075
2076 /* Python wrapper */
2077 static int __pyx_pw_8pybuffer_6Buffer_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
2078 static int __pyx_pw_8pybuffer_6Buffer_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
2079 PyObject *__pyx_v_data = 0;
2080 int __pyx_lineno = 0;
2081 const char *__pyx_filename = NULL;
2082 int __pyx_clineno = 0;
2083 int __pyx_r;
2084 __Pyx_RefNannyDeclarations
2085 __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
2086 {
2087 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_data,0};
2088 PyObject* values[1] = {0};
2089 if (unlikely(__pyx_kwds)) {
2090 Py_ssize_t kw_args;
2091 const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
2092 switch (pos_args) {
2093 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2094 CYTHON_FALLTHROUGH;
2095 case 0: break;
2096 default: goto __pyx_L5_argtuple_error;
2097 }
2098 kw_args = PyDict_Size(__pyx_kwds);
2099 switch (pos_args) {
2100 case 0:
2101 if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_data)) != 0)) kw_args--;
2102 else goto __pyx_L5_argtuple_error;
2103 }
2104 if (unlikely(kw_args > 0)) {
2105 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(0, 56, __pyx_L3_error)
2106 }
2107 } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
2108 goto __pyx_L5_argtuple_error;
2109 } else {
2110 values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2111 }
2112 __pyx_v_data = values[0];
2113 }
2114 goto __pyx_L4_argument_unpacking_done;
2115 __pyx_L5_argtuple_error:;
2116 __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 56, __pyx_L3_error)
2117 __pyx_L3_error:;
2118 __Pyx_AddTraceback("pybuffer.Buffer.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
2119 __Pyx_RefNannyFinishContext();
2120 return -1;
2121 __pyx_L4_argument_unpacking_done:;
2122 __pyx_r = __pyx_pf_8pybuffer_6Buffer___cinit__(((struct __pyx_obj_8pybuffer_Buffer *)__pyx_v_self), __pyx_v_data);
2123
2124 /* function exit code */
2125 __Pyx_RefNannyFinishContext();
2126 return __pyx_r;
2127 }
2128
2129 static int __pyx_pf_8pybuffer_6Buffer___cinit__(struct __pyx_obj_8pybuffer_Buffer *__pyx_v_self, PyObject *__pyx_v_data) {
2130 Py_buffer *__pyx_v_pybuf;
2131 int __pyx_r;
2132 __Pyx_RefNannyDeclarations
2133 int __pyx_t_1;
2134 PyObject *__pyx_t_2 = NULL;
2135 int __pyx_t_3;
2136 PyObject *__pyx_t_4 = NULL;
2137 int __pyx_lineno = 0;
2138 const char *__pyx_filename = NULL;
2139 int __pyx_clineno = 0;
2140 __Pyx_RefNannySetupContext("__cinit__", 0);
2141
2142 /* "pybuffer.pyx":57
2143 * cdef class Buffer(object):
2144 * def __cinit__(self, object data):
2145 * if not PyObject_CheckBuffer(data): # <<<<<<<<<<<<<<
2146 * raise TypeError("object does not present buffer interface")
2147 *
2148 */
2149 __pyx_t_1 = ((!(PyObject_CheckBuffer(__pyx_v_data) != 0)) != 0);
2150 if (unlikely(__pyx_t_1)) {
2151
2152 /* "pybuffer.pyx":58
2153 * def __cinit__(self, object data):
2154 * if not PyObject_CheckBuffer(data):
2155 * raise TypeError("object does not present buffer interface") # <<<<<<<<<<<<<<
2156 *
2157 * cdef Py_buffer* pybuf = &self.pybuf
2158 */
2159 __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 58, __pyx_L1_error)
2160 __Pyx_GOTREF(__pyx_t_2);
2161 __Pyx_Raise(__pyx_t_2, 0, 0, 0);
2162 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2163 __PYX_ERR(0, 58, __pyx_L1_error)
2164
2165 /* "pybuffer.pyx":57
2166 * cdef class Buffer(object):
2167 * def __cinit__(self, object data):
2168 * if not PyObject_CheckBuffer(data): # <<<<<<<<<<<<<<
2169 * raise TypeError("object does not present buffer interface")
2170 *
2171 */
2172 }
2173
2174 /* "pybuffer.pyx":60
2175 * raise TypeError("object does not present buffer interface")
2176 *
2177 * cdef Py_buffer* pybuf = &self.pybuf # <<<<<<<<<<<<<<
2178 * PyObject_GetBuffer(data, pybuf, bufflags)
2179 * self.dtype = TypeDict[getformat(pybuf)]
2180 */
2181 __pyx_v_pybuf = (&__pyx_v_self->pybuf);
2182
2183 /* "pybuffer.pyx":61
2184 *
2185 * cdef Py_buffer* pybuf = &self.pybuf
2186 * PyObject_GetBuffer(data, pybuf, bufflags) # <<<<<<<<<<<<<<
2187 * self.dtype = TypeDict[getformat(pybuf)]
2188 * self.items = pybuf.len // pybuf.itemsize
2189 */
2190 __pyx_t_3 = PyObject_GetBuffer(__pyx_v_data, __pyx_v_pybuf, __pyx_v_8pybuffer_bufflags); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 61, __pyx_L1_error)
2191
2192 /* "pybuffer.pyx":62
2193 * cdef Py_buffer* pybuf = &self.pybuf
2194 * PyObject_GetBuffer(data, pybuf, bufflags)
2195 * self.dtype = TypeDict[getformat(pybuf)] # <<<<<<<<<<<<<<
2196 * self.items = pybuf.len // pybuf.itemsize
2197 *
2198 */
2199 if (unlikely(__pyx_v_8pybuffer_TypeDict == Py_None)) {
2200 PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
2201 __PYX_ERR(0, 62, __pyx_L1_error)
2202 }
2203 __pyx_t_2 = __pyx_f_8pybuffer_getformat(__pyx_v_pybuf); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 62, __pyx_L1_error)
2204 __Pyx_GOTREF(__pyx_t_2);
2205 __pyx_t_4 = __Pyx_PyDict_GetItem(__pyx_v_8pybuffer_TypeDict, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 62, __pyx_L1_error)
2206 __Pyx_GOTREF(__pyx_t_4);
2207 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2208 if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_6mpi4py_3MPI_Datatype))))) __PYX_ERR(0, 62, __pyx_L1_error)
2209 __Pyx_GIVEREF(__pyx_t_4);
2210 __Pyx_GOTREF(__pyx_v_self->dtype);
2211 __Pyx_DECREF(((PyObject *)__pyx_v_self->dtype));
2212 __pyx_v_self->dtype = ((struct PyMPIDatatypeObject *)__pyx_t_4);
2213 __pyx_t_4 = 0;
2214
2215 /* "pybuffer.pyx":63
2216 * PyObject_GetBuffer(data, pybuf, bufflags)
2217 * self.dtype = TypeDict[getformat(pybuf)]
2218 * self.items = pybuf.len // pybuf.itemsize # <<<<<<<<<<<<<<
2219 *
2220 * def __dealloc__(self):
2221 */
2222 if (unlikely(__pyx_v_pybuf->itemsize == 0)) {
2223 PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
2224 __PYX_ERR(0, 63, __pyx_L1_error)
2225 }
2226 else if (sizeof(Py_ssize_t) == sizeof(long) && (!(((Py_ssize_t)-1) > 0)) && unlikely(__pyx_v_pybuf->itemsize == (Py_ssize_t)-1) && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_v_pybuf->len))) {
2227 PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
2228 __PYX_ERR(0, 63, __pyx_L1_error)
2229 }
2230 __pyx_v_self->items = __Pyx_div_Py_ssize_t(__pyx_v_pybuf->len, __pyx_v_pybuf->itemsize);
2231
2232 /* "pybuffer.pyx":56
2233 *
2234 * cdef class Buffer(object):
2235 * def __cinit__(self, object data): # <<<<<<<<<<<<<<
2236 * if not PyObject_CheckBuffer(data):
2237 * raise TypeError("object does not present buffer interface")
2238 */
2239
2240 /* function exit code */
2241 __pyx_r = 0;
2242 goto __pyx_L0;
2243 __pyx_L1_error:;
2244 __Pyx_XDECREF(__pyx_t_2);
2245 __Pyx_XDECREF(__pyx_t_4);
2246 __Pyx_AddTraceback("pybuffer.Buffer.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
2247 __pyx_r = -1;
2248 __pyx_L0:;
2249 __Pyx_RefNannyFinishContext();
2250 return __pyx_r;
2251 }
2252
2253 /* "pybuffer.pyx":65
2254 * self.items = pybuf.len // pybuf.itemsize
2255 *
2256 * def __dealloc__(self): # <<<<<<<<<<<<<<
2257 * PyBuffer_Release(&self.pybuf)
2258 */
2259
2260 /* Python wrapper */
2261 static void __pyx_pw_8pybuffer_6Buffer_3__dealloc__(PyObject *__pyx_v_self); /*proto*/
2262 static void __pyx_pw_8pybuffer_6Buffer_3__dealloc__(PyObject *__pyx_v_self) {
2263 __Pyx_RefNannyDeclarations
2264 __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
2265 __pyx_pf_8pybuffer_6Buffer_2__dealloc__(((struct __pyx_obj_8pybuffer_Buffer *)__pyx_v_self));
2266
2267 /* function exit code */
2268 __Pyx_RefNannyFinishContext();
2269 }
2270
2271 static void __pyx_pf_8pybuffer_6Buffer_2__dealloc__(struct __pyx_obj_8pybuffer_Buffer *__pyx_v_self) {
2272 __Pyx_RefNannyDeclarations
2273 __Pyx_RefNannySetupContext("__dealloc__", 0);
2274
2275 /* "pybuffer.pyx":66
2276 *
2277 * def __dealloc__(self):
2278 * PyBuffer_Release(&self.pybuf) # <<<<<<<<<<<<<<
2279 */
2280 PyBuffer_Release((&__pyx_v_self->pybuf));
2281
2282 /* "pybuffer.pyx":65
2283 * self.items = pybuf.len // pybuf.itemsize
2284 *
2285 * def __dealloc__(self): # <<<<<<<<<<<<<<
2286 * PyBuffer_Release(&self.pybuf)
2287 */
2288
2289 /* function exit code */
2290 __Pyx_RefNannyFinishContext();
2291 }
2292
2293 /* "(tree fragment)":1
2294 * def __reduce_cython__(self): # <<<<<<<<<<<<<<
2295 * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
2296 * def __setstate_cython__(self, __pyx_state):
2297 */
2298
2299 /* Python wrapper */
2300 static PyObject *__pyx_pw_8pybuffer_6Buffer_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
2301 static PyObject *__pyx_pw_8pybuffer_6Buffer_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
2302 PyObject *__pyx_r = 0;
2303 __Pyx_RefNannyDeclarations
2304 __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
2305 __pyx_r = __pyx_pf_8pybuffer_6Buffer_4__reduce_cython__(((struct __pyx_obj_8pybuffer_Buffer *)__pyx_v_self));
2306
2307 /* function exit code */
2308 __Pyx_RefNannyFinishContext();
2309 return __pyx_r;
2310 }
2311
2312 static PyObject *__pyx_pf_8pybuffer_6Buffer_4__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_8pybuffer_Buffer *__pyx_v_self) {
2313 PyObject *__pyx_r = NULL;
2314 __Pyx_RefNannyDeclarations
2315 PyObject *__pyx_t_1 = NULL;
2316 int __pyx_lineno = 0;
2317 const char *__pyx_filename = NULL;
2318 int __pyx_clineno = 0;
2319 __Pyx_RefNannySetupContext("__reduce_cython__", 0);
2320
2321 /* "(tree fragment)":2
2322 * def __reduce_cython__(self):
2323 * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
2324 * def __setstate_cython__(self, __pyx_state):
2325 * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
2326 */
2327 __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error)
2328 __Pyx_GOTREF(__pyx_t_1);
2329 __Pyx_Raise(__pyx_t_1, 0, 0, 0);
2330 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2331 __PYX_ERR(1, 2, __pyx_L1_error)
2332
2333 /* "(tree fragment)":1
2334 * def __reduce_cython__(self): # <<<<<<<<<<<<<<
2335 * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
2336 * def __setstate_cython__(self, __pyx_state):
2337 */
2338
2339 /* function exit code */
2340 __pyx_L1_error:;
2341 __Pyx_XDECREF(__pyx_t_1);
2342 __Pyx_AddTraceback("pybuffer.Buffer.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
2343 __pyx_r = NULL;
2344 __Pyx_XGIVEREF(__pyx_r);
2345 __Pyx_RefNannyFinishContext();
2346 return __pyx_r;
2347 }
2348
2349 /* "(tree fragment)":3
2350 * def __reduce_cython__(self):
2351 * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
2352 * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
2353 * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
2354 */
2355
2356 /* Python wrapper */
2357 static PyObject *__pyx_pw_8pybuffer_6Buffer_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
2358 static PyObject *__pyx_pw_8pybuffer_6Buffer_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
2359 PyObject *__pyx_r = 0;
2360 __Pyx_RefNannyDeclarations
2361 __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
2362 __pyx_r = __pyx_pf_8pybuffer_6Buffer_6__setstate_cython__(((struct __pyx_obj_8pybuffer_Buffer *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
2363
2364 /* function exit code */
2365 __Pyx_RefNannyFinishContext();
2366 return __pyx_r;
2367 }
2368
2369 static PyObject *__pyx_pf_8pybuffer_6Buffer_6__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_8pybuffer_Buffer *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
2370 PyObject *__pyx_r = NULL;
2371 __Pyx_RefNannyDeclarations
2372 PyObject *__pyx_t_1 = NULL;
2373 int __pyx_lineno = 0;
2374 const char *__pyx_filename = NULL;
2375 int __pyx_clineno = 0;
2376 __Pyx_RefNannySetupContext("__setstate_cython__", 0);
2377
2378 /* "(tree fragment)":4
2379 * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
2380 * def __setstate_cython__(self, __pyx_state):
2381 * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
2382 */
2383 __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error)
2384 __Pyx_GOTREF(__pyx_t_1);
2385 __Pyx_Raise(__pyx_t_1, 0, 0, 0);
2386 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2387 __PYX_ERR(1, 4, __pyx_L1_error)
2388
2389 /* "(tree fragment)":3
2390 * def __reduce_cython__(self):
2391 * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
2392 * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
2393 * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
2394 */
2395
2396 /* function exit code */
2397 __pyx_L1_error:;
2398 __Pyx_XDECREF(__pyx_t_1);
2399 __Pyx_AddTraceback("pybuffer.Buffer.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
2400 __pyx_r = NULL;
2401 __Pyx_XGIVEREF(__pyx_r);
2402 __Pyx_RefNannyFinishContext();
2403 return __pyx_r;
2404 }
2405
2406 static PyObject *__pyx_tp_new_8pybuffer_Buffer(PyTypeObject *t, PyObject *a, PyObject *k) {
2407 struct __pyx_obj_8pybuffer_Buffer *p;
2408 PyObject *o;
2409 if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
2410 o = (*t->tp_alloc)(t, 0);
2411 } else {
2412 o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
2413 }
2414 if (unlikely(!o)) return 0;
2415 p = ((struct __pyx_obj_8pybuffer_Buffer *)o);
2416 p->dtype = ((struct PyMPIDatatypeObject *)Py_None); Py_INCREF(Py_None);
2417 p->pybuf.obj = NULL;
2418 if (unlikely(__pyx_pw_8pybuffer_6Buffer_1__cinit__(o, a, k) < 0)) goto bad;
2419 return o;
2420 bad:
2421 Py_DECREF(o); o = 0;
2422 return NULL;
2423 }
2424
2425 static void __pyx_tp_dealloc_8pybuffer_Buffer(PyObject *o) {
2426 struct __pyx_obj_8pybuffer_Buffer *p = (struct __pyx_obj_8pybuffer_Buffer *)o;
2427 #if CYTHON_USE_TP_FINALIZE
2428 if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
2429 if (PyObject_CallFinalizerFromDealloc(o)) return;
2430 }
2431 #endif
2432 PyObject_GC_UnTrack(o);
2433 {
2434 PyObject *etype, *eval, *etb;
2435 PyErr_Fetch(&etype, &eval, &etb);
2436 __Pyx_SET_REFCNT(o, Py_REFCNT(o) + 1);
2437 __pyx_pw_8pybuffer_6Buffer_3__dealloc__(o);
2438 __Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1);
2439 PyErr_Restore(etype, eval, etb);
2440 }
2441 Py_CLEAR(p->dtype);
2442 (*Py_TYPE(o)->tp_free)(o);
2443 }
2444
2445 static int __pyx_tp_traverse_8pybuffer_Buffer(PyObject *o, visitproc v, void *a) {
2446 int e;
2447 struct __pyx_obj_8pybuffer_Buffer *p = (struct __pyx_obj_8pybuffer_Buffer *)o;
2448 if (p->dtype) {
2449 e = (*v)(((PyObject *)p->dtype), a); if (e) return e;
2450 }
2451 if (p->pybuf.obj) {
2452 e = (*v)(p->pybuf.obj, a); if (e) return e;
2453 }
2454 return 0;
2455 }
2456
2457 static int __pyx_tp_clear_8pybuffer_Buffer(PyObject *o) {
2458 PyObject* tmp;
2459 struct __pyx_obj_8pybuffer_Buffer *p = (struct __pyx_obj_8pybuffer_Buffer *)o;
2460 tmp = ((PyObject*)p->dtype);
2461 p->dtype = ((struct PyMPIDatatypeObject *)Py_None); Py_INCREF(Py_None);
2462 Py_XDECREF(tmp);
2463 Py_CLEAR(p->pybuf.obj);
2464 return 0;
2465 }
2466
2467 static PyMethodDef __pyx_methods_8pybuffer_Buffer[] = {
2468 {"__reduce_cython__", (PyCFunction)__pyx_pw_8pybuffer_6Buffer_5__reduce_cython__, METH_NOARGS, 0},
2469 {"__setstate_cython__", (PyCFunction)__pyx_pw_8pybuffer_6Buffer_7__setstate_cython__, METH_O, 0},
2470 {0, 0, 0, 0}
2471 };
2472
2473 static PyTypeObject __pyx_type_8pybuffer_Buffer = {
2474 PyVarObject_HEAD_INIT(0, 0)
2475 "pybuffer.Buffer", /*tp_name*/
2476 sizeof(struct __pyx_obj_8pybuffer_Buffer), /*tp_basicsize*/
2477 0, /*tp_itemsize*/
2478 __pyx_tp_dealloc_8pybuffer_Buffer, /*tp_dealloc*/
2479 #if PY_VERSION_HEX < 0x030800b4
2480 0, /*tp_print*/
2481 #endif
2482 #if PY_VERSION_HEX >= 0x030800b4
2483 0, /*tp_vectorcall_offset*/
2484 #endif
2485 0, /*tp_getattr*/
2486 0, /*tp_setattr*/
2487 #if PY_MAJOR_VERSION < 3
2488 0, /*tp_compare*/
2489 #endif
2490 #if PY_MAJOR_VERSION >= 3
2491 0, /*tp_as_async*/
2492 #endif
2493 0, /*tp_repr*/
2494 0, /*tp_as_number*/
2495 0, /*tp_as_sequence*/
2496 0, /*tp_as_mapping*/
2497 0, /*tp_hash*/
2498 0, /*tp_call*/
2499 0, /*tp_str*/
2500 0, /*tp_getattro*/
2501 0, /*tp_setattro*/
2502 0, /*tp_as_buffer*/
2503 Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
2504 0, /*tp_doc*/
2505 __pyx_tp_traverse_8pybuffer_Buffer, /*tp_traverse*/
2506 __pyx_tp_clear_8pybuffer_Buffer, /*tp_clear*/
2507 0, /*tp_richcompare*/
2508 0, /*tp_weaklistoffset*/
2509 0, /*tp_iter*/
2510 0, /*tp_iternext*/
2511 __pyx_methods_8pybuffer_Buffer, /*tp_methods*/
2512 0, /*tp_members*/
2513 0, /*tp_getset*/
2514 0, /*tp_base*/
2515 0, /*tp_dict*/
2516 0, /*tp_descr_get*/
2517 0, /*tp_descr_set*/
2518 0, /*tp_dictoffset*/
2519 0, /*tp_init*/
2520 0, /*tp_alloc*/
2521 __pyx_tp_new_8pybuffer_Buffer, /*tp_new*/
2522 0, /*tp_free*/
2523 0, /*tp_is_gc*/
2524 0, /*tp_bases*/
2525 0, /*tp_mro*/
2526 0, /*tp_cache*/
2527 0, /*tp_subclasses*/
2528 0, /*tp_weaklist*/
2529 0, /*tp_del*/
2530 0, /*tp_version_tag*/
2531 #if PY_VERSION_HEX >= 0x030400a1
2532 0, /*tp_finalize*/
2533 #endif
2534 #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
2535 0, /*tp_vectorcall*/
2536 #endif
2537 #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
2538 0, /*tp_print*/
2539 #endif
2540 #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
2541 0, /*tp_pypy_flags*/
2542 #endif
2543 };
2544
2545 static PyMethodDef __pyx_methods[] = {
2546 {0, 0, 0, 0}
2547 };
2548
2549 #if PY_MAJOR_VERSION >= 3
2550 #if CYTHON_PEP489_MULTI_PHASE_INIT
2551 static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
2552 static int __pyx_pymod_exec_pybuffer(PyObject* module); /*proto*/
2553 static PyModuleDef_Slot __pyx_moduledef_slots[] = {
2554 {Py_mod_create, (void*)__pyx_pymod_create},
2555 {Py_mod_exec, (void*)__pyx_pymod_exec_pybuffer},
2556 {0, NULL}
2557 };
2558 #endif
2559
2560 static struct PyModuleDef __pyx_moduledef = {
2561 PyModuleDef_HEAD_INIT,
2562 "pybuffer",
2563 0, /* m_doc */
2564 #if CYTHON_PEP489_MULTI_PHASE_INIT
2565 0, /* m_size */
2566 #else
2567 -1, /* m_size */
2568 #endif
2569 __pyx_methods /* m_methods */,
2570 #if CYTHON_PEP489_MULTI_PHASE_INIT
2571 __pyx_moduledef_slots, /* m_slots */
2572 #else
2573 NULL, /* m_reload */
2574 #endif
2575 NULL, /* m_traverse */
2576 NULL, /* m_clear */
2577 NULL /* m_free */
2578 };
2579 #endif
2580 #ifndef CYTHON_SMALL_CODE
2581 #if defined(__clang__)
2582 #define CYTHON_SMALL_CODE
2583 #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
2584 #define CYTHON_SMALL_CODE __attribute__((cold))
2585 #else
2586 #define CYTHON_SMALL_CODE
2587 #endif
2588 #endif
2589
2590 static __Pyx_StringTabEntry __pyx_string_tab[] = {
2591 {&__pyx_n_s_AINT, __pyx_k_AINT, sizeof(__pyx_k_AINT), 0, 0, 1, 1},
2592 {&__pyx_n_s_AttributeError, __pyx_k_AttributeError, sizeof(__pyx_k_AttributeError), 0, 0, 1, 1},
2593 {&__pyx_n_s_B, __pyx_k_B, sizeof(__pyx_k_B), 0, 0, 1, 1},
2594 {&__pyx_n_s_Buffer, __pyx_k_Buffer, sizeof(__pyx_k_Buffer), 0, 0, 1, 1},
2595 {&__pyx_n_s_CHAR, __pyx_k_CHAR, sizeof(__pyx_k_CHAR), 0, 0, 1, 1},
2596 {&__pyx_n_s_C_BOOL, __pyx_k_C_BOOL, sizeof(__pyx_k_C_BOOL), 0, 0, 1, 1},
2597 {&__pyx_n_s_C_DOUBLE_COMPLEX, __pyx_k_C_DOUBLE_COMPLEX, sizeof(__pyx_k_C_DOUBLE_COMPLEX), 0, 0, 1, 1},
2598 {&__pyx_n_s_C_FLOAT_COMPLEX, __pyx_k_C_FLOAT_COMPLEX, sizeof(__pyx_k_C_FLOAT_COMPLEX), 0, 0, 1, 1},
2599 {&__pyx_n_s_C_LONG_DOUBLE_COMPLEX, __pyx_k_C_LONG_DOUBLE_COMPLEX, sizeof(__pyx_k_C_LONG_DOUBLE_COMPLEX), 0, 0, 1, 1},
2600 {&__pyx_n_s_D, __pyx_k_D, sizeof(__pyx_k_D), 0, 0, 1, 1},
2601 {&__pyx_n_s_DOUBLE, __pyx_k_DOUBLE, sizeof(__pyx_k_DOUBLE), 0, 0, 1, 1},
2602 {&__pyx_n_s_F, __pyx_k_F, sizeof(__pyx_k_F), 0, 0, 1, 1},
2603 {&__pyx_n_s_FLOAT, __pyx_k_FLOAT, sizeof(__pyx_k_FLOAT), 0, 0, 1, 1},
2604 {&__pyx_n_s_G, __pyx_k_G, sizeof(__pyx_k_G), 0, 0, 1, 1},
2605 {&__pyx_n_s_H, __pyx_k_H, sizeof(__pyx_k_H), 0, 0, 1, 1},
2606 {&__pyx_n_s_I, __pyx_k_I, sizeof(__pyx_k_I), 0, 0, 1, 1},
2607 {&__pyx_n_s_INT, __pyx_k_INT, sizeof(__pyx_k_INT), 0, 0, 1, 1},
2608 {&__pyx_n_s_L, __pyx_k_L, sizeof(__pyx_k_L), 0, 0, 1, 1},
2609 {&__pyx_n_s_LONG, __pyx_k_LONG, sizeof(__pyx_k_LONG), 0, 0, 1, 1},
2610 {&__pyx_n_s_LONG_DOUBLE, __pyx_k_LONG_DOUBLE, sizeof(__pyx_k_LONG_DOUBLE), 0, 0, 1, 1},
2611 {&__pyx_n_s_LONG_LONG, __pyx_k_LONG_LONG, sizeof(__pyx_k_LONG_LONG), 0, 0, 1, 1},
2612 {&__pyx_n_s_MPI, __pyx_k_MPI, sizeof(__pyx_k_MPI), 0, 0, 1, 1},
2613 {&__pyx_n_s_Q, __pyx_k_Q, sizeof(__pyx_k_Q), 0, 0, 1, 1},
2614 {&__pyx_n_s_SHORT, __pyx_k_SHORT, sizeof(__pyx_k_SHORT), 0, 0, 1, 1},
2615 {&__pyx_n_s_SIGNED_CHAR, __pyx_k_SIGNED_CHAR, sizeof(__pyx_k_SIGNED_CHAR), 0, 0, 1, 1},
2616 {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1},
2617 {&__pyx_n_s_UNSIGNED, __pyx_k_UNSIGNED, sizeof(__pyx_k_UNSIGNED), 0, 0, 1, 1},
2618 {&__pyx_n_s_UNSIGNED_CHAR, __pyx_k_UNSIGNED_CHAR, sizeof(__pyx_k_UNSIGNED_CHAR), 0, 0, 1, 1},
2619 {&__pyx_n_s_UNSIGNED_LONG, __pyx_k_UNSIGNED_LONG, sizeof(__pyx_k_UNSIGNED_LONG), 0, 0, 1, 1},
2620 {&__pyx_n_s_UNSIGNED_LONG_LONG, __pyx_k_UNSIGNED_LONG_LONG, sizeof(__pyx_k_UNSIGNED_LONG_LONG), 0, 0, 1, 1},
2621 {&__pyx_n_s_UNSIGNED_SHORT, __pyx_k_UNSIGNED_SHORT, sizeof(__pyx_k_UNSIGNED_SHORT), 0, 0, 1, 1},
2622 {&__pyx_n_s_Zd, __pyx_k_Zd, sizeof(__pyx_k_Zd), 0, 0, 1, 1},
2623 {&__pyx_n_s_Zf, __pyx_k_Zf, sizeof(__pyx_k_Zf), 0, 0, 1, 1},
2624 {&__pyx_n_s_Zg, __pyx_k_Zg, sizeof(__pyx_k_Zg), 0, 0, 1, 1},
2625 {&__pyx_kp_s__4, __pyx_k__4, sizeof(__pyx_k__4), 0, 0, 1, 0},
2626 {&__pyx_n_s_b, __pyx_k_b, sizeof(__pyx_k_b), 0, 0, 1, 1},
2627 {&__pyx_n_s_c, __pyx_k_c, sizeof(__pyx_k_c), 0, 0, 1, 1},
2628 {&__pyx_n_s_char, __pyx_k_char, sizeof(__pyx_k_char), 0, 0, 1, 1},
2629 {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
2630 {&__pyx_n_s_d, __pyx_k_d, sizeof(__pyx_k_d), 0, 0, 1, 1},
2631 {&__pyx_n_s_data, __pyx_k_data, sizeof(__pyx_k_data), 0, 0, 1, 1},
2632 {&__pyx_n_s_dtype, __pyx_k_dtype, sizeof(__pyx_k_dtype), 0, 0, 1, 1},
2633 {&__pyx_n_s_f, __pyx_k_f, sizeof(__pyx_k_f), 0, 0, 1, 1},
2634 {&__pyx_n_s_g, __pyx_k_g, sizeof(__pyx_k_g), 0, 0, 1, 1},
2635 {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1},
2636 {&__pyx_n_s_h, __pyx_k_h, sizeof(__pyx_k_h), 0, 0, 1, 1},
2637 {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1},
2638 {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
2639 {&__pyx_n_s_l, __pyx_k_l, sizeof(__pyx_k_l), 0, 0, 1, 1},
2640 {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
2641 {&__pyx_n_s_mpi4py, __pyx_k_mpi4py, sizeof(__pyx_k_mpi4py), 0, 0, 1, 1},
2642 {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
2643 {&__pyx_kp_s_no_default___reduce___due_to_non, __pyx_k_no_default___reduce___due_to_non, sizeof(__pyx_k_no_default___reduce___due_to_non), 0, 0, 1, 0},
2644 {&__pyx_kp_s_object_does_not_present_buffer_i, __pyx_k_object_does_not_present_buffer_i, sizeof(__pyx_k_object_does_not_present_buffer_i), 0, 0, 1, 0},
2645 {&__pyx_n_s_p, __pyx_k_p, sizeof(__pyx_k_p), 0, 0, 1, 1},
2646 {&__pyx_n_s_q, __pyx_k_q, sizeof(__pyx_k_q), 0, 0, 1, 1},
2647 {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1},
2648 {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1},
2649 {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1},
2650 {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1},
2651 {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1},
2652 {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
2653 {&__pyx_n_s_typecode, __pyx_k_typecode, sizeof(__pyx_k_typecode), 0, 0, 1, 1},
2654 {0, 0, 0, 0, 0, 0, 0}
2655 };
2656 static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
2657 __pyx_builtin_AttributeError = __Pyx_GetBuiltinName(__pyx_n_s_AttributeError); if (!__pyx_builtin_AttributeError) __PYX_ERR(0, 44, __pyx_L1_error)
2658 __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(0, 44, __pyx_L1_error)
2659 return 0;
2660 __pyx_L1_error:;
2661 return -1;
2662 }
2663
2664 static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
2665 __Pyx_RefNannyDeclarations
2666 __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
2667
2668 /* "pybuffer.pyx":58
2669 * def __cinit__(self, object data):
2670 * if not PyObject_CheckBuffer(data):
2671 * raise TypeError("object does not present buffer interface") # <<<<<<<<<<<<<<
2672 *
2673 * cdef Py_buffer* pybuf = &self.pybuf
2674 */
2675 __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_object_does_not_present_buffer_i); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 58, __pyx_L1_error)
2676 __Pyx_GOTREF(__pyx_tuple_);
2677 __Pyx_GIVEREF(__pyx_tuple_);
2678
2679 /* "(tree fragment)":2
2680 * def __reduce_cython__(self):
2681 * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
2682 * def __setstate_cython__(self, __pyx_state):
2683 * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
2684 */
2685 __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(1, 2, __pyx_L1_error)
2686 __Pyx_GOTREF(__pyx_tuple__2);
2687 __Pyx_GIVEREF(__pyx_tuple__2);
2688
2689 /* "(tree fragment)":4
2690 * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
2691 * def __setstate_cython__(self, __pyx_state):
2692 * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
2693 */
2694 __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(1, 4, __pyx_L1_error)
2695 __Pyx_GOTREF(__pyx_tuple__3);
2696 __Pyx_GIVEREF(__pyx_tuple__3);
2697 __Pyx_RefNannyFinishContext();
2698 return 0;
2699 __pyx_L1_error:;
2700 __Pyx_RefNannyFinishContext();
2701 return -1;
2702 }
2703
2704 static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
2705 if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
2706 return 0;
2707 __pyx_L1_error:;
2708 return -1;
2709 }
2710
2711 static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/
2712 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/
2713 static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/
2714 static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/
2715 static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/
2716 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/
2717 static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/
2718
2719 static int __Pyx_modinit_global_init_code(void) {
2720 __Pyx_RefNannyDeclarations
2721 __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
2722 /*--- Global init code ---*/
2723 __pyx_v_8pybuffer_TypeDict = ((PyObject*)Py_None); Py_INCREF(Py_None);
2724 __Pyx_RefNannyFinishContext();
2725 return 0;
2726 }
2727
2728 static int __Pyx_modinit_variable_export_code(void) {
2729 __Pyx_RefNannyDeclarations
2730 __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
2731 /*--- Variable export code ---*/
2732 __Pyx_RefNannyFinishContext();
2733 return 0;
2734 }
2735
2736 static int __Pyx_modinit_function_export_code(void) {
2737 __Pyx_RefNannyDeclarations
2738 __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
2739 /*--- Function export code ---*/
2740 __Pyx_RefNannyFinishContext();
2741 return 0;
2742 }
2743
2744 static int __Pyx_modinit_type_init_code(void) {
2745 __Pyx_RefNannyDeclarations
2746 int __pyx_lineno = 0;
2747 const char *__pyx_filename = NULL;
2748 int __pyx_clineno = 0;
2749 __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
2750 /*--- Type init code ---*/
2751 if (PyType_Ready(&__pyx_type_8pybuffer_Buffer) < 0) __PYX_ERR(0, 55, __pyx_L1_error)
2752 #if PY_VERSION_HEX < 0x030800B1
2753 __pyx_type_8pybuffer_Buffer.tp_print = 0;
2754 #endif
2755 if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_8pybuffer_Buffer.tp_dictoffset && __pyx_type_8pybuffer_Buffer.tp_getattro == PyObject_GenericGetAttr)) {
2756 __pyx_type_8pybuffer_Buffer.tp_getattro = __Pyx_PyObject_GenericGetAttr;
2757 }
2758 if (PyObject_SetAttr(__pyx_m, __pyx_n_s_Buffer, (PyObject *)&__pyx_type_8pybuffer_Buffer) < 0) __PYX_ERR(0, 55, __pyx_L1_error)
2759 if (__Pyx_setup_reduce((PyObject*)&__pyx_type_8pybuffer_Buffer) < 0) __PYX_ERR(0, 55, __pyx_L1_error)
2760 __pyx_ptype_8pybuffer_Buffer = &__pyx_type_8pybuffer_Buffer;
2761 __Pyx_RefNannyFinishContext();
2762 return 0;
2763 __pyx_L1_error:;
2764 __Pyx_RefNannyFinishContext();
2765 return -1;
2766 }
2767
2768 static int __Pyx_modinit_type_import_code(void) {
2769 __Pyx_RefNannyDeclarations
2770 PyObject *__pyx_t_1 = NULL;
2771 int __pyx_lineno = 0;
2772 const char *__pyx_filename = NULL;
2773 int __pyx_clineno = 0;
2774 __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
2775 /*--- Type import code ---*/
2776 __pyx_t_1 = PyImport_ImportModule("mpi4py.MPI"); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 28, __pyx_L1_error)
2777 __Pyx_GOTREF(__pyx_t_1);
2778 __pyx_ptype_6mpi4py_3MPI_Datatype = __Pyx_ImportType(__pyx_t_1, "mpi4py.MPI", "Datatype", sizeof(struct PyMPIDatatypeObject), __Pyx_ImportType_CheckSize_Warn);
2779 if (!__pyx_ptype_6mpi4py_3MPI_Datatype) __PYX_ERR(2, 28, __pyx_L1_error)
2780 __pyx_ptype_6mpi4py_3MPI_Status = __Pyx_ImportType(__pyx_t_1, "mpi4py.MPI", "Status", sizeof(struct PyMPIStatusObject), __Pyx_ImportType_CheckSize_Warn);
2781 if (!__pyx_ptype_6mpi4py_3MPI_Status) __PYX_ERR(2, 36, __pyx_L1_error)
2782 __pyx_ptype_6mpi4py_3MPI_Request = __Pyx_ImportType(__pyx_t_1, "mpi4py.MPI", "Request", sizeof(struct PyMPIRequestObject), __Pyx_ImportType_CheckSize_Warn);
2783 if (!__pyx_ptype_6mpi4py_3MPI_Request) __PYX_ERR(2, 44, __pyx_L1_error)
2784 __pyx_ptype_6mpi4py_3MPI_Prequest = __Pyx_ImportType(__pyx_t_1, "mpi4py.MPI", "Prequest", sizeof(struct PyMPIPrequestObject), __Pyx_ImportType_CheckSize_Warn);
2785 if (!__pyx_ptype_6mpi4py_3MPI_Prequest) __PYX_ERR(2, 53, __pyx_L1_error)
2786 __pyx_ptype_6mpi4py_3MPI_Grequest = __Pyx_ImportType(__pyx_t_1, "mpi4py.MPI", "Grequest", sizeof(struct PyMPIGrequestObject), __Pyx_ImportType_CheckSize_Warn);
2787 if (!__pyx_ptype_6mpi4py_3MPI_Grequest) __PYX_ERR(2, 59, __pyx_L1_error)
2788 __pyx_ptype_6mpi4py_3MPI_Message = __Pyx_ImportType(__pyx_t_1, "mpi4py.MPI", "Message", sizeof(struct PyMPIMessageObject), __Pyx_ImportType_CheckSize_Warn);
2789 if (!__pyx_ptype_6mpi4py_3MPI_Message) __PYX_ERR(2, 65, __pyx_L1_error)
2790 __pyx_ptype_6mpi4py_3MPI_Op = __Pyx_ImportType(__pyx_t_1, "mpi4py.MPI", "Op", sizeof(struct PyMPIOpObject), __Pyx_ImportType_CheckSize_Warn);
2791 if (!__pyx_ptype_6mpi4py_3MPI_Op) __PYX_ERR(2, 74, __pyx_L1_error)
2792 __pyx_ptype_6mpi4py_3MPI_Group = __Pyx_ImportType(__pyx_t_1, "mpi4py.MPI", "Group", sizeof(struct PyMPIGroupObject), __Pyx_ImportType_CheckSize_Warn);
2793 if (!__pyx_ptype_6mpi4py_3MPI_Group) __PYX_ERR(2, 84, __pyx_L1_error)
2794 __pyx_ptype_6mpi4py_3MPI_Info = __Pyx_ImportType(__pyx_t_1, "mpi4py.MPI", "Info", sizeof(struct PyMPIInfoObject), __Pyx_ImportType_CheckSize_Warn);
2795 if (!__pyx_ptype_6mpi4py_3MPI_Info) __PYX_ERR(2, 92, __pyx_L1_error)
2796 __pyx_ptype_6mpi4py_3MPI_Errhandler = __Pyx_ImportType(__pyx_t_1, "mpi4py.MPI", "Errhandler", sizeof(struct PyMPIErrhandlerObject), __Pyx_ImportType_CheckSize_Warn);
2797 if (!__pyx_ptype_6mpi4py_3MPI_Errhandler) __PYX_ERR(2, 100, __pyx_L1_error)
2798 __pyx_ptype_6mpi4py_3MPI_Comm = __Pyx_ImportType(__pyx_t_1, "mpi4py.MPI", "Comm", sizeof(struct PyMPICommObject), __Pyx_ImportType_CheckSize_Warn);
2799 if (!__pyx_ptype_6mpi4py_3MPI_Comm) __PYX_ERR(2, 108, __pyx_L1_error)
2800 __pyx_ptype_6mpi4py_3MPI_Intracomm = __Pyx_ImportType(__pyx_t_1, "mpi4py.MPI", "Intracomm", sizeof(struct PyMPIIntracommObject), __Pyx_ImportType_CheckSize_Warn);
2801 if (!__pyx_ptype_6mpi4py_3MPI_Intracomm) __PYX_ERR(2, 116, __pyx_L1_error)
2802 __pyx_ptype_6mpi4py_3MPI_Topocomm = __Pyx_ImportType(__pyx_t_1, "mpi4py.MPI", "Topocomm", sizeof(struct PyMPITopocommObject), __Pyx_ImportType_CheckSize_Warn);
2803 if (!__pyx_ptype_6mpi4py_3MPI_Topocomm) __PYX_ERR(2, 122, __pyx_L1_error)
2804 __pyx_ptype_6mpi4py_3MPI_Cartcomm = __Pyx_ImportType(__pyx_t_1, "mpi4py.MPI", "Cartcomm", sizeof(struct PyMPICartcommObject), __Pyx_ImportType_CheckSize_Warn);
2805 if (!__pyx_ptype_6mpi4py_3MPI_Cartcomm) __PYX_ERR(2, 128, __pyx_L1_error)
2806 __pyx_ptype_6mpi4py_3MPI_Graphcomm = __Pyx_ImportType(__pyx_t_1, "mpi4py.MPI", "Graphcomm", sizeof(struct PyMPIGraphcommObject), __Pyx_ImportType_CheckSize_Warn);
2807 if (!__pyx_ptype_6mpi4py_3MPI_Graphcomm) __PYX_ERR(2, 134, __pyx_L1_error)
2808 __pyx_ptype_6mpi4py_3MPI_Distgraphcomm = __Pyx_ImportType(__pyx_t_1, "mpi4py.MPI", "Distgraphcomm", sizeof(struct PyMPIDistgraphcommObject), __Pyx_ImportType_CheckSize_Warn);
2809 if (!__pyx_ptype_6mpi4py_3MPI_Distgraphcomm) __PYX_ERR(2, 140, __pyx_L1_error)
2810 __pyx_ptype_6mpi4py_3MPI_Intercomm = __Pyx_ImportType(__pyx_t_1, "mpi4py.MPI", "Intercomm", sizeof(struct PyMPIIntercommObject), __Pyx_ImportType_CheckSize_Warn);
2811 if (!__pyx_ptype_6mpi4py_3MPI_Intercomm) __PYX_ERR(2, 146, __pyx_L1_error)
2812 __pyx_ptype_6mpi4py_3MPI_Win = __Pyx_ImportType(__pyx_t_1, "mpi4py.MPI", "Win", sizeof(struct PyMPIWinObject), __Pyx_ImportType_CheckSize_Warn);
2813 if (!__pyx_ptype_6mpi4py_3MPI_Win) __PYX_ERR(2, 152, __pyx_L1_error)
2814 __pyx_ptype_6mpi4py_3MPI_File = __Pyx_ImportType(__pyx_t_1, "mpi4py.MPI", "File", sizeof(struct PyMPIFileObject), __Pyx_ImportType_CheckSize_Warn);
2815 if (!__pyx_ptype_6mpi4py_3MPI_File) __PYX_ERR(2, 161, __pyx_L1_error)
2816 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2817 __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 9, __pyx_L1_error)
2818 __Pyx_GOTREF(__pyx_t_1);
2819 __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "type",
2820 #if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000
2821 sizeof(PyTypeObject),
2822 #else
2823 sizeof(PyHeapTypeObject),
2824 #endif
2825 __Pyx_ImportType_CheckSize_Warn);
2826 if (!__pyx_ptype_7cpython_4type_type) __PYX_ERR(3, 9, __pyx_L1_error)
2827 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2828 __Pyx_RefNannyFinishContext();
2829 return 0;
2830 __pyx_L1_error:;
2831 __Pyx_XDECREF(__pyx_t_1);
2832 __Pyx_RefNannyFinishContext();
2833 return -1;
2834 }
2835
2836 static int __Pyx_modinit_variable_import_code(void) {
2837 __Pyx_RefNannyDeclarations
2838 __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
2839 /*--- Variable import code ---*/
2840 __Pyx_RefNannyFinishContext();
2841 return 0;
2842 }
2843
2844 static int __Pyx_modinit_function_import_code(void) {
2845 __Pyx_RefNannyDeclarations
2846 __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
2847 /*--- Function import code ---*/
2848 __Pyx_RefNannyFinishContext();
2849 return 0;
2850 }
2851
2852
2853 #ifndef CYTHON_NO_PYINIT_EXPORT
2854 #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
2855 #elif PY_MAJOR_VERSION < 3
2856 #ifdef __cplusplus
2857 #define __Pyx_PyMODINIT_FUNC extern "C" void
2858 #else
2859 #define __Pyx_PyMODINIT_FUNC void
2860 #endif
2861 #else
2862 #ifdef __cplusplus
2863 #define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
2864 #else
2865 #define __Pyx_PyMODINIT_FUNC PyObject *
2866 #endif
2867 #endif
2868
2869
2870 #if PY_MAJOR_VERSION < 3
2871 __Pyx_PyMODINIT_FUNC initpybuffer(void) CYTHON_SMALL_CODE; /*proto*/
2872 __Pyx_PyMODINIT_FUNC initpybuffer(void)
2873 #else
2874 __Pyx_PyMODINIT_FUNC PyInit_pybuffer(void) CYTHON_SMALL_CODE; /*proto*/
2875 __Pyx_PyMODINIT_FUNC PyInit_pybuffer(void)
2876 #if CYTHON_PEP489_MULTI_PHASE_INIT
2877 {
2878 return PyModuleDef_Init(&__pyx_moduledef);
2879 }
2880 static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
2881 #if PY_VERSION_HEX >= 0x030700A1
2882 static PY_INT64_T main_interpreter_id = -1;
2883 PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
2884 if (main_interpreter_id == -1) {
2885 main_interpreter_id = current_id;
2886 return (unlikely(current_id == -1)) ? -1 : 0;
2887 } else if (unlikely(main_interpreter_id != current_id))
2888 #else
2889 static PyInterpreterState *main_interpreter = NULL;
2890 PyInterpreterState *current_interpreter = PyThreadState_Get()->interp;
2891 if (!main_interpreter) {
2892 main_interpreter = current_interpreter;
2893 } else if (unlikely(main_interpreter != current_interpreter))
2894 #endif
2895 {
2896 PyErr_SetString(
2897 PyExc_ImportError,
2898 "Interpreter change detected - this module can only be loaded into one interpreter per process.");
2899 return -1;
2900 }
2901 return 0;
2902 }
2903 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) {
2904 PyObject *value = PyObject_GetAttrString(spec, from_name);
2905 int result = 0;
2906 if (likely(value)) {
2907 if (allow_none || value != Py_None) {
2908 result = PyDict_SetItemString(moddict, to_name, value);
2909 }
2910 Py_DECREF(value);
2911 } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
2912 PyErr_Clear();
2913 } else {
2914 result = -1;
2915 }
2916 return result;
2917 }
2918 static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
2919 PyObject *module = NULL, *moddict, *modname;
2920 if (__Pyx_check_single_interpreter())
2921 return NULL;
2922 if (__pyx_m)
2923 return __Pyx_NewRef(__pyx_m);
2924 modname = PyObject_GetAttrString(spec, "name");
2925 if (unlikely(!modname)) goto bad;
2926 module = PyModule_NewObject(modname);
2927 Py_DECREF(modname);
2928 if (unlikely(!module)) goto bad;
2929 moddict = PyModule_GetDict(module);
2930 if (unlikely(!moddict)) goto bad;
2931 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
2932 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
2933 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
2934 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
2935 return module;
2936 bad:
2937 Py_XDECREF(module);
2938 return NULL;
2939 }
2940
2941
2942 static CYTHON_SMALL_CODE int __pyx_pymod_exec_pybuffer(PyObject *__pyx_pyinit_module)
2943 #endif
2944 #endif
2945 {
2946 PyObject *__pyx_t_1 = NULL;
2947 PyObject *__pyx_t_2 = NULL;
2948 PyObject *__pyx_t_3 = NULL;
2949 int __pyx_lineno = 0;
2950 const char *__pyx_filename = NULL;
2951 int __pyx_clineno = 0;
2952 __Pyx_RefNannyDeclarations
2953 #if CYTHON_PEP489_MULTI_PHASE_INIT
2954 if (__pyx_m) {
2955 if (__pyx_m == __pyx_pyinit_module) return 0;
2956 PyErr_SetString(PyExc_RuntimeError, "Module 'pybuffer' has already been imported. Re-initialisation is not supported.");
2957 return -1;
2958 }
2959 #elif PY_MAJOR_VERSION >= 3
2960 if (__pyx_m) return __Pyx_NewRef(__pyx_m);
2961 #endif
2962 #if CYTHON_REFNANNY
2963 __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
2964 if (!__Pyx_RefNanny) {
2965 PyErr_Clear();
2966 __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
2967 if (!__Pyx_RefNanny)
2968 Py_FatalError("failed to import 'refnanny' module");
2969 }
2970 #endif
2971 __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_pybuffer(void)", 0);
2972 if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2973 #ifdef __Pxy_PyFrame_Initialize_Offsets
2974 __Pxy_PyFrame_Initialize_Offsets();
2975 #endif
2976 __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
2977 __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
2978 __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
2979 #ifdef __Pyx_CyFunction_USED
2980 if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2981 #endif
2982 #ifdef __Pyx_FusedFunction_USED
2983 if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2984 #endif
2985 #ifdef __Pyx_Coroutine_USED
2986 if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2987 #endif
2988 #ifdef __Pyx_Generator_USED
2989 if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2990 #endif
2991 #ifdef __Pyx_AsyncGen_USED
2992 if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2993 #endif
2994 #ifdef __Pyx_StopAsyncIteration_USED
2995 if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2996 #endif
2997 /*--- Library function declarations ---*/
2998 /*--- Threads initialization code ---*/
2999 #if defined(WITH_THREAD) && PY_VERSION_HEX < 0x030700F0 && defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
3000 PyEval_InitThreads();
3001 #endif
3002 /*--- Module creation code ---*/
3003 #if CYTHON_PEP489_MULTI_PHASE_INIT
3004 __pyx_m = __pyx_pyinit_module;
3005 Py_INCREF(__pyx_m);
3006 #else
3007 #if PY_MAJOR_VERSION < 3
3008 __pyx_m = Py_InitModule4("pybuffer", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
3009 #else
3010 __pyx_m = PyModule_Create(&__pyx_moduledef);
3011 #endif
3012 if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
3013 #endif
3014 __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
3015 Py_INCREF(__pyx_d);
3016 __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
3017 Py_INCREF(__pyx_b);
3018 __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
3019 Py_INCREF(__pyx_cython_runtime);
3020 if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
3021 /*--- Initialize various global constants etc. ---*/
3022 if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3023 #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
3024 if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3025 #endif
3026 if (__pyx_module_is_main_pybuffer) {
3027 if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3028 }
3029 #if PY_MAJOR_VERSION >= 3
3030 {
3031 PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
3032 if (!PyDict_GetItemString(modules, "pybuffer")) {
3033 if (unlikely(PyDict_SetItemString(modules, "pybuffer", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
3034 }
3035 }
3036 #endif
3037 /*--- Builtin init code ---*/
3038 if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3039 /*--- Constants init code ---*/
3040 if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3041 /*--- Global type/function init code ---*/
3042 (void)__Pyx_modinit_global_init_code();
3043 (void)__Pyx_modinit_variable_export_code();
3044 (void)__Pyx_modinit_function_export_code();
3045 if (unlikely(__Pyx_modinit_type_init_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
3046 if (unlikely(__Pyx_modinit_type_import_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
3047 (void)__Pyx_modinit_variable_import_code();
3048 (void)__Pyx_modinit_function_import_code();
3049 /*--- Execution code ---*/
3050 #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
3051 if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3052 #endif
3053
3054 /* "pybuffer.pyx":10
3055 * from libc.stdlib cimport malloc, free
3056 *
3057 * from mpi4py import MPI # <<<<<<<<<<<<<<
3058 *
3059 * ###########################################################
3060 */
3061 __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 10, __pyx_L1_error)
3062 __Pyx_GOTREF(__pyx_t_1);
3063 __Pyx_INCREF(__pyx_n_s_MPI);
3064 __Pyx_GIVEREF(__pyx_n_s_MPI);
3065 PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_MPI);
3066 __pyx_t_2 = __Pyx_Import(__pyx_n_s_mpi4py, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 10, __pyx_L1_error)
3067 __Pyx_GOTREF(__pyx_t_2);
3068 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3069 __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_MPI); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 10, __pyx_L1_error)
3070 __Pyx_GOTREF(__pyx_t_1);
3071 if (PyDict_SetItem(__pyx_d, __pyx_n_s_MPI, __pyx_t_1) < 0) __PYX_ERR(0, 10, __pyx_L1_error)
3072 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3073 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3074
3075 /* "pybuffer.pyx":15
3076 *
3077 * cdef dict TypeDict = {
3078 * "?" : MPI.C_BOOL, # <<<<<<<<<<<<<<
3079 * "c" : MPI.CHAR,
3080 * "b" : MPI.SIGNED_CHAR,
3081 */
3082 __pyx_t_2 = __Pyx_PyDict_NewPresized(22); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 15, __pyx_L1_error)
3083 __Pyx_GOTREF(__pyx_t_2);
3084 __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_MPI); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 15, __pyx_L1_error)
3085 __Pyx_GOTREF(__pyx_t_1);
3086 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_C_BOOL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 15, __pyx_L1_error)
3087 __Pyx_GOTREF(__pyx_t_3);
3088 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3089 if (PyDict_SetItem(__pyx_t_2, __pyx_kp_s__4, __pyx_t_3) < 0) __PYX_ERR(0, 15, __pyx_L1_error)
3090 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3091
3092 /* "pybuffer.pyx":16
3093 * cdef dict TypeDict = {
3094 * "?" : MPI.C_BOOL,
3095 * "c" : MPI.CHAR, # <<<<<<<<<<<<<<
3096 * "b" : MPI.SIGNED_CHAR,
3097 * "h" : MPI.SHORT,
3098 */
3099 __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_MPI); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 16, __pyx_L1_error)
3100 __Pyx_GOTREF(__pyx_t_3);
3101 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_CHAR); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 16, __pyx_L1_error)
3102 __Pyx_GOTREF(__pyx_t_1);
3103 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3104 if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_c, __pyx_t_1) < 0) __PYX_ERR(0, 15, __pyx_L1_error)
3105 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3106
3107 /* "pybuffer.pyx":17
3108 * "?" : MPI.C_BOOL,
3109 * "c" : MPI.CHAR,
3110 * "b" : MPI.SIGNED_CHAR, # <<<<<<<<<<<<<<
3111 * "h" : MPI.SHORT,
3112 * "i" : MPI.INT,
3113 */
3114 __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_MPI); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 17, __pyx_L1_error)
3115 __Pyx_GOTREF(__pyx_t_1);
3116 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_SIGNED_CHAR); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 17, __pyx_L1_error)
3117 __Pyx_GOTREF(__pyx_t_3);
3118 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3119 if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_b, __pyx_t_3) < 0) __PYX_ERR(0, 15, __pyx_L1_error)
3120 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3121
3122 /* "pybuffer.pyx":18
3123 * "c" : MPI.CHAR,
3124 * "b" : MPI.SIGNED_CHAR,
3125 * "h" : MPI.SHORT, # <<<<<<<<<<<<<<
3126 * "i" : MPI.INT,
3127 * "l" : MPI.LONG,
3128 */
3129 __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_MPI); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 18, __pyx_L1_error)
3130 __Pyx_GOTREF(__pyx_t_3);
3131 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_SHORT); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 18, __pyx_L1_error)
3132 __Pyx_GOTREF(__pyx_t_1);
3133 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3134 if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_h, __pyx_t_1) < 0) __PYX_ERR(0, 15, __pyx_L1_error)
3135 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3136
3137 /* "pybuffer.pyx":19
3138 * "b" : MPI.SIGNED_CHAR,
3139 * "h" : MPI.SHORT,
3140 * "i" : MPI.INT, # <<<<<<<<<<<<<<
3141 * "l" : MPI.LONG,
3142 * "q" : MPI.LONG_LONG,
3143 */
3144 __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_MPI); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 19, __pyx_L1_error)
3145 __Pyx_GOTREF(__pyx_t_1);
3146 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_INT); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 19, __pyx_L1_error)
3147 __Pyx_GOTREF(__pyx_t_3);
3148 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3149 if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_i, __pyx_t_3) < 0) __PYX_ERR(0, 15, __pyx_L1_error)
3150 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3151
3152 /* "pybuffer.pyx":20
3153 * "h" : MPI.SHORT,
3154 * "i" : MPI.INT,
3155 * "l" : MPI.LONG, # <<<<<<<<<<<<<<
3156 * "q" : MPI.LONG_LONG,
3157 * "p" : MPI.AINT,
3158 */
3159 __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_MPI); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 20, __pyx_L1_error)
3160 __Pyx_GOTREF(__pyx_t_3);
3161 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_LONG); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 20, __pyx_L1_error)
3162 __Pyx_GOTREF(__pyx_t_1);
3163 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3164 if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_l, __pyx_t_1) < 0) __PYX_ERR(0, 15, __pyx_L1_error)
3165 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3166
3167 /* "pybuffer.pyx":21
3168 * "i" : MPI.INT,
3169 * "l" : MPI.LONG,
3170 * "q" : MPI.LONG_LONG, # <<<<<<<<<<<<<<
3171 * "p" : MPI.AINT,
3172 * "B" : MPI.UNSIGNED_CHAR,
3173 */
3174 __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_MPI); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 21, __pyx_L1_error)
3175 __Pyx_GOTREF(__pyx_t_1);
3176 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_LONG_LONG); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 21, __pyx_L1_error)
3177 __Pyx_GOTREF(__pyx_t_3);
3178 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3179 if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_q, __pyx_t_3) < 0) __PYX_ERR(0, 15, __pyx_L1_error)
3180 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3181
3182 /* "pybuffer.pyx":22
3183 * "l" : MPI.LONG,
3184 * "q" : MPI.LONG_LONG,
3185 * "p" : MPI.AINT, # <<<<<<<<<<<<<<
3186 * "B" : MPI.UNSIGNED_CHAR,
3187 * "H" : MPI.UNSIGNED_SHORT,
3188 */
3189 __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_MPI); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 22, __pyx_L1_error)
3190 __Pyx_GOTREF(__pyx_t_3);
3191 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_AINT); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 22, __pyx_L1_error)
3192 __Pyx_GOTREF(__pyx_t_1);
3193 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3194 if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_p, __pyx_t_1) < 0) __PYX_ERR(0, 15, __pyx_L1_error)
3195 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3196
3197 /* "pybuffer.pyx":23
3198 * "q" : MPI.LONG_LONG,
3199 * "p" : MPI.AINT,
3200 * "B" : MPI.UNSIGNED_CHAR, # <<<<<<<<<<<<<<
3201 * "H" : MPI.UNSIGNED_SHORT,
3202 * "I" : MPI.UNSIGNED,
3203 */
3204 __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_MPI); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 23, __pyx_L1_error)
3205 __Pyx_GOTREF(__pyx_t_1);
3206 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_UNSIGNED_CHAR); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 23, __pyx_L1_error)
3207 __Pyx_GOTREF(__pyx_t_3);
3208 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3209 if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_B, __pyx_t_3) < 0) __PYX_ERR(0, 15, __pyx_L1_error)
3210 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3211
3212 /* "pybuffer.pyx":24
3213 * "p" : MPI.AINT,
3214 * "B" : MPI.UNSIGNED_CHAR,
3215 * "H" : MPI.UNSIGNED_SHORT, # <<<<<<<<<<<<<<
3216 * "I" : MPI.UNSIGNED,
3217 * "L" : MPI.UNSIGNED_LONG,
3218 */
3219 __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_MPI); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 24, __pyx_L1_error)
3220 __Pyx_GOTREF(__pyx_t_3);
3221 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_UNSIGNED_SHORT); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 24, __pyx_L1_error)
3222 __Pyx_GOTREF(__pyx_t_1);
3223 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3224 if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_H, __pyx_t_1) < 0) __PYX_ERR(0, 15, __pyx_L1_error)
3225 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3226
3227 /* "pybuffer.pyx":25
3228 * "B" : MPI.UNSIGNED_CHAR,
3229 * "H" : MPI.UNSIGNED_SHORT,
3230 * "I" : MPI.UNSIGNED, # <<<<<<<<<<<<<<
3231 * "L" : MPI.UNSIGNED_LONG,
3232 * "Q" : MPI.UNSIGNED_LONG_LONG,
3233 */
3234 __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_MPI); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 25, __pyx_L1_error)
3235 __Pyx_GOTREF(__pyx_t_1);
3236 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_UNSIGNED); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 25, __pyx_L1_error)
3237 __Pyx_GOTREF(__pyx_t_3);
3238 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3239 if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_I, __pyx_t_3) < 0) __PYX_ERR(0, 15, __pyx_L1_error)
3240 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3241
3242 /* "pybuffer.pyx":26
3243 * "H" : MPI.UNSIGNED_SHORT,
3244 * "I" : MPI.UNSIGNED,
3245 * "L" : MPI.UNSIGNED_LONG, # <<<<<<<<<<<<<<
3246 * "Q" : MPI.UNSIGNED_LONG_LONG,
3247 * "f" : MPI.FLOAT,
3248 */
3249 __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_MPI); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 26, __pyx_L1_error)
3250 __Pyx_GOTREF(__pyx_t_3);
3251 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_UNSIGNED_LONG); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 26, __pyx_L1_error)
3252 __Pyx_GOTREF(__pyx_t_1);
3253 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3254 if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_L, __pyx_t_1) < 0) __PYX_ERR(0, 15, __pyx_L1_error)
3255 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3256
3257 /* "pybuffer.pyx":27
3258 * "I" : MPI.UNSIGNED,
3259 * "L" : MPI.UNSIGNED_LONG,
3260 * "Q" : MPI.UNSIGNED_LONG_LONG, # <<<<<<<<<<<<<<
3261 * "f" : MPI.FLOAT,
3262 * "d" : MPI.DOUBLE,
3263 */
3264 __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_MPI); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 27, __pyx_L1_error)
3265 __Pyx_GOTREF(__pyx_t_1);
3266 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_UNSIGNED_LONG_LONG); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 27, __pyx_L1_error)
3267 __Pyx_GOTREF(__pyx_t_3);
3268 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3269 if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_Q, __pyx_t_3) < 0) __PYX_ERR(0, 15, __pyx_L1_error)
3270 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3271
3272 /* "pybuffer.pyx":28
3273 * "L" : MPI.UNSIGNED_LONG,
3274 * "Q" : MPI.UNSIGNED_LONG_LONG,
3275 * "f" : MPI.FLOAT, # <<<<<<<<<<<<<<
3276 * "d" : MPI.DOUBLE,
3277 * "g" : MPI.LONG_DOUBLE,
3278 */
3279 __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_MPI); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 28, __pyx_L1_error)
3280 __Pyx_GOTREF(__pyx_t_3);
3281 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_FLOAT); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 28, __pyx_L1_error)
3282 __Pyx_GOTREF(__pyx_t_1);
3283 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3284 if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_f, __pyx_t_1) < 0) __PYX_ERR(0, 15, __pyx_L1_error)
3285 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3286
3287 /* "pybuffer.pyx":29
3288 * "Q" : MPI.UNSIGNED_LONG_LONG,
3289 * "f" : MPI.FLOAT,
3290 * "d" : MPI.DOUBLE, # <<<<<<<<<<<<<<
3291 * "g" : MPI.LONG_DOUBLE,
3292 * "Zf": MPI.C_FLOAT_COMPLEX,
3293 */
3294 __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_MPI); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 29, __pyx_L1_error)
3295 __Pyx_GOTREF(__pyx_t_1);
3296 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_DOUBLE); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 29, __pyx_L1_error)
3297 __Pyx_GOTREF(__pyx_t_3);
3298 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3299 if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_d, __pyx_t_3) < 0) __PYX_ERR(0, 15, __pyx_L1_error)
3300 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3301
3302 /* "pybuffer.pyx":30
3303 * "f" : MPI.FLOAT,
3304 * "d" : MPI.DOUBLE,
3305 * "g" : MPI.LONG_DOUBLE, # <<<<<<<<<<<<<<
3306 * "Zf": MPI.C_FLOAT_COMPLEX,
3307 * "Zd": MPI.C_DOUBLE_COMPLEX,
3308 */
3309 __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_MPI); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 30, __pyx_L1_error)
3310 __Pyx_GOTREF(__pyx_t_3);
3311 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_LONG_DOUBLE); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 30, __pyx_L1_error)
3312 __Pyx_GOTREF(__pyx_t_1);
3313 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3314 if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_g, __pyx_t_1) < 0) __PYX_ERR(0, 15, __pyx_L1_error)
3315 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3316
3317 /* "pybuffer.pyx":31
3318 * "d" : MPI.DOUBLE,
3319 * "g" : MPI.LONG_DOUBLE,
3320 * "Zf": MPI.C_FLOAT_COMPLEX, # <<<<<<<<<<<<<<
3321 * "Zd": MPI.C_DOUBLE_COMPLEX,
3322 * "Zg": MPI.C_LONG_DOUBLE_COMPLEX,
3323 */
3324 __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_MPI); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 31, __pyx_L1_error)
3325 __Pyx_GOTREF(__pyx_t_1);
3326 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_C_FLOAT_COMPLEX); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 31, __pyx_L1_error)
3327 __Pyx_GOTREF(__pyx_t_3);
3328 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3329 if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_Zf, __pyx_t_3) < 0) __PYX_ERR(0, 15, __pyx_L1_error)
3330 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3331
3332 /* "pybuffer.pyx":32
3333 * "g" : MPI.LONG_DOUBLE,
3334 * "Zf": MPI.C_FLOAT_COMPLEX,
3335 * "Zd": MPI.C_DOUBLE_COMPLEX, # <<<<<<<<<<<<<<
3336 * "Zg": MPI.C_LONG_DOUBLE_COMPLEX,
3337 * "F" : MPI.C_FLOAT_COMPLEX,
3338 */
3339 __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_MPI); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 32, __pyx_L1_error)
3340 __Pyx_GOTREF(__pyx_t_3);
3341 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_C_DOUBLE_COMPLEX); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 32, __pyx_L1_error)
3342 __Pyx_GOTREF(__pyx_t_1);
3343 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3344 if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_Zd, __pyx_t_1) < 0) __PYX_ERR(0, 15, __pyx_L1_error)
3345 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3346
3347 /* "pybuffer.pyx":33
3348 * "Zf": MPI.C_FLOAT_COMPLEX,
3349 * "Zd": MPI.C_DOUBLE_COMPLEX,
3350 * "Zg": MPI.C_LONG_DOUBLE_COMPLEX, # <<<<<<<<<<<<<<
3351 * "F" : MPI.C_FLOAT_COMPLEX,
3352 * "D" : MPI.C_DOUBLE_COMPLEX,
3353 */
3354 __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_MPI); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 33, __pyx_L1_error)
3355 __Pyx_GOTREF(__pyx_t_1);
3356 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_C_LONG_DOUBLE_COMPLEX); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 33, __pyx_L1_error)
3357 __Pyx_GOTREF(__pyx_t_3);
3358 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3359 if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_Zg, __pyx_t_3) < 0) __PYX_ERR(0, 15, __pyx_L1_error)
3360 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3361
3362 /* "pybuffer.pyx":34
3363 * "Zd": MPI.C_DOUBLE_COMPLEX,
3364 * "Zg": MPI.C_LONG_DOUBLE_COMPLEX,
3365 * "F" : MPI.C_FLOAT_COMPLEX, # <<<<<<<<<<<<<<
3366 * "D" : MPI.C_DOUBLE_COMPLEX,
3367 * "G" : MPI.C_LONG_DOUBLE_COMPLEX,
3368 */
3369 __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_MPI); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 34, __pyx_L1_error)
3370 __Pyx_GOTREF(__pyx_t_3);
3371 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_C_FLOAT_COMPLEX); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 34, __pyx_L1_error)
3372 __Pyx_GOTREF(__pyx_t_1);
3373 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3374 if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_F, __pyx_t_1) < 0) __PYX_ERR(0, 15, __pyx_L1_error)
3375 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3376
3377 /* "pybuffer.pyx":35
3378 * "Zg": MPI.C_LONG_DOUBLE_COMPLEX,
3379 * "F" : MPI.C_FLOAT_COMPLEX,
3380 * "D" : MPI.C_DOUBLE_COMPLEX, # <<<<<<<<<<<<<<
3381 * "G" : MPI.C_LONG_DOUBLE_COMPLEX,
3382 * }
3383 */
3384 __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_MPI); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 35, __pyx_L1_error)
3385 __Pyx_GOTREF(__pyx_t_1);
3386 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_C_DOUBLE_COMPLEX); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 35, __pyx_L1_error)
3387 __Pyx_GOTREF(__pyx_t_3);
3388 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3389 if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_D, __pyx_t_3) < 0) __PYX_ERR(0, 15, __pyx_L1_error)
3390 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3391
3392 /* "pybuffer.pyx":36
3393 * "F" : MPI.C_FLOAT_COMPLEX,
3394 * "D" : MPI.C_DOUBLE_COMPLEX,
3395 * "G" : MPI.C_LONG_DOUBLE_COMPLEX, # <<<<<<<<<<<<<<
3396 * }
3397 *
3398 */
3399 __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_MPI); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 36, __pyx_L1_error)
3400 __Pyx_GOTREF(__pyx_t_3);
3401 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_C_LONG_DOUBLE_COMPLEX); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 36, __pyx_L1_error)
3402 __Pyx_GOTREF(__pyx_t_1);
3403 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3404 if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_G, __pyx_t_1) < 0) __PYX_ERR(0, 15, __pyx_L1_error)
3405 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3406 __Pyx_XGOTREF(__pyx_v_8pybuffer_TypeDict);
3407 __Pyx_DECREF_SET(__pyx_v_8pybuffer_TypeDict, ((PyObject*)__pyx_t_2));
3408 __Pyx_GIVEREF(__pyx_t_2);
3409 __pyx_t_2 = 0;
3410
3411 /* "pybuffer.pyx":53
3412 * return PyUnicodeString_FromString(pybuf.format)
3413 *
3414 * cdef int bufflags = PyBUF_ANY_CONTIGUOUS | PyBUF_WRITABLE | PyBUF_FORMAT # <<<<<<<<<<<<<<
3415 *
3416 * cdef class Buffer(object):
3417 */
3418 __pyx_v_8pybuffer_bufflags = ((PyBUF_ANY_CONTIGUOUS | PyBUF_WRITABLE) | PyBUF_FORMAT);
3419
3420 /* "pybuffer.pyx":1
3421 * # # <<<<<<<<<<<<<<
3422 * # distutils: language = c++
3423 * #
3424 */
3425 __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error)
3426 __Pyx_GOTREF(__pyx_t_2);
3427 if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
3428 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3429
3430 /*--- Wrapped vars code ---*/
3431
3432 goto __pyx_L0;
3433 __pyx_L1_error:;
3434 __Pyx_XDECREF(__pyx_t_1);
3435 __Pyx_XDECREF(__pyx_t_2);
3436 __Pyx_XDECREF(__pyx_t_3);
3437 if (__pyx_m) {
3438 if (__pyx_d) {
3439 __Pyx_AddTraceback("init pybuffer", __pyx_clineno, __pyx_lineno, __pyx_filename);
3440 }
3441 Py_CLEAR(__pyx_m);
3442 } else if (!PyErr_Occurred()) {
3443 PyErr_SetString(PyExc_ImportError, "init pybuffer");
3444 }
3445 __pyx_L0:;
3446 __Pyx_RefNannyFinishContext();
3447 #if CYTHON_PEP489_MULTI_PHASE_INIT
3448 return (__pyx_m != NULL) ? 0 : -1;
3449 #elif PY_MAJOR_VERSION >= 3
3450 return __pyx_m;
3451 #else
3452 return;
3453 #endif
3454 }
3455
3456 /* --- Runtime support code --- */
3457 /* Refnanny */
3458 #if CYTHON_REFNANNY
3459 static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
3460 PyObject *m = NULL, *p = NULL;
3461 void *r = NULL;
3462 m = PyImport_ImportModule(modname);
3463 if (!m) goto end;
3464 p = PyObject_GetAttrString(m, "RefNannyAPI");
3465 if (!p) goto end;
3466 r = PyLong_AsVoidPtr(p);
3467 end:
3468 Py_XDECREF(p);
3469 Py_XDECREF(m);
3470 return (__Pyx_RefNannyAPIStruct *)r;
3471 }
3472 #endif
3473
3474 /* PyObjectGetAttrStr */
3475 #if CYTHON_USE_TYPE_SLOTS
3476 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
3477 PyTypeObject* tp = Py_TYPE(obj);
3478 if (likely(tp->tp_getattro))
3479 return tp->tp_getattro(obj, attr_name);
3480 #if PY_MAJOR_VERSION < 3
3481 if (likely(tp->tp_getattr))
3482 return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
3483 #endif
3484 return PyObject_GetAttr(obj, attr_name);
3485 }
3486 #endif
3487
3488 /* GetBuiltinName */
3489 static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
3490 PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
3491 if (unlikely(!result)) {
3492 PyErr_Format(PyExc_NameError,
3493 #if PY_MAJOR_VERSION >= 3
3494 "name '%U' is not defined", name);
3495 #else
3496 "name '%.200s' is not defined", PyString_AS_STRING(name));
3497 #endif
3498 }
3499 return result;
3500 }
3501
3502 /* GetTopmostException */
3503 #if CYTHON_USE_EXC_INFO_STACK
3504 static _PyErr_StackItem *
3505 __Pyx_PyErr_GetTopmostException(PyThreadState *tstate)
3506 {
3507 _PyErr_StackItem *exc_info = tstate->exc_info;
3508 while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) &&
3509 exc_info->previous_item != NULL)
3510 {
3511 exc_info = exc_info->previous_item;
3512 }
3513 return exc_info;
3514 }
3515 #endif
3516
3517 /* SaveResetException */
3518 #if CYTHON_FAST_THREAD_STATE
3519 static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
3520 #if CYTHON_USE_EXC_INFO_STACK
3521 _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
3522 *type = exc_info->exc_type;
3523 *value = exc_info->exc_value;
3524 *tb = exc_info->exc_traceback;
3525 #else
3526 *type = tstate->exc_type;
3527 *value = tstate->exc_value;
3528 *tb = tstate->exc_traceback;
3529 #endif
3530 Py_XINCREF(*type);
3531 Py_XINCREF(*value);
3532 Py_XINCREF(*tb);
3533 }
3534 static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
3535 PyObject *tmp_type, *tmp_value, *tmp_tb;
3536 #if CYTHON_USE_EXC_INFO_STACK
3537 _PyErr_StackItem *exc_info = tstate->exc_info;
3538 tmp_type = exc_info->exc_type;
3539 tmp_value = exc_info->exc_value;
3540 tmp_tb = exc_info->exc_traceback;
3541 exc_info->exc_type = type;
3542 exc_info->exc_value = value;
3543 exc_info->exc_traceback = tb;
3544 #else
3545 tmp_type = tstate->exc_type;
3546 tmp_value = tstate->exc_value;
3547 tmp_tb = tstate->exc_traceback;
3548 tstate->exc_type = type;
3549 tstate->exc_value = value;
3550 tstate->exc_traceback = tb;
3551 #endif
3552 Py_XDECREF(tmp_type);
3553 Py_XDECREF(tmp_value);
3554 Py_XDECREF(tmp_tb);
3555 }
3556 #endif
3557
3558 /* PyErrExceptionMatches */
3559 #if CYTHON_FAST_THREAD_STATE
3560 static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
3561 Py_ssize_t i, n;
3562 n = PyTuple_GET_SIZE(tuple);
3563 #if PY_MAJOR_VERSION >= 3
3564 for (i=0; i<n; i++) {
3565 if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
3566 }
3567 #endif
3568 for (i=0; i<n; i++) {
3569 if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
3570 }
3571 return 0;
3572 }
3573 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
3574 PyObject *exc_type = tstate->curexc_type;
3575 if (exc_type == err) return 1;
3576 if (unlikely(!exc_type)) return 0;
3577 if (unlikely(PyTuple_Check(err)))
3578 return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
3579 return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
3580 }
3581 #endif
3582
3583 /* PyErrFetchRestore */
3584 #if CYTHON_FAST_THREAD_STATE
3585 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
3586 PyObject *tmp_type, *tmp_value, *tmp_tb;
3587 tmp_type = tstate->curexc_type;
3588 tmp_value = tstate->curexc_value;
3589 tmp_tb = tstate->curexc_traceback;
3590 tstate->curexc_type = type;
3591 tstate->curexc_value = value;
3592 tstate->curexc_traceback = tb;
3593 Py_XDECREF(tmp_type);
3594 Py_XDECREF(tmp_value);
3595 Py_XDECREF(tmp_tb);
3596 }
3597 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
3598 *type = tstate->curexc_type;
3599 *value = tstate->curexc_value;
3600 *tb = tstate->curexc_traceback;
3601 tstate->curexc_type = 0;
3602 tstate->curexc_value = 0;
3603 tstate->curexc_traceback = 0;
3604 }
3605 #endif
3606
3607 /* RaiseDoubleKeywords */
3608 static void __Pyx_RaiseDoubleKeywordsError(
3609 const char* func_name,
3610 PyObject* kw_name)
3611 {
3612 PyErr_Format(PyExc_TypeError,
3613 #if PY_MAJOR_VERSION >= 3
3614 "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
3615 #else
3616 "%s() got multiple values for keyword argument '%s'", func_name,
3617 PyString_AsString(kw_name));
3618 #endif
3619 }
3620
3621 /* ParseKeywords */
3622 static int __Pyx_ParseOptionalKeywords(
3623 PyObject *kwds,
3624 PyObject **argnames[],
3625 PyObject *kwds2,
3626 PyObject *values[],
3627 Py_ssize_t num_pos_args,
3628 const char* function_name)
3629 {
3630 PyObject *key = 0, *value = 0;
3631 Py_ssize_t pos = 0;
3632 PyObject*** name;
3633 PyObject*** first_kw_arg = argnames + num_pos_args;
3634 while (PyDict_Next(kwds, &pos, &key, &value)) {
3635 name = first_kw_arg;
3636 while (*name && (**name != key)) name++;
3637 if (*name) {
3638 values[name-argnames] = value;
3639 continue;
3640 }
3641 name = first_kw_arg;
3642 #if PY_MAJOR_VERSION < 3
3643 if (likely(PyString_Check(key))) {
3644 while (*name) {
3645 if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
3646 && _PyString_Eq(**name, key)) {
3647 values[name-argnames] = value;
3648 break;
3649 }
3650 name++;
3651 }
3652 if (*name) continue;
3653 else {
3654 PyObject*** argname = argnames;
3655 while (argname != first_kw_arg) {
3656 if ((**argname == key) || (
3657 (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
3658 && _PyString_Eq(**argname, key))) {
3659 goto arg_passed_twice;
3660 }
3661 argname++;
3662 }
3663 }
3664 } else
3665 #endif
3666 if (likely(PyUnicode_Check(key))) {
3667 while (*name) {
3668 int cmp = (**name == key) ? 0 :
3669 #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
3670 (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
3671 #endif
3672 PyUnicode_Compare(**name, key);
3673 if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
3674 if (cmp == 0) {
3675 values[name-argnames] = value;
3676 break;
3677 }
3678 name++;
3679 }
3680 if (*name) continue;
3681 else {
3682 PyObject*** argname = argnames;
3683 while (argname != first_kw_arg) {
3684 int cmp = (**argname == key) ? 0 :
3685 #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
3686 (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
3687 #endif
3688 PyUnicode_Compare(**argname, key);
3689 if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
3690 if (cmp == 0) goto arg_passed_twice;
3691 argname++;
3692 }
3693 }
3694 } else
3695 goto invalid_keyword_type;
3696 if (kwds2) {
3697 if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
3698 } else {
3699 goto invalid_keyword;
3700 }
3701 }
3702 return 0;
3703 arg_passed_twice:
3704 __Pyx_RaiseDoubleKeywordsError(function_name, key);
3705 goto bad;
3706 invalid_keyword_type:
3707 PyErr_Format(PyExc_TypeError,
3708 "%.200s() keywords must be strings", function_name);
3709 goto bad;
3710 invalid_keyword:
3711 PyErr_Format(PyExc_TypeError,
3712 #if PY_MAJOR_VERSION < 3
3713 "%.200s() got an unexpected keyword argument '%.200s'",
3714 function_name, PyString_AsString(key));
3715 #else
3716 "%s() got an unexpected keyword argument '%U'",
3717 function_name, key);
3718 #endif
3719 bad:
3720 return -1;
3721 }
3722
3723 /* RaiseArgTupleInvalid */
3724 static void __Pyx_RaiseArgtupleInvalid(
3725 const char* func_name,
3726 int exact,
3727 Py_ssize_t num_min,
3728 Py_ssize_t num_max,
3729 Py_ssize_t num_found)
3730 {
3731 Py_ssize_t num_expected;
3732 const char *more_or_less;
3733 if (num_found < num_min) {
3734 num_expected = num_min;
3735 more_or_less = "at least";
3736 } else {
3737 num_expected = num_max;
3738 more_or_less = "at most";
3739 }
3740 if (exact) {
3741 more_or_less = "exactly";
3742 }
3743 PyErr_Format(PyExc_TypeError,
3744 "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
3745 func_name, more_or_less, num_expected,
3746 (num_expected == 1) ? "" : "s", num_found);
3747 }
3748
3749 /* PyObjectCall */
3750 #if CYTHON_COMPILING_IN_CPYTHON
3751 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
3752 PyObject *result;
3753 ternaryfunc call = Py_TYPE(func)->tp_call;
3754 if (unlikely(!call))
3755 return PyObject_Call(func, arg, kw);
3756 if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
3757 return NULL;
3758 result = (*call)(func, arg, kw);
3759 Py_LeaveRecursiveCall();
3760 if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
3761 PyErr_SetString(
3762 PyExc_SystemError,
3763 "NULL result without error in PyObject_Call");
3764 }
3765 return result;
3766 }
3767 #endif
3768
3769 /* RaiseException */
3770 #if PY_MAJOR_VERSION < 3
3771 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
3772 CYTHON_UNUSED PyObject *cause) {
3773 __Pyx_PyThreadState_declare
3774 Py_XINCREF(type);
3775 if (!value || value == Py_None)
3776 value = NULL;
3777 else
3778 Py_INCREF(value);
3779 if (!tb || tb == Py_None)
3780 tb = NULL;
3781 else {
3782 Py_INCREF(tb);
3783 if (!PyTraceBack_Check(tb)) {
3784 PyErr_SetString(PyExc_TypeError,
3785 "raise: arg 3 must be a traceback or None");
3786 goto raise_error;
3787 }
3788 }
3789 if (PyType_Check(type)) {
3790 #if CYTHON_COMPILING_IN_PYPY
3791 if (!value) {
3792 Py_INCREF(Py_None);
3793 value = Py_None;
3794 }
3795 #endif
3796 PyErr_NormalizeException(&type, &value, &tb);
3797 } else {
3798 if (value) {
3799 PyErr_SetString(PyExc_TypeError,
3800 "instance exception may not have a separate value");
3801 goto raise_error;
3802 }
3803 value = type;
3804 type = (PyObject*) Py_TYPE(type);
3805 Py_INCREF(type);
3806 if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
3807 PyErr_SetString(PyExc_TypeError,
3808 "raise: exception class must be a subclass of BaseException");
3809 goto raise_error;
3810 }
3811 }
3812 __Pyx_PyThreadState_assign
3813 __Pyx_ErrRestore(type, value, tb);
3814 return;
3815 raise_error:
3816 Py_XDECREF(value);
3817 Py_XDECREF(type);
3818 Py_XDECREF(tb);
3819 return;
3820 }
3821 #else
3822 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
3823 PyObject* owned_instance = NULL;
3824 if (tb == Py_None) {
3825 tb = 0;
3826 } else if (tb && !PyTraceBack_Check(tb)) {
3827 PyErr_SetString(PyExc_TypeError,
3828 "raise: arg 3 must be a traceback or None");
3829 goto bad;
3830 }
3831 if (value == Py_None)
3832 value = 0;
3833 if (PyExceptionInstance_Check(type)) {
3834 if (value) {
3835 PyErr_SetString(PyExc_TypeError,
3836 "instance exception may not have a separate value");
3837 goto bad;
3838 }
3839 value = type;
3840 type = (PyObject*) Py_TYPE(value);
3841 } else if (PyExceptionClass_Check(type)) {
3842 PyObject *instance_class = NULL;
3843 if (value && PyExceptionInstance_Check(value)) {
3844 instance_class = (PyObject*) Py_TYPE(value);
3845 if (instance_class != type) {
3846 int is_subclass = PyObject_IsSubclass(instance_class, type);
3847 if (!is_subclass) {
3848 instance_class = NULL;
3849 } else if (unlikely(is_subclass == -1)) {
3850 goto bad;
3851 } else {
3852 type = instance_class;
3853 }
3854 }
3855 }
3856 if (!instance_class) {
3857 PyObject *args;
3858 if (!value)
3859 args = PyTuple_New(0);
3860 else if (PyTuple_Check(value)) {
3861 Py_INCREF(value);
3862 args = value;
3863 } else
3864 args = PyTuple_Pack(1, value);
3865 if (!args)
3866 goto bad;
3867 owned_instance = PyObject_Call(type, args, NULL);
3868 Py_DECREF(args);
3869 if (!owned_instance)
3870 goto bad;
3871 value = owned_instance;
3872 if (!PyExceptionInstance_Check(value)) {
3873 PyErr_Format(PyExc_TypeError,
3874 "calling %R should have returned an instance of "
3875 "BaseException, not %R",
3876 type, Py_TYPE(value));
3877 goto bad;
3878 }
3879 }
3880 } else {
3881 PyErr_SetString(PyExc_TypeError,
3882 "raise: exception class must be a subclass of BaseException");
3883 goto bad;
3884 }
3885 if (cause) {
3886 PyObject *fixed_cause;
3887 if (cause == Py_None) {
3888 fixed_cause = NULL;
3889 } else if (PyExceptionClass_Check(cause)) {
3890 fixed_cause = PyObject_CallObject(cause, NULL);
3891 if (fixed_cause == NULL)
3892 goto bad;
3893 } else if (PyExceptionInstance_Check(cause)) {
3894 fixed_cause = cause;
3895 Py_INCREF(fixed_cause);
3896 } else {
3897 PyErr_SetString(PyExc_TypeError,
3898 "exception causes must derive from "
3899 "BaseException");
3900 goto bad;
3901 }
3902 PyException_SetCause(value, fixed_cause);
3903 }
3904 PyErr_SetObject(type, value);
3905 if (tb) {
3906 #if CYTHON_COMPILING_IN_PYPY
3907 PyObject *tmp_type, *tmp_value, *tmp_tb;
3908 PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
3909 Py_INCREF(tb);
3910 PyErr_Restore(tmp_type, tmp_value, tb);
3911 Py_XDECREF(tmp_tb);
3912 #else
3913 PyThreadState *tstate = __Pyx_PyThreadState_Current;
3914 PyObject* tmp_tb = tstate->curexc_traceback;
3915 if (tb != tmp_tb) {
3916 Py_INCREF(tb);
3917 tstate->curexc_traceback = tb;
3918 Py_XDECREF(tmp_tb);
3919 }
3920 #endif
3921 }
3922 bad:
3923 Py_XDECREF(owned_instance);
3924 return;
3925 }
3926 #endif
3927
3928 /* DictGetItem */
3929 #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
3930 static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
3931 PyObject *value;
3932 value = PyDict_GetItemWithError(d, key);
3933 if (unlikely(!value)) {
3934 if (!PyErr_Occurred()) {
3935 if (unlikely(PyTuple_Check(key))) {
3936 PyObject* args = PyTuple_Pack(1, key);
3937 if (likely(args)) {
3938 PyErr_SetObject(PyExc_KeyError, args);
3939 Py_DECREF(args);
3940 }
3941 } else {
3942 PyErr_SetObject(PyExc_KeyError, key);
3943 }
3944 }
3945 return NULL;
3946 }
3947 Py_INCREF(value);
3948 return value;
3949 }
3950 #endif
3951
3952 /* ExtTypeTest */
3953 static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
3954 if (unlikely(!type)) {
3955 PyErr_SetString(PyExc_SystemError, "Missing type object");
3956 return 0;
3957 }
3958 if (likely(__Pyx_TypeCheck(obj, type)))
3959 return 1;
3960 PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
3961 Py_TYPE(obj)->tp_name, type->tp_name);
3962 return 0;
3963 }
3964
3965 /* DivInt[Py_ssize_t] */
3966 static CYTHON_INLINE Py_ssize_t __Pyx_div_Py_ssize_t(Py_ssize_t a, Py_ssize_t b) {
3967 Py_ssize_t q = a / b;
3968 Py_ssize_t r = a - q*b;
3969 q -= ((r != 0) & ((r ^ b) < 0));
3970 return q;
3971 }
3972
3973 /* PyObject_GenericGetAttrNoDict */
3974 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
3975 static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
3976 PyErr_Format(PyExc_AttributeError,
3977 #if PY_MAJOR_VERSION >= 3
3978 "'%.50s' object has no attribute '%U'",
3979 tp->tp_name, attr_name);
3980 #else
3981 "'%.50s' object has no attribute '%.400s'",
3982 tp->tp_name, PyString_AS_STRING(attr_name));
3983 #endif
3984 return NULL;
3985 }
3986 static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
3987 PyObject *descr;
3988 PyTypeObject *tp = Py_TYPE(obj);
3989 if (unlikely(!PyString_Check(attr_name))) {
3990 return PyObject_GenericGetAttr(obj, attr_name);
3991 }
3992 assert(!tp->tp_dictoffset);
3993 descr = _PyType_Lookup(tp, attr_name);
3994 if (unlikely(!descr)) {
3995 return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
3996 }
3997 Py_INCREF(descr);
3998 #if PY_MAJOR_VERSION < 3
3999 if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
4000 #endif
4001 {
4002 descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
4003 if (unlikely(f)) {
4004 PyObject *res = f(descr, obj, (PyObject *)tp);
4005 Py_DECREF(descr);
4006 return res;
4007 }
4008 }
4009 return descr;
4010 }
4011 #endif
4012
4013 /* PyObject_GenericGetAttr */
4014 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
4015 static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) {
4016 if (unlikely(Py_TYPE(obj)->tp_dictoffset)) {
4017 return PyObject_GenericGetAttr(obj, attr_name);
4018 }
4019 return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name);
4020 }
4021 #endif
4022
4023 /* PyObjectGetAttrStrNoError */
4024 static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) {
4025 __Pyx_PyThreadState_declare
4026 __Pyx_PyThreadState_assign
4027 if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
4028 __Pyx_PyErr_Clear();
4029 }
4030 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) {
4031 PyObject *result;
4032 #if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS && PY_VERSION_HEX >= 0x030700B1
4033 PyTypeObject* tp = Py_TYPE(obj);
4034 if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) {
4035 return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1);
4036 }
4037 #endif
4038 result = __Pyx_PyObject_GetAttrStr(obj, attr_name);
4039 if (unlikely(!result)) {
4040 __Pyx_PyObject_GetAttrStr_ClearAttributeError();
4041 }
4042 return result;
4043 }
4044
4045 /* SetupReduce */
4046 static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) {
4047 int ret;
4048 PyObject *name_attr;
4049 name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name);
4050 if (likely(name_attr)) {
4051 ret = PyObject_RichCompareBool(name_attr, name, Py_EQ);
4052 } else {
4053 ret = -1;
4054 }
4055 if (unlikely(ret < 0)) {
4056 PyErr_Clear();
4057 ret = 0;
4058 }
4059 Py_XDECREF(name_attr);
4060 return ret;
4061 }
4062 static int __Pyx_setup_reduce(PyObject* type_obj) {
4063 int ret = 0;
4064 PyObject *object_reduce = NULL;
4065 PyObject *object_getstate = NULL;
4066 PyObject *object_reduce_ex = NULL;
4067 PyObject *reduce = NULL;
4068 PyObject *reduce_ex = NULL;
4069 PyObject *reduce_cython = NULL;
4070 PyObject *setstate = NULL;
4071 PyObject *setstate_cython = NULL;
4072 PyObject *getstate = NULL;
4073 #if CYTHON_USE_PYTYPE_LOOKUP
4074 getstate = _PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate);
4075 #else
4076 getstate = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_getstate);
4077 if (!getstate && PyErr_Occurred()) {
4078 goto __PYX_BAD;
4079 }
4080 #endif
4081 if (getstate) {
4082 #if CYTHON_USE_PYTYPE_LOOKUP
4083 object_getstate = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_getstate);
4084 #else
4085 object_getstate = __Pyx_PyObject_GetAttrStrNoError((PyObject*)&PyBaseObject_Type, __pyx_n_s_getstate);
4086 if (!object_getstate && PyErr_Occurred()) {
4087 goto __PYX_BAD;
4088 }
4089 #endif
4090 if (object_getstate != getstate) {
4091 goto __PYX_GOOD;
4092 }
4093 }
4094 #if CYTHON_USE_PYTYPE_LOOKUP
4095 object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
4096 #else
4097 object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
4098 #endif
4099 reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto __PYX_BAD;
4100 if (reduce_ex == object_reduce_ex) {
4101 #if CYTHON_USE_PYTYPE_LOOKUP
4102 object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
4103 #else
4104 object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
4105 #endif
4106 reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto __PYX_BAD;
4107 if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) {
4108 reduce_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_reduce_cython);
4109 if (likely(reduce_cython)) {
4110 ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
4111 ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
4112 } else if (reduce == object_reduce || PyErr_Occurred()) {
4113 goto __PYX_BAD;
4114 }
4115 setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate);
4116 if (!setstate) PyErr_Clear();
4117 if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) {
4118 setstate_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_setstate_cython);
4119 if (likely(setstate_cython)) {
4120 ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
4121 ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
4122 } else if (!setstate || PyErr_Occurred()) {
4123 goto __PYX_BAD;
4124 }
4125 }
4126 PyType_Modified((PyTypeObject*)type_obj);
4127 }
4128 }
4129 goto __PYX_GOOD;
4130 __PYX_BAD:
4131 if (!PyErr_Occurred())
4132 PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name);
4133 ret = -1;
4134 __PYX_GOOD:
4135 #if !CYTHON_USE_PYTYPE_LOOKUP
4136 Py_XDECREF(object_reduce);
4137 Py_XDECREF(object_reduce_ex);
4138 Py_XDECREF(object_getstate);
4139 Py_XDECREF(getstate);
4140 #endif
4141 Py_XDECREF(reduce);
4142 Py_XDECREF(reduce_ex);
4143 Py_XDECREF(reduce_cython);
4144 Py_XDECREF(setstate);
4145 Py_XDECREF(setstate_cython);
4146 return ret;
4147 }
4148
4149 /* TypeImport */
4150 #ifndef __PYX_HAVE_RT_ImportType
4151 #define __PYX_HAVE_RT_ImportType
4152 static PyTypeObject *__Pyx_ImportType(PyObject *module, const char *module_name, const char *class_name,
4153 size_t size, enum __Pyx_ImportType_CheckSize check_size)
4154 {
4155 PyObject *result = 0;
4156 char warning[200];
4157 Py_ssize_t basicsize;
4158 #ifdef Py_LIMITED_API
4159 PyObject *py_basicsize;
4160 #endif
4161 result = PyObject_GetAttrString(module, class_name);
4162 if (!result)
4163 goto bad;
4164 if (!PyType_Check(result)) {
4165 PyErr_Format(PyExc_TypeError,
4166 "%.200s.%.200s is not a type object",
4167 module_name, class_name);
4168 goto bad;
4169 }
4170 #ifndef Py_LIMITED_API
4171 basicsize = ((PyTypeObject *)result)->tp_basicsize;
4172 #else
4173 py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
4174 if (!py_basicsize)
4175 goto bad;
4176 basicsize = PyLong_AsSsize_t(py_basicsize);
4177 Py_DECREF(py_basicsize);
4178 py_basicsize = 0;
4179 if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
4180 goto bad;
4181 #endif
4182 if ((size_t)basicsize < size) {
4183 PyErr_Format(PyExc_ValueError,
4184 "%.200s.%.200s size changed, may indicate binary incompatibility. "
4185 "Expected %zd from C header, got %zd from PyObject",
4186 module_name, class_name, size, basicsize);
4187 goto bad;
4188 }
4189 if (check_size == __Pyx_ImportType_CheckSize_Error && (size_t)basicsize != size) {
4190 PyErr_Format(PyExc_ValueError,
4191 "%.200s.%.200s size changed, may indicate binary incompatibility. "
4192 "Expected %zd from C header, got %zd from PyObject",
4193 module_name, class_name, size, basicsize);
4194 goto bad;
4195 }
4196 else if (check_size == __Pyx_ImportType_CheckSize_Warn && (size_t)basicsize > size) {
4197 PyOS_snprintf(warning, sizeof(warning),
4198 "%s.%s size changed, may indicate binary incompatibility. "
4199 "Expected %zd from C header, got %zd from PyObject",
4200 module_name, class_name, size, basicsize);
4201 if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
4202 }
4203 return (PyTypeObject *)result;
4204 bad:
4205 Py_XDECREF(result);
4206 return NULL;
4207 }
4208 #endif
4209
4210 /* Import */
4211 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
4212 PyObject *empty_list = 0;
4213 PyObject *module = 0;
4214 PyObject *global_dict = 0;
4215 PyObject *empty_dict = 0;
4216 PyObject *list;
4217 #if PY_MAJOR_VERSION < 3
4218 PyObject *py_import;
4219 py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
4220 if (!py_import)
4221 goto bad;
4222 #endif
4223 if (from_list)
4224 list = from_list;
4225 else {
4226 empty_list = PyList_New(0);
4227 if (!empty_list)
4228 goto bad;
4229 list = empty_list;
4230 }
4231 global_dict = PyModule_GetDict(__pyx_m);
4232 if (!global_dict)
4233 goto bad;
4234 empty_dict = PyDict_New();
4235 if (!empty_dict)
4236 goto bad;
4237 {
4238 #if PY_MAJOR_VERSION >= 3
4239 if (level == -1) {
4240 if ((1) && (strchr(__Pyx_MODULE_NAME, '.'))) {
4241 module = PyImport_ImportModuleLevelObject(
4242 name, global_dict, empty_dict, list, 1);
4243 if (!module) {
4244 if (!PyErr_ExceptionMatches(PyExc_ImportError))
4245 goto bad;
4246 PyErr_Clear();
4247 }
4248 }
4249 level = 0;
4250 }
4251 #endif
4252 if (!module) {
4253 #if PY_MAJOR_VERSION < 3
4254 PyObject *py_level = PyInt_FromLong(level);
4255 if (!py_level)
4256 goto bad;
4257 module = PyObject_CallFunctionObjArgs(py_import,
4258 name, global_dict, empty_dict, list, py_level, (PyObject *)NULL);
4259 Py_DECREF(py_level);
4260 #else
4261 module = PyImport_ImportModuleLevelObject(
4262 name, global_dict, empty_dict, list, level);
4263 #endif
4264 }
4265 }
4266 bad:
4267 #if PY_MAJOR_VERSION < 3
4268 Py_XDECREF(py_import);
4269 #endif
4270 Py_XDECREF(empty_list);
4271 Py_XDECREF(empty_dict);
4272 return module;
4273 }
4274
4275 /* ImportFrom */
4276 static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
4277 PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
4278 if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
4279 PyErr_Format(PyExc_ImportError,
4280 #if PY_MAJOR_VERSION < 3
4281 "cannot import name %.230s", PyString_AS_STRING(name));
4282 #else
4283 "cannot import name %S", name);
4284 #endif
4285 }
4286 return value;
4287 }
4288
4289 /* PyDictVersioning */
4290 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
4291 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
4292 PyObject *dict = Py_TYPE(obj)->tp_dict;
4293 return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
4294 }
4295 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
4296 PyObject **dictptr = NULL;
4297 Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
4298 if (offset) {
4299 #if CYTHON_COMPILING_IN_CPYTHON
4300 dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
4301 #else
4302 dictptr = _PyObject_GetDictPtr(obj);
4303 #endif
4304 }
4305 return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
4306 }
4307 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
4308 PyObject *dict = Py_TYPE(obj)->tp_dict;
4309 if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
4310 return 0;
4311 return obj_dict_version == __Pyx_get_object_dict_version(obj);
4312 }
4313 #endif
4314
4315 /* GetModuleGlobalName */
4316 #if CYTHON_USE_DICT_VERSIONS
4317 static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value)
4318 #else
4319 static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
4320 #endif
4321 {
4322 PyObject *result;
4323 #if !CYTHON_AVOID_BORROWED_REFS
4324 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
4325 result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
4326 __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
4327 if (likely(result)) {
4328 return __Pyx_NewRef(result);
4329 } else if (unlikely(PyErr_Occurred())) {
4330 return NULL;
4331 }
4332 #else
4333 result = PyDict_GetItem(__pyx_d, name);
4334 __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
4335 if (likely(result)) {
4336 return __Pyx_NewRef(result);
4337 }
4338 #endif
4339 #else
4340 result = PyObject_GetItem(__pyx_d, name);
4341 __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
4342 if (likely(result)) {
4343 return __Pyx_NewRef(result);
4344 }
4345 PyErr_Clear();
4346 #endif
4347 return __Pyx_GetBuiltinName(name);
4348 }
4349
4350 /* CLineInTraceback */
4351 #ifndef CYTHON_CLINE_IN_TRACEBACK
4352 static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) {
4353 PyObject *use_cline;
4354 PyObject *ptype, *pvalue, *ptraceback;
4355 #if CYTHON_COMPILING_IN_CPYTHON
4356 PyObject **cython_runtime_dict;
4357 #endif
4358 if (unlikely(!__pyx_cython_runtime)) {
4359 return c_line;
4360 }
4361 __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
4362 #if CYTHON_COMPILING_IN_CPYTHON
4363 cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
4364 if (likely(cython_runtime_dict)) {
4365 __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
4366 use_cline, *cython_runtime_dict,
4367 __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback))
4368 } else
4369 #endif
4370 {
4371 PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
4372 if (use_cline_obj) {
4373 use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
4374 Py_DECREF(use_cline_obj);
4375 } else {
4376 PyErr_Clear();
4377 use_cline = NULL;
4378 }
4379 }
4380 if (!use_cline) {
4381 c_line = 0;
4382 (void) PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
4383 }
4384 else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
4385 c_line = 0;
4386 }
4387 __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
4388 return c_line;
4389 }
4390 #endif
4391
4392 /* CodeObjectCache */
4393 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
4394 int start = 0, mid = 0, end = count - 1;
4395 if (end >= 0 && code_line > entries[end].code_line) {
4396 return count;
4397 }
4398 while (start < end) {
4399 mid = start + (end - start) / 2;
4400 if (code_line < entries[mid].code_line) {
4401 end = mid;
4402 } else if (code_line > entries[mid].code_line) {
4403 start = mid + 1;
4404 } else {
4405 return mid;
4406 }
4407 }
4408 if (code_line <= entries[mid].code_line) {
4409 return mid;
4410 } else {
4411 return mid + 1;
4412 }
4413 }
4414 static PyCodeObject *__pyx_find_code_object(int code_line) {
4415 PyCodeObject* code_object;
4416 int pos;
4417 if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
4418 return NULL;
4419 }
4420 pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
4421 if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
4422 return NULL;
4423 }
4424 code_object = __pyx_code_cache.entries[pos].code_object;
4425 Py_INCREF(code_object);
4426 return code_object;
4427 }
4428 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
4429 int pos, i;
4430 __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
4431 if (unlikely(!code_line)) {
4432 return;
4433 }
4434 if (unlikely(!entries)) {
4435 entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
4436 if (likely(entries)) {
4437 __pyx_code_cache.entries = entries;
4438 __pyx_code_cache.max_count = 64;
4439 __pyx_code_cache.count = 1;
4440 entries[0].code_line = code_line;
4441 entries[0].code_object = code_object;
4442 Py_INCREF(code_object);
4443 }
4444 return;
4445 }
4446 pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
4447 if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
4448 PyCodeObject* tmp = entries[pos].code_object;
4449 entries[pos].code_object = code_object;
4450 Py_DECREF(tmp);
4451 return;
4452 }
4453 if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
4454 int new_max = __pyx_code_cache.max_count + 64;
4455 entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
4456 __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry));
4457 if (unlikely(!entries)) {
4458 return;
4459 }
4460 __pyx_code_cache.entries = entries;
4461 __pyx_code_cache.max_count = new_max;
4462 }
4463 for (i=__pyx_code_cache.count; i>pos; i--) {
4464 entries[i] = entries[i-1];
4465 }
4466 entries[pos].code_line = code_line;
4467 entries[pos].code_object = code_object;
4468 __pyx_code_cache.count++;
4469 Py_INCREF(code_object);
4470 }
4471
4472 /* AddTraceback */
4473 #include "compile.h"
4474 #include "frameobject.h"
4475 #include "traceback.h"
4476 #if PY_VERSION_HEX >= 0x030b00a6
4477 #ifndef Py_BUILD_CORE
4478 #define Py_BUILD_CORE 1
4479 #endif
4480 #include "internal/pycore_frame.h"
4481 #endif
4482 static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
4483 const char *funcname, int c_line,
4484 int py_line, const char *filename) {
4485 PyCodeObject *py_code = NULL;
4486 PyObject *py_funcname = NULL;
4487 #if PY_MAJOR_VERSION < 3
4488 PyObject *py_srcfile = NULL;
4489 py_srcfile = PyString_FromString(filename);
4490 if (!py_srcfile) goto bad;
4491 #endif
4492 if (c_line) {
4493 #if PY_MAJOR_VERSION < 3
4494 py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
4495 if (!py_funcname) goto bad;
4496 #else
4497 py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
4498 if (!py_funcname) goto bad;
4499 funcname = PyUnicode_AsUTF8(py_funcname);
4500 if (!funcname) goto bad;
4501 #endif
4502 }
4503 else {
4504 #if PY_MAJOR_VERSION < 3
4505 py_funcname = PyString_FromString(funcname);
4506 if (!py_funcname) goto bad;
4507 #endif
4508 }
4509 #if PY_MAJOR_VERSION < 3
4510 py_code = __Pyx_PyCode_New(
4511 0,
4512 0,
4513 0,
4514 0,
4515 0,
4516 __pyx_empty_bytes, /*PyObject *code,*/
4517 __pyx_empty_tuple, /*PyObject *consts,*/
4518 __pyx_empty_tuple, /*PyObject *names,*/
4519 __pyx_empty_tuple, /*PyObject *varnames,*/
4520 __pyx_empty_tuple, /*PyObject *freevars,*/
4521 __pyx_empty_tuple, /*PyObject *cellvars,*/
4522 py_srcfile, /*PyObject *filename,*/
4523 py_funcname, /*PyObject *name,*/
4524 py_line,
4525 __pyx_empty_bytes /*PyObject *lnotab*/
4526 );
4527 Py_DECREF(py_srcfile);
4528 #else
4529 py_code = PyCode_NewEmpty(filename, funcname, py_line);
4530 #endif
4531 Py_XDECREF(py_funcname); // XDECREF since it's only set on Py3 if cline
4532 return py_code;
4533 bad:
4534 Py_XDECREF(py_funcname);
4535 #if PY_MAJOR_VERSION < 3
4536 Py_XDECREF(py_srcfile);
4537 #endif
4538 return NULL;
4539 }
4540 static void __Pyx_AddTraceback(const char *funcname, int c_line,
4541 int py_line, const char *filename) {
4542 PyCodeObject *py_code = 0;
4543 PyFrameObject *py_frame = 0;
4544 PyThreadState *tstate = __Pyx_PyThreadState_Current;
4545 PyObject *ptype, *pvalue, *ptraceback;
4546 if (c_line) {
4547 c_line = __Pyx_CLineForTraceback(tstate, c_line);
4548 }
4549 py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
4550 if (!py_code) {
4551 __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
4552 py_code = __Pyx_CreateCodeObjectForTraceback(
4553 funcname, c_line, py_line, filename);
4554 if (!py_code) {
4555 /* If the code object creation fails, then we should clear the
4556 fetched exception references and propagate the new exception */
4557 Py_XDECREF(ptype);
4558 Py_XDECREF(pvalue);
4559 Py_XDECREF(ptraceback);
4560 goto bad;
4561 }
4562 __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
4563 __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
4564 }
4565 py_frame = PyFrame_New(
4566 tstate, /*PyThreadState *tstate,*/
4567 py_code, /*PyCodeObject *code,*/
4568 __pyx_d, /*PyObject *globals,*/
4569 0 /*PyObject *locals*/
4570 );
4571 if (!py_frame) goto bad;
4572 __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
4573 PyTraceBack_Here(py_frame);
4574 bad:
4575 Py_XDECREF(py_code);
4576 Py_XDECREF(py_frame);
4577 }
4578
4579 /* CIntToPy */
4580 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
4581 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
4582 #pragma GCC diagnostic push
4583 #pragma GCC diagnostic ignored "-Wconversion"
4584 #endif
4585 const long neg_one = (long) -1, const_zero = (long) 0;
4586 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
4587 #pragma GCC diagnostic pop
4588 #endif
4589 const int is_unsigned = neg_one > const_zero;
4590 if (is_unsigned) {
4591 if (sizeof(long) < sizeof(long)) {
4592 return PyInt_FromLong((long) value);
4593 } else if (sizeof(long) <= sizeof(unsigned long)) {
4594 return PyLong_FromUnsignedLong((unsigned long) value);
4595 #ifdef HAVE_LONG_LONG
4596 } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
4597 return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
4598 #endif
4599 }
4600 } else {
4601 if (sizeof(long) <= sizeof(long)) {
4602 return PyInt_FromLong((long) value);
4603 #ifdef HAVE_LONG_LONG
4604 } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
4605 return PyLong_FromLongLong((PY_LONG_LONG) value);
4606 #endif
4607 }
4608 }
4609 {
4610 int one = 1; int little = (int)*(unsigned char *)&one;
4611 unsigned char *bytes = (unsigned char *)&value;
4612 return _PyLong_FromByteArray(bytes, sizeof(long),
4613 little, !is_unsigned);
4614 }
4615 }
4616
4617 /* CIntFromPyVerify */
4618 #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
4619 __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
4620 #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
4621 __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
4622 #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
4623 {\
4624 func_type value = func_value;\
4625 if (sizeof(target_type) < sizeof(func_type)) {\
4626 if (unlikely(value != (func_type) (target_type) value)) {\
4627 func_type zero = 0;\
4628 if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
4629 return (target_type) -1;\
4630 if (is_unsigned && unlikely(value < zero))\
4631 goto raise_neg_overflow;\
4632 else\
4633 goto raise_overflow;\
4634 }\
4635 }\
4636 return (target_type) value;\
4637 }
4638
4639 /* CIntFromPy */
4640 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
4641 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
4642 #pragma GCC diagnostic push
4643 #pragma GCC diagnostic ignored "-Wconversion"
4644 #endif
4645 const long neg_one = (long) -1, const_zero = (long) 0;
4646 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
4647 #pragma GCC diagnostic pop
4648 #endif
4649 const int is_unsigned = neg_one > const_zero;
4650 #if PY_MAJOR_VERSION < 3
4651 if (likely(PyInt_Check(x))) {
4652 if (sizeof(long) < sizeof(long)) {
4653 __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
4654 } else {
4655 long val = PyInt_AS_LONG(x);
4656 if (is_unsigned && unlikely(val < 0)) {
4657 goto raise_neg_overflow;
4658 }
4659 return (long) val;
4660 }
4661 } else
4662 #endif
4663 if (likely(PyLong_Check(x))) {
4664 if (is_unsigned) {
4665 #if CYTHON_USE_PYLONG_INTERNALS
4666 const digit* digits = ((PyLongObject*)x)->ob_digit;
4667 switch (Py_SIZE(x)) {
4668 case 0: return (long) 0;
4669 case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
4670 case 2:
4671 if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
4672 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
4673 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4674 } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
4675 return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
4676 }
4677 }
4678 break;
4679 case 3:
4680 if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
4681 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
4682 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4683 } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
4684 return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
4685 }
4686 }
4687 break;
4688 case 4:
4689 if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
4690 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
4691 __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])))
4692 } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
4693 return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
4694 }
4695 }
4696 break;
4697 }
4698 #endif
4699 #if CYTHON_COMPILING_IN_CPYTHON
4700 if (unlikely(Py_SIZE(x) < 0)) {
4701 goto raise_neg_overflow;
4702 }
4703 #else
4704 {
4705 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
4706 if (unlikely(result < 0))
4707 return (long) -1;
4708 if (unlikely(result == 1))
4709 goto raise_neg_overflow;
4710 }
4711 #endif
4712 if (sizeof(long) <= sizeof(unsigned long)) {
4713 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
4714 #ifdef HAVE_LONG_LONG
4715 } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
4716 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
4717 #endif
4718 }
4719 } else {
4720 #if CYTHON_USE_PYLONG_INTERNALS
4721 const digit* digits = ((PyLongObject*)x)->ob_digit;
4722 switch (Py_SIZE(x)) {
4723 case 0: return (long) 0;
4724 case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
4725 case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
4726 case -2:
4727 if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
4728 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
4729 __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4730 } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
4731 return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
4732 }
4733 }
4734 break;
4735 case 2:
4736 if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
4737 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
4738 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4739 } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
4740 return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
4741 }
4742 }
4743 break;
4744 case -3:
4745 if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
4746 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
4747 __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4748 } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
4749 return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
4750 }
4751 }
4752 break;
4753 case 3:
4754 if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
4755 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
4756 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4757 } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
4758 return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
4759 }
4760 }
4761 break;
4762 case -4:
4763 if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
4764 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
4765 __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])))
4766 } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
4767 return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
4768 }
4769 }
4770 break;
4771 case 4:
4772 if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
4773 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
4774 __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])))
4775 } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
4776 return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
4777 }
4778 }
4779 break;
4780 }
4781 #endif
4782 if (sizeof(long) <= sizeof(long)) {
4783 __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
4784 #ifdef HAVE_LONG_LONG
4785 } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
4786 __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
4787 #endif
4788 }
4789 }
4790 {
4791 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
4792 PyErr_SetString(PyExc_RuntimeError,
4793 "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
4794 #else
4795 long val;
4796 PyObject *v = __Pyx_PyNumber_IntOrLong(x);
4797 #if PY_MAJOR_VERSION < 3
4798 if (likely(v) && !PyLong_Check(v)) {
4799 PyObject *tmp = v;
4800 v = PyNumber_Long(tmp);
4801 Py_DECREF(tmp);
4802 }
4803 #endif
4804 if (likely(v)) {
4805 int one = 1; int is_little = (int)*(unsigned char *)&one;
4806 unsigned char *bytes = (unsigned char *)&val;
4807 int ret = _PyLong_AsByteArray((PyLongObject *)v,
4808 bytes, sizeof(val),
4809 is_little, !is_unsigned);
4810 Py_DECREF(v);
4811 if (likely(!ret))
4812 return val;
4813 }
4814 #endif
4815 return (long) -1;
4816 }
4817 } else {
4818 long val;
4819 PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
4820 if (!tmp) return (long) -1;
4821 val = __Pyx_PyInt_As_long(tmp);
4822 Py_DECREF(tmp);
4823 return val;
4824 }
4825 raise_overflow:
4826 PyErr_SetString(PyExc_OverflowError,
4827 "value too large to convert to long");
4828 return (long) -1;
4829 raise_neg_overflow:
4830 PyErr_SetString(PyExc_OverflowError,
4831 "can't convert negative value to long");
4832 return (long) -1;
4833 }
4834
4835 /* CIntFromPy */
4836 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
4837 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
4838 #pragma GCC diagnostic push
4839 #pragma GCC diagnostic ignored "-Wconversion"
4840 #endif
4841 const int neg_one = (int) -1, const_zero = (int) 0;
4842 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
4843 #pragma GCC diagnostic pop
4844 #endif
4845 const int is_unsigned = neg_one > const_zero;
4846 #if PY_MAJOR_VERSION < 3
4847 if (likely(PyInt_Check(x))) {
4848 if (sizeof(int) < sizeof(long)) {
4849 __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
4850 } else {
4851 long val = PyInt_AS_LONG(x);
4852 if (is_unsigned && unlikely(val < 0)) {
4853 goto raise_neg_overflow;
4854 }
4855 return (int) val;
4856 }
4857 } else
4858 #endif
4859 if (likely(PyLong_Check(x))) {
4860 if (is_unsigned) {
4861 #if CYTHON_USE_PYLONG_INTERNALS
4862 const digit* digits = ((PyLongObject*)x)->ob_digit;
4863 switch (Py_SIZE(x)) {
4864 case 0: return (int) 0;
4865 case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
4866 case 2:
4867 if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
4868 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
4869 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4870 } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
4871 return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
4872 }
4873 }
4874 break;
4875 case 3:
4876 if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
4877 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
4878 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4879 } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
4880 return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
4881 }
4882 }
4883 break;
4884 case 4:
4885 if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
4886 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
4887 __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])))
4888 } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
4889 return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
4890 }
4891 }
4892 break;
4893 }
4894 #endif
4895 #if CYTHON_COMPILING_IN_CPYTHON
4896 if (unlikely(Py_SIZE(x) < 0)) {
4897 goto raise_neg_overflow;
4898 }
4899 #else
4900 {
4901 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
4902 if (unlikely(result < 0))
4903 return (int) -1;
4904 if (unlikely(result == 1))
4905 goto raise_neg_overflow;
4906 }
4907 #endif
4908 if (sizeof(int) <= sizeof(unsigned long)) {
4909 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
4910 #ifdef HAVE_LONG_LONG
4911 } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
4912 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
4913 #endif
4914 }
4915 } else {
4916 #if CYTHON_USE_PYLONG_INTERNALS
4917 const digit* digits = ((PyLongObject*)x)->ob_digit;
4918 switch (Py_SIZE(x)) {
4919 case 0: return (int) 0;
4920 case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
4921 case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0])
4922 case -2:
4923 if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
4924 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
4925 __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4926 } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
4927 return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
4928 }
4929 }
4930 break;
4931 case 2:
4932 if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
4933 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
4934 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4935 } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
4936 return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
4937 }
4938 }
4939 break;
4940 case -3:
4941 if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
4942 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
4943 __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4944 } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
4945 return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
4946 }
4947 }
4948 break;
4949 case 3:
4950 if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
4951 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
4952 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
4953 } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
4954 return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
4955 }
4956 }
4957 break;
4958 case -4:
4959 if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
4960 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
4961 __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])))
4962 } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
4963 return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
4964 }
4965 }
4966 break;
4967 case 4:
4968 if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
4969 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
4970 __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])))
4971 } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
4972 return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
4973 }
4974 }
4975 break;
4976 }
4977 #endif
4978 if (sizeof(int) <= sizeof(long)) {
4979 __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
4980 #ifdef HAVE_LONG_LONG
4981 } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
4982 __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
4983 #endif
4984 }
4985 }
4986 {
4987 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
4988 PyErr_SetString(PyExc_RuntimeError,
4989 "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
4990 #else
4991 int val;
4992 PyObject *v = __Pyx_PyNumber_IntOrLong(x);
4993 #if PY_MAJOR_VERSION < 3
4994 if (likely(v) && !PyLong_Check(v)) {
4995 PyObject *tmp = v;
4996 v = PyNumber_Long(tmp);
4997 Py_DECREF(tmp);
4998 }
4999 #endif
5000 if (likely(v)) {
5001 int one = 1; int is_little = (int)*(unsigned char *)&one;
5002 unsigned char *bytes = (unsigned char *)&val;
5003 int ret = _PyLong_AsByteArray((PyLongObject *)v,
5004 bytes, sizeof(val),
5005 is_little, !is_unsigned);
5006 Py_DECREF(v);
5007 if (likely(!ret))
5008 return val;
5009 }
5010 #endif
5011 return (int) -1;
5012 }
5013 } else {
5014 int val;
5015 PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
5016 if (!tmp) return (int) -1;
5017 val = __Pyx_PyInt_As_int(tmp);
5018 Py_DECREF(tmp);
5019 return val;
5020 }
5021 raise_overflow:
5022 PyErr_SetString(PyExc_OverflowError,
5023 "value too large to convert to int");
5024 return (int) -1;
5025 raise_neg_overflow:
5026 PyErr_SetString(PyExc_OverflowError,
5027 "can't convert negative value to int");
5028 return (int) -1;
5029 }
5030
5031 /* FastTypeChecks */
5032 #if CYTHON_COMPILING_IN_CPYTHON
5033 static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
5034 while (a) {
5035 a = a->tp_base;
5036 if (a == b)
5037 return 1;
5038 }
5039 return b == &PyBaseObject_Type;
5040 }
5041 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
5042 PyObject *mro;
5043 if (a == b) return 1;
5044 mro = a->tp_mro;
5045 if (likely(mro)) {
5046 Py_ssize_t i, n;
5047 n = PyTuple_GET_SIZE(mro);
5048 for (i = 0; i < n; i++) {
5049 if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
5050 return 1;
5051 }
5052 return 0;
5053 }
5054 return __Pyx_InBases(a, b);
5055 }
5056 #if PY_MAJOR_VERSION == 2
5057 static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
5058 PyObject *exception, *value, *tb;
5059 int res;
5060 __Pyx_PyThreadState_declare
5061 __Pyx_PyThreadState_assign
5062 __Pyx_ErrFetch(&exception, &value, &tb);
5063 res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
5064 if (unlikely(res == -1)) {
5065 PyErr_WriteUnraisable(err);
5066 res = 0;
5067 }
5068 if (!res) {
5069 res = PyObject_IsSubclass(err, exc_type2);
5070 if (unlikely(res == -1)) {
5071 PyErr_WriteUnraisable(err);
5072 res = 0;
5073 }
5074 }
5075 __Pyx_ErrRestore(exception, value, tb);
5076 return res;
5077 }
5078 #else
5079 static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
5080 int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
5081 if (!res) {
5082 res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
5083 }
5084 return res;
5085 }
5086 #endif
5087 static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
5088 Py_ssize_t i, n;
5089 assert(PyExceptionClass_Check(exc_type));
5090 n = PyTuple_GET_SIZE(tuple);
5091 #if PY_MAJOR_VERSION >= 3
5092 for (i=0; i<n; i++) {
5093 if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
5094 }
5095 #endif
5096 for (i=0; i<n; i++) {
5097 PyObject *t = PyTuple_GET_ITEM(tuple, i);
5098 #if PY_MAJOR_VERSION < 3
5099 if (likely(exc_type == t)) return 1;
5100 #endif
5101 if (likely(PyExceptionClass_Check(t))) {
5102 if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
5103 } else {
5104 }
5105 }
5106 return 0;
5107 }
5108 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
5109 if (likely(err == exc_type)) return 1;
5110 if (likely(PyExceptionClass_Check(err))) {
5111 if (likely(PyExceptionClass_Check(exc_type))) {
5112 return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
5113 } else if (likely(PyTuple_Check(exc_type))) {
5114 return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
5115 } else {
5116 }
5117 }
5118 return PyErr_GivenExceptionMatches(err, exc_type);
5119 }
5120 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
5121 assert(PyExceptionClass_Check(exc_type1));
5122 assert(PyExceptionClass_Check(exc_type2));
5123 if (likely(err == exc_type1 || err == exc_type2)) return 1;
5124 if (likely(PyExceptionClass_Check(err))) {
5125 return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
5126 }
5127 return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
5128 }
5129 #endif
5130
5131 /* CheckBinaryVersion */
5132 static int __Pyx_check_binary_version(void) {
5133 char ctversion[5];
5134 int same=1, i, found_dot;
5135 const char* rt_from_call = Py_GetVersion();
5136 PyOS_snprintf(ctversion, 5, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
5137 found_dot = 0;
5138 for (i = 0; i < 4; i++) {
5139 if (!ctversion[i]) {
5140 same = (rt_from_call[i] < '0' || rt_from_call[i] > '9');
5141 break;
5142 }
5143 if (rt_from_call[i] != ctversion[i]) {
5144 same = 0;
5145 break;
5146 }
5147 }
5148 if (!same) {
5149 char rtversion[5] = {'\0'};
5150 char message[200];
5151 for (i=0; i<4; ++i) {
5152 if (rt_from_call[i] == '.') {
5153 if (found_dot) break;
5154 found_dot = 1;
5155 } else if (rt_from_call[i] < '0' || rt_from_call[i] > '9') {
5156 break;
5157 }
5158 rtversion[i] = rt_from_call[i];
5159 }
5160 PyOS_snprintf(message, sizeof(message),
5161 "compiletime version %s of module '%.100s' "
5162 "does not match runtime version %s",
5163 ctversion, __Pyx_MODULE_NAME, rtversion);
5164 return PyErr_WarnEx(NULL, message, 1);
5165 }
5166 return 0;
5167 }
5168
5169 /* InitStrings */
5170 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
5171 while (t->p) {
5172 #if PY_MAJOR_VERSION < 3
5173 if (t->is_unicode) {
5174 *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
5175 } else if (t->intern) {
5176 *t->p = PyString_InternFromString(t->s);
5177 } else {
5178 *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
5179 }
5180 #else
5181 if (t->is_unicode | t->is_str) {
5182 if (t->intern) {
5183 *t->p = PyUnicode_InternFromString(t->s);
5184 } else if (t->encoding) {
5185 *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
5186 } else {
5187 *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
5188 }
5189 } else {
5190 *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
5191 }
5192 #endif
5193 if (!*t->p)
5194 return -1;
5195 if (PyObject_Hash(*t->p) == -1)
5196 return -1;
5197 ++t;
5198 }
5199 return 0;
5200 }
5201
5202 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
5203 return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
5204 }
5205 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
5206 Py_ssize_t ignore;
5207 return __Pyx_PyObject_AsStringAndSize(o, &ignore);
5208 }
5209 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
5210 #if !CYTHON_PEP393_ENABLED
5211 static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
5212 char* defenc_c;
5213 PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
5214 if (!defenc) return NULL;
5215 defenc_c = PyBytes_AS_STRING(defenc);
5216 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
5217 {
5218 char* end = defenc_c + PyBytes_GET_SIZE(defenc);
5219 char* c;
5220 for (c = defenc_c; c < end; c++) {
5221 if ((unsigned char) (*c) >= 128) {
5222 PyUnicode_AsASCIIString(o);
5223 return NULL;
5224 }
5225 }
5226 }
5227 #endif
5228 *length = PyBytes_GET_SIZE(defenc);
5229 return defenc_c;
5230 }
5231 #else
5232 static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
5233 if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
5234 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
5235 if (likely(PyUnicode_IS_ASCII(o))) {
5236 *length = PyUnicode_GET_LENGTH(o);
5237 return PyUnicode_AsUTF8(o);
5238 } else {
5239 PyUnicode_AsASCIIString(o);
5240 return NULL;
5241 }
5242 #else
5243 return PyUnicode_AsUTF8AndSize(o, length);
5244 #endif
5245 }
5246 #endif
5247 #endif
5248 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
5249 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
5250 if (
5251 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
5252 __Pyx_sys_getdefaultencoding_not_ascii &&
5253 #endif
5254 PyUnicode_Check(o)) {
5255 return __Pyx_PyUnicode_AsStringAndSize(o, length);
5256 } else
5257 #endif
5258 #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
5259 if (PyByteArray_Check(o)) {
5260 *length = PyByteArray_GET_SIZE(o);
5261 return PyByteArray_AS_STRING(o);
5262 } else
5263 #endif
5264 {
5265 char* result;
5266 int r = PyBytes_AsStringAndSize(o, &result, length);
5267 if (unlikely(r < 0)) {
5268 return NULL;
5269 } else {
5270 return result;
5271 }
5272 }
5273 }
5274 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
5275 int is_true = x == Py_True;
5276 if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
5277 else return PyObject_IsTrue(x);
5278 }
5279 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
5280 int retval;
5281 if (unlikely(!x)) return -1;
5282 retval = __Pyx_PyObject_IsTrue(x);
5283 Py_DECREF(x);
5284 return retval;
5285 }
5286 static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
5287 #if PY_MAJOR_VERSION >= 3
5288 if (PyLong_Check(result)) {
5289 if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
5290 "__int__ returned non-int (type %.200s). "
5291 "The ability to return an instance of a strict subclass of int "
5292 "is deprecated, and may be removed in a future version of Python.",
5293 Py_TYPE(result)->tp_name)) {
5294 Py_DECREF(result);
5295 return NULL;
5296 }
5297 return result;
5298 }
5299 #endif
5300 PyErr_Format(PyExc_TypeError,
5301 "__%.4s__ returned non-%.4s (type %.200s)",
5302 type_name, type_name, Py_TYPE(result)->tp_name);
5303 Py_DECREF(result);
5304 return NULL;
5305 }
5306 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
5307 #if CYTHON_USE_TYPE_SLOTS
5308 PyNumberMethods *m;
5309 #endif
5310 const char *name = NULL;
5311 PyObject *res = NULL;
5312 #if PY_MAJOR_VERSION < 3
5313 if (likely(PyInt_Check(x) || PyLong_Check(x)))
5314 #else
5315 if (likely(PyLong_Check(x)))
5316 #endif
5317 return __Pyx_NewRef(x);
5318 #if CYTHON_USE_TYPE_SLOTS
5319 m = Py_TYPE(x)->tp_as_number;
5320 #if PY_MAJOR_VERSION < 3
5321 if (m && m->nb_int) {
5322 name = "int";
5323 res = m->nb_int(x);
5324 }
5325 else if (m && m->nb_long) {
5326 name = "long";
5327 res = m->nb_long(x);
5328 }
5329 #else
5330 if (likely(m && m->nb_int)) {
5331 name = "int";
5332 res = m->nb_int(x);
5333 }
5334 #endif
5335 #else
5336 if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
5337 res = PyNumber_Int(x);
5338 }
5339 #endif
5340 if (likely(res)) {
5341 #if PY_MAJOR_VERSION < 3
5342 if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
5343 #else
5344 if (unlikely(!PyLong_CheckExact(res))) {
5345 #endif
5346 return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
5347 }
5348 }
5349 else if (!PyErr_Occurred()) {
5350 PyErr_SetString(PyExc_TypeError,
5351 "an integer is required");
5352 }
5353 return res;
5354 }
5355 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
5356 Py_ssize_t ival;
5357 PyObject *x;
5358 #if PY_MAJOR_VERSION < 3
5359 if (likely(PyInt_CheckExact(b))) {
5360 if (sizeof(Py_ssize_t) >= sizeof(long))
5361 return PyInt_AS_LONG(b);
5362 else
5363 return PyInt_AsSsize_t(b);
5364 }
5365 #endif
5366 if (likely(PyLong_CheckExact(b))) {
5367 #if CYTHON_USE_PYLONG_INTERNALS
5368 const digit* digits = ((PyLongObject*)b)->ob_digit;
5369 const Py_ssize_t size = Py_SIZE(b);
5370 if (likely(__Pyx_sst_abs(size) <= 1)) {
5371 ival = likely(size) ? digits[0] : 0;
5372 if (size == -1) ival = -ival;
5373 return ival;
5374 } else {
5375 switch (size) {
5376 case 2:
5377 if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
5378 return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
5379 }
5380 break;
5381 case -2:
5382 if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
5383 return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
5384 }
5385 break;
5386 case 3:
5387 if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
5388 return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
5389 }
5390 break;
5391 case -3:
5392 if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
5393 return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
5394 }
5395 break;
5396 case 4:
5397 if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
5398 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]));
5399 }
5400 break;
5401 case -4:
5402 if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
5403 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]));
5404 }
5405 break;
5406 }
5407 }
5408 #endif
5409 return PyLong_AsSsize_t(b);
5410 }
5411 x = PyNumber_Index(b);
5412 if (!x) return -1;
5413 ival = PyInt_AsSsize_t(x);
5414 Py_DECREF(x);
5415 return ival;
5416 }
5417 static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject* o) {
5418 if (sizeof(Py_hash_t) == sizeof(Py_ssize_t)) {
5419 return (Py_hash_t) __Pyx_PyIndex_AsSsize_t(o);
5420 #if PY_MAJOR_VERSION < 3
5421 } else if (likely(PyInt_CheckExact(o))) {
5422 return PyInt_AS_LONG(o);
5423 #endif
5424 } else {
5425 Py_ssize_t ival;
5426 PyObject *x;
5427 x = PyNumber_Index(o);
5428 if (!x) return -1;
5429 ival = PyInt_AsLong(x);
5430 Py_DECREF(x);
5431 return ival;
5432 }
5433 }
5434 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
5435 return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
5436 }
5437 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
5438 return PyInt_FromSize_t(ival);
5439 }
5440
5441
5442 #endif /* Py_PYTHON_H */