Cython 3.1.0a1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (301) hide show
  1. Cython/Build/BuildExecutable.py +169 -0
  2. Cython/Build/Cache.py +199 -0
  3. Cython/Build/Cythonize.py +250 -0
  4. Cython/Build/Dependencies.py +1275 -0
  5. Cython/Build/Distutils.py +1 -0
  6. Cython/Build/Inline.py +342 -0
  7. Cython/Build/IpythonMagic.py +560 -0
  8. Cython/Build/Tests/TestCyCache.py +119 -0
  9. Cython/Build/Tests/TestCythonizeArgsParser.py +481 -0
  10. Cython/Build/Tests/TestDependencies.py +133 -0
  11. Cython/Build/Tests/TestInline.py +112 -0
  12. Cython/Build/Tests/TestIpythonMagic.py +287 -0
  13. Cython/Build/Tests/TestRecythonize.py +212 -0
  14. Cython/Build/Tests/TestStripLiterals.py +155 -0
  15. Cython/Build/Tests/__init__.py +1 -0
  16. Cython/Build/__init__.py +8 -0
  17. Cython/CodeWriter.py +811 -0
  18. Cython/Compiler/AnalysedTreeTransforms.py +97 -0
  19. Cython/Compiler/Annotate.py +326 -0
  20. Cython/Compiler/AutoDocTransforms.py +314 -0
  21. Cython/Compiler/Buffer.py +680 -0
  22. Cython/Compiler/Builtin.py +862 -0
  23. Cython/Compiler/CmdLine.py +243 -0
  24. Cython/Compiler/Code.pxd +145 -0
  25. Cython/Compiler/Code.py +3328 -0
  26. Cython/Compiler/CodeGeneration.py +33 -0
  27. Cython/Compiler/CythonScope.py +179 -0
  28. Cython/Compiler/Dataclass.py +868 -0
  29. Cython/Compiler/DebugFlags.py +21 -0
  30. Cython/Compiler/Errors.py +295 -0
  31. Cython/Compiler/ExprNodes.py +15051 -0
  32. Cython/Compiler/FlowControl.pxd +97 -0
  33. Cython/Compiler/FlowControl.py +1438 -0
  34. Cython/Compiler/FusedNode.py +998 -0
  35. Cython/Compiler/Future.py +16 -0
  36. Cython/Compiler/Interpreter.py +57 -0
  37. Cython/Compiler/Lexicon.py +340 -0
  38. Cython/Compiler/LineTable.py +114 -0
  39. Cython/Compiler/Main.py +779 -0
  40. Cython/Compiler/MatchCaseNodes.py +259 -0
  41. Cython/Compiler/MemoryView.py +860 -0
  42. Cython/Compiler/ModuleNode.py +4065 -0
  43. Cython/Compiler/Naming.py +369 -0
  44. Cython/Compiler/Nodes.py +10557 -0
  45. Cython/Compiler/Optimize.py +5269 -0
  46. Cython/Compiler/Options.py +828 -0
  47. Cython/Compiler/ParseTreeTransforms.pxd +78 -0
  48. Cython/Compiler/ParseTreeTransforms.py +4441 -0
  49. Cython/Compiler/Parsing.pxd +9 -0
  50. Cython/Compiler/Parsing.py +4797 -0
  51. Cython/Compiler/Pipeline.py +425 -0
  52. Cython/Compiler/PyrexTypes.py +5572 -0
  53. Cython/Compiler/Pythran.py +223 -0
  54. Cython/Compiler/Scanning.pxd +40 -0
  55. Cython/Compiler/Scanning.py +574 -0
  56. Cython/Compiler/StringEncoding.py +347 -0
  57. Cython/Compiler/Symtab.py +2998 -0
  58. Cython/Compiler/Tests/TestBuffer.py +105 -0
  59. Cython/Compiler/Tests/TestBuiltin.py +72 -0
  60. Cython/Compiler/Tests/TestCmdLine.py +573 -0
  61. Cython/Compiler/Tests/TestCode.py +86 -0
  62. Cython/Compiler/Tests/TestFlowControl.py +65 -0
  63. Cython/Compiler/Tests/TestGrammar.py +202 -0
  64. Cython/Compiler/Tests/TestMemView.py +71 -0
  65. Cython/Compiler/Tests/TestParseTreeTransforms.py +285 -0
  66. Cython/Compiler/Tests/TestScanning.py +134 -0
  67. Cython/Compiler/Tests/TestSignatureMatching.py +73 -0
  68. Cython/Compiler/Tests/TestStringEncoding.py +33 -0
  69. Cython/Compiler/Tests/TestTreeFragment.py +63 -0
  70. Cython/Compiler/Tests/TestTreePath.py +93 -0
  71. Cython/Compiler/Tests/TestTypes.py +75 -0
  72. Cython/Compiler/Tests/TestUtilityLoad.py +112 -0
  73. Cython/Compiler/Tests/TestVisitor.py +61 -0
  74. Cython/Compiler/Tests/Utils.py +36 -0
  75. Cython/Compiler/Tests/__init__.py +1 -0
  76. Cython/Compiler/TreeFragment.py +278 -0
  77. Cython/Compiler/TreePath.py +290 -0
  78. Cython/Compiler/TypeInference.py +584 -0
  79. Cython/Compiler/TypeSlots.py +1181 -0
  80. Cython/Compiler/UFuncs.py +311 -0
  81. Cython/Compiler/UtilNodes.py +387 -0
  82. Cython/Compiler/UtilityCode.py +274 -0
  83. Cython/Compiler/Version.py +8 -0
  84. Cython/Compiler/Visitor.pxd +53 -0
  85. Cython/Compiler/Visitor.py +861 -0
  86. Cython/Compiler/__init__.py +1 -0
  87. Cython/Coverage.py +443 -0
  88. Cython/Debugger/Cygdb.py +179 -0
  89. Cython/Debugger/DebugWriter.py +82 -0
  90. Cython/Debugger/Tests/TestLibCython.py +275 -0
  91. Cython/Debugger/Tests/__init__.py +1 -0
  92. Cython/Debugger/Tests/cfuncs.c +8 -0
  93. Cython/Debugger/Tests/codefile +49 -0
  94. Cython/Debugger/Tests/test_libcython_in_gdb.py +578 -0
  95. Cython/Debugger/Tests/test_libpython_in_gdb.py +90 -0
  96. Cython/Debugger/__init__.py +1 -0
  97. Cython/Debugger/libcython.py +1549 -0
  98. Cython/Debugger/libpython.py +2821 -0
  99. Cython/Debugging.py +20 -0
  100. Cython/Distutils/__init__.py +2 -0
  101. Cython/Distutils/build_ext.py +137 -0
  102. Cython/Distutils/extension.py +96 -0
  103. Cython/Distutils/old_build_ext.py +351 -0
  104. Cython/Includes/cpython/__init__.pxd +173 -0
  105. Cython/Includes/cpython/array.pxd +174 -0
  106. Cython/Includes/cpython/bool.pxd +37 -0
  107. Cython/Includes/cpython/buffer.pxd +112 -0
  108. Cython/Includes/cpython/bytearray.pxd +33 -0
  109. Cython/Includes/cpython/bytes.pxd +200 -0
  110. Cython/Includes/cpython/cellobject.pxd +35 -0
  111. Cython/Includes/cpython/ceval.pxd +8 -0
  112. Cython/Includes/cpython/codecs.pxd +121 -0
  113. Cython/Includes/cpython/complex.pxd +55 -0
  114. Cython/Includes/cpython/contextvars.pxd +141 -0
  115. Cython/Includes/cpython/conversion.pxd +36 -0
  116. Cython/Includes/cpython/datetime.pxd +384 -0
  117. Cython/Includes/cpython/descr.pxd +26 -0
  118. Cython/Includes/cpython/dict.pxd +187 -0
  119. Cython/Includes/cpython/exc.pxd +263 -0
  120. Cython/Includes/cpython/fileobject.pxd +57 -0
  121. Cython/Includes/cpython/float.pxd +47 -0
  122. Cython/Includes/cpython/function.pxd +65 -0
  123. Cython/Includes/cpython/genobject.pxd +25 -0
  124. Cython/Includes/cpython/getargs.pxd +12 -0
  125. Cython/Includes/cpython/instance.pxd +25 -0
  126. Cython/Includes/cpython/iterator.pxd +36 -0
  127. Cython/Includes/cpython/iterobject.pxd +24 -0
  128. Cython/Includes/cpython/list.pxd +92 -0
  129. Cython/Includes/cpython/long.pxd +149 -0
  130. Cython/Includes/cpython/longintrepr.pxd +19 -0
  131. Cython/Includes/cpython/mapping.pxd +63 -0
  132. Cython/Includes/cpython/marshal.pxd +66 -0
  133. Cython/Includes/cpython/mem.pxd +120 -0
  134. Cython/Includes/cpython/memoryview.pxd +50 -0
  135. Cython/Includes/cpython/method.pxd +49 -0
  136. Cython/Includes/cpython/module.pxd +208 -0
  137. Cython/Includes/cpython/number.pxd +258 -0
  138. Cython/Includes/cpython/object.pxd +433 -0
  139. Cython/Includes/cpython/pycapsule.pxd +143 -0
  140. Cython/Includes/cpython/pylifecycle.pxd +68 -0
  141. Cython/Includes/cpython/pyport.pxd +8 -0
  142. Cython/Includes/cpython/pystate.pxd +95 -0
  143. Cython/Includes/cpython/pythread.pxd +53 -0
  144. Cython/Includes/cpython/ref.pxd +67 -0
  145. Cython/Includes/cpython/sequence.pxd +134 -0
  146. Cython/Includes/cpython/set.pxd +119 -0
  147. Cython/Includes/cpython/slice.pxd +70 -0
  148. Cython/Includes/cpython/time.pxd +129 -0
  149. Cython/Includes/cpython/tuple.pxd +72 -0
  150. Cython/Includes/cpython/type.pxd +53 -0
  151. Cython/Includes/cpython/unicode.pxd +639 -0
  152. Cython/Includes/cpython/version.pxd +32 -0
  153. Cython/Includes/cpython/weakref.pxd +42 -0
  154. Cython/Includes/libc/__init__.pxd +1 -0
  155. Cython/Includes/libc/complex.pxd +35 -0
  156. Cython/Includes/libc/errno.pxd +127 -0
  157. Cython/Includes/libc/float.pxd +43 -0
  158. Cython/Includes/libc/limits.pxd +28 -0
  159. Cython/Includes/libc/locale.pxd +46 -0
  160. Cython/Includes/libc/math.pxd +209 -0
  161. Cython/Includes/libc/setjmp.pxd +10 -0
  162. Cython/Includes/libc/signal.pxd +64 -0
  163. Cython/Includes/libc/stddef.pxd +9 -0
  164. Cython/Includes/libc/stdint.pxd +105 -0
  165. Cython/Includes/libc/stdio.pxd +80 -0
  166. Cython/Includes/libc/stdlib.pxd +72 -0
  167. Cython/Includes/libc/string.pxd +50 -0
  168. Cython/Includes/libc/time.pxd +47 -0
  169. Cython/Includes/libcpp/__init__.pxd +4 -0
  170. Cython/Includes/libcpp/algorithm.pxd +320 -0
  171. Cython/Includes/libcpp/any.pxd +16 -0
  172. Cython/Includes/libcpp/atomic.pxd +59 -0
  173. Cython/Includes/libcpp/bit.pxd +29 -0
  174. Cython/Includes/libcpp/cast.pxd +12 -0
  175. Cython/Includes/libcpp/cmath.pxd +518 -0
  176. Cython/Includes/libcpp/complex.pxd +106 -0
  177. Cython/Includes/libcpp/deque.pxd +165 -0
  178. Cython/Includes/libcpp/execution.pxd +15 -0
  179. Cython/Includes/libcpp/forward_list.pxd +63 -0
  180. Cython/Includes/libcpp/functional.pxd +26 -0
  181. Cython/Includes/libcpp/iterator.pxd +34 -0
  182. Cython/Includes/libcpp/limits.pxd +61 -0
  183. Cython/Includes/libcpp/list.pxd +117 -0
  184. Cython/Includes/libcpp/map.pxd +252 -0
  185. Cython/Includes/libcpp/memory.pxd +115 -0
  186. Cython/Includes/libcpp/numbers.pxd +15 -0
  187. Cython/Includes/libcpp/numeric.pxd +131 -0
  188. Cython/Includes/libcpp/optional.pxd +34 -0
  189. Cython/Includes/libcpp/pair.pxd +1 -0
  190. Cython/Includes/libcpp/queue.pxd +25 -0
  191. Cython/Includes/libcpp/random.pxd +166 -0
  192. Cython/Includes/libcpp/set.pxd +228 -0
  193. Cython/Includes/libcpp/stack.pxd +11 -0
  194. Cython/Includes/libcpp/string.pxd +333 -0
  195. Cython/Includes/libcpp/typeindex.pxd +15 -0
  196. Cython/Includes/libcpp/typeinfo.pxd +10 -0
  197. Cython/Includes/libcpp/unordered_map.pxd +193 -0
  198. Cython/Includes/libcpp/unordered_set.pxd +152 -0
  199. Cython/Includes/libcpp/utility.pxd +30 -0
  200. Cython/Includes/libcpp/vector.pxd +167 -0
  201. Cython/Includes/openmp.pxd +50 -0
  202. Cython/Includes/posix/__init__.pxd +1 -0
  203. Cython/Includes/posix/dlfcn.pxd +14 -0
  204. Cython/Includes/posix/fcntl.pxd +86 -0
  205. Cython/Includes/posix/ioctl.pxd +4 -0
  206. Cython/Includes/posix/mman.pxd +101 -0
  207. Cython/Includes/posix/resource.pxd +57 -0
  208. Cython/Includes/posix/select.pxd +21 -0
  209. Cython/Includes/posix/signal.pxd +73 -0
  210. Cython/Includes/posix/stat.pxd +98 -0
  211. Cython/Includes/posix/stdio.pxd +37 -0
  212. Cython/Includes/posix/stdlib.pxd +29 -0
  213. Cython/Includes/posix/strings.pxd +9 -0
  214. Cython/Includes/posix/time.pxd +71 -0
  215. Cython/Includes/posix/types.pxd +30 -0
  216. Cython/Includes/posix/uio.pxd +26 -0
  217. Cython/Includes/posix/unistd.pxd +271 -0
  218. Cython/Includes/posix/wait.pxd +38 -0
  219. Cython/Plex/Actions.pxd +24 -0
  220. Cython/Plex/Actions.py +119 -0
  221. Cython/Plex/DFA.pxd +14 -0
  222. Cython/Plex/DFA.py +164 -0
  223. Cython/Plex/Errors.py +48 -0
  224. Cython/Plex/Lexicons.py +178 -0
  225. Cython/Plex/Machines.pxd +36 -0
  226. Cython/Plex/Machines.py +238 -0
  227. Cython/Plex/Regexps.py +539 -0
  228. Cython/Plex/Scanners.pxd +47 -0
  229. Cython/Plex/Scanners.py +360 -0
  230. Cython/Plex/Transitions.pxd +14 -0
  231. Cython/Plex/Transitions.py +239 -0
  232. Cython/Plex/__init__.py +34 -0
  233. Cython/Runtime/__init__.py +1 -0
  234. Cython/Runtime/refnanny.pyx +261 -0
  235. Cython/Shadow.py +656 -0
  236. Cython/Shadow.pyi +521 -0
  237. Cython/StringIOTree.py +170 -0
  238. Cython/Tempita/__init__.py +4 -0
  239. Cython/Tempita/_looper.py +154 -0
  240. Cython/Tempita/_tempita.py +1091 -0
  241. Cython/TestUtils.py +417 -0
  242. Cython/Tests/TestCodeWriter.py +128 -0
  243. Cython/Tests/TestCythonUtils.py +202 -0
  244. Cython/Tests/TestJediTyper.py +223 -0
  245. Cython/Tests/TestShadow.py +114 -0
  246. Cython/Tests/TestStringIOTree.py +67 -0
  247. Cython/Tests/TestTestUtils.py +90 -0
  248. Cython/Tests/__init__.py +1 -0
  249. Cython/Tests/xmlrunner.py +390 -0
  250. Cython/Utility/AsyncGen.c +1263 -0
  251. Cython/Utility/Buffer.c +875 -0
  252. Cython/Utility/Builtins.c +660 -0
  253. Cython/Utility/CConvert.pyx +134 -0
  254. Cython/Utility/CMath.c +95 -0
  255. Cython/Utility/CommonStructures.c +139 -0
  256. Cython/Utility/Complex.c +378 -0
  257. Cython/Utility/Coroutine.c +2413 -0
  258. Cython/Utility/CpdefEnums.pyx +108 -0
  259. Cython/Utility/CppConvert.pyx +279 -0
  260. Cython/Utility/CppSupport.cpp +133 -0
  261. Cython/Utility/CythonFunction.c +1851 -0
  262. Cython/Utility/Dataclasses.c +185 -0
  263. Cython/Utility/Dataclasses.py +112 -0
  264. Cython/Utility/Embed.c +125 -0
  265. Cython/Utility/Exceptions.c +1017 -0
  266. Cython/Utility/ExtensionTypes.c +797 -0
  267. Cython/Utility/FunctionArguments.c +573 -0
  268. Cython/Utility/ImportExport.c +912 -0
  269. Cython/Utility/MemoryView.pyx +1478 -0
  270. Cython/Utility/MemoryView_C.c +992 -0
  271. Cython/Utility/ModuleSetupCode.c +2501 -0
  272. Cython/Utility/NumpyImportArray.c +46 -0
  273. Cython/Utility/ObjectHandling.c +3054 -0
  274. Cython/Utility/Optimize.c +1533 -0
  275. Cython/Utility/Overflow.c +404 -0
  276. Cython/Utility/Printing.c +86 -0
  277. Cython/Utility/Profile.c +660 -0
  278. Cython/Utility/StringTools.c +1206 -0
  279. Cython/Utility/TestCyUtilityLoader.pyx +8 -0
  280. Cython/Utility/TestCythonScope.pyx +75 -0
  281. Cython/Utility/TestUtilityLoader.c +12 -0
  282. Cython/Utility/TypeConversion.c +1329 -0
  283. Cython/Utility/UFuncs.pyx +50 -0
  284. Cython/Utility/UFuncs_C.c +89 -0
  285. Cython/Utility/__init__.py +28 -0
  286. Cython/Utility/arrayarray.h +143 -0
  287. Cython/Utils.py +687 -0
  288. Cython/__init__.py +10 -0
  289. Cython/__init__.pyi +7 -0
  290. Cython/py.typed +0 -0
  291. Cython-3.1.0a1.dist-info/COPYING.txt +19 -0
  292. Cython-3.1.0a1.dist-info/LICENSE.txt +176 -0
  293. Cython-3.1.0a1.dist-info/METADATA +67 -0
  294. Cython-3.1.0a1.dist-info/RECORD +301 -0
  295. Cython-3.1.0a1.dist-info/WHEEL +5 -0
  296. Cython-3.1.0a1.dist-info/entry_points.txt +4 -0
  297. Cython-3.1.0a1.dist-info/top_level.txt +3 -0
  298. cython.py +29 -0
  299. pyximport/__init__.py +4 -0
  300. pyximport/pyxbuild.py +160 -0
  301. pyximport/pyximport.py +482 -0
