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