@@ -0,0 +1,3054 @@
1
+ /*
2
+ * General object operations and protocol implementations,
3
+ * including their specialisations for certain builtins.
4
+ *
5
+ * Optional optimisations for builtins are in Optimize.c.
6
+ *
7
+ * Required replacements of builtins are in Builtins.c.
8
+ */
9
+
10
+ /////////////// RaiseNoneIterError.proto ///////////////
11
+
12
+ static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void);
13
+
14
+ /////////////// RaiseNoneIterError ///////////////
15
+
16
+ static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
17
+ PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
18
+ }
19
+
20
+ /////////////// RaiseTooManyValuesToUnpack.proto ///////////////
21
+
22
+ static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
23
+
24
+ /////////////// RaiseTooManyValuesToUnpack ///////////////
25
+
26
+ static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
27
+ PyErr_Format(PyExc_ValueError,
28
+ "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
29
+ }
30
+
31
+ /////////////// RaiseNeedMoreValuesToUnpack.proto ///////////////
32
+
33
+ static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
34
+
35
+ /////////////// RaiseNeedMoreValuesToUnpack ///////////////
36
+
37
+ static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
38
+ PyErr_Format(PyExc_ValueError,
39
+ "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
40
+ index, (index == 1) ? "" : "s");
41
+ }
42
+
43
+ /////////////// UnpackTupleError.proto ///////////////
44
+
45
+ static void __Pyx_UnpackTupleError(PyObject *, Py_ssize_t index); /*proto*/
46
+
47
+ /////////////// UnpackTupleError ///////////////
48
+ //@requires: RaiseNoneIterError
49
+ //@requires: RaiseNeedMoreValuesToUnpack
50
+ //@requires: RaiseTooManyValuesToUnpack
51
+
52
+ static void __Pyx_UnpackTupleError(PyObject *t, Py_ssize_t index) {
53
+ if (t == Py_None) {
54
+ __Pyx_RaiseNoneNotIterableError();
55
+ } else {
56
+ Py_ssize_t size = __Pyx_PyTuple_GET_SIZE(t);
57
+ #if !CYTHON_ASSUME_SAFE_SIZE
58
+ if (unlikely(size < 0)) return;
59
+ #endif
60
+ if (size < index) {
61
+ __Pyx_RaiseNeedMoreValuesError(size);
62
+ } else {
63
+ __Pyx_RaiseTooManyValuesError(index);
64
+ }
65
+ }
66
+ }
67
+
68
+ /////////////// UnpackItemEndCheck.proto ///////////////
69
+
70
+ static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected); /*proto*/
71
+
72
+ /////////////// UnpackItemEndCheck ///////////////
73
+ //@requires: RaiseTooManyValuesToUnpack
74
+ //@requires: IterFinish
75
+
76
+ static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
77
+ if (unlikely(retval)) {
78
+ Py_DECREF(retval);
79
+ __Pyx_RaiseTooManyValuesError(expected);
80
+ return -1;
81
+ }
82
+
83
+ return __Pyx_IterFinish();
84
+ }
85
+
86
+ /////////////// UnpackTuple2.proto ///////////////
87
+
88
+ static CYTHON_INLINE int __Pyx_unpack_tuple2(
89
+ PyObject* tuple, PyObject** value1, PyObject** value2, int is_tuple, int has_known_size, int decref_tuple);
90
+
91
+ static CYTHON_INLINE int __Pyx_unpack_tuple2_exact(
92
+ PyObject* tuple, PyObject** value1, PyObject** value2, int decref_tuple);
93
+ static int __Pyx_unpack_tuple2_generic(
94
+ PyObject* tuple, PyObject** value1, PyObject** value2, int has_known_size, int decref_tuple);
95
+
96
+ /////////////// UnpackTuple2 ///////////////
97
+ //@requires: UnpackItemEndCheck
98
+ //@requires: UnpackTupleError
99
+ //@requires: RaiseNeedMoreValuesToUnpack
100
+
101
+ static CYTHON_INLINE int __Pyx_unpack_tuple2(
102
+ PyObject* tuple, PyObject** value1, PyObject** value2, int is_tuple, int has_known_size, int decref_tuple) {
103
+ if (likely(is_tuple || PyTuple_Check(tuple))) {
104
+ Py_ssize_t size;
105
+ if (has_known_size) {
106
+ return __Pyx_unpack_tuple2_exact(tuple, value1, value2, decref_tuple);
107
+ }
108
+ size = __Pyx_PyTuple_GET_SIZE(tuple);
109
+ if (likely(size == 2)) {
110
+ return __Pyx_unpack_tuple2_exact(tuple, value1, value2, decref_tuple);
111
+ }
112
+ if (size >= 0) {
113
+ // "size == -1" indicates an error already.
114
+ __Pyx_UnpackTupleError(tuple, 2);
115
+ }
116
+ return -1;
117
+ } else {
118
+ return __Pyx_unpack_tuple2_generic(tuple, value1, value2, has_known_size, decref_tuple);
119
+ }
120
+ }
121
+
122
+ static CYTHON_INLINE int __Pyx_unpack_tuple2_exact(
123
+ PyObject* tuple, PyObject** pvalue1, PyObject** pvalue2, int decref_tuple) {
124
+ PyObject *value1 = NULL, *value2 = NULL;
125
+ #if CYTHON_AVOID_BORROWED_REFS || !CYTHON_ASSUME_SAFE_MACROS
126
+ value1 = __Pyx_PySequence_ITEM(tuple, 0); if (unlikely(!value1)) goto bad;
127
+ value2 = __Pyx_PySequence_ITEM(tuple, 1); if (unlikely(!value2)) goto bad;
128
+ #else
129
+ value1 = PyTuple_GET_ITEM(tuple, 0); Py_INCREF(value1);
130
+ value2 = PyTuple_GET_ITEM(tuple, 1); Py_INCREF(value2);
131
+ #endif
132
+ if (decref_tuple) {
133
+ Py_DECREF(tuple);
134
+ }
135
+
136
+ *pvalue1 = value1;
137
+ *pvalue2 = value2;
138
+ return 0;
139
+ #if CYTHON_AVOID_BORROWED_REFS || !CYTHON_ASSUME_SAFE_MACROS
140
+ bad:
141
+ Py_XDECREF(value1);
142
+ Py_XDECREF(value2);
143
+ if (decref_tuple) { Py_XDECREF(tuple); }
144
+ return -1;
145
+ #endif
146
+ }
147
+
148
+ static int __Pyx_unpack_tuple2_generic(PyObject* tuple, PyObject** pvalue1, PyObject** pvalue2,
149
+ int has_known_size, int decref_tuple) {
150
+ Py_ssize_t index;
151
+ PyObject *value1 = NULL, *value2 = NULL, *iter = NULL;
152
+ iternextfunc iternext;
153
+
154
+ iter = PyObject_GetIter(tuple);
155
+ if (unlikely(!iter)) goto bad;
156
+ if (decref_tuple) { Py_DECREF(tuple); tuple = NULL; }
157
+
158
+ iternext = __Pyx_PyObject_GetIterNextFunc(iter);
159
+ value1 = iternext(iter); if (unlikely(!value1)) { index = 0; goto unpacking_failed; }
160
+ value2 = iternext(iter); if (unlikely(!value2)) { index = 1; goto unpacking_failed; }
161
+ if (!has_known_size && unlikely(__Pyx_IternextUnpackEndCheck(iternext(iter), 2))) goto bad;
162
+
163
+ Py_DECREF(iter);
164
+ *pvalue1 = value1;
165
+ *pvalue2 = value2;
166
+ return 0;
167
+
168
+ unpacking_failed:
169
+ if (!has_known_size && __Pyx_IterFinish() == 0)
170
+ __Pyx_RaiseNeedMoreValuesError(index);
171
+ bad:
172
+ Py_XDECREF(iter);
173
+ Py_XDECREF(value1);
174
+ Py_XDECREF(value2);
175
+ if (decref_tuple) { Py_XDECREF(tuple); }
176
+ return -1;
177
+ }
178
+
179
+
180
+ /////////////// IterNextPlain.proto ///////////////
181
+
182
+ static CYTHON_INLINE PyObject *__Pyx_PyIter_Next_Plain(PyObject *iterator);
183
+ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
184
+ static PyObject *__Pyx_GetBuiltinNext_LimitedAPI(void);
185
+ #endif
186
+
187
+ /////////////// IterNextPlain.module_state_decls ///////////////
188
+
189
+ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
190
+ PyObject *__Pyx_GetBuiltinNext_LimitedAPI_cache;
191
+ #endif
192
+
193
+ /////////////// IterNextPlain ///////////////
194
+ //@requires: GetBuiltinName
195
+
196
+ // There is no replacement for "Py_TYPE(obj)->iternext" in the C-API.
197
+ // PyIter_Next() discards the StopIteration, unlike Python's "next()".
198
+ // PyObject_GetSlot() rejects non-heap types in CPython < 3.10 (and PyPy).
199
+
200
+ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
201
+ static PyObject *__Pyx_GetBuiltinNext_LimitedAPI(void) {
202
+ if (unlikely(!CGLOBAL(__Pyx_GetBuiltinNext_LimitedAPI_cache)))
203
+ CGLOBAL(__Pyx_GetBuiltinNext_LimitedAPI_cache) = __Pyx_GetBuiltinName(PYIDENT("next"));
204
+ // Returns the globally owned reference, not a new reference!
205
+ return CGLOBAL(__Pyx_GetBuiltinNext_LimitedAPI_cache);
206
+ }
207
+ #endif
208
+
209
+ static CYTHON_INLINE PyObject *__Pyx_PyIter_Next_Plain(PyObject *iterator) {
210
+ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
211
+ PyObject *result;
212
+ PyObject *next = __Pyx_GetBuiltinNext_LimitedAPI();
213
+ if (unlikely(!next)) return NULL;
214
+ result = PyObject_CallFunctionObjArgs(next, iterator, NULL);
215
+ return result;
216
+ #else
217
+ (void)__Pyx_GetBuiltinName; // only for early limited API
218
+ iternextfunc iternext = __Pyx_PyObject_GetIterNextFunc(iterator);
219
+ assert(iternext);
220
+ return iternext(iterator);
221
+ #endif
222
+ }
223
+
224
+
225
+ /////////////// IterNext.proto ///////////////
226
+
227
+ #define __Pyx_PyIter_Next(obj) __Pyx_PyIter_Next2(obj, NULL)
228
+ static CYTHON_INLINE PyObject *__Pyx_PyIter_Next2(PyObject *, PyObject *); /*proto*/
229
+
230
+ /////////////// IterNext ///////////////
231
+ //@requires: Exceptions.c::PyThreadStateGet
232
+ //@requires: Exceptions.c::PyErrFetchRestore
233
+ //@requires: GetBuiltinName
234
+ //@requires: IterNextPlain
235
+
236
+ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x03080000
237
+ // In the Limited API for Py 3.7, PyIter_Check is defined but as a macro that uses
238
+ // non-limited API features and thus is unusable. Therefore, just call builtin next.
239
+ static PyObject *__Pyx_PyIter_Next2(PyObject *o, PyObject *defval) {
240
+ PyObject *result;
241
+ PyObject *next = __Pyx_GetBuiltinNext_LimitedAPI();
242
+ if (unlikely(!next)) return NULL;
243
+ // This works if defval is NULL or not
244
+ result = PyObject_CallFunctionObjArgs(next, o, defval, NULL);
245
+ return result;
246
+ }
247
+ #else
248
+ static PyObject *__Pyx_PyIter_Next2Default(PyObject* defval) {
249
+ PyObject* exc_type;
250
+ __Pyx_PyThreadState_declare
251
+ __Pyx_PyThreadState_assign
252
+ exc_type = __Pyx_PyErr_CurrentExceptionType();
253
+ if (unlikely(exc_type)) {
254
+ if (!defval || unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))
255
+ return NULL;
256
+ __Pyx_PyErr_Clear();
257
+ Py_INCREF(defval);
258
+ return defval;
259
+ }
260
+ if (defval) {
261
+ Py_INCREF(defval);
262
+ return defval;
263
+ }
264
+ __Pyx_PyErr_SetNone(PyExc_StopIteration);
265
+ return NULL;
266
+ }
267
+
268
+ static void __Pyx_PyIter_Next_ErrorNoIterator(PyObject *iterator) {
269
+ __Pyx_TypeName iterator_type_name = __Pyx_PyType_GetName(Py_TYPE(iterator));
270
+ PyErr_Format(PyExc_TypeError,
271
+ __Pyx_FMT_TYPENAME " object is not an iterator", iterator_type_name);
272
+ __Pyx_DECREF_TypeName(iterator_type_name);
273
+ }
274
+
275
+ // originally copied from Py3's builtin_next()
276
+ static CYTHON_INLINE PyObject *__Pyx_PyIter_Next2(PyObject* iterator, PyObject* defval) {
277
+ PyObject* next;
278
+ #if !CYTHON_COMPILING_IN_LIMITED_API
279
+ // We always do a quick slot check because calling PyIter_Check() is so wasteful.
280
+ iternextfunc iternext = __Pyx_PyObject_TryGetSlot(iterator, tp_iternext, iternextfunc);
281
+ if (likely(iternext)) {
282
+ next = iternext(iterator);
283
+ if (likely(next))
284
+ return next;
285
+ #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030d0000
286
+ // If the reason for failure was "not implemented", we're done raising the appropriate exception.
287
+ if (unlikely(iternext == &_PyObject_NextNotImplemented))
288
+ return NULL;
289
+ #endif
290
+ } else if (CYTHON_USE_TYPE_SLOTS) {
291
+ // If CYTHON_USE_TYPE_SLOTS, then the slot was really not set and we don't have an iterable.
292
+ __Pyx_PyIter_Next_ErrorNoIterator(iterator);
293
+ return NULL;
294
+ } else
295
+ // Without CYTHON_USE_TYPE_SLOTS, don't trust "tp_iternext" and rely on PyIter_Check().
296
+ #endif
297
+ if (unlikely(!PyIter_Check(iterator))) {
298
+ __Pyx_PyIter_Next_ErrorNoIterator(iterator);
299
+ return NULL;
300
+ } else {
301
+ // We'll probably only end up here in the Limited API, where we'd call Python's "next()" now.
302
+ // If we have a default value, we don't need the StopIteration and can use PyIter_Next().
303
+ next = defval ? PyIter_Next(iterator) : __Pyx_PyIter_Next_Plain(iterator);
304
+ if (likely(next))
305
+ return next;
306
+ }
307
+ return __Pyx_PyIter_Next2Default(defval);
308
+ }
309
+ #endif
310
+
311
+ /////////////// IterFinish.proto ///////////////
312
+
313
+ static CYTHON_INLINE int __Pyx_IterFinish(void); /*proto*/
314
+
315
+ /////////////// IterFinish ///////////////
316
+ //@requires: Exceptions.c::PyThreadStateGet
317
+ //@requires: Exceptions.c::PyErrFetchRestore
318
+
319
+ // When PyIter_Next(iter) has returned NULL in order to signal termination,
320
+ // this function does the right cleanup and returns 0 on success. If it
321
+ // detects an error that occurred in the iterator, it returns -1.
322
+
323
+ static CYTHON_INLINE int __Pyx_IterFinish(void) {
324
+ PyObject* exc_type;
325
+ __Pyx_PyThreadState_declare
326
+ __Pyx_PyThreadState_assign
327
+ exc_type = __Pyx_PyErr_CurrentExceptionType();
328
+ if (unlikely(exc_type)) {
329
+ if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))
330
+ return -1;
331
+ __Pyx_PyErr_Clear();
332
+ return 0;
333
+ }
334
+ return 0;
335
+ }
336
+
337
+
338
+ /////////////// ObjectGetItem.proto ///////////////
339
+
340
+ #if CYTHON_USE_TYPE_SLOTS
341
+ static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject *key);/*proto*/
342
+ #else
343
+ #define __Pyx_PyObject_GetItem(obj, key) PyObject_GetItem(obj, key)
344
+ #endif
345
+
346
+ /////////////// ObjectGetItem ///////////////
347
+ // //@requires: GetItemInt - added in IndexNode as it uses templating.
348
+ //@requires: PyObjectGetAttrStrNoError
349
+ //@requires: PyObjectCallOneArg
350
+
351
+ #if CYTHON_USE_TYPE_SLOTS
352
+ static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject *index) {
353
+ // Get element from sequence object `obj` at index `index`.
354
+ PyObject *runerr = NULL;
355
+ Py_ssize_t key_value;
356
+ key_value = __Pyx_PyIndex_AsSsize_t(index);
357
+ if (likely(key_value != -1 || !(runerr = PyErr_Occurred()))) {
358
+ return __Pyx_GetItemInt_Fast(obj, key_value, 0, 1, 1);
359
+ }
360
+
361
+ // Error handling code -- only manage OverflowError differently.
362
+ if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) {
363
+ __Pyx_TypeName index_type_name = __Pyx_PyType_GetName(Py_TYPE(index));
364
+ PyErr_Clear();
365
+ PyErr_Format(PyExc_IndexError,
366
+ "cannot fit '" __Pyx_FMT_TYPENAME "' into an index-sized integer", index_type_name);
367
+ __Pyx_DECREF_TypeName(index_type_name);
368
+ }
369
+ return NULL;
370
+ }
371
+
372
+ static PyObject *__Pyx_PyObject_GetItem_Slow(PyObject *obj, PyObject *key) {
373
+ __Pyx_TypeName obj_type_name;
374
+ // Handles less common slow-path checks for GetItem
375
+ if (likely(PyType_Check(obj))) {
376
+ PyObject *meth = __Pyx_PyObject_GetAttrStrNoError(obj, PYIDENT("__class_getitem__"));
377
+ if (!meth) {
378
+ PyErr_Clear();
379
+ } else {
380
+ PyObject *result = __Pyx_PyObject_CallOneArg(meth, key);
381
+ Py_DECREF(meth);
382
+ return result;
383
+ }
384
+ }
385
+
386
+ obj_type_name = __Pyx_PyType_GetName(Py_TYPE(obj));
387
+ PyErr_Format(PyExc_TypeError,
388
+ "'" __Pyx_FMT_TYPENAME "' object is not subscriptable", obj_type_name);
389
+ __Pyx_DECREF_TypeName(obj_type_name);
390
+ return NULL;
391
+ }
392
+
393
+ static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject *key) {
394
+ PyTypeObject *tp = Py_TYPE(obj);
395
+ PyMappingMethods *mm = tp->tp_as_mapping;
396
+ PySequenceMethods *sm = tp->tp_as_sequence;
397
+
398
+ if (likely(mm && mm->mp_subscript)) {
399
+ return mm->mp_subscript(obj, key);
400
+ }
401
+ if (likely(sm && sm->sq_item)) {
402
+ return __Pyx_PyObject_GetIndex(obj, key);
403
+ }
404
+ return __Pyx_PyObject_GetItem_Slow(obj, key);
405
+ }
406
+ #endif
407
+
408
+
409
+ /////////////// DictGetItem.proto ///////////////
410
+
411
+ #if !CYTHON_COMPILING_IN_PYPY
412
+ static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key);/*proto*/
413
+
414
+ #define __Pyx_PyObject_Dict_GetItem(obj, name) \
415
+ (likely(PyDict_CheckExact(obj)) ? \
416
+ __Pyx_PyDict_GetItem(obj, name) : PyObject_GetItem(obj, name))
417
+
418
+ #else
419
+ #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key)
420
+ #define __Pyx_PyObject_Dict_GetItem(obj, name) PyObject_GetItem(obj, name)
421
+ #endif
422
+
423
+ /////////////// DictGetItem ///////////////
424
+
425
+ #if !CYTHON_COMPILING_IN_PYPY
426
+ static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
427
+ PyObject *value;
428
+ value = PyDict_GetItemWithError(d, key);
429
+ if (unlikely(!value)) {
430
+ if (!PyErr_Occurred()) {
431
+ if (unlikely(PyTuple_Check(key))) {
432
+ // CPython interprets tuples as separate arguments => must wrap them in another tuple.
433
+ PyObject* args = PyTuple_Pack(1, key);
434
+ if (likely(args)) {
435
+ PyErr_SetObject(PyExc_KeyError, args);
436
+ Py_DECREF(args);
437
+ }
438
+ } else {
439
+ // Avoid tuple packing if possible.
440
+ PyErr_SetObject(PyExc_KeyError, key);
441
+ }
442
+ }
443
+ return NULL;
444
+ }
445
+ Py_INCREF(value);
446
+ return value;
447
+ }
448
+ #endif
449
+
450
+ /////////////// GetItemInt.proto ///////////////
451
+ //@substitute: tempita
452
+
453
+ #define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \
454
+ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \
455
+ __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) : \
456
+ (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) : \
457
+ __Pyx_GetItemInt_Generic(o, to_py_func(i))))
458
+
459
+ {{for type in ['List', 'Tuple']}}
460
+ #define __Pyx_GetItemInt_{{type}}(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \
461
+ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \
462
+ __Pyx_GetItemInt_{{type}}_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) : \
463
+ (PyErr_SetString(PyExc_IndexError, "{{ type.lower() }} index out of range"), (PyObject*)NULL))
464
+
465
+ static CYTHON_INLINE PyObject *__Pyx_GetItemInt_{{type}}_Fast(PyObject *o, Py_ssize_t i,
466
+ int wraparound, int boundscheck);
467
+ {{endfor}}
468
+
469
+ static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
470
+ static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
471
+ int is_list, int wraparound, int boundscheck);
472
+
473
+ /////////////// GetItemInt ///////////////
474
+ //@substitute: tempita
475
+
476
+ static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
477
+ PyObject *r;
478
+ if (unlikely(!j)) return NULL;
479
+ r = PyObject_GetItem(o, j);
480
+ Py_DECREF(j);
481
+ return r;
482
+ }
483
+
484
+ {{for type in ['List', 'Tuple']}}
485
+ static CYTHON_INLINE PyObject *__Pyx_GetItemInt_{{type}}_Fast(PyObject *o, Py_ssize_t i,
486
+ CYTHON_NCP_UNUSED int wraparound,
487
+ CYTHON_NCP_UNUSED int boundscheck) {
488
+ #if CYTHON_ASSUME_SAFE_MACROS && CYTHON_ASSUME_SAFE_SIZE && !CYTHON_AVOID_BORROWED_REFS{{if type == 'List'}} && !CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS{{endif}}
489
+ Py_ssize_t wrapped_i = i;
490
+ if (wraparound & unlikely(i < 0)) {
491
+ wrapped_i += Py{{type}}_GET_SIZE(o);
492
+ }
493
+ if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, Py{{type}}_GET_SIZE(o)))) {
494
+ PyObject *r = Py{{type}}_GET_ITEM(o, wrapped_i);
495
+ Py_INCREF(r);
496
+ return r;
497
+ }
498
+ return __Pyx_GetItemInt_Generic(o, PyLong_FromSsize_t(i));
499
+ #else
500
+ return PySequence_GetItem(o, i);
501
+ #endif
502
+ }
503
+ {{endfor}}
504
+
505
+ static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
506
+ CYTHON_NCP_UNUSED int wraparound,
507
+ CYTHON_NCP_UNUSED int boundscheck) {
508
+ #if CYTHON_ASSUME_SAFE_MACROS && CYTHON_ASSUME_SAFE_SIZE && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
509
+ if (is_list || PyList_CheckExact(o)) {
510
+ Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
511
+ if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) {
512
+ return __Pyx_PyList_GetItemRef(o, n);
513
+ }
514
+ }
515
+ else if (PyTuple_CheckExact(o)) {
516
+ Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
517
+ if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) {
518
+ PyObject *r = PyTuple_GET_ITEM(o, n);
519
+ Py_INCREF(r);
520
+ return r;
521
+ }
522
+ } else {
523
+ // inlined PySequence_GetItem() + special cased length overflow
524
+ PyMappingMethods *mm = Py_TYPE(o)->tp_as_mapping;
525
+ PySequenceMethods *sm = Py_TYPE(o)->tp_as_sequence;
526
+ if (mm && mm->mp_subscript) {
527
+ PyObject *r, *key = PyLong_FromSsize_t(i);
528
+ if (unlikely(!key)) return NULL;
529
+ r = mm->mp_subscript(o, key);
530
+ Py_DECREF(key);
531
+ return r;
532
+ }
533
+ if (likely(sm && sm->sq_item)) {
534
+ if (wraparound && unlikely(i < 0) && likely(sm->sq_length)) {
535
+ Py_ssize_t l = sm->sq_length(o);
536
+ if (likely(l >= 0)) {
537
+ i += l;
538
+ } else {
539
+ // if length > max(Py_ssize_t), maybe the object can wrap around itself?
540
+ if (!PyErr_ExceptionMatches(PyExc_OverflowError))
541
+ return NULL;
542
+ PyErr_Clear();
543
+ }
544
+ }
545
+ return sm->sq_item(o, i);
546
+ }
547
+ }
548
+ #else
549
+ // PySequence_GetItem behaves differently to PyObject_GetItem for i<0
550
+ // and possibly some other cases so can't generally be substituted
551
+ if (is_list || !PyMapping_Check(o)) {
552
+ return PySequence_GetItem(o, i);
553
+ }
554
+ #endif
555
+ return __Pyx_GetItemInt_Generic(o, PyLong_FromSsize_t(i));
556
+ }
557
+
558
+ /////////////// SetItemInt.proto ///////////////
559
+
560
+ #define __Pyx_SetItemInt(o, i, v, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \
561
+ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \
562
+ __Pyx_SetItemInt_Fast(o, (Py_ssize_t)i, v, is_list, wraparound, boundscheck) : \
563
+ (is_list ? (PyErr_SetString(PyExc_IndexError, "list assignment index out of range"), -1) : \
564
+ __Pyx_SetItemInt_Generic(o, to_py_func(i), v)))
565
+
566
+ static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v);
567
+ static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v,
568
+ int is_list, int wraparound, int boundscheck);
569
+
570
+ /////////////// SetItemInt ///////////////
571
+
572
+ static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) {
573
+ int r;
574
+ if (unlikely(!j)) return -1;
575
+ r = PyObject_SetItem(o, j, v);
576
+ Py_DECREF(j);
577
+ return r;
578
+ }
579
+
580
+ static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, int is_list,
581
+ CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) {
582
+ #if CYTHON_ASSUME_SAFE_MACROS && CYTHON_ASSUME_SAFE_SIZE && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
583
+ if (is_list || PyList_CheckExact(o)) {
584
+ Py_ssize_t n = (!wraparound) ? i : ((likely(i >= 0)) ? i : i + PyList_GET_SIZE(o));
585
+ if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o)))) {
586
+ Py_INCREF(v);
587
+ #if CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS
588
+ PyList_SetItem(o, n, v);
589
+ #else
590
+ PyObject* old = PyList_GET_ITEM(o, n);
591
+ PyList_SET_ITEM(o, n, v);
592
+ Py_DECREF(old);
593
+ #endif
594
+ return 1;
595
+ }
596
+ } else {
597
+ // inlined PySequence_SetItem() + special cased length overflow
598
+ PyMappingMethods *mm = Py_TYPE(o)->tp_as_mapping;
599
+ PySequenceMethods *sm = Py_TYPE(o)->tp_as_sequence;
600
+ if (mm && mm->mp_ass_subscript) {
601
+ int r;
602
+ PyObject *key = PyLong_FromSsize_t(i);
603
+ if (unlikely(!key)) return -1;
604
+ r = mm->mp_ass_subscript(o, key, v);
605
+ Py_DECREF(key);
606
+ return r;
607
+ }
608
+ if (likely(sm && sm->sq_ass_item)) {
609
+ if (wraparound && unlikely(i < 0) && likely(sm->sq_length)) {
610
+ Py_ssize_t l = sm->sq_length(o);
611
+ if (likely(l >= 0)) {
612
+ i += l;
613
+ } else {
614
+ // if length > max(Py_ssize_t), maybe the object can wrap around itself?
615
+ if (!PyErr_ExceptionMatches(PyExc_OverflowError))
616
+ return -1;
617
+ PyErr_Clear();
618
+ }
619
+ }
620
+ return sm->sq_ass_item(o, i, v);
621
+ }
622
+ }
623
+ #else
624
+ // PySequence_SetItem behaves differently to PyObject_SetItem for i<0
625
+ // and possibly some other cases so can't generally be substituted
626
+ if (is_list || !PyMapping_Check(o))
627
+ {
628
+ return PySequence_SetItem(o, i, v);
629
+ }
630
+ #endif
631
+ return __Pyx_SetItemInt_Generic(o, PyLong_FromSsize_t(i), v);
632
+ }
633
+
634
+
635
+ /////////////// DelItemInt.proto ///////////////
636
+
637
+ #define __Pyx_DelItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \
638
+ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \
639
+ __Pyx_DelItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound) : \
640
+ (is_list ? (PyErr_SetString(PyExc_IndexError, "list assignment index out of range"), -1) : \
641
+ __Pyx_DelItem_Generic(o, to_py_func(i))))
642
+
643
+ static int __Pyx_DelItem_Generic(PyObject *o, PyObject *j);
644
+ static CYTHON_INLINE int __Pyx_DelItemInt_Fast(PyObject *o, Py_ssize_t i,
645
+ int is_list, int wraparound);
646
+
647
+ /////////////// DelItemInt ///////////////
648
+
649
+ static int __Pyx_DelItem_Generic(PyObject *o, PyObject *j) {
650
+ int r;
651
+ if (unlikely(!j)) return -1;
652
+ r = PyObject_DelItem(o, j);
653
+ Py_DECREF(j);
654
+ return r;
655
+ }
656
+
657
+ static CYTHON_INLINE int __Pyx_DelItemInt_Fast(PyObject *o, Py_ssize_t i,
658
+ int is_list, CYTHON_NCP_UNUSED int wraparound) {
659
+ #if !CYTHON_USE_TYPE_SLOTS
660
+ // PySequence_DelItem behaves differently to PyObject_DelItem for i<0
661
+ // and possibly some other cases so can't generally be substituted
662
+ if (is_list || !PyMapping_Check(o)) {
663
+ return PySequence_DelItem(o, i);
664
+ }
665
+ #else
666
+ // inlined PySequence_DelItem() + special cased length overflow
667
+ PyMappingMethods *mm = Py_TYPE(o)->tp_as_mapping;
668
+ PySequenceMethods *sm = Py_TYPE(o)->tp_as_sequence;
669
+ if ((!is_list) && mm && mm->mp_ass_subscript) {
670
+ PyObject *key = PyLong_FromSsize_t(i);
671
+ return likely(key) ? mm->mp_ass_subscript(o, key, (PyObject *)NULL) : -1;
672
+ }
673
+ if (likely(sm && sm->sq_ass_item)) {
674
+ if (wraparound && unlikely(i < 0) && likely(sm->sq_length)) {
675
+ Py_ssize_t l = sm->sq_length(o);
676
+ if (likely(l >= 0)) {
677
+ i += l;
678
+ } else {
679
+ // if length > max(Py_ssize_t), maybe the object can wrap around itself?
680
+ if (!PyErr_ExceptionMatches(PyExc_OverflowError))
681
+ return -1;
682
+ PyErr_Clear();
683
+ }
684
+ }
685
+ return sm->sq_ass_item(o, i, (PyObject *)NULL);
686
+ }
687
+ #endif
688
+ return __Pyx_DelItem_Generic(o, PyLong_FromSsize_t(i));
689
+ }
690
+
691
+
692
+ /////////////// SliceObject.proto ///////////////
693
+
694
+ // we pass pointer addresses to show the C compiler what is NULL and what isn't
695
+ {{if access == 'Get'}}
696
+ static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(
697
+ PyObject* obj, Py_ssize_t cstart, Py_ssize_t cstop,
698
+ PyObject** py_start, PyObject** py_stop, PyObject** py_slice,
699
+ int has_cstart, int has_cstop, int wraparound);
700
+ {{else}}
701
+ #define __Pyx_PyObject_DelSlice(obj, cstart, cstop, py_start, py_stop, py_slice, has_cstart, has_cstop, wraparound) \
702
+ __Pyx_PyObject_SetSlice(obj, (PyObject*)NULL, cstart, cstop, py_start, py_stop, py_slice, has_cstart, has_cstop, wraparound)
703
+
704
+ // we pass pointer addresses to show the C compiler what is NULL and what isn't
705
+ static CYTHON_INLINE int __Pyx_PyObject_SetSlice(
706
+ PyObject* obj, PyObject* value, Py_ssize_t cstart, Py_ssize_t cstop,
707
+ PyObject** py_start, PyObject** py_stop, PyObject** py_slice,
708
+ int has_cstart, int has_cstop, int wraparound);
709
+ {{endif}}
710
+
711
+ /////////////// SliceObject ///////////////
712
+
713
+ {{if access == 'Get'}}
714
+ static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(PyObject* obj,
715
+ {{else}}
716
+ static CYTHON_INLINE int __Pyx_PyObject_SetSlice(PyObject* obj, PyObject* value,
717
+ {{endif}}
718
+ Py_ssize_t cstart, Py_ssize_t cstop,
719
+ PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice,
720
+ int has_cstart, int has_cstop, int wraparound) {
721
+ __Pyx_TypeName obj_type_name;
722
+ #if CYTHON_USE_TYPE_SLOTS
723
+ PyMappingMethods* mp = Py_TYPE(obj)->tp_as_mapping;
724
+ CYTHON_UNUSED_VAR(wraparound);
725
+ {{if access == 'Get'}}
726
+ if (likely(mp && mp->mp_subscript))
727
+ {{else}}
728
+ if (likely(mp && mp->mp_ass_subscript))
729
+ {{endif}}
730
+ #endif
731
+ {
732
+ {{if access == 'Get'}}PyObject*{{else}}int{{endif}} result;
733
+ PyObject *py_slice, *py_start, *py_stop;
734
+ if (_py_slice) {
735
+ py_slice = *_py_slice;
736
+ } else {
737
+ PyObject* owned_start = NULL;
738
+ PyObject* owned_stop = NULL;
739
+ if (_py_start) {
740
+ py_start = *_py_start;
741
+ } else {
742
+ if (has_cstart) {
743
+ owned_start = py_start = PyLong_FromSsize_t(cstart);
744
+ if (unlikely(!py_start)) goto bad;
745
+ } else
746
+ py_start = Py_None;
747
+ }
748
+ if (_py_stop) {
749
+ py_stop = *_py_stop;
750
+ } else {
751
+ if (has_cstop) {
752
+ owned_stop = py_stop = PyLong_FromSsize_t(cstop);
753
+ if (unlikely(!py_stop)) {
754
+ Py_XDECREF(owned_start);
755
+ goto bad;
756
+ }
757
+ } else
758
+ py_stop = Py_None;
759
+ }
760
+ py_slice = PySlice_New(py_start, py_stop, Py_None);
761
+ Py_XDECREF(owned_start);
762
+ Py_XDECREF(owned_stop);
763
+ if (unlikely(!py_slice)) goto bad;
764
+ }
765
+ #if CYTHON_USE_TYPE_SLOTS
766
+ {{if access == 'Get'}}
767
+ result = mp->mp_subscript(obj, py_slice);
768
+ #else
769
+ result = PyObject_GetItem(obj, py_slice);
770
+ {{else}}
771
+ result = mp->mp_ass_subscript(obj, py_slice, value);
772
+ #else
773
+ result = value ? PyObject_SetItem(obj, py_slice, value) : PyObject_DelItem(obj, py_slice);
774
+ {{endif}}
775
+ #endif
776
+ if (!_py_slice) {
777
+ Py_DECREF(py_slice);
778
+ }
779
+ return result;
780
+ }
781
+ obj_type_name = __Pyx_PyType_GetName(Py_TYPE(obj));
782
+ PyErr_Format(PyExc_TypeError,
783
+ {{if access == 'Get'}}
784
+ "'" __Pyx_FMT_TYPENAME "' object is unsliceable", obj_type_name);
785
+ {{else}}
786
+ "'" __Pyx_FMT_TYPENAME "' object does not support slice %.10s",
787
+ obj_type_name, value ? "assignment" : "deletion");
788
+ {{endif}}
789
+ __Pyx_DECREF_TypeName(obj_type_name);
790
+
791
+ bad:
792
+ return {{if access == 'Get'}}NULL{{else}}-1{{endif}};
793
+ }
794
+
795
+
796
+ /////////////// TupleAndListFromArray.proto ///////////////
797
+
798
+ #if CYTHON_COMPILING_IN_CPYTHON
799
+ static CYTHON_INLINE PyObject* __Pyx_PyList_FromArray(PyObject *const *src, Py_ssize_t n);
800
+ #endif
801
+ #if CYTHON_COMPILING_IN_CPYTHON || CYTHON_METH_FASTCALL
802
+ static CYTHON_INLINE PyObject* __Pyx_PyTuple_FromArray(PyObject *const *src, Py_ssize_t n);
803
+ #endif
804
+
805
+
806
+ /////////////// TupleAndListFromArray ///////////////
807
+
808
+ #if !CYTHON_COMPILING_IN_CPYTHON && CYTHON_METH_FASTCALL
809
+ static CYTHON_INLINE PyObject *
810
+ __Pyx_PyTuple_FromArray(PyObject *const *src, Py_ssize_t n)
811
+ {
812
+ PyObject *res;
813
+ Py_ssize_t i;
814
+ if (n <= 0) {
815
+ return __Pyx_NewRef(EMPTY(tuple));
816
+ }
817
+ res = PyTuple_New(n);
818
+ if (unlikely(res == NULL)) return NULL;
819
+ for (i = 0; i < n; i++) {
820
+ if (unlikely(__Pyx_PyTuple_SET_ITEM(res, i, src[i]) < 0)) {
821
+ Py_DECREF(res);
822
+ return NULL;
823
+ }
824
+ Py_INCREF(src[i]);
825
+ }
826
+ return res;
827
+ }
828
+ #elif CYTHON_COMPILING_IN_CPYTHON
829
+ static CYTHON_INLINE void __Pyx_copy_object_array(PyObject *const *CYTHON_RESTRICT src, PyObject** CYTHON_RESTRICT dest, Py_ssize_t length) {
830
+ PyObject *v;
831
+ Py_ssize_t i;
832
+ for (i = 0; i < length; i++) {
833
+ v = dest[i] = src[i];
834
+ Py_INCREF(v);
835
+ }
836
+ }
837
+
838
+ static CYTHON_INLINE PyObject *
839
+ __Pyx_PyTuple_FromArray(PyObject *const *src, Py_ssize_t n)
840
+ {
841
+ PyObject *res;
842
+ if (n <= 0) {
843
+ return __Pyx_NewRef(EMPTY(tuple));
844
+ }
845
+ res = PyTuple_New(n);
846
+ if (unlikely(res == NULL)) return NULL;
847
+ __Pyx_copy_object_array(src, ((PyTupleObject*)res)->ob_item, n);
848
+ return res;
849
+ }
850
+
851
+ static CYTHON_INLINE PyObject *
852
+ __Pyx_PyList_FromArray(PyObject *const *src, Py_ssize_t n)
853
+ {
854
+ PyObject *res;
855
+ if (n <= 0) {
856
+ return PyList_New(0);
857
+ }
858
+ res = PyList_New(n);
859
+ if (unlikely(res == NULL)) return NULL;
860
+ __Pyx_copy_object_array(src, ((PyListObject*)res)->ob_item, n);
861
+ return res;
862
+ }
863
+ #endif
864
+
865
+
866
+ /////////////// SliceTupleAndList.proto ///////////////
867
+
868
+ #if CYTHON_COMPILING_IN_CPYTHON
869
+ static CYTHON_INLINE PyObject* __Pyx_PyList_GetSlice(PyObject* src, Py_ssize_t start, Py_ssize_t stop);
870
+ static CYTHON_INLINE PyObject* __Pyx_PyTuple_GetSlice(PyObject* src, Py_ssize_t start, Py_ssize_t stop);
871
+ #else
872
+ #define __Pyx_PyList_GetSlice(seq, start, stop) PySequence_GetSlice(seq, start, stop)
873
+ #define __Pyx_PyTuple_GetSlice(seq, start, stop) PySequence_GetSlice(seq, start, stop)
874
+ #endif
875
+
876
+ /////////////// SliceTupleAndList ///////////////
877
+ //@requires: TupleAndListFromArray
878
+ //@substitute: tempita
879
+
880
+ #if CYTHON_COMPILING_IN_CPYTHON
881
+ static CYTHON_INLINE void __Pyx_crop_slice(Py_ssize_t* _start, Py_ssize_t* _stop, Py_ssize_t* _length) {
882
+ Py_ssize_t start = *_start, stop = *_stop, length = *_length;
883
+ if (start < 0) {
884
+ start += length;
885
+ if (start < 0)
886
+ start = 0;
887
+ }
888
+
889
+ if (stop < 0)
890
+ stop += length;
891
+ else if (stop > length)
892
+ stop = length;
893
+
894
+ *_length = stop - start;
895
+ *_start = start;
896
+ *_stop = stop;
897
+ }
898
+
899
+ {{for type in ['List', 'Tuple']}}
900
+ static CYTHON_INLINE PyObject* __Pyx_Py{{type}}_GetSlice(
901
+ PyObject* src, Py_ssize_t start, Py_ssize_t stop) {
902
+ Py_ssize_t length = Py{{type}}_GET_SIZE(src);
903
+ __Pyx_crop_slice(&start, &stop, &length);
904
+ {{if type=='List'}}
905
+ if (length <= 0) {
906
+ // Avoid undefined behaviour when accessing `ob_item` of an empty list.
907
+ return PyList_New(0);
908
+ }
909
+ {{endif}}
910
+ return __Pyx_Py{{type}}_FromArray(((Py{{type}}Object*)src)->ob_item + start, length);
911
+ }
912
+ {{endfor}}
913
+ #endif
914
+
915
+
916
+ /////////////// CalculateMetaclass.proto ///////////////
917
+
918
+ static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases);
919
+
920
+ /////////////// CalculateMetaclass ///////////////
921
+
922
+ static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases) {
923
+ Py_ssize_t i, nbases;
924
+ #if CYTHON_ASSUME_SAFE_SIZE
925
+ nbases = PyTuple_GET_SIZE(bases);
926
+ #else
927
+ nbases = PyTuple_Size(bases);
928
+ if (nbases < 0) return NULL;
929
+ #endif
930
+ for (i=0; i < nbases; i++) {
931
+ PyTypeObject *tmptype;
932
+ #if CYTHON_ASSUME_SAFE_MACROS
933
+ PyObject *tmp = PyTuple_GET_ITEM(bases, i);
934
+ #else
935
+ PyObject *tmp = PyTuple_GetItem(bases, i);
936
+ if (!tmp) return NULL;
937
+ #endif
938
+ tmptype = Py_TYPE(tmp);
939
+ if (!metaclass) {
940
+ metaclass = tmptype;
941
+ continue;
942
+ }
943
+ if (PyType_IsSubtype(metaclass, tmptype))
944
+ continue;
945
+ if (PyType_IsSubtype(tmptype, metaclass)) {
946
+ metaclass = tmptype;
947
+ continue;
948
+ }
949
+ // else:
950
+ PyErr_SetString(PyExc_TypeError,
951
+ "metaclass conflict: "
952
+ "the metaclass of a derived class "
953
+ "must be a (non-strict) subclass "
954
+ "of the metaclasses of all its bases");
955
+ return NULL;
956
+ }
957
+ if (!metaclass) {
958
+ metaclass = &PyType_Type;
959
+ }
960
+ // make owned reference
961
+ Py_INCREF((PyObject*) metaclass);
962
+ return (PyObject*) metaclass;
963
+ }
964
+
965
+
966
+ /////////////// FindInheritedMetaclass.proto ///////////////
967
+
968
+ static PyObject *__Pyx_FindInheritedMetaclass(PyObject *bases); /*proto*/
969
+
970
+ /////////////// FindInheritedMetaclass ///////////////
971
+ //@requires: PyObjectGetAttrStr
972
+ //@requires: CalculateMetaclass
973
+
974
+ static PyObject *__Pyx_FindInheritedMetaclass(PyObject *bases) {
975
+ PyObject *metaclass;
976
+ #if CYTHON_ASSUME_SAFE_SIZE
977
+ if (PyTuple_Check(bases) && PyTuple_GET_SIZE(bases) > 0)
978
+ #else
979
+ Py_ssize_t tuple_size = PyTuple_Check(bases) ? PyTuple_Size(bases) : 0;
980
+ if (unlikely(tuple_size < 0)) return NULL;
981
+ if (tuple_size > 0)
982
+ #endif
983
+ {
984
+ PyTypeObject *metatype;
985
+ #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
986
+ PyObject *base = PyTuple_GET_ITEM(bases, 0);
987
+ #else
988
+ PyObject *base = __Pyx_PySequence_ITEM(bases, 0);
989
+ #endif
990
+ metatype = Py_TYPE(base);
991
+ metaclass = __Pyx_CalculateMetaclass(metatype, bases);
992
+ #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
993
+ Py_DECREF(base);
994
+ #endif
995
+ } else {
996
+ // no bases => use default metaclass
997
+ metaclass = (PyObject *) &PyType_Type;
998
+ Py_INCREF(metaclass);
999
+ }
1000
+ return metaclass;
1001
+ }
1002
+
1003
+ /////////////// Py3MetaclassGet.proto ///////////////
1004
+
1005
+ static PyObject *__Pyx_Py3MetaclassGet(PyObject *bases, PyObject *mkw); /*proto*/
1006
+
1007
+ /////////////// Py3MetaclassGet ///////////////
1008
+ //@requires: FindInheritedMetaclass
1009
+ //@requires: CalculateMetaclass
1010
+
1011
+ static PyObject *__Pyx_Py3MetaclassGet(PyObject *bases, PyObject *mkw) {
1012
+ PyObject *metaclass = mkw ? __Pyx_PyDict_GetItemStr(mkw, PYIDENT("metaclass")) : NULL;
1013
+ if (metaclass) {
1014
+ Py_INCREF(metaclass);
1015
+ if (PyDict_DelItem(mkw, PYIDENT("metaclass")) < 0) {
1016
+ Py_DECREF(metaclass);
1017
+ return NULL;
1018
+ }
1019
+ if (PyType_Check(metaclass)) {
1020
+ PyObject* orig = metaclass;
1021
+ metaclass = __Pyx_CalculateMetaclass((PyTypeObject*) metaclass, bases);
1022
+ Py_DECREF(orig);
1023
+ }
1024
+ return metaclass;
1025
+ }
1026
+ return __Pyx_FindInheritedMetaclass(bases);
1027
+ }
1028
+
1029
+ /////////////// CreateClass.proto ///////////////
1030
+
1031
+ static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name,
1032
+ PyObject *qualname, PyObject *modname); /*proto*/
1033
+
1034
+ /////////////// CreateClass ///////////////
1035
+ //@requires: FindInheritedMetaclass
1036
+ //@requires: CalculateMetaclass
1037
+
1038
+ static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name,
1039
+ PyObject *qualname, PyObject *modname) {
1040
+ PyObject *result;
1041
+ PyObject *metaclass;
1042
+
1043
+ if (unlikely(PyDict_SetItem(dict, PYIDENT("__module__"), modname) < 0))
1044
+ return NULL;
1045
+ if (unlikely(PyDict_SetItem(dict, PYIDENT("__qualname__"), qualname) < 0))
1046
+ return NULL;
1047
+
1048
+ /* Python2 __metaclass__ */
1049
+ metaclass = __Pyx_PyDict_GetItemStr(dict, PYIDENT("__metaclass__"));
1050
+ if (metaclass) {
1051
+ Py_INCREF(metaclass);
1052
+ if (PyType_Check(metaclass)) {
1053
+ PyObject* orig = metaclass;
1054
+ metaclass = __Pyx_CalculateMetaclass((PyTypeObject*) metaclass, bases);
1055
+ Py_DECREF(orig);
1056
+ }
1057
+ } else {
1058
+ metaclass = __Pyx_FindInheritedMetaclass(bases);
1059
+ }
1060
+ if (unlikely(!metaclass))
1061
+ return NULL;
1062
+ result = PyObject_CallFunctionObjArgs(metaclass, name, bases, dict, NULL);
1063
+ Py_DECREF(metaclass);
1064
+ return result;
1065
+ }
1066
+
1067
+ /////////////// Py3UpdateBases.proto ///////////////
1068
+
1069
+ static PyObject* __Pyx_PEP560_update_bases(PyObject *bases); /* proto */
1070
+
1071
+ /////////////// Py3UpdateBases /////////////////////
1072
+ //@requires: PyObjectCallOneArg
1073
+ //@requires: PyObjectGetAttrStrNoError
1074
+
1075
+ /* Shamelessly adapted from cpython/bltinmodule.c update_bases */
1076
+ static PyObject*
1077
+ __Pyx_PEP560_update_bases(PyObject *bases)
1078
+ {
1079
+ Py_ssize_t i, j, size_bases;
1080
+ PyObject *base = NULL, *meth, *new_base, *result, *new_bases = NULL;
1081
+ /*assert(PyTuple_Check(bases));*/
1082
+
1083
+ #if CYTHON_ASSUME_SAFE_SIZE
1084
+ size_bases = PyTuple_GET_SIZE(bases);
1085
+ #else
1086
+ size_bases = PyTuple_Size(bases);
1087
+ if (size_bases < 0) return NULL;
1088
+ #endif
1089
+ for (i = 0; i < size_bases; i++) {
1090
+ // original code in CPython: base = args[i];
1091
+ #if CYTHON_AVOID_BORROWED_REFS
1092
+ Py_CLEAR(base);
1093
+ #endif
1094
+ #if CYTHON_ASSUME_SAFE_MACROS
1095
+ base = PyTuple_GET_ITEM(bases, i);
1096
+ #else
1097
+ base = PyTuple_GetItem(bases, i);
1098
+ if (!base) goto error;
1099
+ #endif
1100
+ #if CYTHON_AVOID_BORROWED_REFS
1101
+ Py_INCREF(base);
1102
+ #endif
1103
+ if (PyType_Check(base)) {
1104
+ if (new_bases) {
1105
+ // If we already have made a replacement, then we append every normal base,
1106
+ // otherwise just skip it.
1107
+ if (PyList_Append(new_bases, base) < 0) {
1108
+ goto error;
1109
+ }
1110
+ }
1111
+ continue;
1112
+ }
1113
+ // original code in CPython:
1114
+ // if (_PyObject_LookupAttrId(base, &PyId___mro_entries__, &meth) < 0) {
1115
+ meth = __Pyx_PyObject_GetAttrStrNoError(base, PYIDENT("__mro_entries__"));
1116
+ if (!meth && PyErr_Occurred()) {
1117
+ goto error;
1118
+ }
1119
+ if (!meth) {
1120
+ if (new_bases) {
1121
+ if (PyList_Append(new_bases, base) < 0) {
1122
+ goto error;
1123
+ }
1124
+ }
1125
+ continue;
1126
+ }
1127
+ new_base = __Pyx_PyObject_CallOneArg(meth, bases);
1128
+ Py_DECREF(meth);
1129
+ if (!new_base) {
1130
+ goto error;
1131
+ }
1132
+ if (!PyTuple_Check(new_base)) {
1133
+ PyErr_SetString(PyExc_TypeError,
1134
+ "__mro_entries__ must return a tuple");
1135
+ Py_DECREF(new_base);
1136
+ goto error;
1137
+ }
1138
+ if (!new_bases) {
1139
+ // If this is a first successful replacement, create new_bases list and
1140
+ // copy previously encountered bases.
1141
+ if (!(new_bases = PyList_New(i))) {
1142
+ goto error;
1143
+ }
1144
+ for (j = 0; j < i; j++) {
1145
+ // original code in CPython: base = args[j];
1146
+ // We use a different name here to keep refcounting separate from base
1147
+ PyObject *base_from_list;
1148
+ #if CYTHON_ASSUME_SAFE_MACROS
1149
+ base_from_list = PyTuple_GET_ITEM(bases, j);
1150
+ PyList_SET_ITEM(new_bases, j, base_from_list);
1151
+ Py_INCREF(base_from_list);
1152
+ #else
1153
+ base_from_list = PyTuple_GetItem(bases, j);
1154
+ if (!base_from_list) goto error;
1155
+ Py_INCREF(base_from_list);
1156
+ if (PyList_SetItem(new_bases, j, base_from_list) < 0) goto error;
1157
+ #endif
1158
+ }
1159
+ }
1160
+ #if CYTHON_ASSUME_SAFE_SIZE
1161
+ j = PyList_GET_SIZE(new_bases);
1162
+ #else
1163
+ j = PyList_Size(new_bases);
1164
+ if (j < 0) goto error;
1165
+ #endif
1166
+ if (PyList_SetSlice(new_bases, j, j, new_base) < 0) {
1167
+ goto error;
1168
+ }
1169
+ Py_DECREF(new_base);
1170
+ }
1171
+ if (!new_bases) {
1172
+ // unlike the CPython implementation, always return a new reference
1173
+ Py_INCREF(bases);
1174
+ return bases;
1175
+ }
1176
+ result = PyList_AsTuple(new_bases);
1177
+ Py_DECREF(new_bases);
1178
+ #if CYTHON_AVOID_BORROWED_REFS
1179
+ Py_XDECREF(base);
1180
+ #endif
1181
+ return result;
1182
+
1183
+ error:
1184
+ Py_XDECREF(new_bases);
1185
+ #if CYTHON_AVOID_BORROWED_REFS
1186
+ Py_XDECREF(base);
1187
+ #endif
1188
+ return NULL;
1189
+ }
1190
+
1191
+ /////////////// Py3ClassCreate.proto ///////////////
1192
+
1193
+ static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, PyObject *qualname,
1194
+ PyObject *mkw, PyObject *modname, PyObject *doc); /*proto*/
1195
+ static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases, PyObject *dict,
1196
+ PyObject *mkw, int calculate_metaclass, int allow_py2_metaclass); /*proto*/
1197
+
1198
+ /////////////// Py3ClassCreate ///////////////
1199
+ //@requires: PyObjectGetAttrStrNoError
1200
+ //@requires: CalculateMetaclass
1201
+ //@requires: PyObjectFastCall
1202
+ //@requires: PyObjectCall2Args
1203
+ //@requires: PyObjectLookupSpecial
1204
+ // only in fallback code:
1205
+
1206
+ static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name,
1207
+ PyObject *qualname, PyObject *mkw, PyObject *modname, PyObject *doc) {
1208
+ PyObject *ns;
1209
+ if (metaclass) {
1210
+ PyObject *prep = __Pyx_PyObject_GetAttrStrNoError(metaclass, PYIDENT("__prepare__"));
1211
+ if (prep) {
1212
+ PyObject *pargs[3] = {NULL, name, bases};
1213
+ ns = __Pyx_PyObject_FastCallDict(prep, pargs+1, 2 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET, mkw);
1214
+ Py_DECREF(prep);
1215
+ } else {
1216
+ if (unlikely(PyErr_Occurred()))
1217
+ return NULL;
1218
+ ns = PyDict_New();
1219
+ }
1220
+ } else {
1221
+ ns = PyDict_New();
1222
+ }
1223
+
1224
+ if (unlikely(!ns))
1225
+ return NULL;
1226
+
1227
+ /* Required here to emulate assignment order */
1228
+ if (unlikely(PyObject_SetItem(ns, PYIDENT("__module__"), modname) < 0)) goto bad;
1229
+ if (unlikely(PyObject_SetItem(ns, PYIDENT("__qualname__"), qualname) < 0)) goto bad;
1230
+ if (unlikely(doc && PyObject_SetItem(ns, PYIDENT("__doc__"), doc) < 0)) goto bad;
1231
+ return ns;
1232
+ bad:
1233
+ Py_DECREF(ns);
1234
+ return NULL;
1235
+ }
1236
+
1237
+ static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases,
1238
+ PyObject *dict, PyObject *mkw,
1239
+ int calculate_metaclass, int allow_py2_metaclass) {
1240
+ PyObject *result;
1241
+ PyObject *owned_metaclass = NULL;
1242
+ PyObject *margs[4] = {NULL, name, bases, dict};
1243
+ if (allow_py2_metaclass) {
1244
+ /* honour Python2 __metaclass__ for backward compatibility */
1245
+ owned_metaclass = PyObject_GetItem(dict, PYIDENT("__metaclass__"));
1246
+ if (owned_metaclass) {
1247
+ metaclass = owned_metaclass;
1248
+ } else if (likely(PyErr_ExceptionMatches(PyExc_KeyError))) {
1249
+ PyErr_Clear();
1250
+ } else {
1251
+ return NULL;
1252
+ }
1253
+ }
1254
+ if (calculate_metaclass && (!metaclass || PyType_Check(metaclass))) {
1255
+ metaclass = __Pyx_CalculateMetaclass((PyTypeObject*) metaclass, bases);
1256
+ Py_XDECREF(owned_metaclass);
1257
+ if (unlikely(!metaclass))
1258
+ return NULL;
1259
+ owned_metaclass = metaclass;
1260
+ }
1261
+ result = __Pyx_PyObject_FastCallDict(metaclass, margs+1, 3 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET, mkw);
1262
+ Py_XDECREF(owned_metaclass);
1263
+ return result;
1264
+ }
1265
+
1266
+ /////////////// ExtTypeTest.proto ///////////////
1267
+
1268
+ static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/
1269
+
1270
+ /////////////// ExtTypeTest ///////////////
1271
+
1272
+ static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
1273
+ __Pyx_TypeName obj_type_name;
1274
+ __Pyx_TypeName type_name;
1275
+ if (unlikely(!type)) {
1276
+ PyErr_SetString(PyExc_SystemError, "Missing type object");
1277
+ return 0;
1278
+ }
1279
+ if (likely(__Pyx_TypeCheck(obj, type)))
1280
+ return 1;
1281
+ obj_type_name = __Pyx_PyType_GetName(Py_TYPE(obj));
1282
+ type_name = __Pyx_PyType_GetName(type);
1283
+ PyErr_Format(PyExc_TypeError,
1284
+ "Cannot convert " __Pyx_FMT_TYPENAME " to " __Pyx_FMT_TYPENAME,
1285
+ obj_type_name, type_name);
1286
+ __Pyx_DECREF_TypeName(obj_type_name);
1287
+ __Pyx_DECREF_TypeName(type_name);
1288
+ return 0;
1289
+ }
1290
+
1291
+ /////////////// CallableCheck.proto ///////////////
1292
+
1293
+ #if CYTHON_USE_TYPE_SLOTS
1294
+ #define __Pyx_PyCallable_Check(obj) (Py_TYPE(obj)->tp_call != NULL)
1295
+ #else
1296
+ #define __Pyx_PyCallable_Check(obj) PyCallable_Check(obj)
1297
+ #endif
1298
+
1299
+ /////////////// PyDictContains.proto ///////////////
1300
+
1301
+ static CYTHON_INLINE int __Pyx_PyDict_ContainsTF(PyObject* item, PyObject* dict, int eq) {
1302
+ int result = PyDict_Contains(dict, item);
1303
+ return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
1304
+ }
1305
+
1306
+ /////////////// PySetContains.proto ///////////////
1307
+
1308
+ static CYTHON_INLINE int __Pyx_PySet_ContainsTF(PyObject* key, PyObject* set, int eq); /* proto */
1309
+
1310
+ /////////////// PySetContains ///////////////
1311
+ //@requires: Builtins.c::pyfrozenset_new
1312
+
1313
+ static int __Pyx_PySet_ContainsUnhashable(PyObject *set, PyObject *key) {
1314
+ int result = -1;
1315
+ if (PySet_Check(key) && PyErr_ExceptionMatches(PyExc_TypeError)) {
1316
+ /* Convert key to frozenset */
1317
+ PyObject *tmpkey;
1318
+ PyErr_Clear();
1319
+ tmpkey = __Pyx_PyFrozenSet_New(key);
1320
+ if (tmpkey != NULL) {
1321
+ result = PySet_Contains(set, tmpkey);
1322
+ Py_DECREF(tmpkey);
1323
+ }
1324
+ }
1325
+ return result;
1326
+ }
1327
+
1328
+ static CYTHON_INLINE int __Pyx_PySet_ContainsTF(PyObject* key, PyObject* set, int eq) {
1329
+ int result = PySet_Contains(set, key);
1330
+
1331
+ if (unlikely(result < 0)) {
1332
+ result = __Pyx_PySet_ContainsUnhashable(set, key);
1333
+ }
1334
+ return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
1335
+ }
1336
+
1337
+ /////////////// PySequenceContains.proto ///////////////
1338
+
1339
+ static CYTHON_INLINE int __Pyx_PySequence_ContainsTF(PyObject* item, PyObject* seq, int eq) {
1340
+ int result = PySequence_Contains(seq, item);
1341
+ return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
1342
+ }
1343
+
1344
+ /////////////// PyBoolOrNullFromLong.proto ///////////////
1345
+
1346
+ static CYTHON_INLINE PyObject* __Pyx_PyBoolOrNull_FromLong(long b) {
1347
+ return unlikely(b < 0) ? NULL : __Pyx_PyBool_FromLong(b);
1348
+ }
1349
+
1350
+ /////////////// GetBuiltinName.proto ///////////////
1351
+
1352
+ static PyObject *__Pyx_GetBuiltinName(PyObject *name); /*proto*/
1353
+
1354
+ /////////////// GetBuiltinName ///////////////
1355
+ //@requires: PyObjectGetAttrStrNoError
1356
+
1357
+ static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
1358
+ PyObject* result = __Pyx_PyObject_GetAttrStrNoError(NAMED_CGLOBAL(builtins_cname), name);
1359
+ if (unlikely(!result) && !PyErr_Occurred()) {
1360
+ PyErr_Format(PyExc_NameError,
1361
+ "name '%U' is not defined", name);
1362
+ }
1363
+ return result;
1364
+ }
1365
+
1366
+ /////////////// GetNameInClass.proto ///////////////
1367
+
1368
+ #define __Pyx_GetNameInClass(var, nmspace, name) (var) = __Pyx__GetNameInClass(nmspace, name)
1369
+ static PyObject *__Pyx__GetNameInClass(PyObject *nmspace, PyObject *name); /*proto*/
1370
+
1371
+ /////////////// GetNameInClass ///////////////
1372
+ //@requires: GetModuleGlobalName
1373
+
1374
+ static PyObject *__Pyx__GetNameInClass(PyObject *nmspace, PyObject *name) {
1375
+ PyObject *result;
1376
+ PyObject *dict;
1377
+ assert(PyType_Check(nmspace));
1378
+ #if CYTHON_USE_TYPE_SLOTS
1379
+ dict = ((PyTypeObject*)nmspace)->tp_dict;
1380
+ Py_XINCREF(dict);
1381
+ #else
1382
+ dict = PyObject_GetAttr(nmspace, PYIDENT("__dict__"));
1383
+ #endif
1384
+ if (likely(dict)) {
1385
+ result = PyObject_GetItem(dict, name);
1386
+ Py_DECREF(dict);
1387
+ if (result) {
1388
+ return result;
1389
+ }
1390
+ }
1391
+ PyErr_Clear();
1392
+ __Pyx_GetModuleGlobalNameUncached(result, name);
1393
+ return result;
1394
+ }
1395
+
1396
+
1397
+ /////////////// SetNameInClass.proto ///////////////
1398
+
1399
+ #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030d0000
1400
+ // Identifier names are always interned and have a pre-calculated hash value.
1401
+ #define __Pyx_SetNameInClass(ns, name, value) \
1402
+ (likely(PyDict_CheckExact(ns)) ? _PyDict_SetItem_KnownHash(ns, name, value, ((PyASCIIObject *) name)->hash) : PyObject_SetItem(ns, name, value))
1403
+ #elif CYTHON_COMPILING_IN_CPYTHON
1404
+ #define __Pyx_SetNameInClass(ns, name, value) \
1405
+ (likely(PyDict_CheckExact(ns)) ? PyDict_SetItem(ns, name, value) : PyObject_SetItem(ns, name, value))
1406
+ #else
1407
+ #define __Pyx_SetNameInClass(ns, name, value) PyObject_SetItem(ns, name, value)
1408
+ #endif
1409
+
1410
+ /////////////// SetNewInClass.proto ///////////////
1411
+
1412
+ static int __Pyx_SetNewInClass(PyObject *ns, PyObject *name, PyObject *value);
1413
+
1414
+ /////////////// SetNewInClass ///////////////
1415
+ //@requires: SetNameInClass
1416
+
1417
+ // Special-case setting __new__: if it's a Cython function, wrap it in a
1418
+ // staticmethod. This is similar to what Python does for a Python function
1419
+ // called __new__.
1420
+ static int __Pyx_SetNewInClass(PyObject *ns, PyObject *name, PyObject *value) {
1421
+ #ifdef __Pyx_CyFunction_USED
1422
+ int ret;
1423
+ if (__Pyx_CyFunction_Check(value)) {
1424
+ PyObject *staticnew;
1425
+ #if !CYTHON_COMPILING_IN_LIMITED_API
1426
+ staticnew = PyStaticMethod_New(value);
1427
+ #else
1428
+ PyObject *builtins, *staticmethod_str, *staticmethod;
1429
+ builtins = PyEval_GetBuiltins(); // borrowed
1430
+ if (!builtins) return -1;
1431
+ staticmethod_str = PyUnicode_FromStringAndSize("staticmethod", 12);
1432
+ if (!staticmethod_str) return -1;
1433
+ staticmethod = PyObject_GetItem(builtins, staticmethod_str);
1434
+ Py_DECREF(staticmethod_str);
1435
+ if (!staticmethod) return -1;
1436
+ staticnew = PyObject_CallFunctionObjArgs(staticmethod, value, NULL);
1437
+ Py_DECREF(staticmethod);
1438
+ #endif
1439
+ if (unlikely(!staticnew)) return -1;
1440
+ ret = __Pyx_SetNameInClass(ns, name, staticnew);
1441
+ Py_DECREF(staticnew);
1442
+ return ret;
1443
+ }
1444
+ #endif
1445
+ return __Pyx_SetNameInClass(ns, name, value);
1446
+ }
1447
+
1448
+
1449
+ /////////////// GetModuleGlobalName.proto ///////////////
1450
+ //@requires: PyDictVersioning
1451
+
1452
+ #if CYTHON_USE_DICT_VERSIONS
1453
+ #define __Pyx_GetModuleGlobalName(var, name) do { \
1454
+ static PY_UINT64_T __pyx_dict_version = 0; \
1455
+ static PyObject *__pyx_dict_cached_value = NULL; \
1456
+ (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(NAMED_CGLOBAL(moddict_cname)))) ? \
1457
+ (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) : \
1458
+ __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value); \
1459
+ } while(0)
1460
+ #define __Pyx_GetModuleGlobalNameUncached(var, name) do { \
1461
+ PY_UINT64_T __pyx_dict_version; \
1462
+ PyObject *__pyx_dict_cached_value; \
1463
+ (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value); \
1464
+ } while(0)
1465
+ static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value); /*proto*/
1466
+ #else
1467
+ #define __Pyx_GetModuleGlobalName(var, name) (var) = __Pyx__GetModuleGlobalName(name)
1468
+ #define __Pyx_GetModuleGlobalNameUncached(var, name) (var) = __Pyx__GetModuleGlobalName(name)
1469
+ static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name); /*proto*/
1470
+ #endif
1471
+
1472
+
1473
+ /////////////// GetModuleGlobalName ///////////////
1474
+ //@requires: GetBuiltinName
1475
+ //@substitute: naming
1476
+
1477
+ #if CYTHON_USE_DICT_VERSIONS
1478
+ static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value)
1479
+ #else
1480
+ static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
1481
+ #endif
1482
+ {
1483
+ PyObject *result;
1484
+ #if CYTHON_COMPILING_IN_LIMITED_API
1485
+ if (unlikely(!$module_cname)) {
1486
+ return NULL;
1487
+ }
1488
+ result = PyObject_GetAttr($module_cname, name);
1489
+ if (likely(result)) {
1490
+ return result;
1491
+ }
1492
+ #elif !CYTHON_AVOID_BORROWED_REFS && !CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS
1493
+ // Identifier names are always interned and have a pre-calculated hash value.
1494
+ result = _PyDict_GetItem_KnownHash(NAMED_CGLOBAL(moddict_cname), name, ((PyASCIIObject *) name)->hash);
1495
+ __PYX_UPDATE_DICT_CACHE(NAMED_CGLOBAL(moddict_cname), result, *dict_cached_value, *dict_version)
1496
+ if (likely(result)) {
1497
+ return __Pyx_NewRef(result);
1498
+ } else if (unlikely(PyErr_Occurred())) {
1499
+ return NULL;
1500
+ }
1501
+ #elif !CYTHON_AVOID_BORROWED_REFS
1502
+ if (unlikely(__Pyx_PyDict_GetItemRef(NAMED_CGLOBAL(moddict_cname), name, &result) == -1)) PyErr_Clear();
1503
+ __PYX_UPDATE_DICT_CACHE(NAMED_CGLOBAL(moddict_cname), result, *dict_cached_value, *dict_version)
1504
+ if (likely(result)) {
1505
+ return result;
1506
+ }
1507
+ #else
1508
+ result = PyObject_GetItem(NAMED_CGLOBAL(moddict_cname), name);
1509
+ __PYX_UPDATE_DICT_CACHE(NAMED_CGLOBAL(moddict_cname), result, *dict_cached_value, *dict_version)
1510
+ if (likely(result)) {
1511
+ return __Pyx_NewRef(result);
1512
+ }
1513
+ PyErr_Clear();
1514
+ #endif
1515
+ return __Pyx_GetBuiltinName(name);
1516
+ }
1517
+
1518
+ //////////////////// GetAttr.proto ////////////////////
1519
+
1520
+ static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *); /*proto*/
1521
+
1522
+ //////////////////// GetAttr ////////////////////
1523
+ //@requires: PyObjectGetAttrStr
1524
+
1525
+ static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
1526
+ #if CYTHON_USE_TYPE_SLOTS
1527
+ if (likely(PyUnicode_Check(n)))
1528
+ return __Pyx_PyObject_GetAttrStr(o, n);
1529
+ #endif
1530
+ return PyObject_GetAttr(o, n);
1531
+ }
1532
+
1533
+
1534
+ /////////////// PyObjectLookupSpecial.proto ///////////////
1535
+
1536
+ #if CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
1537
+ #define __Pyx_PyObject_LookupSpecialNoError(obj, attr_name) __Pyx__PyObject_LookupSpecial(obj, attr_name, 0)
1538
+ #define __Pyx_PyObject_LookupSpecial(obj, attr_name) __Pyx__PyObject_LookupSpecial(obj, attr_name, 1)
1539
+
1540
+ static CYTHON_INLINE PyObject* __Pyx__PyObject_LookupSpecial(PyObject* obj, PyObject* attr_name, int with_error); /*proto*/
1541
+
1542
+ #else
1543
+ #define __Pyx_PyObject_LookupSpecialNoError(o,n) __Pyx_PyObject_GetAttrStrNoError(o,n)
1544
+ #define __Pyx_PyObject_LookupSpecial(o,n) __Pyx_PyObject_GetAttrStr(o,n)
1545
+ #endif
1546
+
1547
+ /////////////// PyObjectLookupSpecial ///////////////
1548
+ //@requires: PyObjectGetAttrStr
1549
+ //@requires: PyObjectGetAttrStrNoError
1550
+
1551
+ #if CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
1552
+ static CYTHON_INLINE PyObject* __Pyx__PyObject_LookupSpecial(PyObject* obj, PyObject* attr_name, int with_error) {
1553
+ PyObject *res;
1554
+ PyTypeObject *tp = Py_TYPE(obj);
1555
+ // adapted from CPython's special_lookup() in ceval.c
1556
+ res = _PyType_Lookup(tp, attr_name);
1557
+ if (likely(res)) {
1558
+ descrgetfunc f = Py_TYPE(res)->tp_descr_get;
1559
+ if (!f) {
1560
+ Py_INCREF(res);
1561
+ } else {
1562
+ res = f(res, obj, (PyObject *)tp);
1563
+ }
1564
+ } else if (with_error) {
1565
+ PyErr_SetObject(PyExc_AttributeError, attr_name);
1566
+ }
1567
+ return res;
1568
+ }
1569
+ #endif
1570
+
1571
+ /////////////// PyObjectGetAttrStrNoError.proto ///////////////
1572
+
1573
+ static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name);/*proto*/
1574
+
1575
+ /////////////// PyObjectGetAttrStrNoError ///////////////
1576
+ //@requires: PyObjectGetAttrStr
1577
+ //@requires: Exceptions.c::PyThreadStateGet
1578
+ //@requires: Exceptions.c::PyErrFetchRestore
1579
+ //@requires: Exceptions.c::PyErrExceptionMatches
1580
+
1581
+ #if __PYX_LIMITED_VERSION_HEX < 0x030d00A1
1582
+ static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) {
1583
+ __Pyx_PyThreadState_declare
1584
+ __Pyx_PyThreadState_assign
1585
+ if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
1586
+ __Pyx_PyErr_Clear();
1587
+ }
1588
+ #endif
1589
+
1590
+ static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) {
1591
+ PyObject *result;
1592
+ #if __PYX_LIMITED_VERSION_HEX >= 0x030d00A1
1593
+ (void) PyObject_GetOptionalAttr(obj, attr_name, &result);
1594
+ return result;
1595
+ #else
1596
+ #if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS
1597
+ // _PyObject_GenericGetAttrWithDict() in CPython 3.7+ can avoid raising the AttributeError.
1598
+ // See https://bugs.python.org/issue32544
1599
+ PyTypeObject* tp = Py_TYPE(obj);
1600
+ if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) {
1601
+ return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1);
1602
+ }
1603
+ #endif
1604
+ result = __Pyx_PyObject_GetAttrStr(obj, attr_name);
1605
+ if (unlikely(!result)) {
1606
+ __Pyx_PyObject_GetAttrStr_ClearAttributeError();
1607
+ }
1608
+ return result;
1609
+ #endif
1610
+ }
1611
+
1612
+
1613
+ /////////////// PyObjectGetAttrStr.proto ///////////////
1614
+
1615
+ #if CYTHON_USE_TYPE_SLOTS
1616
+ static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);/*proto*/
1617
+ #else
1618
+ #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
1619
+ #endif
1620
+
1621
+ /////////////// PyObjectGetAttrStr ///////////////
1622
+
1623
+ #if CYTHON_USE_TYPE_SLOTS
1624
+ static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
1625
+ PyTypeObject* tp = Py_TYPE(obj);
1626
+ if (likely(tp->tp_getattro))
1627
+ return tp->tp_getattro(obj, attr_name);
1628
+ return PyObject_GetAttr(obj, attr_name);
1629
+ }
1630
+ #endif
1631
+
1632
+
1633
+ /////////////// PyObjectSetAttrStr.proto ///////////////
1634
+
1635
+ #if CYTHON_USE_TYPE_SLOTS
1636
+ #define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o, n, NULL)
1637
+ static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value);/*proto*/
1638
+ #else
1639
+ #define __Pyx_PyObject_DelAttrStr(o,n) PyObject_DelAttr(o,n)
1640
+ #define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v)
1641
+ #endif
1642
+
1643
+ /////////////// PyObjectSetAttrStr ///////////////
1644
+
1645
+ #if CYTHON_USE_TYPE_SLOTS
1646
+ static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) {
1647
+ PyTypeObject* tp = Py_TYPE(obj);
1648
+ if (likely(tp->tp_setattro))
1649
+ return tp->tp_setattro(obj, attr_name, value);
1650
+ return PyObject_SetAttr(obj, attr_name, value);
1651
+ }
1652
+ #endif
1653
+
1654
+
1655
+ /////////////// PyObjectGetMethod.proto ///////////////
1656
+
1657
+ static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method);/*proto*/
1658
+
1659
+ /////////////// PyObjectGetMethod ///////////////
1660
+ //@requires: PyObjectGetAttrStr
1661
+
1662
+ static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method) {
1663
+ PyObject *attr;
1664
+ #if CYTHON_UNPACK_METHODS && CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_PYTYPE_LOOKUP
1665
+ __Pyx_TypeName type_name;
1666
+ // Copied from _PyObject_GetMethod() in CPython 3.7
1667
+ PyTypeObject *tp = Py_TYPE(obj);
1668
+ PyObject *descr;
1669
+ descrgetfunc f = NULL;
1670
+ PyObject **dictptr, *dict;
1671
+ int meth_found = 0;
1672
+
1673
+ assert (*method == NULL);
1674
+
1675
+ if (unlikely(tp->tp_getattro != PyObject_GenericGetAttr)) {
1676
+ attr = __Pyx_PyObject_GetAttrStr(obj, name);
1677
+ goto try_unpack;
1678
+ }
1679
+ if (unlikely(tp->tp_dict == NULL) && unlikely(PyType_Ready(tp) < 0)) {
1680
+ return 0;
1681
+ }
1682
+
1683
+ descr = _PyType_Lookup(tp, name);
1684
+ if (likely(descr != NULL)) {
1685
+ Py_INCREF(descr);
1686
+ #if defined(Py_TPFLAGS_METHOD_DESCRIPTOR) && Py_TPFLAGS_METHOD_DESCRIPTOR
1687
+ if (__Pyx_PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_METHOD_DESCRIPTOR))
1688
+ #else
1689
+ // Repeating the condition below accommodates for MSVC's inability to test macros inside of macro expansions.
1690
+ #ifdef __Pyx_CyFunction_USED
1691
+ if (likely(PyFunction_Check(descr) || __Pyx_IS_TYPE(descr, &PyMethodDescr_Type) || __Pyx_CyFunction_Check(descr)))
1692
+ #else
1693
+ if (likely(PyFunction_Check(descr) || __Pyx_IS_TYPE(descr, &PyMethodDescr_Type)))
1694
+ #endif
1695
+ #endif
1696
+ {
1697
+ meth_found = 1;
1698
+ } else {
1699
+ f = Py_TYPE(descr)->tp_descr_get;
1700
+ if (f != NULL && PyDescr_IsData(descr)) {
1701
+ attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
1702
+ Py_DECREF(descr);
1703
+ goto try_unpack;
1704
+ }
1705
+ }
1706
+ }
1707
+
1708
+ dictptr = _PyObject_GetDictPtr(obj);
1709
+ if (dictptr != NULL && (dict = *dictptr) != NULL) {
1710
+ Py_INCREF(dict);
1711
+ attr = __Pyx_PyDict_GetItemStr(dict, name);
1712
+ if (attr != NULL) {
1713
+ Py_INCREF(attr);
1714
+ Py_DECREF(dict);
1715
+ Py_XDECREF(descr);
1716
+ goto try_unpack;
1717
+ }
1718
+ Py_DECREF(dict);
1719
+ }
1720
+
1721
+ if (meth_found) {
1722
+ *method = descr;
1723
+ return 1;
1724
+ }
1725
+
1726
+ if (f != NULL) {
1727
+ attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
1728
+ Py_DECREF(descr);
1729
+ goto try_unpack;
1730
+ }
1731
+
1732
+ if (likely(descr != NULL)) {
1733
+ *method = descr;
1734
+ return 0;
1735
+ }
1736
+
1737
+ type_name = __Pyx_PyType_GetName(tp);
1738
+ PyErr_Format(PyExc_AttributeError,
1739
+ "'" __Pyx_FMT_TYPENAME "' object has no attribute '%U'",
1740
+ type_name, name);
1741
+ __Pyx_DECREF_TypeName(type_name);
1742
+ return 0;
1743
+
1744
+ // Generic fallback implementation using normal attribute lookup.
1745
+ #else
1746
+ attr = __Pyx_PyObject_GetAttrStr(obj, name);
1747
+ goto try_unpack;
1748
+ #endif
1749
+
1750
+ try_unpack:
1751
+ #if CYTHON_UNPACK_METHODS
1752
+ // Even if we failed to avoid creating a bound method object, it's still worth unpacking it now, if possible.
1753
+ if (likely(attr) && PyMethod_Check(attr) && likely(PyMethod_GET_SELF(attr) == obj)) {
1754
+ PyObject *function = PyMethod_GET_FUNCTION(attr);
1755
+ Py_INCREF(function);
1756
+ Py_DECREF(attr);
1757
+ *method = function;
1758
+ return 1;
1759
+ }
1760
+ #endif
1761
+ *method = attr;
1762
+ return 0;
1763
+ }
1764
+
1765
+
1766
+ /////////////// UnpackUnboundCMethod.proto ///////////////
1767
+
1768
+ typedef struct {
1769
+ PyObject *type;
1770
+ PyObject **method_name;
1771
+ // "func" is set on first access (direct C function pointer)
1772
+ PyCFunction func;
1773
+ // "method" is set on first access (fallback)
1774
+ PyObject *method;
1775
+ int flag;
1776
+ } __Pyx_CachedCFunction;
1777
+
1778
+ /////////////// UnpackUnboundCMethod ///////////////
1779
+ //@requires: PyObjectGetAttrStr
1780
+
1781
+ static PyObject *__Pyx_SelflessCall(PyObject *method, PyObject *args, PyObject *kwargs) {
1782
+ // NOTE: possible optimization - use vectorcall
1783
+ PyObject *result;
1784
+ PyObject *selfless_args = PyTuple_GetSlice(args, 1, PyTuple_Size(args));
1785
+ if (unlikely(!selfless_args)) return NULL;
1786
+
1787
+ result = PyObject_Call(method, selfless_args, kwargs);
1788
+ Py_DECREF(selfless_args);
1789
+ return result;
1790
+ }
1791
+
1792
+ static PyMethodDef __Pyx_UnboundCMethod_Def = {
1793
+ /* .ml_name = */ "CythonUnboundCMethod",
1794
+ /* .ml_meth = */ __PYX_REINTERPRET_FUNCION(PyCFunction, __Pyx_SelflessCall),
1795
+ /* .ml_flags = */ METH_VARARGS | METH_KEYWORDS,
1796
+ /* .ml_doc = */ NULL
1797
+ };
1798
+
1799
+ static int __Pyx_TryUnpackUnboundCMethod(__Pyx_CachedCFunction* target) {
1800
+ PyObject *method;
1801
+ method = __Pyx_PyObject_GetAttrStr(target->type, *target->method_name);
1802
+ if (unlikely(!method))
1803
+ return -1;
1804
+ target->method = method;
1805
+ // FIXME: use functionality from CythonFunction.c/ClassMethod
1806
+ #if CYTHON_COMPILING_IN_CPYTHON
1807
+ if (likely(__Pyx_TypeCheck(method, &PyMethodDescr_Type)))
1808
+ {
1809
+ PyMethodDescrObject *descr = (PyMethodDescrObject*) method;
1810
+ target->func = descr->d_method->ml_meth;
1811
+ target->flag = descr->d_method->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_STACKLESS);
1812
+ } else
1813
+ #endif
1814
+ // bound classmethods need special treatment
1815
+ #if CYTHON_COMPILING_IN_PYPY
1816
+ // In PyPy, functions are regular methods, so just do the self check.
1817
+ #else
1818
+ if (PyCFunction_Check(method))
1819
+ #endif
1820
+ {
1821
+ PyObject *self;
1822
+ int self_found;
1823
+ #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_PYPY
1824
+ self = PyObject_GetAttrString(method, "__self__");
1825
+ if (!self) {
1826
+ PyErr_Clear();
1827
+ }
1828
+ #else
1829
+ self = PyCFunction_GET_SELF(method);
1830
+ #endif
1831
+ self_found = (self && self != Py_None);
1832
+ #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_PYPY
1833
+ Py_XDECREF(self);
1834
+ #endif
1835
+ if (self_found) {
1836
+ PyObject *unbound_method = PyCFunction_New(&__Pyx_UnboundCMethod_Def, method);
1837
+ if (unlikely(!unbound_method)) return -1;
1838
+ // New PyCFunction will own method reference, thus decref __Pyx_PyObject_GetAttrStr
1839
+ Py_DECREF(method);
1840
+ target->method = unbound_method;
1841
+ }
1842
+ }
1843
+ return 0;
1844
+ }
1845
+
1846
+
1847
+ /////////////// CallUnboundCMethod0.proto ///////////////
1848
+
1849
+ CYTHON_UNUSED
1850
+ static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self); /*proto*/
1851
+
1852
+ #if CYTHON_COMPILING_IN_CPYTHON
1853
+ // FASTCALL methods receive "&empty_tuple" as simple "PyObject[0]*"
1854
+ #define __Pyx_CallUnboundCMethod0(cfunc, self) \
1855
+ (likely((cfunc)->func) ? \
1856
+ (likely((cfunc)->flag == METH_NOARGS) ? (*((cfunc)->func))(self, NULL) : \
1857
+ (likely((cfunc)->flag == METH_FASTCALL) ? \
1858
+ (*(__Pyx_PyCFunctionFast)(void*)(PyCFunction)(cfunc)->func)(self, &EMPTY(tuple), 0) : \
1859
+ ((cfunc)->flag == (METH_FASTCALL | METH_KEYWORDS) ? \
1860
+ (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)(cfunc)->func)(self, &EMPTY(tuple), 0, NULL) : \
1861
+ (likely((cfunc)->flag == (METH_VARARGS | METH_KEYWORDS)) ? ((*(PyCFunctionWithKeywords)(void*)(PyCFunction)(cfunc)->func)(self, EMPTY(tuple), NULL)) : \
1862
+ ((cfunc)->flag == METH_VARARGS ? (*((cfunc)->func))(self, EMPTY(tuple)) : \
1863
+ __Pyx__CallUnboundCMethod0(cfunc, self)))))) : \
1864
+ __Pyx__CallUnboundCMethod0(cfunc, self))
1865
+ #else
1866
+ #define __Pyx_CallUnboundCMethod0(cfunc, self) __Pyx__CallUnboundCMethod0(cfunc, self)
1867
+ #endif
1868
+
1869
+ /////////////// CallUnboundCMethod0 ///////////////
1870
+ //@requires: UnpackUnboundCMethod
1871
+ //@requires: PyObjectCallOneArg
1872
+
1873
+ static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self) {
1874
+ PyObject *result;
1875
+ if (unlikely(!cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
1876
+ result = __Pyx_PyObject_CallOneArg(cfunc->method, self);
1877
+ return result;
1878
+ }
1879
+
1880
+
1881
+ /////////////// CallUnboundCMethod1.proto ///////////////
1882
+
1883
+ CYTHON_UNUSED
1884
+ static PyObject* __Pyx__CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg);/*proto*/
1885
+
1886
+ #if CYTHON_COMPILING_IN_CPYTHON
1887
+ static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg);/*proto*/
1888
+ #else
1889
+ #define __Pyx_CallUnboundCMethod1(cfunc, self, arg) __Pyx__CallUnboundCMethod1(cfunc, self, arg)
1890
+ #endif
1891
+
1892
+ /////////////// CallUnboundCMethod1 ///////////////
1893
+ //@requires: UnpackUnboundCMethod
1894
+ //@requires: PyObjectCall2Args
1895
+
1896
+ #if CYTHON_COMPILING_IN_CPYTHON
1897
+ static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg) {
1898
+ if (likely(cfunc->func)) {
1899
+ int flag = cfunc->flag;
1900
+ if (flag == METH_O) {
1901
+ return (*(cfunc->func))(self, arg);
1902
+ } else if (flag == METH_FASTCALL) {
1903
+ return (*(__Pyx_PyCFunctionFast)(void*)(PyCFunction)cfunc->func)(self, &arg, 1);
1904
+ } else if (flag == (METH_FASTCALL | METH_KEYWORDS)) {
1905
+ return (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)cfunc->func)(self, &arg, 1, NULL);
1906
+ }
1907
+ }
1908
+ return __Pyx__CallUnboundCMethod1(cfunc, self, arg);
1909
+ }
1910
+ #endif
1911
+
1912
+ static PyObject* __Pyx__CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg){
1913
+ PyObject *result = NULL;
1914
+ if (unlikely(!cfunc->func && !cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
1915
+ #if CYTHON_COMPILING_IN_CPYTHON
1916
+ if (cfunc->func && (cfunc->flag & METH_VARARGS)) {
1917
+ PyObject *args = PyTuple_New(1);
1918
+ if (unlikely(!args)) return NULL;
1919
+ Py_INCREF(arg);
1920
+ PyTuple_SET_ITEM(args, 0, arg);
1921
+ if (cfunc->flag & METH_KEYWORDS)
1922
+ result = (*(PyCFunctionWithKeywords)(void*)(PyCFunction)cfunc->func)(self, args, NULL);
1923
+ else
1924
+ result = (*cfunc->func)(self, args);
1925
+ Py_DECREF(args);
1926
+ } else
1927
+ #endif
1928
+ {
1929
+ result = __Pyx_PyObject_Call2Args(cfunc->method, self, arg);
1930
+ }
1931
+ return result;
1932
+ }
1933
+
1934
+
1935
+ /////////////// CallUnboundCMethod2.proto ///////////////
1936
+
1937
+ CYTHON_UNUSED
1938
+ static PyObject* __Pyx__CallUnboundCMethod2(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg1, PyObject* arg2); /*proto*/
1939
+
1940
+ #if CYTHON_COMPILING_IN_CPYTHON
1941
+ static CYTHON_INLINE PyObject *__Pyx_CallUnboundCMethod2(__Pyx_CachedCFunction *cfunc, PyObject *self, PyObject *arg1, PyObject *arg2); /*proto*/
1942
+ #else
1943
+ #define __Pyx_CallUnboundCMethod2(cfunc, self, arg1, arg2) __Pyx__CallUnboundCMethod2(cfunc, self, arg1, arg2)
1944
+ #endif
1945
+
1946
+ /////////////// CallUnboundCMethod2 ///////////////
1947
+ //@requires: UnpackUnboundCMethod
1948
+ //@requires: PyObjectFastCall
1949
+
1950
+ #if CYTHON_COMPILING_IN_CPYTHON
1951
+ static CYTHON_INLINE PyObject *__Pyx_CallUnboundCMethod2(__Pyx_CachedCFunction *cfunc, PyObject *self, PyObject *arg1, PyObject *arg2) {
1952
+ if (likely(cfunc->func)) {
1953
+ PyObject *args[2] = {arg1, arg2};
1954
+ if (cfunc->flag == METH_FASTCALL) {
1955
+ return (*(__Pyx_PyCFunctionFast)(void*)(PyCFunction)cfunc->func)(self, args, 2);
1956
+ }
1957
+ if (cfunc->flag == (METH_FASTCALL | METH_KEYWORDS))
1958
+ return (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)cfunc->func)(self, args, 2, NULL);
1959
+ }
1960
+ return __Pyx__CallUnboundCMethod2(cfunc, self, arg1, arg2);
1961
+ }
1962
+ #endif
1963
+
1964
+ static PyObject* __Pyx__CallUnboundCMethod2(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg1, PyObject* arg2){
1965
+ PyObject *result = NULL;
1966
+ if (unlikely(!cfunc->func && !cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
1967
+ #if CYTHON_COMPILING_IN_CPYTHON
1968
+ if (cfunc->func && (cfunc->flag & METH_VARARGS)) {
1969
+ PyObject *args = PyTuple_New(2);
1970
+ if (unlikely(!args)) return NULL;
1971
+ Py_INCREF(arg1);
1972
+ PyTuple_SET_ITEM(args, 0, arg1);
1973
+ Py_INCREF(arg2);
1974
+ PyTuple_SET_ITEM(args, 1, arg2);
1975
+ if (cfunc->flag & METH_KEYWORDS)
1976
+ result = (*(PyCFunctionWithKeywords)(void*)(PyCFunction)cfunc->func)(self, args, NULL);
1977
+ else
1978
+ result = (*cfunc->func)(self, args);
1979
+ Py_DECREF(args);
1980
+ return result;
1981
+ }
1982
+ #endif
1983
+ {
1984
+ PyObject *args[4] = {NULL, self, arg1, arg2};
1985
+ return __Pyx_PyObject_FastCall(cfunc->method, args+1, 3 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET);
1986
+ }
1987
+ }
1988
+
1989
+
1990
+ /////////////// PyObjectFastCall.proto ///////////////
1991
+
1992
+ #define __Pyx_PyObject_FastCall(func, args, nargs) __Pyx_PyObject_FastCallDict(func, args, (size_t)(nargs), NULL)
1993
+ static CYTHON_INLINE PyObject* __Pyx_PyObject_FastCallDict(PyObject *func, PyObject **args, size_t nargs, PyObject *kwargs); /*proto*/
1994
+
1995
+ /////////////// PyObjectFastCall ///////////////
1996
+ //@requires: PyObjectCall
1997
+ //@requires: PyFunctionFastCall
1998
+ //@requires: PyObjectCallMethO
1999
+
2000
+ #if PY_VERSION_HEX < 0x03090000 || CYTHON_COMPILING_IN_LIMITED_API
2001
+ static PyObject* __Pyx_PyObject_FastCall_fallback(PyObject *func, PyObject **args, size_t nargs, PyObject *kwargs) {
2002
+ PyObject *argstuple;
2003
+ PyObject *result = 0;
2004
+ size_t i;
2005
+
2006
+ argstuple = PyTuple_New((Py_ssize_t)nargs);
2007
+ if (unlikely(!argstuple)) return NULL;
2008
+ for (i = 0; i < nargs; i++) {
2009
+ Py_INCREF(args[i]);
2010
+ if (__Pyx_PyTuple_SET_ITEM(argstuple, (Py_ssize_t)i, args[i]) != (0)) goto bad;
2011
+ }
2012
+ result = __Pyx_PyObject_Call(func, argstuple, kwargs);
2013
+ bad:
2014
+ Py_DECREF(argstuple);
2015
+ return result;
2016
+ }
2017
+ #endif
2018
+
2019
+ static CYTHON_INLINE PyObject* __Pyx_PyObject_FastCallDict(PyObject *func, PyObject **args, size_t _nargs, PyObject *kwargs) {
2020
+ // Special fast paths for 0 and 1 arguments
2021
+ // NOTE: in many cases, this is called with a constant value for nargs
2022
+ // which is known at compile-time. So the branches below will typically
2023
+ // be optimized away.
2024
+ Py_ssize_t nargs = __Pyx_PyVectorcall_NARGS(_nargs);
2025
+ #if CYTHON_COMPILING_IN_CPYTHON
2026
+ if (nargs == 0 && kwargs == NULL) {
2027
+ if (__Pyx_CyOrPyCFunction_Check(func) && likely( __Pyx_CyOrPyCFunction_GET_FLAGS(func) & METH_NOARGS))
2028
+ return __Pyx_PyObject_CallMethO(func, NULL);
2029
+ }
2030
+ else if (nargs == 1 && kwargs == NULL) {
2031
+ if (__Pyx_CyOrPyCFunction_Check(func) && likely( __Pyx_CyOrPyCFunction_GET_FLAGS(func) & METH_O))
2032
+ return __Pyx_PyObject_CallMethO(func, args[0]);
2033
+ }
2034
+ #endif
2035
+
2036
+ #if PY_VERSION_HEX < 0x030800B1
2037
+ #if CYTHON_FAST_PYCCALL
2038
+ if (PyCFunction_Check(func)) {
2039
+ if (kwargs) {
2040
+ return _PyCFunction_FastCallDict(func, args, nargs, kwargs);
2041
+ } else {
2042
+ return _PyCFunction_FastCallKeywords(func, args, nargs, NULL);
2043
+ }
2044
+ }
2045
+ if (!kwargs && __Pyx_IS_TYPE(func, &PyMethodDescr_Type)) {
2046
+ return _PyMethodDescr_FastCallKeywords(func, args, nargs, NULL);
2047
+ }
2048
+ #endif
2049
+ #if CYTHON_FAST_PYCALL
2050
+ if (PyFunction_Check(func)) {
2051
+ return __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs);
2052
+ }
2053
+ #endif
2054
+ #endif
2055
+
2056
+ if (kwargs == NULL) {
2057
+ #if CYTHON_VECTORCALL && !CYTHON_COMPILING_IN_LIMITED_API
2058
+ #if PY_VERSION_HEX < 0x03090000
2059
+ vectorcallfunc f = _PyVectorcall_Function(func);
2060
+ #else
2061
+ vectorcallfunc f = PyVectorcall_Function(func);
2062
+ #endif
2063
+ if (f) {
2064
+ return f(func, args, (size_t)nargs, NULL);
2065
+ }
2066
+ #elif defined(__Pyx_CyFunction_USED) && CYTHON_BACKPORT_VECTORCALL
2067
+ // exclude fused functions for now
2068
+ if (__Pyx_CyFunction_CheckExact(func)) {
2069
+ __pyx_vectorcallfunc f = __Pyx_CyFunction_func_vectorcall(func);
2070
+ if (f) return f(func, args, (size_t)nargs, NULL);
2071
+ }
2072
+ #elif CYTHON_COMPILING_IN_LIMITED_API && CYTHON_VECTORCALL
2073
+ return PyObject_Vectorcall(func, args, (size_t)nargs, NULL);
2074
+ #endif
2075
+ }
2076
+
2077
+ if (nargs == 0) {
2078
+ return __Pyx_PyObject_Call(func, EMPTY(tuple), kwargs);
2079
+ }
2080
+ #if PY_VERSION_HEX >= 0x03090000 && !CYTHON_COMPILING_IN_LIMITED_API
2081
+ return PyObject_VectorcallDict(func, args, (size_t)nargs, kwargs);
2082
+ #else
2083
+ return __Pyx_PyObject_FastCall_fallback(func, args, (size_t)nargs, kwargs);
2084
+ #endif
2085
+ }
2086
+
2087
+ /////////////// PyObjectVectorCallKwBuilder.proto ////////////////
2088
+ //@requires: PyObjectFastCall
2089
+ // For versions that define PyObject_Vectorcall, use PyObject_Vectorcall and define functions to build a kwnames tuple and add arguments to args.
2090
+ // For versions that don't, use __Pyx_PyObject_FastCallDict and functions to build a keyword dictionary
2091
+
2092
+ CYTHON_UNUSED static int __Pyx_VectorcallBuilder_AddArg_Check(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n); /* proto */
2093
+
2094
+ #if CYTHON_VECTORCALL
2095
+ #if PY_VERSION_HEX >= 0x03090000
2096
+ #define __Pyx_Object_Vectorcall_CallFromBuilder PyObject_Vectorcall
2097
+ #else
2098
+ #define __Pyx_Object_Vectorcall_CallFromBuilder _PyObject_Vectorcall
2099
+ #endif
2100
+
2101
+ #define __Pyx_MakeVectorcallBuilderKwds(n) PyTuple_New(n)
2102
+
2103
+ static int __Pyx_VectorcallBuilder_AddArg(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n); /* proto */
2104
+ static int __Pyx_VectorcallBuilder_AddArgStr(const char *key, PyObject *value, PyObject *builder, PyObject **args, int n); /* proto */
2105
+ #else
2106
+ #define __Pyx_Object_Vectorcall_CallFromBuilder __Pyx_PyObject_FastCallDict
2107
+
2108
+ #define __Pyx_MakeVectorcallBuilderKwds(n) PyDict_New()
2109
+
2110
+ #define __Pyx_VectorcallBuilder_AddArg(key, value, builder, args, n) PyDict_SetItem(builder, key, value)
2111
+ #define __Pyx_VectorcallBuilder_AddArgStr(key, value, builder, args, n) PyDict_SetItemString(builder, key, value)
2112
+ #endif
2113
+
2114
+
2115
+
2116
+ /////////////// PyObjectVectorCallKwBuilder ////////////////
2117
+
2118
+ #if CYTHON_VECTORCALL
2119
+ static int __Pyx_VectorcallBuilder_AddArg(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n) {
2120
+ (void)__Pyx_PyObject_FastCallDict;
2121
+
2122
+ if (__Pyx_PyTuple_SET_ITEM(builder, n, key) != (0)) return -1;
2123
+ Py_INCREF(key);
2124
+ args[n] = value;
2125
+ return 0;
2126
+ }
2127
+
2128
+ CYTHON_UNUSED static int __Pyx_VectorcallBuilder_AddArg_Check(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n) {
2129
+ (void)__Pyx_VectorcallBuilder_AddArgStr;
2130
+ if (unlikely(!PyUnicode_Check(key))) {
2131
+ PyErr_SetString(PyExc_TypeError, "keywords must be strings");
2132
+ return -1;
2133
+ }
2134
+ return __Pyx_VectorcallBuilder_AddArg(key, value, builder, args, n);
2135
+ }
2136
+
2137
+ static int __Pyx_VectorcallBuilder_AddArgStr(const char *key, PyObject *value, PyObject *builder, PyObject **args, int n) {
2138
+ PyObject *pyKey = PyUnicode_FromString(key);
2139
+ if (!pyKey) return -1;
2140
+ return __Pyx_VectorcallBuilder_AddArg(pyKey, value, builder, args, n);
2141
+ }
2142
+ #else // CYTHON_VECTORCALL
2143
+ CYTHON_UNUSED static int __Pyx_VectorcallBuilder_AddArg_Check(PyObject *key, PyObject *value, PyObject *builder, CYTHON_UNUSED PyObject **args, CYTHON_UNUSED int n) {
2144
+ if (unlikely(!PyUnicode_Check(key))) {
2145
+ PyErr_SetString(PyExc_TypeError, "keywords must be strings");
2146
+ return -1;
2147
+ }
2148
+ return PyDict_SetItem(builder, key, value);
2149
+ }
2150
+ #endif
2151
+
2152
+ /////////////// PyObjectCallMethod0.proto ///////////////
2153
+
2154
+ static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name); /*proto*/
2155
+
2156
+ /////////////// PyObjectCallMethod0 ///////////////
2157
+ //@requires: PyObjectGetMethod
2158
+ //@requires: PyObjectCallOneArg
2159
+ //@requires: PyObjectCallNoArg
2160
+
2161
+ static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name) {
2162
+ PyObject *method = NULL, *result = NULL;
2163
+ int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method);
2164
+ if (likely(is_method)) {
2165
+ result = __Pyx_PyObject_CallOneArg(method, obj);
2166
+ Py_DECREF(method);
2167
+ return result;
2168
+ }
2169
+ if (unlikely(!method)) goto bad;
2170
+ result = __Pyx_PyObject_CallNoArg(method);
2171
+ Py_DECREF(method);
2172
+ bad:
2173
+ return result;
2174
+ }
2175
+
2176
+
2177
+ /////////////// PyObjectCallMethod1.proto ///////////////
2178
+
2179
+ static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg); /*proto*/
2180
+
2181
+ /////////////// PyObjectCallMethod1 ///////////////
2182
+ //@requires: PyObjectGetMethod
2183
+ //@requires: PyObjectCallOneArg
2184
+ //@requires: PyObjectCall2Args
2185
+
2186
+ #if !(CYTHON_VECTORCALL && __PYX_LIMITED_VERSION_HEX >= 0x030C00A2)
2187
+ static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg) {
2188
+ // Separate function to avoid excessive inlining.
2189
+ PyObject *result = __Pyx_PyObject_CallOneArg(method, arg);
2190
+ Py_DECREF(method);
2191
+ return result;
2192
+ }
2193
+ #endif
2194
+
2195
+ static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) {
2196
+ #if CYTHON_VECTORCALL && __PYX_LIMITED_VERSION_HEX >= 0x030C00A2
2197
+ PyObject *args[2] = {obj, arg};
2198
+ // avoid unused functions
2199
+ (void) __Pyx_PyObject_GetMethod;
2200
+ (void) __Pyx_PyObject_CallOneArg;
2201
+ (void) __Pyx_PyObject_Call2Args;
2202
+ return PyObject_VectorcallMethod(method_name, args, 2 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL);
2203
+ #else
2204
+ PyObject *method = NULL, *result;
2205
+ int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method);
2206
+ if (likely(is_method)) {
2207
+ result = __Pyx_PyObject_Call2Args(method, obj, arg);
2208
+ Py_DECREF(method);
2209
+ return result;
2210
+ }
2211
+ if (unlikely(!method)) return NULL;
2212
+ return __Pyx__PyObject_CallMethod1(method, arg);
2213
+ #endif
2214
+ }
2215
+
2216
+
2217
+ /////////////// tp_new.proto ///////////////
2218
+ //@requires: ModuleSetupCode.c::GetRuntimeVersion
2219
+
2220
+ #define __Pyx_tp_new(type_obj, args) __Pyx_tp_new_kwargs(type_obj, args, NULL)
2221
+ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
2222
+ static PyObject* __Pyx_tp_new_fallback(PyObject* type_obj, PyObject* args, PyObject* kwargs); /*proto*/
2223
+ #endif
2224
+ static CYTHON_INLINE PyObject* __Pyx_tp_new_kwargs(PyObject* type_obj, PyObject* args, PyObject* kwargs) {
2225
+ newfunc tp_new = __Pyx_PyType_TryGetSlot((PyTypeObject*)type_obj, tp_new, newfunc);
2226
+ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
2227
+ if (!tp_new) return __Pyx_tp_new_fallback(type_obj, args, kwargs);
2228
+ #else
2229
+ assert(tp_new != NULL);
2230
+ #endif
2231
+ return tp_new((PyTypeObject*)type_obj, args, kwargs);
2232
+ }
2233
+
2234
+ /////////////// tp_new ///////////////
2235
+
2236
+ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
2237
+ static PyObject* __Pyx_tp_new_fallback(PyObject* type_obj, PyObject* args, PyObject* kwargs) {
2238
+ PyObject *new_func = NULL, *new_args = NULL, *obj;
2239
+ Py_ssize_t i, nargs = PyTuple_Size(args);
2240
+
2241
+ if (unlikely(nargs < 0)) goto bad;
2242
+ new_args = PyTuple_New(nargs + 1);
2243
+ if (unlikely(!new_args)) goto bad;
2244
+ for (i = 0; i < nargs + 1; i++) {
2245
+ PyObject *item = (i == 0) ? type_obj : PyTuple_GetItem(args, i - 1);
2246
+ if (unlikely(!item)) goto bad;
2247
+ Py_INCREF(item);
2248
+ if (unlikely(PyTuple_SetItem(new_args, i, item)) < 0) goto bad;
2249
+ }
2250
+
2251
+ new_func = PyObject_GetAttrString(type_obj, "__new__");
2252
+ if (unlikely(!new_func)) goto bad;
2253
+ obj = PyObject_Call(new_func, new_args, kwargs);
2254
+ Py_DECREF(new_func);
2255
+ Py_DECREF(new_args);
2256
+ return obj;
2257
+
2258
+ bad:
2259
+ Py_XDECREF(new_func);
2260
+ Py_XDECREF(new_args);
2261
+ return NULL;
2262
+ }
2263
+ #endif
2264
+
2265
+ /////////////// PyObjectCall.proto ///////////////
2266
+
2267
+ #if CYTHON_COMPILING_IN_CPYTHON
2268
+ static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); /*proto*/
2269
+ #else
2270
+ #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
2271
+ #endif
2272
+
2273
+ /////////////// PyObjectCall ///////////////
2274
+
2275
+ #if CYTHON_COMPILING_IN_CPYTHON
2276
+ static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
2277
+ PyObject *result;
2278
+ ternaryfunc call = Py_TYPE(func)->tp_call;
2279
+
2280
+ if (unlikely(!call))
2281
+ return PyObject_Call(func, arg, kw);
2282
+ if (unlikely(Py_EnterRecursiveCall(" while calling a Python object")))
2283
+ return NULL;
2284
+ result = (*call)(func, arg, kw);
2285
+ Py_LeaveRecursiveCall();
2286
+ if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
2287
+ PyErr_SetString(
2288
+ PyExc_SystemError,
2289
+ "NULL result without error in PyObject_Call");
2290
+ }
2291
+ return result;
2292
+ }
2293
+ #endif
2294
+
2295
+
2296
+ /////////////// PyObjectCallMethO.proto ///////////////
2297
+
2298
+ #if CYTHON_COMPILING_IN_CPYTHON
2299
+ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg); /*proto*/
2300
+ #endif
2301
+
2302
+ /////////////// PyObjectCallMethO ///////////////
2303
+
2304
+ #if CYTHON_COMPILING_IN_CPYTHON
2305
+ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
2306
+ PyObject *self, *result;
2307
+ PyCFunction cfunc;
2308
+ cfunc = __Pyx_CyOrPyCFunction_GET_FUNCTION(func);
2309
+ self = __Pyx_CyOrPyCFunction_GET_SELF(func);
2310
+
2311
+ if (unlikely(Py_EnterRecursiveCall(" while calling a Python object")))
2312
+ return NULL;
2313
+ result = cfunc(self, arg);
2314
+ Py_LeaveRecursiveCall();
2315
+ if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
2316
+ PyErr_SetString(
2317
+ PyExc_SystemError,
2318
+ "NULL result without error in PyObject_Call");
2319
+ }
2320
+ return result;
2321
+ }
2322
+ #endif
2323
+
2324
+
2325
+ /////////////// PyFunctionFastCall.proto ///////////////
2326
+
2327
+ #if CYTHON_FAST_PYCALL
2328
+
2329
+ #if !CYTHON_VECTORCALL
2330
+ #define __Pyx_PyFunction_FastCall(func, args, nargs) \
2331
+ __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
2332
+
2333
+ static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs);
2334
+ #endif
2335
+
2336
+ // Backport from Python 3
2337
+ // Assert a build-time dependency, as an expression.
2338
+ // Your compile will fail if the condition isn't true, or can't be evaluated
2339
+ // by the compiler. This can be used in an expression: its value is 0.
2340
+ // Example:
2341
+ // #define foo_to_char(foo) \
2342
+ // ((char *)(foo) \
2343
+ // + Py_BUILD_ASSERT_EXPR(offsetof(struct foo, string) == 0))
2344
+ //
2345
+ // Written by Rusty Russell, public domain, https://ccodearchive.net/
2346
+ #define __Pyx_BUILD_ASSERT_EXPR(cond) \
2347
+ (sizeof(char [1 - 2*!(cond)]) - 1)
2348
+
2349
+ #ifndef Py_MEMBER_SIZE
2350
+ // Get the size of a structure member in bytes
2351
+ #define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
2352
+ #endif
2353
+
2354
+ #if !CYTHON_VECTORCALL
2355
+ #if PY_VERSION_HEX >= 0x03080000
2356
+ #include "frameobject.h"
2357
+ #define __Pxy_PyFrame_Initialize_Offsets()
2358
+ #define __Pyx_PyFrame_GetLocalsplus(frame) ((frame)->f_localsplus)
2359
+ #else
2360
+ // Initialised by module init code.
2361
+ static size_t __pyx_pyframe_localsplus_offset = 0;
2362
+
2363
+ #include "frameobject.h"
2364
+ // This is the long runtime version of
2365
+ // #define __Pyx_PyFrame_GetLocalsplus(frame) ((frame)->f_localsplus)
2366
+ // offsetof(PyFrameObject, f_localsplus) differs between regular C-Python and Stackless Python < 3.8.
2367
+ // Therefore the offset is computed at run time from PyFrame_type.tp_basicsize. That is feasible,
2368
+ // because f_localsplus is the last field of PyFrameObject (checked by Py_BUILD_ASSERT_EXPR below).
2369
+ #define __Pxy_PyFrame_Initialize_Offsets() \
2370
+ ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)), \
2371
+ (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus)))
2372
+ #define __Pyx_PyFrame_GetLocalsplus(frame) \
2373
+ (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset))
2374
+ #endif
2375
+ #endif /* !CYTHON_VECTORCALL */
2376
+
2377
+ #endif /* CYTHON_FAST_PYCALL */
2378
+
2379
+
2380
+ /////////////// PyFunctionFastCall ///////////////
2381
+ // copied from CPython 3.6 ceval.c
2382
+
2383
+ #if CYTHON_FAST_PYCALL && !CYTHON_VECTORCALL
2384
+ static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
2385
+ PyObject *globals) {
2386
+ PyFrameObject *f;
2387
+ PyThreadState *tstate = __Pyx_PyThreadState_Current;
2388
+ PyObject **fastlocals;
2389
+ Py_ssize_t i;
2390
+ PyObject *result;
2391
+
2392
+ assert(globals != NULL);
2393
+ /* XXX Perhaps we should create a specialized
2394
+ PyFrame_New() that doesn't take locals, but does
2395
+ take builtins without sanity checking them.
2396
+ */
2397
+ assert(tstate != NULL);
2398
+ f = PyFrame_New(tstate, co, globals, NULL);
2399
+ if (f == NULL) {
2400
+ return NULL;
2401
+ }
2402
+
2403
+ fastlocals = __Pyx_PyFrame_GetLocalsplus(f);
2404
+
2405
+ for (i = 0; i < na; i++) {
2406
+ Py_INCREF(*args);
2407
+ fastlocals[i] = *args++;
2408
+ }
2409
+ result = PyEval_EvalFrameEx(f,0);
2410
+
2411
+ ++tstate->recursion_depth;
2412
+ Py_DECREF(f);
2413
+ --tstate->recursion_depth;
2414
+
2415
+ return result;
2416
+ }
2417
+
2418
+
2419
+ static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) {
2420
+ PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
2421
+ PyObject *globals = PyFunction_GET_GLOBALS(func);
2422
+ PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
2423
+ PyObject *closure;
2424
+ PyObject *kwdefs;
2425
+ //PyObject *name, *qualname;
2426
+ PyObject *kwtuple, **k;
2427
+ PyObject **d;
2428
+ Py_ssize_t nd;
2429
+ Py_ssize_t nk;
2430
+ PyObject *result;
2431
+
2432
+ assert(kwargs == NULL || PyDict_Check(kwargs));
2433
+ nk = kwargs ? PyDict_Size(kwargs) : 0;
2434
+
2435
+ if (unlikely(Py_EnterRecursiveCall(" while calling a Python object"))) {
2436
+ return NULL;
2437
+ }
2438
+
2439
+ if (
2440
+ co->co_kwonlyargcount == 0 &&
2441
+ likely(kwargs == NULL || nk == 0) &&
2442
+ co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
2443
+ /* Fast paths */
2444
+ if (argdefs == NULL && co->co_argcount == nargs) {
2445
+ result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
2446
+ goto done;
2447
+ }
2448
+ else if (nargs == 0 && argdefs != NULL
2449
+ && co->co_argcount == Py_SIZE(argdefs)) {
2450
+ /* function called with no arguments, but all parameters have
2451
+ a default value: use default values as arguments .*/
2452
+ args = &PyTuple_GET_ITEM(argdefs, 0);
2453
+ result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
2454
+ goto done;
2455
+ }
2456
+ }
2457
+
2458
+ if (kwargs != NULL) {
2459
+ Py_ssize_t pos, i;
2460
+ kwtuple = PyTuple_New(2 * nk);
2461
+ if (kwtuple == NULL) {
2462
+ result = NULL;
2463
+ goto done;
2464
+ }
2465
+
2466
+ k = &PyTuple_GET_ITEM(kwtuple, 0);
2467
+ pos = i = 0;
2468
+ while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
2469
+ Py_INCREF(k[i]);
2470
+ Py_INCREF(k[i+1]);
2471
+ i += 2;
2472
+ }
2473
+ nk = i / 2;
2474
+ }
2475
+ else {
2476
+ kwtuple = NULL;
2477
+ k = NULL;
2478
+ }
2479
+
2480
+ closure = PyFunction_GET_CLOSURE(func);
2481
+ kwdefs = PyFunction_GET_KW_DEFAULTS(func);
2482
+ //name = ((PyFunctionObject *)func) -> func_name;
2483
+ //qualname = ((PyFunctionObject *)func) -> func_qualname;
2484
+
2485
+ if (argdefs != NULL) {
2486
+ d = &PyTuple_GET_ITEM(argdefs, 0);
2487
+ nd = Py_SIZE(argdefs);
2488
+ }
2489
+ else {
2490
+ d = NULL;
2491
+ nd = 0;
2492
+ }
2493
+
2494
+ //return _PyEval_EvalCodeWithName((PyObject*)co, globals, (PyObject *)NULL,
2495
+ // args, nargs,
2496
+ // NULL, 0,
2497
+ // d, nd, kwdefs,
2498
+ // closure, name, qualname);
2499
+ result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
2500
+ args, (int)nargs,
2501
+ k, (int)nk,
2502
+ d, (int)nd, kwdefs, closure);
2503
+ Py_XDECREF(kwtuple);
2504
+
2505
+ done:
2506
+ Py_LeaveRecursiveCall();
2507
+ return result;
2508
+ }
2509
+ #endif /* CYTHON_FAST_PYCALL && !CYTHON_VECTORCALL */
2510
+
2511
+
2512
+ /////////////// PyObjectCall2Args.proto ///////////////
2513
+
2514
+ static CYTHON_INLINE PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2); /*proto*/
2515
+
2516
+ /////////////// PyObjectCall2Args ///////////////
2517
+ //@requires: PyObjectFastCall
2518
+
2519
+ static CYTHON_INLINE PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) {
2520
+ PyObject *args[3] = {NULL, arg1, arg2};
2521
+ return __Pyx_PyObject_FastCall(function, args+1, 2 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET);
2522
+ }
2523
+
2524
+
2525
+ /////////////// PyObjectCallOneArg.proto ///////////////
2526
+
2527
+ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg); /*proto*/
2528
+
2529
+ /////////////// PyObjectCallOneArg ///////////////
2530
+ //@requires: PyObjectFastCall
2531
+
2532
+ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
2533
+ PyObject *args[2] = {NULL, arg};
2534
+ return __Pyx_PyObject_FastCall(func, args+1, 1 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET);
2535
+ }
2536
+
2537
+
2538
+ /////////////// PyObjectCallNoArg.proto ///////////////
2539
+
2540
+ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func); /*proto*/
2541
+
2542
+ /////////////// PyObjectCallNoArg ///////////////
2543
+ //@requires: PyObjectFastCall
2544
+
2545
+ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
2546
+ PyObject *arg[2] = {NULL, NULL};
2547
+ return __Pyx_PyObject_FastCall(func, arg + 1, 0 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET);
2548
+ }
2549
+
2550
+
2551
+ /////////////// PyVectorcallFastCallDict.proto ///////////////
2552
+
2553
+ #if CYTHON_METH_FASTCALL && (CYTHON_VECTORCALL || CYTHON_BACKPORT_VECTORCALL)
2554
+ static CYTHON_INLINE PyObject *__Pyx_PyVectorcall_FastCallDict(PyObject *func, __pyx_vectorcallfunc vc, PyObject *const *args, size_t nargs, PyObject *kw);
2555
+ #endif
2556
+
2557
+ /////////////// PyVectorcallFastCallDict ///////////////
2558
+
2559
+ #if CYTHON_METH_FASTCALL && (CYTHON_VECTORCALL || CYTHON_BACKPORT_VECTORCALL)
2560
+ // Slow path when kw is non-empty
2561
+ static PyObject *__Pyx_PyVectorcall_FastCallDict_kw(PyObject *func, __pyx_vectorcallfunc vc, PyObject *const *args, size_t nargs, PyObject *kw)
2562
+ {
2563
+ // Code based on _PyObject_FastCallDict() and _PyStack_UnpackDict() from CPython
2564
+ PyObject *res = NULL;
2565
+ PyObject *kwnames;
2566
+ PyObject **newargs;
2567
+ PyObject **kwvalues;
2568
+ Py_ssize_t i, pos;
2569
+ size_t j;
2570
+ PyObject *key, *value;
2571
+ unsigned long keys_are_strings;
2572
+ #if !CYTHON_ASSUME_SAFE_SIZE
2573
+ Py_ssize_t nkw = PyDict_Size(kw);
2574
+ if (unlikely(nkw == -1)) return NULL;
2575
+ #else
2576
+ Py_ssize_t nkw = PyDict_GET_SIZE(kw);
2577
+ #endif
2578
+
2579
+ // Copy positional arguments
2580
+ newargs = (PyObject **)PyMem_Malloc((nargs + (size_t)nkw) * sizeof(args[0]));
2581
+ if (unlikely(newargs == NULL)) {
2582
+ PyErr_NoMemory();
2583
+ return NULL;
2584
+ }
2585
+ for (j = 0; j < nargs; j++) newargs[j] = args[j];
2586
+
2587
+ // Copy keyword arguments
2588
+ kwnames = PyTuple_New(nkw);
2589
+ if (unlikely(kwnames == NULL)) {
2590
+ PyMem_Free(newargs);
2591
+ return NULL;
2592
+ }
2593
+ kwvalues = newargs + nargs;
2594
+ pos = i = 0;
2595
+ keys_are_strings = Py_TPFLAGS_UNICODE_SUBCLASS;
2596
+ while (PyDict_Next(kw, &pos, &key, &value)) {
2597
+ keys_are_strings &=
2598
+ #if CYTHON_COMPILING_IN_LIMITED_API
2599
+ PyType_GetFlags(Py_TYPE(key));
2600
+ #else
2601
+ Py_TYPE(key)->tp_flags;
2602
+ #endif
2603
+ Py_INCREF(key);
2604
+ Py_INCREF(value);
2605
+ #if !CYTHON_ASSUME_SAFE_MACROS
2606
+ if (unlikely(PyTuple_SetItem(kwnames, i, key) < 0)) goto cleanup;
2607
+ #else
2608
+ PyTuple_SET_ITEM(kwnames, i, key);
2609
+ #endif
2610
+ kwvalues[i] = value;
2611
+ i++;
2612
+ }
2613
+ if (unlikely(!keys_are_strings)) {
2614
+ PyErr_SetString(PyExc_TypeError, "keywords must be strings");
2615
+ goto cleanup;
2616
+ }
2617
+
2618
+ // The actual call
2619
+ res = vc(func, newargs, nargs, kwnames);
2620
+
2621
+ cleanup:
2622
+ Py_DECREF(kwnames);
2623
+ for (i = 0; i < nkw; i++)
2624
+ Py_DECREF(kwvalues[i]);
2625
+ PyMem_Free(newargs);
2626
+ return res;
2627
+ }
2628
+
2629
+ static CYTHON_INLINE PyObject *__Pyx_PyVectorcall_FastCallDict(PyObject *func, __pyx_vectorcallfunc vc, PyObject *const *args, size_t nargs, PyObject *kw)
2630
+ {
2631
+ Py_ssize_t kw_size =
2632
+ likely(kw == NULL) ?
2633
+ 0 :
2634
+ #if !CYTHON_ASSUME_SAFE_SIZE
2635
+ PyDict_Size(kw);
2636
+ #else
2637
+ PyDict_GET_SIZE(kw);
2638
+ #endif
2639
+
2640
+ if (kw_size == 0) {
2641
+ return vc(func, args, nargs, NULL);
2642
+ }
2643
+ #if !CYTHON_ASSUME_SAFE_SIZE
2644
+ else if (unlikely(kw_size == -1)) {
2645
+ return NULL;
2646
+ }
2647
+ #endif
2648
+ return __Pyx_PyVectorcall_FastCallDict_kw(func, vc, args, nargs, kw);
2649
+ }
2650
+ #endif
2651
+
2652
+
2653
+ /////////////// MatrixMultiply.proto ///////////////
2654
+
2655
+ // TODO: remove
2656
+ #define __Pyx_PyNumber_MatrixMultiply(x,y) PyNumber_MatrixMultiply(x,y)
2657
+ #define __Pyx_PyNumber_InPlaceMatrixMultiply(x,y) PyNumber_InPlaceMatrixMultiply(x,y)
2658
+
2659
+
2660
+ /////////////// PyDictVersioning.proto ///////////////
2661
+
2662
+ #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
2663
+ #define __PYX_DICT_VERSION_INIT ((PY_UINT64_T) -1)
2664
+ #define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag)
2665
+ #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var) \
2666
+ (version_var) = __PYX_GET_DICT_VERSION(dict); \
2667
+ (cache_var) = (value);
2668
+
2669
+ #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) { \
2670
+ static PY_UINT64_T __pyx_dict_version = 0; \
2671
+ static PyObject *__pyx_dict_cached_value = NULL; \
2672
+ if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) { \
2673
+ (VAR) = __pyx_dict_cached_value; \
2674
+ } else { \
2675
+ (VAR) = __pyx_dict_cached_value = (LOOKUP); \
2676
+ __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT); \
2677
+ } \
2678
+ }
2679
+
2680
+ static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj); /*proto*/
2681
+ static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj); /*proto*/
2682
+ static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version); /*proto*/
2683
+
2684
+ #else
2685
+ #define __PYX_GET_DICT_VERSION(dict) (0)
2686
+ #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
2687
+ #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) (VAR) = (LOOKUP);
2688
+ #endif
2689
+
2690
+ /////////////// PyDictVersioning ///////////////
2691
+
2692
+ #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
2693
+ static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
2694
+ PyObject *dict = Py_TYPE(obj)->tp_dict;
2695
+ return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
2696
+ }
2697
+
2698
+ static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
2699
+ PyObject **dictptr = NULL;
2700
+ Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
2701
+ if (offset) {
2702
+ #if CYTHON_COMPILING_IN_CPYTHON
2703
+ dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
2704
+ #else
2705
+ dictptr = _PyObject_GetDictPtr(obj);
2706
+ #endif
2707
+ }
2708
+ return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
2709
+ }
2710
+
2711
+ static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
2712
+ PyObject *dict = Py_TYPE(obj)->tp_dict;
2713
+ if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
2714
+ return 0;
2715
+ return obj_dict_version == __Pyx_get_object_dict_version(obj);
2716
+ }
2717
+ #endif
2718
+
2719
+ ////////////// CachedMethodType.module_state_decls ////////////
2720
+
2721
+ #if CYTHON_COMPILING_IN_LIMITED_API
2722
+ PyObject *__Pyx_CachedMethodType;
2723
+ #endif
2724
+
2725
+ ////////////// CachedMethodType.init //////////////
2726
+
2727
+ #if CYTHON_COMPILING_IN_LIMITED_API
2728
+ {
2729
+ PyObject *typesModule=NULL;
2730
+ typesModule = PyImport_ImportModule("types");
2731
+ if (typesModule) {
2732
+ CGLOBAL(__Pyx_CachedMethodType) = PyObject_GetAttrString(typesModule, "MethodType");
2733
+ Py_DECREF(typesModule);
2734
+ }
2735
+ } // error handling follows
2736
+ #endif
2737
+
2738
+ /////////////// CachedMethodType.cleanup ////////////////
2739
+
2740
+ #if CYTHON_COMPILING_IN_LIMITED_API
2741
+ Py_CLEAR(CGLOBAL(__Pyx_CachedMethodType));
2742
+ #endif
2743
+
2744
+ /////////////// PyMethodNew.proto ///////////////
2745
+
2746
+ static PyObject *__Pyx_PyMethod_New(PyObject *func, PyObject *self, PyObject *typ); /* proto */
2747
+
2748
+ /////////////// PyMethodNew ///////////////
2749
+ //@requires: CachedMethodType
2750
+
2751
+ #if CYTHON_COMPILING_IN_LIMITED_API
2752
+ static PyObject *__Pyx_PyMethod_New(PyObject *func, PyObject *self, PyObject *typ) {
2753
+ PyObject *result;
2754
+ CYTHON_UNUSED_VAR(typ);
2755
+ if (!self)
2756
+ return __Pyx_NewRef(func);
2757
+ #if __PYX_LIMITED_VERSION_HEX >= 0x030C0000
2758
+ {
2759
+ PyObject *args[] = {func, self};
2760
+ result = PyObject_Vectorcall(CGLOBAL(__Pyx_CachedMethodType), args, 2, NULL);
2761
+ }
2762
+ #else
2763
+ result = PyObject_CallFunctionObjArgs(CGLOBAL(__Pyx_CachedMethodType), func, self, NULL);
2764
+ #endif
2765
+ return result;
2766
+ }
2767
+ #else
2768
+ // This should be an actual function (not a macro), such that we can put it
2769
+ // directly in a tp_descr_get slot.
2770
+ static PyObject *__Pyx_PyMethod_New(PyObject *func, PyObject *self, PyObject *typ) {
2771
+ CYTHON_UNUSED_VAR(typ);
2772
+ if (!self)
2773
+ return __Pyx_NewRef(func);
2774
+ return PyMethod_New(func, self);
2775
+ }
2776
+ #endif
2777
+
2778
+ ///////////// PyMethodNew2Arg.proto /////////////
2779
+
2780
+ // TODO: remove
2781
+ // Another wrapping of PyMethod_New that matches the Python3 signature
2782
+ #define __Pyx_PyMethod_New2Arg PyMethod_New
2783
+
2784
+
2785
+ /////////////// UnicodeConcatInPlace.proto ////////////////
2786
+
2787
+ # if CYTHON_COMPILING_IN_CPYTHON
2788
+ // __Pyx_PyUnicode_ConcatInPlace may modify the first argument 'left'
2789
+ // However, unlike `PyUnicode_Append` it will never NULL it.
2790
+ // It behaves like a regular function - returns a new reference and NULL on error
2791
+ #if CYTHON_REFNANNY
2792
+ #define __Pyx_PyUnicode_ConcatInPlace(left, right) __Pyx_PyUnicode_ConcatInPlaceImpl(&left, right, __pyx_refnanny)
2793
+ #else
2794
+ #define __Pyx_PyUnicode_ConcatInPlace(left, right) __Pyx_PyUnicode_ConcatInPlaceImpl(&left, right)
2795
+ #endif
2796
+ // __Pyx_PyUnicode_ConcatInPlace is slightly odd because it has the potential to modify the input
2797
+ // argument (but only in cases where no user should notice). Therefore, it needs to keep Cython's
2798
+ // refnanny informed.
2799
+ static CYTHON_INLINE PyObject *__Pyx_PyUnicode_ConcatInPlaceImpl(PyObject **p_left, PyObject *right
2800
+ #if CYTHON_REFNANNY
2801
+ , void* __pyx_refnanny
2802
+ #endif
2803
+ ); /* proto */
2804
+ #else
2805
+ #define __Pyx_PyUnicode_ConcatInPlace __Pyx_PyUnicode_Concat
2806
+ #endif
2807
+ #define __Pyx_PyUnicode_ConcatInPlaceSafe(left, right) ((unlikely((left) == Py_None) || unlikely((right) == Py_None)) ? \
2808
+ PyNumber_InPlaceAdd(left, right) : __Pyx_PyUnicode_ConcatInPlace(left, right))
2809
+
2810
+ /////////////// UnicodeConcatInPlace ////////////////
2811
+
2812
+ # if CYTHON_COMPILING_IN_CPYTHON
2813
+ // copied directly from unicode_object.c "unicode_modifiable
2814
+ // removing _PyUnicode_HASH since it's a macro we don't have
2815
+ // - this is OK because trying PyUnicode_Resize on a non-modifyable
2816
+ // object will still work, it just won't happen in place
2817
+ static int
2818
+ __Pyx_unicode_modifiable(PyObject *unicode)
2819
+ {
2820
+ if (Py_REFCNT(unicode) != 1)
2821
+ return 0;
2822
+ if (!PyUnicode_CheckExact(unicode))
2823
+ return 0;
2824
+ if (PyUnicode_CHECK_INTERNED(unicode))
2825
+ return 0;
2826
+ return 1;
2827
+ }
2828
+
2829
+ static CYTHON_INLINE PyObject *__Pyx_PyUnicode_ConcatInPlaceImpl(PyObject **p_left, PyObject *right
2830
+ #if CYTHON_REFNANNY
2831
+ , void* __pyx_refnanny
2832
+ #endif
2833
+ ) {
2834
+ // heavily based on PyUnicode_Append
2835
+ PyObject *left = *p_left;
2836
+ Py_ssize_t left_len, right_len, new_len;
2837
+
2838
+ if (unlikely(__Pyx_PyUnicode_READY(left) == -1))
2839
+ return NULL;
2840
+ if (unlikely(__Pyx_PyUnicode_READY(right) == -1))
2841
+ return NULL;
2842
+
2843
+ // Shortcuts
2844
+ left_len = PyUnicode_GET_LENGTH(left);
2845
+ if (left_len == 0) {
2846
+ Py_INCREF(right);
2847
+ return right;
2848
+ }
2849
+ right_len = PyUnicode_GET_LENGTH(right);
2850
+ if (right_len == 0) {
2851
+ Py_INCREF(left);
2852
+ return left;
2853
+ }
2854
+ if (unlikely(left_len > PY_SSIZE_T_MAX - right_len)) {
2855
+ PyErr_SetString(PyExc_OverflowError,
2856
+ "strings are too large to concat");
2857
+ return NULL;
2858
+ }
2859
+ new_len = left_len + right_len;
2860
+
2861
+ if (__Pyx_unicode_modifiable(left)
2862
+ && PyUnicode_CheckExact(right)
2863
+ && PyUnicode_KIND(right) <= PyUnicode_KIND(left)
2864
+ // Don't resize for ascii += latin1. Convert ascii to latin1 requires
2865
+ // to change the structure size, but characters are stored just after
2866
+ // the structure, and so it requires to move all characters which is
2867
+ // not so different than duplicating the string.
2868
+ && !(PyUnicode_IS_ASCII(left) && !PyUnicode_IS_ASCII(right))) {
2869
+
2870
+ int ret;
2871
+ // GIVEREF/GOTREF since we expect *p_left to change (although it won't change on failures).
2872
+ __Pyx_GIVEREF(*p_left);
2873
+ ret = PyUnicode_Resize(p_left, new_len);
2874
+ __Pyx_GOTREF(*p_left);
2875
+ if (unlikely(ret != 0))
2876
+ return NULL;
2877
+
2878
+ // copy 'right' into the newly allocated area of 'left'
2879
+ #if PY_VERSION_HEX >= 0x030d0000
2880
+ if (unlikely(PyUnicode_CopyCharacters(*p_left, left_len, right, 0, right_len) < 0)) return NULL;
2881
+ #else
2882
+ _PyUnicode_FastCopyCharacters(*p_left, left_len, right, 0, right_len);
2883
+ #endif
2884
+ __Pyx_INCREF(*p_left);
2885
+ __Pyx_GIVEREF(*p_left);
2886
+ return *p_left;
2887
+ } else {
2888
+ return __Pyx_PyUnicode_Concat(left, right);
2889
+ }
2890
+ }
2891
+ #endif
2892
+
2893
+
2894
+ /////////////// PySequenceMultiply.proto ///////////////
2895
+
2896
+ #define __Pyx_PySequence_Multiply_Left(mul, seq) __Pyx_PySequence_Multiply(seq, mul)
2897
+ static CYTHON_INLINE PyObject* __Pyx_PySequence_Multiply(PyObject *seq, Py_ssize_t mul);
2898
+
2899
+ /////////////// PySequenceMultiply ///////////////
2900
+
2901
+ static PyObject* __Pyx_PySequence_Multiply_Generic(PyObject *seq, Py_ssize_t mul) {
2902
+ PyObject *result, *pymul = PyLong_FromSsize_t(mul);
2903
+ if (unlikely(!pymul))
2904
+ return NULL;
2905
+ result = PyNumber_Multiply(seq, pymul);
2906
+ Py_DECREF(pymul);
2907
+ return result;
2908
+ }
2909
+
2910
+ static CYTHON_INLINE PyObject* __Pyx_PySequence_Multiply(PyObject *seq, Py_ssize_t mul) {
2911
+ #if CYTHON_USE_TYPE_SLOTS
2912
+ PyTypeObject *type = Py_TYPE(seq);
2913
+ if (likely(type->tp_as_sequence && type->tp_as_sequence->sq_repeat)) {
2914
+ return type->tp_as_sequence->sq_repeat(seq, mul);
2915
+ } else
2916
+ #endif
2917
+ {
2918
+ return __Pyx_PySequence_Multiply_Generic(seq, mul);
2919
+ }
2920
+ }
2921
+
2922
+
2923
+ /////////////// FormatTypeName.proto ///////////////
2924
+
2925
+ #if CYTHON_COMPILING_IN_LIMITED_API
2926
+ typedef PyObject *__Pyx_TypeName;
2927
+ #define __Pyx_FMT_TYPENAME "%U"
2928
+ static __Pyx_TypeName __Pyx_PyType_GetName(PyTypeObject* tp); /*proto*/
2929
+ #define __Pyx_DECREF_TypeName(obj) Py_XDECREF(obj)
2930
+ #else
2931
+ typedef const char *__Pyx_TypeName;
2932
+ #define __Pyx_FMT_TYPENAME "%.200s"
2933
+ #define __Pyx_PyType_GetName(tp) ((tp)->tp_name)
2934
+ #define __Pyx_DECREF_TypeName(obj)
2935
+ #endif
2936
+
2937
+ /////////////// FormatTypeName ///////////////
2938
+
2939
+ #if CYTHON_COMPILING_IN_LIMITED_API
2940
+ static __Pyx_TypeName
2941
+ __Pyx_PyType_GetName(PyTypeObject* tp)
2942
+ {
2943
+ PyObject *name = __Pyx_PyObject_GetAttrStr((PyObject *)tp,
2944
+ PYIDENT("__name__"));
2945
+ if (unlikely(name == NULL) || unlikely(!PyUnicode_Check(name))) {
2946
+ PyErr_Clear();
2947
+ Py_XDECREF(name);
2948
+ name = __Pyx_NewRef(PYUNICODE("?"));
2949
+ }
2950
+ return name;
2951
+ }
2952
+ #endif
2953
+
2954
+
2955
+ /////////////// RaiseUnexpectedTypeError.proto ///////////////
2956
+
2957
+ static int __Pyx_RaiseUnexpectedTypeError(const char *expected, PyObject *obj); /*proto*/
2958
+
2959
+ /////////////// RaiseUnexpectedTypeError ///////////////
2960
+
2961
+ static int
2962
+ __Pyx_RaiseUnexpectedTypeError(const char *expected, PyObject *obj)
2963
+ {
2964
+ __Pyx_TypeName obj_type_name = __Pyx_PyType_GetName(Py_TYPE(obj));
2965
+ PyErr_Format(PyExc_TypeError, "Expected %s, got " __Pyx_FMT_TYPENAME,
2966
+ expected, obj_type_name);
2967
+ __Pyx_DECREF_TypeName(obj_type_name);
2968
+ return 0;
2969
+ }
2970
+
2971
+
2972
+ /////////////// RaiseUnboundLocalError.proto ///////////////
2973
+ static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname);/*proto*/
2974
+
2975
+ /////////////// RaiseUnboundLocalError ///////////////
2976
+ static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) {
2977
+ PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname);
2978
+ }
2979
+
2980
+
2981
+ /////////////// RaiseClosureNameError.proto ///////////////
2982
+ static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname);/*proto*/
2983
+
2984
+ /////////////// RaiseClosureNameError ///////////////
2985
+ static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname) {
2986
+ PyErr_Format(PyExc_NameError, "free variable '%s' referenced before assignment in enclosing scope", varname);
2987
+ }
2988
+
2989
+
2990
+ /////////////// RaiseUnboundMemoryviewSliceNogil.proto ///////////////
2991
+ static void __Pyx_RaiseUnboundMemoryviewSliceNogil(const char *varname);/*proto*/
2992
+
2993
+ /////////////// RaiseUnboundMemoryviewSliceNogil ///////////////
2994
+ //@requires: RaiseUnboundLocalError
2995
+
2996
+ // Don't inline the function, it should really never be called in production
2997
+ static void __Pyx_RaiseUnboundMemoryviewSliceNogil(const char *varname) {
2998
+ PyGILState_STATE gilstate = PyGILState_Ensure();
2999
+ __Pyx_RaiseUnboundLocalError(varname);
3000
+ PyGILState_Release(gilstate);
3001
+ }
3002
+
3003
+ //////////////// RaiseCppGlobalNameError.proto ///////////////////////
3004
+ static CYTHON_INLINE void __Pyx_RaiseCppGlobalNameError(const char *varname); /*proto*/
3005
+
3006
+ /////////////// RaiseCppGlobalNameError //////////////////////////////
3007
+ static CYTHON_INLINE void __Pyx_RaiseCppGlobalNameError(const char *varname) {
3008
+ PyErr_Format(PyExc_NameError, "C++ global '%s' is not initialized", varname);
3009
+ }
3010
+
3011
+ //////////////// RaiseCppAttributeError.proto ///////////////////////
3012
+ static CYTHON_INLINE void __Pyx_RaiseCppAttributeError(const char *varname); /*proto*/
3013
+
3014
+ /////////////// RaiseCppAttributeError //////////////////////////////
3015
+ static CYTHON_INLINE void __Pyx_RaiseCppAttributeError(const char *varname) {
3016
+ PyErr_Format(PyExc_AttributeError, "C++ attribute '%s' is not initialized", varname);
3017
+ }
3018
+
3019
+ /////////////// ListPack.proto //////////////////////////////////////
3020
+
3021
+ // Equivalent to PyTuple_Pack for sections where we want to reduce the code size
3022
+ static PyObject *__Pyx_PyList_Pack(Py_ssize_t n, ...); /* proto */
3023
+
3024
+ /////////////// ListPack //////////////////////////////////////
3025
+
3026
+ static PyObject *__Pyx_PyList_Pack(Py_ssize_t n, ...) {
3027
+ va_list va;
3028
+ PyObject *l = PyList_New(n);
3029
+ va_start(va, n);
3030
+ if (unlikely(!l)) goto end;
3031
+
3032
+ for (Py_ssize_t i=0; i<n; ++i) {
3033
+ PyObject *arg = va_arg(va, PyObject*);
3034
+ Py_INCREF(arg);
3035
+ if (__Pyx_PyList_SET_ITEM(l, i, arg) != (0)) {
3036
+ Py_CLEAR(l);
3037
+ goto end;
3038
+ }
3039
+ }
3040
+
3041
+ end:
3042
+ va_end(va);
3043
+ return l;
3044
+ }
3045
+
3046
+ /////////////// LengthHint.proto //////////////////////////////////////
3047
+
3048
+ #if CYTHON_COMPILING_IN_LIMITED_API
3049
+ // We could reimplement it fully, however since it's only an optimization
3050
+ // the simpler version is to make it the default.
3051
+ #define __Pyx_PyObject_LengthHint(o, defaultval) (defaultval)
3052
+ #else
3053
+ #define __Pyx_PyObject_LengthHint(o, defaultval) PyObject_LengthHint(o, defaultval)
3054
+ #endif