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,3319 @@
1
+ /////////////// InitLimitedAPI ///////////////
2
+
3
+ #if defined(Py_LIMITED_API)
4
+ #if !defined(CYTHON_LIMITED_API)
5
+ // Use Py_LIMITED_API as the main control for Cython's limited API mode.
6
+ // However it's still possible to define CYTHON_LIMITED_API alone to
7
+ // force Cython to use Limited-API code without enforcing it in Python.
8
+ #define CYTHON_LIMITED_API 1
9
+ #endif
10
+ #elif defined(CYTHON_LIMITED_API)
11
+ #ifdef _MSC_VER
12
+ #pragma message ("Limited API usage is enabled with 'CYTHON_LIMITED_API' but 'Py_LIMITED_API' does not define a Python target version. Consider setting 'Py_LIMITED_API' instead.")
13
+ #else
14
+ #warning Limited API usage is enabled with 'CYTHON_LIMITED_API' but 'Py_LIMITED_API' does not define a Python target version. Consider setting 'Py_LIMITED_API' instead.
15
+ #endif
16
+ #endif
17
+
18
+ /////////////// CModulePreamble ///////////////
19
+
20
+ #include <stddef.h> /* For offsetof */
21
+ #ifndef offsetof
22
+ #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
23
+ #endif
24
+
25
+ #if !defined(_WIN32) && !defined(WIN32) && !defined(MS_WINDOWS)
26
+ #ifndef __stdcall
27
+ #define __stdcall
28
+ #endif
29
+ #ifndef __cdecl
30
+ #define __cdecl
31
+ #endif
32
+ #ifndef __fastcall
33
+ #define __fastcall
34
+ #endif
35
+ #endif
36
+
37
+ #ifdef __has_builtin
38
+ #define __Pyx_has_cbuiltin(name) __has_builtin(name)
39
+ #else
40
+ #define __Pyx_has_cbuiltin(name) (0)
41
+ #endif
42
+
43
+ #ifndef DL_IMPORT
44
+ #define DL_IMPORT(t) t
45
+ #endif
46
+ #ifndef DL_EXPORT
47
+ #define DL_EXPORT(t) t
48
+ #endif
49
+
50
+ // For use in DL_IMPORT/DL_EXPORT macros.
51
+ #define __PYX_COMMA ,
52
+
53
+ #ifndef PY_LONG_LONG
54
+ #define PY_LONG_LONG LONG_LONG
55
+ #endif
56
+
57
+ #ifndef Py_HUGE_VAL
58
+ #define Py_HUGE_VAL HUGE_VAL
59
+ #endif
60
+
61
+ // For the limited API it often makes sense to use Py_LIMITED_API rather than PY_VERSION_HEX
62
+ // when doing version checks.
63
+ #define __PYX_LIMITED_VERSION_HEX PY_VERSION_HEX
64
+
65
+ #if defined(CYTHON_LIMITED_API)
66
+ #ifdef Py_LIMITED_API
67
+ #undef __PYX_LIMITED_VERSION_HEX
68
+ #define __PYX_LIMITED_VERSION_HEX Py_LIMITED_API
69
+ #if Py_LIMITED_API < 0x03090000
70
+ #error "Cython 3.3 requires the Python Limited API version to be 3.9 or greater."
71
+ #endif
72
+ #endif
73
+ #if defined(GRAALVM_PYTHON) || defined(PYPY_VERSION)
74
+ #ifdef _MSC_VER
75
+ #pragma message ("Py_LIMITED_API is defined on PyPy or GraalPy. This takes precedence over Cython's specialized \
76
+ code for PyPy and GraalPy and is unlikely to work.")
77
+ #else
78
+ #warning "Py_LIMITED_API is defined on PyPy or GraalPy. This takes precedence over Cython's specialized \
79
+ code for PyPy and GraalPy and is unlikely to work."
80
+ #endif
81
+ #endif
82
+ #define CYTHON_COMPILING_IN_PYPY 0
83
+ #define CYTHON_COMPILING_IN_CPYTHON 0
84
+ #define CYTHON_COMPILING_IN_LIMITED_API 1
85
+ #define CYTHON_COMPILING_IN_GRAAL 0
86
+
87
+ #define CYTHON_COMPILING_IN_CPYTHON_FREETHREADING 0
88
+
89
+ #undef CYTHON_USE_TYPE_SLOTS
90
+ #define CYTHON_USE_TYPE_SLOTS 0
91
+ #undef CYTHON_USE_TYPE_SPECS
92
+ #define CYTHON_USE_TYPE_SPECS 1
93
+ #undef CYTHON_USE_PYTYPE_LOOKUP
94
+ #define CYTHON_USE_PYTYPE_LOOKUP 0
95
+ #undef CYTHON_USE_PYLIST_INTERNALS
96
+ #define CYTHON_USE_PYLIST_INTERNALS 0
97
+ #undef CYTHON_USE_UNICODE_INTERNALS
98
+ #define CYTHON_USE_UNICODE_INTERNALS 0
99
+ #ifndef CYTHON_USE_UNICODE_WRITER
100
+ #define CYTHON_USE_UNICODE_WRITER 0
101
+ #endif
102
+ #undef CYTHON_USE_PYLONG_INTERNALS
103
+ #define CYTHON_USE_PYLONG_INTERNALS 0
104
+ #ifndef CYTHON_AVOID_BORROWED_REFS
105
+ #define CYTHON_AVOID_BORROWED_REFS 0
106
+ #endif
107
+ #ifndef CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS
108
+ #define CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS 0
109
+ #endif
110
+ #undef CYTHON_ASSUME_SAFE_MACROS
111
+ #define CYTHON_ASSUME_SAFE_MACROS 0
112
+ #undef CYTHON_ASSUME_SAFE_SIZE
113
+ #define CYTHON_ASSUME_SAFE_SIZE 0
114
+ #undef CYTHON_UNPACK_METHODS
115
+ #define CYTHON_UNPACK_METHODS 0
116
+ #undef CYTHON_FAST_THREAD_STATE
117
+ #define CYTHON_FAST_THREAD_STATE 0
118
+ #undef CYTHON_FAST_GIL
119
+ #define CYTHON_FAST_GIL 0
120
+ #undef CYTHON_VECTORCALL
121
+ #define CYTHON_VECTORCALL (__PYX_LIMITED_VERSION_HEX >= 0x030C0000)
122
+ #ifndef CYTHON_VECTORCALL_TPNEW
123
+ #define CYTHON_VECTORCALL_TPNEW (CYTHON_VECTORCALL && __PYX_LIMITED_VERSION_HEX >= 0x030E0000)
124
+ #endif
125
+ #ifndef CYTHON_PEP487_INIT_SUBCLASS
126
+ #define CYTHON_PEP487_INIT_SUBCLASS 1
127
+ #endif
128
+ #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
129
+ #define CYTHON_PEP489_MULTI_PHASE_INIT 1
130
+ #endif
131
+ #ifndef CYTHON_USE_MODULE_STATE
132
+ #define CYTHON_USE_MODULE_STATE 0
133
+ #endif
134
+ #undef CYTHON_USE_SYS_MONITORING
135
+ #define CYTHON_USE_SYS_MONITORING 0
136
+ #ifndef CYTHON_USE_TP_FINALIZE
137
+ // PyObject_CallFinalizerFromDealloc is missing and not easily replaced
138
+ #define CYTHON_USE_TP_FINALIZE (__PYX_LIMITED_VERSION_HEX >= 0x030F0000 && PY_VERSION_HEX > 0x030F00A8)
139
+ #endif
140
+ #ifndef CYTHON_USE_AM_SEND
141
+ #define CYTHON_USE_AM_SEND (__PYX_LIMITED_VERSION_HEX >= 0x030A0000)
142
+ #endif
143
+ #undef CYTHON_USE_DICT_VERSIONS
144
+ #define CYTHON_USE_DICT_VERSIONS 0
145
+ #undef CYTHON_USE_EXC_INFO_STACK
146
+ #define CYTHON_USE_EXC_INFO_STACK 0
147
+ #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
148
+ #define CYTHON_UPDATE_DESCRIPTOR_DOC 0
149
+ #endif
150
+ #ifndef CYTHON_USE_OWN_PREP_RERAISE_STAR
151
+ #define CYTHON_USE_OWN_PREP_RERAISE_STAR 1
152
+ #endif
153
+ #ifndef CYTHON_USE_FREELISTS
154
+ #define CYTHON_USE_FREELISTS 1
155
+ #endif
156
+ #undef CYTHON_IMMORTAL_CONSTANTS
157
+ #define CYTHON_IMMORTAL_CONSTANTS 0
158
+ // Opaque objects: generally we prefer not to use them for performance reasons.
159
+ #if __PYX_LIMITED_VERSION_HEX < 0x030E0000
160
+ // If users manually request them then they aren't usable before 3.14 because
161
+ // it isn't possible to specify relative offsets like vectorcall.
162
+ #undef CYTHON_OPAQUE_OBJECTS
163
+ #define CYTHON_OPAQUE_OBJECTS 0
164
+ #elif !defined(CYTHON_OPAQUE_OBJECTS)
165
+ // From 3.15 it starts being needed for freethreading compatibility
166
+ #define CYTHON_OPAQUE_OBJECTS (__PYX_LIMITED_VERSION_HEX >= 0x030F0000)
167
+ #endif
168
+
169
+ #elif defined(GRAALVM_PYTHON)
170
+ /* For very preliminary testing purposes. Most variables are set the same as PyPy.
171
+ The existence of this section does not imply that anything works or is even tested */
172
+ // GRAALVM_PYTHON test comes before PyPy test because GraalPython unhelpfully defines PYPY_VERSION
173
+ #define CYTHON_COMPILING_IN_PYPY 0
174
+ #define CYTHON_COMPILING_IN_CPYTHON 0
175
+ #define CYTHON_COMPILING_IN_LIMITED_API 0
176
+ #define CYTHON_COMPILING_IN_GRAAL 1
177
+
178
+ #define CYTHON_COMPILING_IN_CPYTHON_FREETHREADING 0
179
+
180
+ #ifndef CYTHON_USE_TYPE_SLOTS
181
+ #define CYTHON_USE_TYPE_SLOTS 0
182
+ #endif
183
+ #undef CYTHON_USE_TYPE_SPECS
184
+ #define CYTHON_USE_TYPE_SPECS 0
185
+ #undef CYTHON_USE_PYTYPE_LOOKUP
186
+ #define CYTHON_USE_PYTYPE_LOOKUP 0
187
+ #undef CYTHON_USE_PYLIST_INTERNALS
188
+ #define CYTHON_USE_PYLIST_INTERNALS 0
189
+ #undef CYTHON_USE_UNICODE_INTERNALS
190
+ #define CYTHON_USE_UNICODE_INTERNALS 0
191
+ #undef CYTHON_USE_UNICODE_WRITER
192
+ #define CYTHON_USE_UNICODE_WRITER 0
193
+ #undef CYTHON_USE_PYLONG_INTERNALS
194
+ #define CYTHON_USE_PYLONG_INTERNALS 0
195
+ #undef CYTHON_AVOID_BORROWED_REFS
196
+ #define CYTHON_AVOID_BORROWED_REFS 1
197
+ #undef CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS
198
+ #define CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS 0
199
+ #undef CYTHON_ASSUME_SAFE_MACROS
200
+ #define CYTHON_ASSUME_SAFE_MACROS 0
201
+ #undef CYTHON_ASSUME_SAFE_SIZE
202
+ #define CYTHON_ASSUME_SAFE_SIZE 0
203
+ #undef CYTHON_UNPACK_METHODS
204
+ #define CYTHON_UNPACK_METHODS 0
205
+ #undef CYTHON_FAST_THREAD_STATE
206
+ #define CYTHON_FAST_THREAD_STATE 0
207
+ #undef CYTHON_FAST_GIL
208
+ #define CYTHON_FAST_GIL 0
209
+ #ifndef CYTHON_VECTORCALL
210
+ #define CYTHON_VECTORCALL 1
211
+ #endif
212
+ #if CYTHON_USE_TYPE_SPECS && PY_VERSION_HEX < 0x030E0000
213
+ // Py_tp_vectorcall slot unavailable
214
+ #undef CYTHON_VECTORCALL_TPNEW
215
+ #define CYTHON_VECTORCALL_TPNEW 0
216
+ #elif !defined(CYTHON_VECTORCALL_TPNEW)
217
+ #define CYTHON_VECTORCALL_TPNEW CYTHON_VECTORCALL
218
+ #endif
219
+ #ifndef CYTHON_PEP487_INIT_SUBCLASS
220
+ #define CYTHON_PEP487_INIT_SUBCLASS 1
221
+ #endif
222
+ #undef CYTHON_PEP489_MULTI_PHASE_INIT
223
+ #define CYTHON_PEP489_MULTI_PHASE_INIT 1
224
+ #undef CYTHON_USE_MODULE_STATE
225
+ #define CYTHON_USE_MODULE_STATE 0
226
+ #undef CYTHON_USE_SYS_MONITORING
227
+ #define CYTHON_USE_SYS_MONITORING 0
228
+ #undef CYTHON_USE_TP_FINALIZE
229
+ #define CYTHON_USE_TP_FINALIZE 0
230
+ #undef CYTHON_USE_AM_SEND
231
+ #define CYTHON_USE_AM_SEND 0
232
+ #undef CYTHON_USE_DICT_VERSIONS
233
+ #define CYTHON_USE_DICT_VERSIONS 0
234
+ #undef CYTHON_USE_EXC_INFO_STACK
235
+ #define CYTHON_USE_EXC_INFO_STACK 1
236
+ #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
237
+ #define CYTHON_UPDATE_DESCRIPTOR_DOC 0
238
+ #endif
239
+ #ifndef CYTHON_USE_OWN_PREP_RERAISE_STAR
240
+ #define CYTHON_USE_OWN_PREP_RERAISE_STAR 1
241
+ #endif
242
+ #undef CYTHON_USE_FREELISTS
243
+ #define CYTHON_USE_FREELISTS 0
244
+ #undef CYTHON_IMMORTAL_CONSTANTS
245
+ #define CYTHON_IMMORTAL_CONSTANTS 0
246
+ #undef CYTHON_OPAQUE_OBJECTS
247
+ #define CYTHON_OPAQUE_OBJECTS 0
248
+
249
+ #elif defined(PYPY_VERSION)
250
+ #define CYTHON_COMPILING_IN_PYPY 1
251
+ #define CYTHON_COMPILING_IN_CPYTHON 0
252
+ #define CYTHON_COMPILING_IN_LIMITED_API 0
253
+ #define CYTHON_COMPILING_IN_GRAAL 0
254
+
255
+ #define CYTHON_COMPILING_IN_CPYTHON_FREETHREADING 0
256
+
257
+ #undef CYTHON_USE_TYPE_SLOTS
258
+ #define CYTHON_USE_TYPE_SLOTS 1
259
+ #ifndef CYTHON_USE_TYPE_SPECS
260
+ #define CYTHON_USE_TYPE_SPECS 0
261
+ #endif
262
+ #undef CYTHON_USE_PYTYPE_LOOKUP
263
+ #define CYTHON_USE_PYTYPE_LOOKUP 0
264
+ #undef CYTHON_USE_PYLIST_INTERNALS
265
+ #define CYTHON_USE_PYLIST_INTERNALS 0
266
+ #undef CYTHON_USE_UNICODE_INTERNALS
267
+ #define CYTHON_USE_UNICODE_INTERNALS 0
268
+ #undef CYTHON_USE_UNICODE_WRITER
269
+ #define CYTHON_USE_UNICODE_WRITER 0
270
+ #undef CYTHON_USE_PYLONG_INTERNALS
271
+ #define CYTHON_USE_PYLONG_INTERNALS 0
272
+ #undef CYTHON_AVOID_BORROWED_REFS
273
+ #define CYTHON_AVOID_BORROWED_REFS 1
274
+ #undef CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS
275
+ #define CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS 1
276
+ #undef CYTHON_ASSUME_SAFE_MACROS
277
+ #define CYTHON_ASSUME_SAFE_MACROS 0
278
+ #ifndef CYTHON_ASSUME_SAFE_SIZE
279
+ #define CYTHON_ASSUME_SAFE_SIZE 1
280
+ #endif
281
+ #undef CYTHON_UNPACK_METHODS
282
+ #define CYTHON_UNPACK_METHODS 0
283
+ #undef CYTHON_FAST_THREAD_STATE
284
+ #define CYTHON_FAST_THREAD_STATE 0
285
+ #undef CYTHON_FAST_GIL
286
+ #define CYTHON_FAST_GIL 0
287
+ #ifndef CYTHON_VECTORCALL
288
+ #define CYTHON_VECTORCALL 1
289
+ #endif
290
+ #if CYTHON_USE_TYPE_SPECS && PY_VERSION_HEX < 0x030E0000
291
+ // Py_tp_vectorcall slot unavailable
292
+ #undef CYTHON_VECTORCALL_TPNEW
293
+ #define CYTHON_VECTORCALL_TPNEW 0
294
+ #elif !defined(CYTHON_VECTORCALL_TPNEW)
295
+ // PyPy doesn't define the slot below 7.3.8.
296
+ #define CYTHON_VECTORCALL_TPNEW (PYPY_VERSION_NUM >= 0x07030800 && CYTHON_VECTORCALL)
297
+ #endif
298
+ #ifndef CYTHON_PEP487_INIT_SUBCLASS
299
+ #define CYTHON_PEP487_INIT_SUBCLASS 1
300
+ #endif
301
+ #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
302
+ #define CYTHON_PEP489_MULTI_PHASE_INIT 1
303
+ #endif
304
+ #undef CYTHON_USE_MODULE_STATE
305
+ #define CYTHON_USE_MODULE_STATE 0
306
+ #undef CYTHON_USE_SYS_MONITORING
307
+ #define CYTHON_USE_SYS_MONITORING 0
308
+ #ifndef CYTHON_USE_TP_FINALIZE
309
+ #define CYTHON_USE_TP_FINALIZE (PYPY_VERSION_NUM >= 0x07030C00)
310
+ #endif
311
+ #undef CYTHON_USE_AM_SEND
312
+ #define CYTHON_USE_AM_SEND 0
313
+ #undef CYTHON_USE_DICT_VERSIONS
314
+ #define CYTHON_USE_DICT_VERSIONS 0
315
+ #undef CYTHON_USE_EXC_INFO_STACK
316
+ #define CYTHON_USE_EXC_INFO_STACK 0
317
+ #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
318
+ #define CYTHON_UPDATE_DESCRIPTOR_DOC (PYPY_VERSION_NUM >= 0x07031100)
319
+ #endif
320
+ #ifndef CYTHON_USE_OWN_PREP_RERAISE_STAR
321
+ #define CYTHON_USE_OWN_PREP_RERAISE_STAR 1
322
+ #endif
323
+ #undef CYTHON_USE_FREELISTS
324
+ #define CYTHON_USE_FREELISTS 0
325
+ #undef CYTHON_IMMORTAL_CONSTANTS
326
+ #define CYTHON_IMMORTAL_CONSTANTS 0
327
+ #undef CYTHON_OPAQUE_OBJECTS
328
+ #define CYTHON_OPAQUE_OBJECTS 0
329
+
330
+ #else
331
+ #define CYTHON_COMPILING_IN_PYPY 0
332
+ #define CYTHON_COMPILING_IN_CPYTHON 1
333
+ #define CYTHON_COMPILING_IN_LIMITED_API 0
334
+ #define CYTHON_COMPILING_IN_GRAAL 0
335
+
336
+ #ifdef Py_GIL_DISABLED
337
+ #define CYTHON_COMPILING_IN_CPYTHON_FREETHREADING 1
338
+ #else
339
+ #define CYTHON_COMPILING_IN_CPYTHON_FREETHREADING 0
340
+ #endif
341
+
342
+ #if PY_VERSION_HEX < 0x030A0000
343
+ // Before Py3.10, PyObject_GetSlot() rejects static (non-heap) types.
344
+ #undef CYTHON_USE_TYPE_SLOTS
345
+ #define CYTHON_USE_TYPE_SLOTS 1
346
+ #elif !defined(CYTHON_USE_TYPE_SLOTS)
347
+ #define CYTHON_USE_TYPE_SLOTS 1
348
+ #endif
349
+ #ifndef CYTHON_USE_TYPE_SPECS
350
+ #define CYTHON_USE_TYPE_SPECS 0
351
+ #endif
352
+ #ifndef CYTHON_USE_PYTYPE_LOOKUP
353
+ #define CYTHON_USE_PYTYPE_LOOKUP 1
354
+ #endif
355
+ #ifndef CYTHON_USE_PYLONG_INTERNALS
356
+ #define CYTHON_USE_PYLONG_INTERNALS 1
357
+ #endif
358
+ #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
359
+ #undef CYTHON_USE_PYLIST_INTERNALS
360
+ // Use thread-safe CPython C API calls to manipulate list contents
361
+ #define CYTHON_USE_PYLIST_INTERNALS 0
362
+ #elif !defined(CYTHON_USE_PYLIST_INTERNALS)
363
+ #define CYTHON_USE_PYLIST_INTERNALS 1
364
+ #endif
365
+ #ifndef CYTHON_USE_UNICODE_INTERNALS
366
+ #define CYTHON_USE_UNICODE_INTERNALS 1
367
+ #endif
368
+ #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING || PY_VERSION_HEX >= 0x030B00A2
369
+ // Python 3.11a2 hid _PyLong_FormatAdvancedWriter and _PyFloat_FormatAdvancedWriter
370
+ // therefore disable unicode writer until a better alternative appears
371
+ #undef CYTHON_USE_UNICODE_WRITER
372
+ #define CYTHON_USE_UNICODE_WRITER 0
373
+ #elif !defined(CYTHON_USE_UNICODE_WRITER)
374
+ #define CYTHON_USE_UNICODE_WRITER 1
375
+ #endif
376
+ // CYTHON_AVOID_BORROWED_REFS - Avoid borrowed references and always request owned references directly instead.
377
+ #ifndef CYTHON_AVOID_BORROWED_REFS
378
+ #define CYTHON_AVOID_BORROWED_REFS 0
379
+ #endif
380
+ // CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS - Avoid borrowed references that are not thread-safe in the free-threaded build of CPython.
381
+ #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
382
+ #undef CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS
383
+ #define CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS 1
384
+ #elif !defined(CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS)
385
+ #define CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS 0
386
+ #endif
387
+ // CYTHON_ASSUME_SAFE_MACROS - Assume that macro calls do not fail and do not raise exceptions.
388
+ #ifndef CYTHON_ASSUME_SAFE_MACROS
389
+ #define CYTHON_ASSUME_SAFE_MACROS 1
390
+ #endif
391
+ // CYTHON_ASSUME_SAFE_SIZE - Assume that Py*_GET_SIZE() calls do not fail and do not raise exceptions.
392
+ #ifndef CYTHON_ASSUME_SAFE_SIZE
393
+ #define CYTHON_ASSUME_SAFE_SIZE 1
394
+ #endif
395
+ #ifndef CYTHON_UNPACK_METHODS
396
+ #define CYTHON_UNPACK_METHODS 1
397
+ #endif
398
+ #ifndef CYTHON_FAST_THREAD_STATE
399
+ #define CYTHON_FAST_THREAD_STATE 1
400
+ #endif
401
+ #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
402
+ #undef CYTHON_FAST_GIL
403
+ #define CYTHON_FAST_GIL 0
404
+ #elif !defined(CYTHON_FAST_GIL)
405
+ // FIXME: FastGIL can probably be supported also in CPython 3.12 but needs to be adapted.
406
+ // The gain is unclear, however, since the GIL handling itself became faster in recent CPython versions.
407
+ #define CYTHON_FAST_GIL (PY_VERSION_HEX < 0x030C00A6)
408
+ #endif
409
+ #ifndef CYTHON_VECTORCALL
410
+ #define CYTHON_VECTORCALL 1
411
+ #endif
412
+ #if CYTHON_USE_TYPE_SPECS && PY_VERSION_HEX < 0x030E0000
413
+ // Py_tp_vectorcall slot unavailable
414
+ #undef CYTHON_VECTORCALL_TPNEW
415
+ #define CYTHON_VECTORCALL_TPNEW 0
416
+ #elif !defined(CYTHON_VECTORCALL_TPNEW)
417
+ #define CYTHON_VECTORCALL_TPNEW CYTHON_VECTORCALL
418
+ #endif
419
+ #ifndef CYTHON_PEP487_INIT_SUBCLASS
420
+ #define CYTHON_PEP487_INIT_SUBCLASS 1
421
+ #endif
422
+ #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
423
+ #define CYTHON_PEP489_MULTI_PHASE_INIT 1
424
+ #endif
425
+ // CYTHON_USE_MODULE_STATE - Use a module state/globals struct tied to the module object.
426
+ #ifndef CYTHON_USE_MODULE_STATE
427
+ // EXPERIMENTAL !!
428
+ #define CYTHON_USE_MODULE_STATE 0
429
+ #endif
430
+ #ifndef CYTHON_USE_SYS_MONITORING
431
+ #define CYTHON_USE_SYS_MONITORING (PY_VERSION_HEX >= 0x030d00B1)
432
+ #endif
433
+ #ifndef CYTHON_USE_TP_FINALIZE
434
+ #define CYTHON_USE_TP_FINALIZE 1
435
+ #endif
436
+ #ifndef CYTHON_USE_AM_SEND
437
+ #define CYTHON_USE_AM_SEND 1
438
+ #endif
439
+ #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
440
+ #undef CYTHON_USE_DICT_VERSIONS
441
+ #define CYTHON_USE_DICT_VERSIONS 0
442
+ #elif !defined(CYTHON_USE_DICT_VERSIONS)
443
+ // Python 3.12a5 deprecated "ma_version_tag"
444
+ // and we use static variables with dict versions so it's incompatible with module state
445
+ #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX < 0x030C00A5 && !CYTHON_USE_MODULE_STATE)
446
+ #endif
447
+ #ifndef CYTHON_USE_EXC_INFO_STACK
448
+ #define CYTHON_USE_EXC_INFO_STACK 1
449
+ #endif
450
+ #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
451
+ #define CYTHON_UPDATE_DESCRIPTOR_DOC 1
452
+ #endif
453
+ #ifndef CYTHON_USE_OWN_PREP_RERAISE_STAR
454
+ // Allow this to be overridden mainly to aid debugging of our internal
455
+ // implementation
456
+ #define CYTHON_USE_OWN_PREP_RERAISE_STAR (PY_VERSION_HEX < 0x030C00B2)
457
+ #endif
458
+ #ifndef CYTHON_USE_FREELISTS
459
+ #define CYTHON_USE_FREELISTS (!CYTHON_COMPILING_IN_CPYTHON_FREETHREADING)
460
+ #endif
461
+ #if defined(CYTHON_IMMORTAL_CONSTANTS) && PY_VERSION_HEX < 0x030C0000
462
+ #undef CYTHON_IMMORTAL_CONSTANTS
463
+ #define CYTHON_IMMORTAL_CONSTANTS 0 // definitely won't work
464
+ #elif !defined(CYTHON_IMMORTAL_CONSTANTS)
465
+ // The assumption is that immortal constants mainly help reduce contention when accessed from many threads
466
+ // (hence freethreading only), and that with module state the module may be unloaded and reloaded (so they
467
+ // could be a memory leak). However the user can always override these assumptions.
468
+ #define CYTHON_IMMORTAL_CONSTANTS (PY_VERSION_HEX >= 0x030C0000 && !CYTHON_USE_MODULE_STATE && CYTHON_COMPILING_IN_CPYTHON_FREETHREADING)
469
+ #endif
470
+ #ifndef CYTHON_OPAQUE_OBJECTS
471
+ #define CYTHON_OPAQUE_OBJECTS 0
472
+ #endif
473
+ #endif
474
+
475
+ #if CYTHON_USE_PYLONG_INTERNALS
476
+ /* These short defines from the PyLong header can easily conflict with other code */
477
+ #undef SHIFT
478
+ #undef BASE
479
+ #undef MASK
480
+ /* Compile-time sanity check that these are indeed equal. Github issue #2670. */
481
+ #ifdef SIZEOF_VOID_P
482
+ enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) };
483
+ #endif
484
+ #endif
485
+
486
+ #ifndef __has_attribute
487
+ #define __has_attribute(x) 0
488
+ #endif
489
+
490
+ #ifndef __has_cpp_attribute
491
+ #define __has_cpp_attribute(x) 0
492
+ #endif
493
+
494
+ // restrict
495
+ #ifndef CYTHON_RESTRICT
496
+ #if defined(__GNUC__)
497
+ #define CYTHON_RESTRICT __restrict__
498
+ #elif defined(_MSC_VER) && _MSC_VER >= 1400
499
+ #define CYTHON_RESTRICT __restrict
500
+ #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
501
+ #define CYTHON_RESTRICT restrict
502
+ #else
503
+ #define CYTHON_RESTRICT
504
+ #endif
505
+ #endif
506
+
507
+ // unused attribute
508
+ #ifndef CYTHON_UNUSED
509
+ #if defined(__cplusplus)
510
+ /* for clang __has_cpp_attribute(maybe_unused) is true even before C++17
511
+ * but leads to warnings with -pedantic, since it is a C++17 feature */
512
+ #if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L)
513
+ #if __has_cpp_attribute(maybe_unused)
514
+ #define CYTHON_UNUSED [[maybe_unused]]
515
+ #endif
516
+ #endif
517
+ #elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
518
+ #define CYTHON_UNUSED [[maybe_unused]]
519
+ #endif
520
+ #endif
521
+ #ifndef CYTHON_UNUSED
522
+ # if defined(__GNUC__)
523
+ # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
524
+ # define CYTHON_UNUSED __attribute__ ((__unused__))
525
+ # else
526
+ # define CYTHON_UNUSED
527
+ # endif
528
+ # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
529
+ # define CYTHON_UNUSED __attribute__ ((__unused__))
530
+ # else
531
+ # define CYTHON_UNUSED
532
+ # endif
533
+ #endif
534
+
535
+ #ifndef CYTHON_UNUSED_VAR
536
+ # if defined(__cplusplus)
537
+ template<class T> void CYTHON_UNUSED_VAR( const T& ) { }
538
+ # else
539
+ # define CYTHON_UNUSED_VAR(x) (void)(x)
540
+ # endif
541
+ #endif
542
+
543
+ #ifndef CYTHON_MAYBE_UNUSED_VAR
544
+ #define CYTHON_MAYBE_UNUSED_VAR(x) CYTHON_UNUSED_VAR(x)
545
+ #endif
546
+
547
+ #ifndef CYTHON_NCP_UNUSED
548
+ # if CYTHON_COMPILING_IN_CPYTHON && !CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
549
+ # define CYTHON_NCP_UNUSED
550
+ # else
551
+ # define CYTHON_NCP_UNUSED CYTHON_UNUSED
552
+ # endif
553
+ #endif
554
+
555
+ #ifndef CYTHON_USE_CPP_STD_MOVE
556
+ // msvc doesn't set __cplusplus to a useful value
557
+ #if defined(__cplusplus) && ( \
558
+ __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1600))
559
+ #define CYTHON_USE_CPP_STD_MOVE 1
560
+ #else
561
+ #define CYTHON_USE_CPP_STD_MOVE 0
562
+ #endif
563
+ #endif
564
+
565
+ #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
566
+
567
+ #include <stdint.h>
568
+ typedef uintptr_t __pyx_uintptr_t;
569
+
570
+ #ifndef CYTHON_FALLTHROUGH
571
+ #if defined(__cplusplus)
572
+ /* for clang __has_cpp_attribute(fallthrough) is true even before C++17
573
+ * but leads to warnings with -pedantic, since it is a C++17 feature */
574
+ #if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L)
575
+ #if __has_cpp_attribute(fallthrough)
576
+ #define CYTHON_FALLTHROUGH [[fallthrough]]
577
+ #endif
578
+ #endif
579
+
580
+ #ifndef CYTHON_FALLTHROUGH
581
+ #if __has_cpp_attribute(clang::fallthrough)
582
+ #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
583
+ #elif __has_cpp_attribute(gnu::fallthrough)
584
+ #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
585
+ #endif
586
+ #endif
587
+ #endif
588
+
589
+ #ifndef CYTHON_FALLTHROUGH
590
+ #if __has_attribute(fallthrough)
591
+ #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
592
+ #else
593
+ #define CYTHON_FALLTHROUGH
594
+ #endif
595
+ #endif
596
+
597
+ #if defined(__clang__) && defined(__apple_build_version__)
598
+ #if __apple_build_version__ < 7000000 /* Xcode < 7.0 */
599
+ #undef CYTHON_FALLTHROUGH
600
+ #define CYTHON_FALLTHROUGH
601
+ #endif
602
+ #endif
603
+ #endif
604
+
605
+ #ifdef Py_UNREACHABLE
606
+ #define __Pyx_UNREACHABLE() Py_UNREACHABLE()
607
+ #elif __Pyx_has_cbuiltin(__builtin_unreachable)
608
+ #define __Pyx_UNREACHABLE() __builtin_unreachable()
609
+ #elif defined(__clang__) || defined(__INTEL_COMPILER) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)))
610
+ #define __Pyx_UNREACHABLE() __builtin_unreachable()
611
+ #elif defined(_MSC_VER)
612
+ #define __Pyx_UNREACHABLE() __assume(0)
613
+ #else
614
+ #define __Pyx_UNREACHABLE() Py_FatalError("Unreachable C code path reached")
615
+ #endif
616
+
617
+ #ifndef Py_UNREACHABLE
618
+ #define Py_UNREACHABLE() __Pyx_UNREACHABLE()
619
+ #endif
620
+
621
+ #ifdef __cplusplus
622
+ template <typename T>
623
+ struct __PYX_IS_UNSIGNED_IMPL {static const bool value = T(0) < T(-1);};
624
+ #define __PYX_IS_UNSIGNED(type) (__PYX_IS_UNSIGNED_IMPL<type>::value)
625
+ #else
626
+ #define __PYX_IS_UNSIGNED(type) (((type)-1) > 0)
627
+ #endif
628
+
629
+ #if CYTHON_COMPILING_IN_PYPY == 1
630
+ #define __PYX_NEED_TP_PRINT_SLOT (PY_VERSION_HEX < 0x030A0000)
631
+ #else
632
+ #define __PYX_NEED_TP_PRINT_SLOT 0
633
+ #endif
634
+ // reinterpret
635
+
636
+ // TODO: refactor existing code to use those macros
637
+ #define __PYX_REINTERPRET_FUNCION(func_pointer, other_pointer) ((func_pointer)(void(*)(void))(other_pointer))
638
+ // #define __PYX_REINTERPRET_POINTER(pointer_type, pointer) ((pointer_type)(void *)(pointer))
639
+ // #define __PYX_RUNTIME_REINTERPRET(type, var) (*(type *)(&var))
640
+
641
+ #if __PYX_LIMITED_VERSION_HEX < 0x030C0000
642
+ #define __Pyx_PyErr_FetchException(petype, peval, petb) PyErr_Fetch(petype, peval, petb)
643
+ #define __Pyx_PyErr_RestoreException(etype, eval, etb) PyErr_Restore(etype, eval, etb)
644
+ #else
645
+ #define __Pyx_PyErr_FetchException(petype, peval, petb) *(petype)=NULL; *(peval)=PyErr_GetRaisedException(); *(petb)=NULL
646
+ #define __Pyx_PyErr_RestoreException(etype, eval, etb) PyErr_SetRaisedException(eval)
647
+ #endif
648
+
649
+
650
+ /////////////// CInitCode ///////////////
651
+
652
+ // inline attribute
653
+ #ifndef CYTHON_INLINE
654
+ #if defined(__clang__)
655
+ #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
656
+ #elif defined(__GNUC__)
657
+ #define CYTHON_INLINE __inline__
658
+ #elif defined(_MSC_VER)
659
+ #define CYTHON_INLINE __inline
660
+ #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
661
+ #define CYTHON_INLINE inline
662
+ #else
663
+ #define CYTHON_INLINE
664
+ #endif
665
+ #endif
666
+
667
+
668
+ /////////////// CppInitCode ///////////////
669
+
670
+ #ifndef __cplusplus
671
+ #error "Cython files generated with the C++ option must be compiled with a C++ compiler."
672
+ #endif
673
+
674
+ // inline attribute
675
+ #ifndef CYTHON_INLINE
676
+ #if defined(__clang__)
677
+ #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
678
+ #else
679
+ #define CYTHON_INLINE inline
680
+ #endif
681
+ #endif
682
+
683
+ // Work around clang bug https://stackoverflow.com/questions/21847816/c-invoke-nested-template-class-destructor
684
+ // (even without the clang bug, the need not to know the typename is generally a benefit)
685
+ template<typename T>
686
+ void __Pyx_call_destructor(T& x) {
687
+ x.~T();
688
+ }
689
+
690
+ // Used for temporary variables of "reference" type.
691
+ template<typename T>
692
+ class __Pyx_FakeReference {
693
+ public:
694
+ __Pyx_FakeReference() : ptr(NULL) { }
695
+ // __Pyx_FakeReference(T& ref) : ptr(&ref) { }
696
+ // Const version needed as Cython doesn't know about const overloads (e.g. for stl containers).
697
+ __Pyx_FakeReference(const T& ref) : ptr(const_cast<T*>(&ref)) { }
698
+ T *operator->() { return ptr; }
699
+ T *operator&() { return ptr; }
700
+ operator T&() { return *ptr; }
701
+ // TODO(robertwb): Delegate all operators (or auto-generate unwrapping code where needed).
702
+ template<typename U> bool operator ==(const U& other) const { return *ptr == other; }
703
+ template<typename U> bool operator !=(const U& other) const { return *ptr != other; }
704
+ template<typename U> bool operator==(const __Pyx_FakeReference<U>& other) const { return *ptr == *other.ptr; }
705
+ template<typename U> bool operator!=(const __Pyx_FakeReference<U>& other) const { return *ptr != *other.ptr; }
706
+ private:
707
+ T *ptr;
708
+ };
709
+
710
+
711
+ /////////////// PythonCompatibility ///////////////
712
+ //@substitute: naming
713
+
714
+ #define __PYX_BUILD_PY_SSIZE_T "n"
715
+ #define CYTHON_FORMAT_SSIZE_T "z"
716
+
717
+ // TODO: remove this block
718
+ #define __Pyx_BUILTIN_MODULE_NAME "builtins"
719
+ #define __Pyx_DefaultClassType PyType_Type
720
+
721
+ #if CYTHON_COMPILING_IN_LIMITED_API
722
+ // Cython uses these constants but they are not available in the limited API.
723
+ // Therefore define them as static variables and look them up at module init.
724
+ #ifndef CO_OPTIMIZED
725
+ static int CO_OPTIMIZED;
726
+ #endif
727
+ #ifndef CO_NEWLOCALS
728
+ static int CO_NEWLOCALS;
729
+ #endif
730
+ #ifndef CO_VARARGS
731
+ static int CO_VARARGS;
732
+ #endif
733
+ #ifndef CO_VARKEYWORDS
734
+ static int CO_VARKEYWORDS;
735
+ #endif
736
+ #ifndef CO_ASYNC_GENERATOR
737
+ static int CO_ASYNC_GENERATOR;
738
+ #endif
739
+ #ifndef CO_GENERATOR
740
+ static int CO_GENERATOR;
741
+ #endif
742
+ #ifndef CO_COROUTINE
743
+ static int CO_COROUTINE;
744
+ #endif
745
+ #else
746
+ #ifndef CO_COROUTINE
747
+ #define CO_COROUTINE 0x80
748
+ #endif
749
+ #ifndef CO_ASYNC_GENERATOR
750
+ #define CO_ASYNC_GENERATOR 0x200
751
+ #endif
752
+ #endif
753
+ static int __Pyx_init_co_variables(void); /* proto */
754
+
755
+ #if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_Is)
756
+ #define __Pyx_Py_Is(x, y) Py_Is(x, y)
757
+ #else
758
+ #define __Pyx_Py_Is(x, y) ((x) == (y))
759
+ #endif
760
+ #if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_IsNone)
761
+ #define __Pyx_Py_IsNone(ob) Py_IsNone(ob)
762
+ #else
763
+ #define __Pyx_Py_IsNone(ob) __Pyx_Py_Is((ob), Py_None)
764
+ #endif
765
+ #if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_IsTrue)
766
+ #define __Pyx_Py_IsTrue(ob) Py_IsTrue(ob)
767
+ #else
768
+ #define __Pyx_Py_IsTrue(ob) __Pyx_Py_Is((ob), Py_True)
769
+ #endif
770
+ #if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_IsFalse)
771
+ #define __Pyx_Py_IsFalse(ob) Py_IsFalse(ob)
772
+ #else
773
+ #define __Pyx_Py_IsFalse(ob) __Pyx_Py_Is((ob), Py_False)
774
+ #endif
775
+ #define __Pyx_NoneAsNull(obj) (__Pyx_Py_IsNone(obj) ? NULL : (obj))
776
+
777
+ #if CYTHON_COMPILING_IN_PYPY
778
+ #define __Pyx_PyObject_GC_IsFinalized(o) _PyGC_FINALIZED(o)
779
+ #else
780
+ #define __Pyx_PyObject_GC_IsFinalized(o) PyObject_GC_IsFinalized(o)
781
+ #endif
782
+
783
+ #if CYTHON_COMPILING_IN_LIMITED_API
784
+ // These can be deduced at runtime and are enough of an optimization that
785
+ // it's worth doing (while still respecting the decision not to add them to
786
+ // the Limited API).
787
+ static unsigned long __Pyx_Runtime_TPFLAGS_SEQUENCE;
788
+ static unsigned long __Pyx_Runtime_TPFLAGS_MAPPING;
789
+ #else
790
+ #define __Pyx_Runtime_TPFLAGS_SEQUENCE Py_TPFLAGS_SEQUENCE
791
+ #define __Pyx_Runtime_TPFLAGS_MAPPING Py_TPFLAGS_MAPPING
792
+ #endif
793
+
794
+ static int __Pyx_init_tpflags_variables(void); /* proto */
795
+
796
+ #ifndef Py_TPFLAGS_HAVE_FINALIZE
797
+ #define Py_TPFLAGS_HAVE_FINALIZE 0
798
+ #endif
799
+ #ifndef Py_TPFLAGS_SEQUENCE
800
+ #define Py_TPFLAGS_SEQUENCE (CYTHON_COMPILING_IN_LIMITED_API ? 0 : 1 << 5)
801
+ #endif
802
+ #ifndef Py_TPFLAGS_MAPPING
803
+ #define Py_TPFLAGS_MAPPING (CYTHON_COMPILING_IN_LIMITED_API ? 0 : 1 << 6)
804
+ #endif
805
+ #ifndef Py_TPFLAGS_IMMUTABLETYPE
806
+ #define Py_TPFLAGS_IMMUTABLETYPE (1UL << 8)
807
+ #endif
808
+ #ifndef Py_TPFLAGS_DISALLOW_INSTANTIATION
809
+ #define Py_TPFLAGS_DISALLOW_INSTANTIATION (1UL << 7)
810
+ #endif
811
+
812
+ #ifndef METH_STACKLESS
813
+ // Now unused. Already defined for Stackless Python (all versions) and C-Python >= 3.7.
814
+ // Value if defined: Stackless Python < 3.6: 0x80 else 0x100.
815
+ #define METH_STACKLESS 0
816
+ #endif
817
+ #if !defined(METH_FASTCALL) || CYTHON_COMPILING_IN_PYPY
818
+ // new in CPython 3.6, but changed in 3.7 - see
819
+ // positional-only parameters:
820
+ // https://bugs.python.org/issue29464
821
+ // const args:
822
+ // https://bugs.python.org/issue32240
823
+ // PyPy doesn't have the const args.
824
+ #ifndef METH_FASTCALL
825
+ #define METH_FASTCALL 0x80
826
+ #endif
827
+ typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
828
+ // new in CPython 3.7, used to be old signature of _PyCFunctionFast() in 3.6
829
+ typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
830
+ Py_ssize_t nargs, PyObject *kwnames);
831
+ #else
832
+ #if PY_VERSION_HEX >= 0x030d00A4
833
+ # define __Pyx_PyCFunctionFast PyCFunctionFast
834
+ # define __Pyx_PyCFunctionFastWithKeywords PyCFunctionFastWithKeywords
835
+ #else
836
+ # define __Pyx_PyCFunctionFast _PyCFunctionFast
837
+ # define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
838
+ #endif
839
+ #endif
840
+
841
+ #if CYTHON_VECTORCALL
842
+ #define __Pyx_METH_FASTCALL METH_FASTCALL
843
+ #define __Pyx_PyCFunction_FastCall __Pyx_PyCFunctionFast
844
+ #define __Pyx_PyCFunction_FastCallWithKeywords __Pyx_PyCFunctionFastWithKeywords
845
+ #else
846
+ #define __Pyx_METH_FASTCALL METH_VARARGS
847
+ #define __Pyx_PyCFunction_FastCall PyCFunction
848
+ #define __Pyx_PyCFunction_FastCallWithKeywords PyCFunctionWithKeywords
849
+ #endif
850
+
851
+ #if CYTHON_VECTORCALL
852
+ #define __pyx_vectorcallfunc vectorcallfunc
853
+ #define __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET PY_VECTORCALL_ARGUMENTS_OFFSET
854
+ #define __Pyx_PyVectorcall_NARGS(n) PyVectorcall_NARGS((size_t)(n))
855
+ #else
856
+ #define __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET 0
857
+ #define __Pyx_PyVectorcall_NARGS(n) ((Py_ssize_t)(n))
858
+ #endif
859
+
860
+ // These PyCFunction related macros get redefined in CythonFunction.c.
861
+ // We need our own copies because the inline functions in CPython have a type-check assert
862
+ // that breaks with a CyFunction in debug mode.
863
+ #define __Pyx_PyCFunction_CheckExact(func) PyCFunction_CheckExact(func)
864
+ #define __Pyx_CyOrPyCFunction_Check(func) PyCFunction_Check(func)
865
+
866
+ #if CYTHON_COMPILING_IN_CPYTHON
867
+ #define __Pyx_CyOrPyCFunction_GET_FUNCTION(func) (((PyCFunctionObject*)(func))->m_ml->ml_meth)
868
+ #elif !CYTHON_COMPILING_IN_LIMITED_API
869
+ // It's probably easier for non-CPythons to support PyCFunction_GET_FUNCTION() than the object struct layout.
870
+ #define __Pyx_CyOrPyCFunction_GET_FUNCTION(func) PyCFunction_GET_FUNCTION(func)
871
+ // Unused in CYTHON_COMPILING_IN_LIMITED_API.
872
+ #endif
873
+ #if CYTHON_COMPILING_IN_CPYTHON
874
+ #define __Pyx_CyOrPyCFunction_GET_FLAGS(func) (((PyCFunctionObject*)(func))->m_ml->ml_flags)
875
+ static CYTHON_INLINE PyObject* __Pyx_CyOrPyCFunction_GET_SELF(PyObject *func) {
876
+ return (__Pyx_CyOrPyCFunction_GET_FLAGS(func) & METH_STATIC) ? NULL : ((PyCFunctionObject*)func)->m_self;
877
+ }
878
+ // Only used if CYTHON_COMPILING_IN_CPYTHON.
879
+ #endif
880
+ static CYTHON_INLINE int __Pyx__IsSameCFunction(PyObject *func, void (*cfunc)(void)) {
881
+ #if CYTHON_COMPILING_IN_LIMITED_API
882
+ return PyCFunction_Check(func) && PyCFunction_GetFunction(func) == (PyCFunction) cfunc;
883
+ #else
884
+ return PyCFunction_Check(func) && PyCFunction_GET_FUNCTION(func) == (PyCFunction) cfunc;
885
+ #endif
886
+ }
887
+ #define __Pyx_IsSameCFunction(func, cfunc) __Pyx__IsSameCFunction(func, cfunc)
888
+
889
+ // PEP-573: PyCFunction holds reference to defining class (PyCMethodObject)
890
+ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
891
+ #define __Pyx_PyType_FromModuleAndSpec(m, s, b) ((void)m, PyType_FromSpecWithBases(s, b))
892
+ #else
893
+ #define __Pyx_PyType_FromModuleAndSpec(m, s, b) PyType_FromModuleAndSpec(m, s, b)
894
+ #endif
895
+ #if CYTHON_COMPILING_IN_PYPY
896
+ // PyPy's internal definition misses the const
897
+ typedef PyObject *(*__Pyx_PyCMethod)(PyObject *, PyTypeObject *, PyObject *const *, size_t, PyObject *);
898
+ #else
899
+ #define __Pyx_PyCMethod PyCMethod
900
+ #endif
901
+ #ifndef METH_METHOD
902
+ #define METH_METHOD 0x200
903
+ #endif
904
+
905
+ #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
906
+ #define PyObject_Malloc(s) PyMem_Malloc(s)
907
+ #define PyObject_Free(p) PyMem_Free(p)
908
+ #define PyObject_Realloc(p) PyMem_Realloc(p)
909
+ #endif
910
+
911
+ #if CYTHON_COMPILING_IN_LIMITED_API
912
+ // __Pyx_PyCode_HasFreeVars isn't easily emulated in the limited API (but isn't really necessary)
913
+ #define __Pyx_PyFrame_SetLineNumber(frame, lineno)
914
+ #elif CYTHON_COMPILING_IN_GRAAL && defined(GRAALPY_VERSION_NUM) && GRAALPY_VERSION_NUM > 0x19000000
915
+ #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
916
+ #define __Pyx_PyFrame_SetLineNumber(frame, lineno) GraalPyFrame_SetLineNumber((frame), (lineno))
917
+ #elif CYTHON_COMPILING_IN_GRAAL
918
+ // Remove when GraalPy 24 goes EOL
919
+ #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
920
+ #define __Pyx_PyFrame_SetLineNumber(frame, lineno) _PyFrame_SetLineNumber((frame), (lineno))
921
+ #else
922
+ #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
923
+ #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
924
+ #endif
925
+
926
+ #if CYTHON_COMPILING_IN_LIMITED_API
927
+ #define __Pyx_PyThreadState_Current PyThreadState_Get()
928
+ #elif !CYTHON_FAST_THREAD_STATE
929
+ #define __Pyx_PyThreadState_Current PyThreadState_GET()
930
+ #elif PY_VERSION_HEX >= 0x030d00A1
931
+ #define __Pyx_PyThreadState_Current PyThreadState_GetUnchecked()
932
+ #else
933
+ #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
934
+ #endif
935
+
936
+ // For our shared types, they are only ever opaque in the Limited API.
937
+ // While there may be a reason to let users override their own types,
938
+ // there's no benefit to changing our internal types except in the Limited API.
939
+ #if CYTHON_OPAQUE_OBJECTS && CYTHON_COMPILING_IN_LIMITED_API
940
+ #define __PYX_SHARED_SIZEOF(T) -((int)sizeof(T))
941
+ #define __PYX_SHARED_RELATIVE_OFFSET Py_RELATIVE_OFFSET
942
+ #define CYTHON_OPAQUE_SHARED_TYPES 1
943
+ #else
944
+ #define __PYX_SHARED_SIZEOF(T) sizeof(T)
945
+ #define __PYX_SHARED_RELATIVE_OFFSET 0
946
+ #define CYTHON_OPAQUE_SHARED_TYPES 0
947
+ #endif
948
+
949
+ #if CYTHON_USE_MODULE_STATE
950
+ static CYTHON_INLINE void *__Pyx__PyModule_GetState(PyObject *op)
951
+ {
952
+ void *result;
953
+
954
+ result = PyModule_GetState(op);
955
+ if (!result)
956
+ Py_FatalError("Couldn't find the module state");
957
+ return result;
958
+ }
959
+ // Define a macro with a cast because the modulestate type isn't known yet and
960
+ // is a typedef struct so impossible to forward declare
961
+ #define __Pyx_PyModule_GetState(o) ($modulestatetype_cname *)__Pyx__PyModule_GetState(o)
962
+ #else
963
+ #define __Pyx_PyModule_GetState(op) ((void)op,$modulestateglobal_cname)
964
+ #endif
965
+
966
+ // The "Try" variants may return NULL on static types with the Limited API on earlier versions
967
+ // so should be used for optimization rather than where a result is required.
968
+ #define __Pyx_PyObject_GetSlot(obj, name, func_ctype) __Pyx_PyType_GetSlot(Py_TYPE((PyObject *) obj), name, func_ctype)
969
+ #define __Pyx_PyObject_TryGetSlot(obj, name, func_ctype) __Pyx_PyType_TryGetSlot(Py_TYPE(obj), name, func_ctype)
970
+ #define __Pyx_PyObject_GetSubSlot(obj, sub, name, func_ctype) __Pyx_PyType_GetSubSlot(Py_TYPE(obj), sub, name, func_ctype)
971
+ #define __Pyx_PyObject_TryGetSubSlot(obj, sub, name, func_ctype) __Pyx_PyType_TryGetSubSlot(Py_TYPE(obj), sub, name, func_ctype)
972
+ #if CYTHON_USE_TYPE_SLOTS
973
+ #define __Pyx_PyType_GetSlot(type, name, func_ctype) ((type)->name)
974
+ #define __Pyx_PyType_TryGetSlot(type, name, func_ctype) __Pyx_PyType_GetSlot(type, name, func_ctype)
975
+ #define __Pyx_PyType_GetSubSlot(type, sub, name, func_ctype) (((type)->sub) ? ((type)->sub->name) : NULL)
976
+ #define __Pyx_PyType_TryGetSubSlot(type, sub, name, func_ctype) __Pyx_PyType_GetSubSlot(type, sub, name, func_ctype)
977
+ #else
978
+ #define __Pyx_PyType_GetSlot(type, name, func_ctype) ((func_ctype) PyType_GetSlot((type), Py_##name))
979
+ #define __Pyx_PyType_TryGetSlot(type, name, func_ctype) \
980
+ ((__PYX_LIMITED_VERSION_HEX >= 0x030A0000 || \
981
+ (PyType_GetFlags(type) & Py_TPFLAGS_HEAPTYPE) || __Pyx_get_runtime_version() >= 0x030A0000) ? \
982
+ __Pyx_PyType_GetSlot(type, name, func_ctype) : NULL)
983
+ #define __Pyx_PyType_GetSubSlot(obj, sub, name, func_ctype) __Pyx_PyType_GetSlot(obj, name, func_ctype)
984
+ #define __Pyx_PyType_TryGetSubSlot(obj, sub, name, func_ctype) __Pyx_PyType_TryGetSlot(obj, name, func_ctype)
985
+ #endif
986
+
987
+ #if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
988
+ #define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
989
+ #else
990
+ #define __Pyx_PyDict_NewPresized(n) PyDict_New()
991
+ #endif
992
+
993
+ #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
994
+ #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
995
+
996
+ #if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_UNICODE_INTERNALS
997
+ // _PyDict_GetItem_KnownHash() existed from CPython 3.5 to 3.12, but it was
998
+ // dropping exceptions in 3.5. Since 3.6, exceptions are kept.
999
+ #define __Pyx_PyDict_GetItemStrWithError(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
1000
+ static CYTHON_INLINE PyObject * __Pyx_PyDict_GetItemStr(PyObject *dict, PyObject *name) {
1001
+ PyObject *res = __Pyx_PyDict_GetItemStrWithError(dict, name);
1002
+ if (res == NULL && PyErr_Occurred()) {
1003
+ // Like PyDict_GetItem, this is a bit indiscriminate about catching *all* errors.
1004
+ // Recent versions of Python format any unraised exception so do that too here.
1005
+ PyErr_WriteUnraisable(NULL);
1006
+ }
1007
+ return res;
1008
+ }
1009
+ #elif !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07020000
1010
+ #define __Pyx_PyDict_GetItemStrWithError PyDict_GetItemWithError
1011
+ #define __Pyx_PyDict_GetItemStr PyDict_GetItem
1012
+ #else
1013
+ static CYTHON_INLINE PyObject * __Pyx_PyDict_GetItemStrWithError(PyObject *dict, PyObject *name) {
1014
+ // This is tricky - we should return a borrowed reference but not swallow non-KeyError exceptions. 8-|
1015
+ // But: this function is only used in Py2 and older PyPys,
1016
+ // and currently only for argument parsing and other non-correctness-critical lookups
1017
+ // and we know that 'name' is an interned 'str' with pre-calculated hash value (only comparisons can fail),
1018
+ // thus, performance matters more than correctness here, especially in the "not found" case.
1019
+ #if CYTHON_COMPILING_IN_PYPY
1020
+ // So we ignore any exceptions in old PyPys ...
1021
+ return PyDict_GetItem(dict, name);
1022
+ #else
1023
+ // and hack together a stripped-down and modified PyDict_GetItem() in CPython 2.
1024
+ PyDictEntry *ep;
1025
+ PyDictObject *mp = (PyDictObject*) dict;
1026
+ long hash = ((PyStringObject *) name)->ob_shash;
1027
+ assert(hash != -1); /* hash values of interned strings are always initialised */
1028
+ ep = (mp->ma_lookup)(mp, name, hash);
1029
+ if (ep == NULL) {
1030
+ // error occurred
1031
+ return NULL;
1032
+ }
1033
+ // found or not found
1034
+ return ep->me_value;
1035
+ #endif
1036
+ }
1037
+ #define __Pyx_PyDict_GetItemStr PyDict_GetItem
1038
+ #endif
1039
+
1040
+ /* Type slots */
1041
+
1042
+ #if CYTHON_USE_TYPE_SLOTS
1043
+ #define __Pyx_PyType_GetFlags(tp) (((PyTypeObject *)tp)->tp_flags)
1044
+ #define __Pyx_PyType_HasFeature(type, feature) ((__Pyx_PyType_GetFlags(type) & (feature)) != 0)
1045
+ #else
1046
+ #define __Pyx_PyType_GetFlags(tp) (PyType_GetFlags((PyTypeObject *)tp))
1047
+ #define __Pyx_PyType_HasFeature(type, feature) PyType_HasFeature(type, feature)
1048
+ #endif
1049
+
1050
+ // There is no replacement for "Py_TYPE(obj)->iternext" in the C-API.
1051
+ // PyIter_Next() discards the StopIteration, unlike Python's "next()".
1052
+ #define __Pyx_PyObject_GetIterNextFunc(iterator) __Pyx_PyObject_GetSlot(iterator, tp_iternext, iternextfunc)
1053
+
1054
+ #if CYTHON_USE_TYPE_SPECS
1055
+ // In Py3.8+, instances of heap types need to decref their type on deallocation.
1056
+ // https://bugs.python.org/issue35810
1057
+ #define __Pyx_PyHeapTypeObject_GC_Del(obj) { \
1058
+ PyTypeObject *type = Py_TYPE((PyObject*)obj); \
1059
+ assert(__Pyx_PyType_HasFeature(type, Py_TPFLAGS_HEAPTYPE)); \
1060
+ PyObject_GC_Del(obj); \
1061
+ Py_DECREF(type); \
1062
+ }
1063
+ #else
1064
+ #define __Pyx_PyHeapTypeObject_GC_Del(obj) PyObject_GC_Del(obj)
1065
+ #endif
1066
+
1067
+ #if CYTHON_COMPILING_IN_LIMITED_API
1068
+ #define __Pyx_PyUnicode_READY(op) (0)
1069
+ #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_ReadChar(u, i)
1070
+ #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((void)u, 1114111U)
1071
+ #define __Pyx_PyUnicode_KIND(u) ((void)u, (0))
1072
+ #define __Pyx_PyUnicode_KIND_04(u) __Pyx_PyUnicode_KIND(u)
1073
+ // __Pyx_PyUnicode_DATA() and __Pyx_PyUnicode_READ() must go together, e.g. for iteration.
1074
+ #define __Pyx_PyUnicode_DATA(u) ((void*)u)
1075
+ #define __Pyx_PyUnicode_READ(k, d, i) ((void)k, PyUnicode_ReadChar((PyObject*)(d), i))
1076
+ //#define __Pyx_PyUnicode_WRITE(k, d, i, ch) /* not available */
1077
+ #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GetLength(u))
1078
+ #else
1079
+ #if PY_VERSION_HEX >= 0x030C0000
1080
+ // Py3.12 / PEP-623 removed wstr type unicode strings and all of the PyUnicode_READY() machinery.
1081
+ #define __Pyx_PyUnicode_READY(op) (0)
1082
+ #else
1083
+ #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ? \
1084
+ 0 : _PyUnicode_Ready((PyObject *)(op)))
1085
+ #endif
1086
+
1087
+ #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
1088
+ #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
1089
+ #define __Pyx_PyUnicode_KIND(u) ((int)PyUnicode_KIND(u))
1090
+ #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
1091
+ #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
1092
+ #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, (Py_UCS4) ch)
1093
+ #if PY_VERSION_HEX >= 0x030C0000
1094
+ #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_LENGTH(u))
1095
+ #else
1096
+ #if CYTHON_COMPILING_IN_CPYTHON
1097
+ // Avoid calling deprecated C-API functions in Py3.9+ that PEP-623 schedules for removal in Py3.12.
1098
+ // https://www.python.org/dev/peps/pep-0623/
1099
+ #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : ((PyCompactUnicodeObject *)(u))->wstr_length))
1100
+ #else
1101
+ #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
1102
+ #endif
1103
+ #endif
1104
+
1105
+ static CYTHON_INLINE int __Pyx_PyUnicode_KIND_04(PyObject *o) {
1106
+ // Returns 0 for ASCII strings and KIND (1, 2, 4) otherwise.
1107
+ return __Pyx_PyUnicode_KIND(o) - (int) !!PyUnicode_IS_ASCII(o);
1108
+ }
1109
+ #endif
1110
+
1111
+ #if CYTHON_COMPILING_IN_PYPY
1112
+ #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
1113
+ #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
1114
+ #else
1115
+ #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
1116
+ #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ? \
1117
+ PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
1118
+ #endif
1119
+
1120
+ #if CYTHON_COMPILING_IN_PYPY
1121
+ #if !defined(PyUnicode_DecodeUnicodeEscape)
1122
+ #define PyUnicode_DecodeUnicodeEscape(s, size, errors) PyUnicode_Decode(s, size, "unicode_escape", errors)
1123
+ #endif
1124
+ #if !defined(PyUnicode_Contains)
1125
+ #define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
1126
+ #endif
1127
+ #if !defined(PyByteArray_Check)
1128
+ #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
1129
+ #endif
1130
+ #if !defined(PyObject_Format)
1131
+ #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
1132
+ #endif
1133
+ #endif
1134
+
1135
+ // ("..." % x) must call PyNumber_Remainder() if x is a string subclass that implements "__rmod__()".
1136
+ #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
1137
+
1138
+ #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
1139
+ #define __Pyx_PySequence_ListKeepNew(obj) \
1140
+ (likely(PyList_CheckExact(obj) && PyUnstable_Object_IsUniquelyReferenced(obj)) ? __Pyx_NewRef(obj) : PySequence_List(obj))
1141
+ #elif CYTHON_COMPILING_IN_CPYTHON
1142
+ #define __Pyx_PySequence_ListKeepNew(obj) \
1143
+ (likely(PyList_CheckExact(obj) && Py_REFCNT(obj) == 1) ? __Pyx_NewRef(obj) : PySequence_List(obj))
1144
+ #else
1145
+ #define __Pyx_PySequence_ListKeepNew(obj) PySequence_List(obj)
1146
+ #endif
1147
+
1148
+ #ifndef PySet_CheckExact
1149
+ #define PySet_CheckExact(obj) Py_IS_TYPE(obj, &PySet_Type)
1150
+ #endif
1151
+
1152
+ enum __Pyx_ReferenceSharing {
1153
+ __Pyx_ReferenceSharing_DefinitelyUnique, // We created it so we know it's unshared - no need to check
1154
+ __Pyx_ReferenceSharing_OwnStrongReference,
1155
+ __Pyx_ReferenceSharing_FunctionArgument,
1156
+ __Pyx_ReferenceSharing_SharedReference, // Never trust it to be unshared because it's a global or similar
1157
+ };
1158
+
1159
+ #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING && PY_VERSION_HEX >= 0x030E0000
1160
+ #define __Pyx_IS_UNIQUELY_REFERENCED(o, sharing) \
1161
+ (sharing == __Pyx_ReferenceSharing_DefinitelyUnique ? 1 : \
1162
+ (sharing == __Pyx_ReferenceSharing_FunctionArgument ? PyUnstable_Object_IsUniqueReferencedTemporary(o) : \
1163
+ (sharing == __Pyx_ReferenceSharing_OwnStrongReference ? PyUnstable_Object_IsUniquelyReferenced(o) : 0)))
1164
+ #elif (CYTHON_COMPILING_IN_CPYTHON && !CYTHON_COMPILING_IN_CPYTHON_FREETHREADING) || CYTHON_COMPILING_IN_LIMITED_API
1165
+ #define __Pyx_IS_UNIQUELY_REFERENCED(o, sharing) (((void)sharing), Py_REFCNT(o) == 1)
1166
+ #else
1167
+ // On other platforms we don't trust the refcount so don't optimize based on it
1168
+ #define __Pyx_IS_UNIQUELY_REFERENCED(o, sharing) (((void)o), ((void)sharing), 0)
1169
+ #endif
1170
+
1171
+
1172
+ // __Pyx_PyList_GetItemRef(): return safely owned reference, bounds checking, no wraparound
1173
+ #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000
1174
+ #define __Pyx_PyList_GetItemRef(o, i) PyList_GetItemRef(o, i)
1175
+ #elif CYTHON_AVOID_BORROWED_REFS || CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS
1176
+ #if CYTHON_COMPILING_IN_LIMITED_API || !CYTHON_ASSUME_SAFE_MACROS
1177
+ #define __Pyx_PyList_GetItemRef(o, i) (likely((i) >= 0) ? PySequence_GetItem(o, i) : (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
1178
+ #else
1179
+ #define __Pyx_PyList_GetItemRef(o, i) PySequence_ITEM(o, i)
1180
+ #endif
1181
+ #elif CYTHON_COMPILING_IN_LIMITED_API || !(CYTHON_ASSUME_SAFE_MACROS && CYTHON_ASSUME_SAFE_SIZE)
1182
+ #define __Pyx_PyList_GetItemRef(o, i) __Pyx_XNewRef(PyList_GetItem(o, i))
1183
+ #else
1184
+ #define __Pyx_PyList_GetItemRef(o, i) (likely(__Pyx_is_valid_index(i, PyList_GET_SIZE(o))) ? \
1185
+ __Pyx_NewRef(PyList_GET_ITEM(o, i)) : (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
1186
+ #endif
1187
+
1188
+ // __Pyx_PyList_GET_ITEM_REF(): return safely owned reference, no bounds checking (if avoidable), no wraparound
1189
+ #if CYTHON_AVOID_BORROWED_REFS || CYTHON_COMPILING_IN_LIMITED_API
1190
+ #define __Pyx_PyList_GET_ITEM_REF(o, i, unsafe_shared) ((void)(unsafe_shared), \
1191
+ __Pyx_PyList_GetItemRef(o, i))
1192
+ #elif CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS
1193
+ #if CYTHON_ASSUME_SAFE_MACROS
1194
+ #define __Pyx_PyList_GET_ITEM_REF(o, i, unsafe_shared) ( \
1195
+ __Pyx_IS_UNIQUELY_REFERENCED(o, unsafe_shared) ? \
1196
+ __Pyx_NewRef(PyList_GET_ITEM(o, i)) : __Pyx_PyList_GetItemRef(o, i))
1197
+ #else
1198
+ #define __Pyx_PyList_GET_ITEM_REF(o, i, unsafe_shared) ( \
1199
+ __Pyx_IS_UNIQUELY_REFERENCED(o, unsafe_shared) ? \
1200
+ __Pyx_XNewRef(PyList_GetItem(o, i)) : __Pyx_PyList_GetItemRef(o, i))
1201
+ #endif
1202
+ #elif CYTHON_ASSUME_SAFE_MACROS
1203
+ #define __Pyx_PyList_GET_ITEM_REF(o, i, unsafe_shared) ((void)(unsafe_shared), \
1204
+ __Pyx_NewRef(PyList_GET_ITEM(o, i)))
1205
+ #else
1206
+ #define __Pyx_PyList_GET_ITEM_REF(o, i, unsafe_shared) ((void)(unsafe_shared), \
1207
+ __Pyx_XNewRef(PyList_GetItem(o, i)))
1208
+ #endif
1209
+
1210
+ #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000
1211
+ #define __Pyx_PyDict_GetItemRef(dict, key, result) PyDict_GetItemRef(dict, key, result)
1212
+ #elif CYTHON_AVOID_BORROWED_REFS || CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS
1213
+ static CYTHON_INLINE int __Pyx_PyDict_GetItemRef(PyObject *dict, PyObject *key, PyObject **result) {
1214
+ *result = PyObject_GetItem(dict, key);
1215
+ if (*result == NULL) {
1216
+ if (PyErr_ExceptionMatches(PyExc_KeyError)) {
1217
+ PyErr_Clear();
1218
+ return 0;
1219
+ }
1220
+ return -1;
1221
+ }
1222
+ return 1;
1223
+ }
1224
+ #else
1225
+ static CYTHON_INLINE int __Pyx_PyDict_GetItemRef(PyObject *dict, PyObject *key, PyObject **result) {
1226
+ *result = PyDict_GetItemWithError(dict, key);
1227
+ if (*result == NULL) {
1228
+ return PyErr_Occurred() ? -1 : 0;
1229
+ }
1230
+ Py_INCREF(*result);
1231
+ return 1;
1232
+ }
1233
+ #endif
1234
+
1235
+ // No-op macro for calling Py_VISIT() on known constants that can never participate in reference cycles.
1236
+ // Users can define "CYTHON_DEBUG_VISIT_CONST=1" to help in debugging reference issues.
1237
+ #if defined(CYTHON_DEBUG_VISIT_CONST) && CYTHON_DEBUG_VISIT_CONST
1238
+ #define __Pyx_VISIT_CONST(obj) Py_VISIT(obj)
1239
+ #else
1240
+ #define __Pyx_VISIT_CONST(obj)
1241
+ #endif
1242
+
1243
+ #if CYTHON_ASSUME_SAFE_MACROS
1244
+ #define __Pyx_PySequence_ITEM(o, i) PySequence_ITEM(o, i)
1245
+ #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq)
1246
+ #define __Pyx_PyTuple_SET_ITEM(o, i, v) (PyTuple_SET_ITEM(o, i, v), (0))
1247
+ #define __Pyx_PyTuple_GET_ITEM(o, i) PyTuple_GET_ITEM(o, i)
1248
+ #define __Pyx_PyList_SET_ITEM(o, i, v) (PyList_SET_ITEM(o, i, v), (0))
1249
+ #define __Pyx_PyList_GET_ITEM(o, i) PyList_GET_ITEM(o, i)
1250
+ #else
1251
+ // NOTE: implements wrap-around
1252
+ #define __Pyx_PySequence_ITEM(o, i) PySequence_GetItem(o, i)
1253
+ // NOTE: might fail with exception => check for -1
1254
+ #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq)
1255
+ // NOTE: this doesn't leak a reference to whatever is at o[i]
1256
+ #define __Pyx_PyTuple_SET_ITEM(o, i, v) PyTuple_SetItem(o, i, v)
1257
+ #define __Pyx_PyTuple_GET_ITEM(o, i) PyTuple_GetItem(o, i)
1258
+ #define __Pyx_PyList_SET_ITEM(o, i, v) PyList_SetItem(o, i, v)
1259
+ #define __Pyx_PyList_GET_ITEM(o, i) PyList_GetItem(o, i)
1260
+ #endif
1261
+
1262
+ #if CYTHON_ASSUME_SAFE_SIZE
1263
+ #define __Pyx_PyTuple_GET_SIZE(o) PyTuple_GET_SIZE(o)
1264
+ #define __Pyx_PyList_GET_SIZE(o) PyList_GET_SIZE(o)
1265
+ #define __Pyx_PySet_GET_SIZE(o) PySet_GET_SIZE(o)
1266
+ #define __Pyx_PyDict_GET_SIZE(o) PyDict_GET_SIZE(o)
1267
+ #define __Pyx_PyBytes_GET_SIZE(o) PyBytes_GET_SIZE(o)
1268
+ #define __Pyx_PyByteArray_GET_SIZE(o) PyByteArray_GET_SIZE(o)
1269
+ #define __Pyx_PyUnicode_GET_LENGTH(o) PyUnicode_GET_LENGTH(o)
1270
+ #else
1271
+ // These all need exception checks for -1.
1272
+ #define __Pyx_PyTuple_GET_SIZE(o) PyTuple_Size(o)
1273
+ #define __Pyx_PyList_GET_SIZE(o) PyList_Size(o)
1274
+ #define __Pyx_PySet_GET_SIZE(o) PySet_Size(o)
1275
+ #define __Pyx_PyDict_GET_SIZE(o) PyDict_Size(o)
1276
+ #define __Pyx_PyBytes_GET_SIZE(o) PyBytes_Size(o)
1277
+ #define __Pyx_PyByteArray_GET_SIZE(o) PyByteArray_Size(o)
1278
+ #define __Pyx_PyUnicode_GET_LENGTH(o) PyUnicode_GetLength(o)
1279
+ #endif
1280
+
1281
+ #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_InternFromString)
1282
+ #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
1283
+ #endif
1284
+
1285
+ #define __Pyx_PyLong_FromHash_t PyLong_FromSsize_t
1286
+ #define __Pyx_PyLong_AsHash_t __Pyx_PyIndex_AsSsize_t
1287
+
1288
+
1289
+ // backport of PyAsyncMethods from Py3.10 to older Py3.x versions
1290
+ #if __PYX_LIMITED_VERSION_HEX >= 0x030A0000
1291
+ #define __Pyx_PySendResult PySendResult
1292
+ #else
1293
+ typedef enum {
1294
+ PYGEN_RETURN = 0,
1295
+ PYGEN_ERROR = -1,
1296
+ PYGEN_NEXT = 1,
1297
+ } __Pyx_PySendResult;
1298
+ #endif
1299
+
1300
+ #if CYTHON_COMPILING_IN_LIMITED_API || PY_VERSION_HEX < 0x030A00A3
1301
+ typedef __Pyx_PySendResult (*__Pyx_pyiter_sendfunc)(PyObject *iter, PyObject *value, PyObject **result);
1302
+ #else
1303
+ #define __Pyx_pyiter_sendfunc sendfunc
1304
+ #endif
1305
+
1306
+ // "Py_am_send" requires Py3.10 when using type specs (which utility code types do).
1307
+ #if !CYTHON_USE_AM_SEND
1308
+ #define __PYX_HAS_PY_AM_SEND 0
1309
+ #elif __PYX_LIMITED_VERSION_HEX >= 0x030A0000
1310
+ #define __PYX_HAS_PY_AM_SEND 1
1311
+ #else
1312
+ #define __PYX_HAS_PY_AM_SEND 2 // our own backported implementation
1313
+ #endif
1314
+
1315
+ #if __PYX_HAS_PY_AM_SEND < 2
1316
+ #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
1317
+ #else
1318
+ // PyAsyncMethods in Py<3.10 lacks "am_send"
1319
+ typedef struct {
1320
+ unaryfunc am_await;
1321
+ unaryfunc am_aiter;
1322
+ unaryfunc am_anext;
1323
+ __Pyx_pyiter_sendfunc am_send;
1324
+ } __Pyx_PyAsyncMethodsStruct;
1325
+
1326
+ #define __Pyx_SlotTpAsAsync(s) ((PyAsyncMethods*)(s))
1327
+ #endif
1328
+
1329
+ // Use a flag in Py < 3.10 to mark coroutines that have the "am_send" field.
1330
+ #if CYTHON_USE_AM_SEND && PY_VERSION_HEX < 0x030A00F0
1331
+ #define __Pyx_TPFLAGS_HAVE_AM_SEND (1UL << 21)
1332
+ #else
1333
+ #define __Pyx_TPFLAGS_HAVE_AM_SEND (0)
1334
+ #endif
1335
+
1336
+ #if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030A0000
1337
+ // PyMem_Calloc *is* in the Stable ABI in all the Limited API versions we care about.
1338
+ // However, it is omitted from the Python headers which means that C incorrectly
1339
+ // assumes it returns an int (and generates dubious code on based on that assumption).
1340
+ // Therefore, copy the prototype.
1341
+ #ifdef __cplusplus
1342
+ extern "C"
1343
+ #endif
1344
+ PyAPI_FUNC(void *) PyMem_Calloc(size_t nelem, size_t elsize); /* proto */
1345
+ #endif
1346
+
1347
+ #if CYTHON_COMPILING_IN_LIMITED_API
1348
+ // returns 1 for success and 0 for failure to enable it to be chained in an &&
1349
+ static int __Pyx_init_co_variable(PyObject *inspect, const char* name, int *write_to) {
1350
+ int value;
1351
+ PyObject *py_value = PyObject_GetAttrString(inspect, name);
1352
+ if (!py_value) return 0;
1353
+ // There's a small chance of overflow here, but it'd only happen if inspect was set up wrongly.
1354
+ value = (int) PyLong_AsLong(py_value);
1355
+ Py_DECREF(py_value);
1356
+ *write_to = value;
1357
+ return value != -1 || !PyErr_Occurred();
1358
+ }
1359
+
1360
+ // Returns 0 on success and -1 on failure for normal error handling
1361
+ static int __Pyx_init_co_variables(void) {
1362
+ PyObject *inspect;
1363
+ int result;
1364
+ inspect = PyImport_ImportModule("inspect");
1365
+
1366
+ result =
1367
+ #if !defined(CO_OPTIMIZED)
1368
+ __Pyx_init_co_variable(inspect, "CO_OPTIMIZED", &CO_OPTIMIZED) &&
1369
+ #endif
1370
+ #if !defined(CO_NEWLOCALS)
1371
+ __Pyx_init_co_variable(inspect, "CO_NEWLOCALS", &CO_NEWLOCALS) &&
1372
+ #endif
1373
+ #if !defined(CO_VARARGS)
1374
+ __Pyx_init_co_variable(inspect, "CO_VARARGS", &CO_VARARGS) &&
1375
+ #endif
1376
+ #if !defined(CO_VARKEYWORDS)
1377
+ __Pyx_init_co_variable(inspect, "CO_VARKEYWORDS", &CO_VARKEYWORDS) &&
1378
+ #endif
1379
+ #if !defined(CO_ASYNC_GENERATOR)
1380
+ __Pyx_init_co_variable(inspect, "CO_ASYNC_GENERATOR", &CO_ASYNC_GENERATOR) &&
1381
+ #endif
1382
+ #if !defined(CO_GENERATOR)
1383
+ __Pyx_init_co_variable(inspect, "CO_GENERATOR", &CO_GENERATOR) &&
1384
+ #endif
1385
+ #if !defined(CO_COROUTINE)
1386
+ __Pyx_init_co_variable(inspect, "CO_COROUTINE", &CO_COROUTINE) &&
1387
+ #endif
1388
+ 1;
1389
+
1390
+ Py_DECREF(inspect);
1391
+ return result ? 0 : -1;
1392
+ }
1393
+
1394
+ static int __Pyx_init_tpflags_bitcount(unsigned long flag) {
1395
+ int count = 0;
1396
+ while (flag) {
1397
+ count += (int) (flag & 1);
1398
+ flag >>= 1;
1399
+ }
1400
+ return count;
1401
+ }
1402
+
1403
+ // It's quite possible that the flags aren't reliably available at runtime.
1404
+ // Therefore most errors are ignored and we just leave the values as 0.
1405
+ static int __Pyx_init_tpflags_variables(void) {
1406
+ if (__Pyx_Runtime_TPFLAGS_SEQUENCE != 0 && __Pyx_Runtime_TPFLAGS_MAPPING != 0) {
1407
+ // Already set (possibly in another subinterpreter). Note that there's a
1408
+ // harmless race here because the variables aren't atomic.
1409
+ return 0;
1410
+ }
1411
+
1412
+ PyObject *collections_abc = PyImport_ImportModule("collections.abc");
1413
+ if (!collections_abc) return -1;
1414
+
1415
+ int result = 0;
1416
+ PyObject *sequence = NULL, *mapping = NULL;
1417
+ #if __PYX_LIMITED_VERSION_HEX >= 0x030D0000
1418
+ if (PyObject_GetOptionalAttrString(collections_abc, "Sequence", &sequence) != 1) goto fail;
1419
+ if (PyObject_GetOptionalAttrString(collections_abc, "Mapping", &mapping) != 1) goto fail;
1420
+ #else
1421
+ sequence = PyObject_GetAttrString(collections_abc, "Sequence");
1422
+ if (!sequence) goto fail_attr_lookup;
1423
+ mapping = PyObject_GetAttrString(collections_abc, "Mapping");
1424
+ if (!mapping) goto fail_attr_lookup;
1425
+ #endif
1426
+
1427
+ // The assumption is that the the type flags for sequence and mapping
1428
+ // should be identical except for a single bit on each class.
1429
+ // If that isn't true then fail silently.
1430
+
1431
+ if (!PyType_Check(sequence) || !PyType_Check(mapping)) goto fail;
1432
+ {
1433
+ unsigned long sequence_flags = PyType_GetFlags((PyTypeObject*)sequence);
1434
+ unsigned long mapping_flags = PyType_GetFlags((PyTypeObject*)mapping);
1435
+ unsigned long mutual_flags = sequence_flags & mapping_flags;
1436
+ sequence_flags = sequence_flags ^ mutual_flags;
1437
+ mapping_flags = mapping_flags ^ mutual_flags;
1438
+
1439
+ if (__Pyx_Runtime_TPFLAGS_SEQUENCE == 0 && __Pyx_init_tpflags_bitcount(sequence_flags) == 1) {
1440
+ __Pyx_Runtime_TPFLAGS_SEQUENCE = sequence_flags;
1441
+ }
1442
+ if (__Pyx_Runtime_TPFLAGS_MAPPING == 0 && __Pyx_init_tpflags_bitcount(mapping_flags) == 1) {
1443
+ __Pyx_Runtime_TPFLAGS_MAPPING = mapping_flags;
1444
+ }
1445
+ }
1446
+
1447
+ cleanup:
1448
+ Py_XDECREF(mapping);
1449
+ Py_XDECREF(sequence);
1450
+ Py_DECREF(collections_abc);
1451
+
1452
+ return result;
1453
+ #if __PYX_LIMITED_VERSION_HEX < 0x030D0000
1454
+ fail_attr_lookup:
1455
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
1456
+ PyErr_Clear();
1457
+ }
1458
+ #endif
1459
+ fail:
1460
+ result = PyErr_Occurred() ? -1 : 0;
1461
+ goto cleanup;
1462
+ }
1463
+ #else
1464
+ static int __Pyx_init_co_variables(void) {
1465
+ return 0; // It's a limited API-only feature
1466
+ }
1467
+
1468
+ static int __Pyx_init_tpflags_variables(void) {
1469
+ return 0; // It's a limited API-only feature
1470
+ }
1471
+ #endif
1472
+
1473
+ /////////////// CythonABIVersion.proto ///////////////
1474
+ //@proto_block: module_declarations
1475
+ // This needs to go after the utility code 'proto' section but before user code and utility impl.
1476
+
1477
+ #if CYTHON_COMPILING_IN_LIMITED_API
1478
+ // The limited API makes some significant changes to data structures, so we don't
1479
+ // want to share the implementations compiled with and without the limited API.
1480
+ #if CYTHON_VECTORCALL
1481
+ #define __PYX_VECTORCALL_ABI_SUFFIX "_vectorcall"
1482
+ #else
1483
+ #define __PYX_VECTORCALL_ABI_SUFFIX
1484
+ #endif
1485
+
1486
+ #define __PYX_LIMITED_ABI_SUFFIX "limited" __PYX_VECTORCALL_ABI_SUFFIX __PYX_AM_SEND_ABI_SUFFIX
1487
+ #else
1488
+ #define __PYX_LIMITED_ABI_SUFFIX
1489
+ #endif
1490
+
1491
+ #if __PYX_HAS_PY_AM_SEND == 1
1492
+ #define __PYX_AM_SEND_ABI_SUFFIX
1493
+ #elif __PYX_HAS_PY_AM_SEND == 2
1494
+ #define __PYX_AM_SEND_ABI_SUFFIX "amsendbackport"
1495
+ #else
1496
+ #define __PYX_AM_SEND_ABI_SUFFIX "noamsend"
1497
+ #endif
1498
+
1499
+ #ifndef __PYX_MONITORING_ABI_SUFFIX
1500
+ #define __PYX_MONITORING_ABI_SUFFIX
1501
+ #endif
1502
+
1503
+ #if CYTHON_USE_TP_FINALIZE
1504
+ #define __PYX_TP_FINALIZE_ABI_SUFFIX
1505
+ #else
1506
+ // affects destruction of async generator/coroutines
1507
+ #define __PYX_TP_FINALIZE_ABI_SUFFIX "nofinalize"
1508
+ #endif
1509
+
1510
+ #if CYTHON_USE_FREELISTS || !defined(__Pyx_AsyncGen_USED)
1511
+ #define __PYX_FREELISTS_ABI_SUFFIX
1512
+ #else
1513
+ // affects allocation/deallocation of async generator objects.
1514
+ #define __PYX_FREELISTS_ABI_SUFFIX "nofreelists"
1515
+ #endif
1516
+
1517
+ // Outside the Limited API we don't use opaque objects for shared types (even if we may use them elsewhere)
1518
+ #if CYTHON_OPAQUE_OBJECTS && CYTHON_COMPILING_IN_LIMITED_API
1519
+ #define __PYX_OPAQUE_OBJECTS_ABI_SUFFIX "opaque"
1520
+ #else
1521
+ #define __PYX_OPAQUE_OBJECTS_ABI_SUFFIX
1522
+ #endif
1523
+
1524
+ #define CYTHON_ABI __PYX_ABI_VERSION __PYX_LIMITED_ABI_SUFFIX __PYX_MONITORING_ABI_SUFFIX __PYX_TP_FINALIZE_ABI_SUFFIX __PYX_FREELISTS_ABI_SUFFIX __PYX_AM_SEND_ABI_SUFFIX __PYX_OPAQUE_OBJECTS_ABI_SUFFIX
1525
+
1526
+ #define __PYX_ABI_MODULE_NAME "_cython_" CYTHON_ABI
1527
+ #define __PYX_TYPE_MODULE_PREFIX __PYX_ABI_MODULE_NAME "."
1528
+
1529
+ /////////////// PythonCompatibility.init ///////////////
1530
+
1531
+ if (likely(__Pyx_init_co_variables() == 0 && __Pyx_init_tpflags_variables() == 0)); else
1532
+
1533
+
1534
+ /////////////// IncludeStructmemberH.proto ///////////////
1535
+ //@proto_block: utility_code_proto_before_types
1536
+
1537
+ #include <structmember.h>
1538
+
1539
+
1540
+ /////////////// SmallCodeConfig ///////////////
1541
+
1542
+ #ifndef CYTHON_SMALL_CODE
1543
+ #if defined(__clang__)
1544
+ #define CYTHON_SMALL_CODE
1545
+ #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
1546
+ #define CYTHON_SMALL_CODE __attribute__((cold))
1547
+ #else
1548
+ #define CYTHON_SMALL_CODE
1549
+ #endif
1550
+ #endif
1551
+
1552
+
1553
+ /////////////// PyModInitFuncType ///////////////
1554
+
1555
+ #ifndef CYTHON_NO_PYINIT_EXPORT
1556
+ #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
1557
+ #else
1558
+ // define this to PyObject * manually because PyMODINIT_FUNC adds __declspec(dllexport) to it's definition.
1559
+ #ifdef __cplusplus
1560
+ #define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
1561
+ #else
1562
+ #define __Pyx_PyMODINIT_FUNC PyObject *
1563
+ #endif
1564
+ #endif
1565
+
1566
+
1567
+ /////////////// FastTypeChecks.proto ///////////////
1568
+
1569
+ #if CYTHON_COMPILING_IN_CPYTHON
1570
+ #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
1571
+ #define __Pyx_TypeCheck2(obj, type1, type2) __Pyx_IsAnySubtype2(Py_TYPE(obj), (PyTypeObject *)type1, (PyTypeObject *)type2)
1572
+ static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);/*proto*/
1573
+ static CYTHON_INLINE int __Pyx_IsAnySubtype2(PyTypeObject *cls, PyTypeObject *a, PyTypeObject *b);/*proto*/
1574
+ #define __Pyx_PyAnySet_Check(obj) __Pyx_TypeCheck2(obj, &PySet_Type, &PyFrozenSet_Type)
1575
+ #else
1576
+ #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
1577
+ #define __Pyx_TypeCheck2(obj, type1, type2) (PyObject_TypeCheck(obj, (PyTypeObject *)type1) || PyObject_TypeCheck(obj, (PyTypeObject *)type2))
1578
+ #define __Pyx_PyAnySet_Check(obj) PyAnySet_Check(obj)
1579
+ #endif
1580
+
1581
+
1582
+ /////////////// FastTypeChecks ///////////////
1583
+
1584
+ #if CYTHON_COMPILING_IN_CPYTHON
1585
+ static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
1586
+ while (a) {
1587
+ a = __Pyx_PyType_GetSlot(a, tp_base, PyTypeObject*);
1588
+ if (a == b)
1589
+ return 1;
1590
+ }
1591
+ return b == &PyBaseObject_Type;
1592
+ }
1593
+
1594
+ static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
1595
+ PyObject *mro;
1596
+ if (a == b) return 1;
1597
+ mro = a->tp_mro;
1598
+ if (likely(mro)) {
1599
+ Py_ssize_t i, n;
1600
+ n = PyTuple_GET_SIZE(mro);
1601
+ for (i = 0; i < n; i++) {
1602
+ if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
1603
+ return 1;
1604
+ }
1605
+ return 0;
1606
+ }
1607
+ // should only get here for incompletely initialised types, i.e. never under normal usage patterns
1608
+ return __Pyx_InBases(a, b);
1609
+ }
1610
+
1611
+ static CYTHON_INLINE int __Pyx_IsAnySubtype2(PyTypeObject *cls, PyTypeObject *a, PyTypeObject *b) {
1612
+ PyObject *mro;
1613
+ if (cls == a || cls == b) return 1;
1614
+ mro = cls->tp_mro;
1615
+ if (likely(mro)) {
1616
+ Py_ssize_t i, n;
1617
+ n = PyTuple_GET_SIZE(mro);
1618
+ for (i = 0; i < n; i++) {
1619
+ PyObject *base = PyTuple_GET_ITEM(mro, i);
1620
+ if (base == (PyObject *)a || base == (PyObject *)b)
1621
+ return 1;
1622
+ }
1623
+ return 0;
1624
+ }
1625
+ // should only get here for incompletely initialised types, i.e. never under normal usage patterns
1626
+ return __Pyx_InBases(cls, a) || __Pyx_InBases(cls, b);
1627
+ }
1628
+ #endif
1629
+
1630
+
1631
+ /////////////// MathInitCode ///////////////
1632
+
1633
+ #if defined(_WIN32) || defined(WIN32) || defined(MS_WINDOWS)
1634
+ #ifndef _USE_MATH_DEFINES
1635
+ #define _USE_MATH_DEFINES
1636
+ #endif
1637
+ #endif
1638
+ #include <math.h>
1639
+
1640
+ #if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
1641
+ #define __Pyx_truncl trunc
1642
+ #else
1643
+ #define __Pyx_truncl truncl
1644
+ #endif
1645
+
1646
+ /////////////// ForceInitThreads.proto ///////////////
1647
+ //@proto_block: utility_code_proto_before_types
1648
+
1649
+ #ifndef __PYX_FORCE_INIT_THREADS
1650
+ #define __PYX_FORCE_INIT_THREADS 0
1651
+ #endif
1652
+
1653
+
1654
+ /////////////// ModuleCreationPEP489 ///////////////
1655
+ //@substitute: naming
1656
+
1657
+ #if CYTHON_COMPILING_IN_LIMITED_API && (__PYX_LIMITED_VERSION_HEX < 0x030A0000 && \
1658
+ (defined(_WIN32) || defined(WIN32) || defined(MS_WINDOWS)))
1659
+ static PY_INT64_T __Pyx_GetCurrentInterpreterId(void) {
1660
+ {
1661
+ PyObject *module = PyImport_ImportModule("_interpreters"); // 3.13+ I think
1662
+ if (!module) {
1663
+ if (!PyErr_ExceptionMatches(PyExc_Exception)) {
1664
+ goto bad; // BaseException
1665
+ }
1666
+ PyErr_Clear(); // just try the 3.8-3.12 version
1667
+ module = PyImport_ImportModule("_xxsubinterpreters");
1668
+ if (!module) goto bad;
1669
+ }
1670
+ PyObject *current = PyObject_CallMethod(module, "get_current", NULL);
1671
+ Py_DECREF(module);
1672
+ if (!current) goto bad;
1673
+ if (PyTuple_Check(current)) {
1674
+ // I think 3.13+ returns a tuple of (ID, whence),
1675
+ // but it's obviously a private module so the API changes a bit.
1676
+ PyObject *new_current = PySequence_GetItem(current, 0);
1677
+ Py_DECREF(current);
1678
+ current = new_current;
1679
+ if (!new_current) goto bad;
1680
+ }
1681
+ long long as_c_int = PyLong_AsLongLong(current);
1682
+ Py_DECREF(current);
1683
+ return as_c_int;
1684
+ }
1685
+ bad:
1686
+ PySys_WriteStderr("__Pyx_GetCurrentInterpreterId failed. Try setting the C define CYTHON_PEP489_MULTI_PHASE_INIT=0\n");
1687
+ return -1;
1688
+ }
1689
+ #endif
1690
+
1691
+ //#if CYTHON_PEP489_MULTI_PHASE_INIT
1692
+ #if !CYTHON_USE_MODULE_STATE
1693
+ static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
1694
+ static PY_INT64_T main_interpreter_id = -1;
1695
+ #if CYTHON_COMPILING_IN_GRAAL && defined(GRAALPY_VERSION_NUM) && GRAALPY_VERSION_NUM > 0x19000000
1696
+ PY_INT64_T current_id = GraalPyInterpreterState_GetIDFromThreadState(PyThreadState_Get());
1697
+ #elif CYTHON_COMPILING_IN_GRAAL
1698
+ PY_INT64_T current_id = PyInterpreterState_GetIDFromThreadState(PyThreadState_Get());
1699
+ #elif CYTHON_COMPILING_IN_LIMITED_API && (__PYX_LIMITED_VERSION_HEX < 0x030A0000 && \
1700
+ (defined(_WIN32) || defined(WIN32) || defined(MS_WINDOWS)))
1701
+ // Although PyInterpreterState_Get is part of the Stable ABI from Python 3.9,
1702
+ // it was somehow omitted from the Windows dll in that version.
1703
+ PY_INT64_T current_id = __Pyx_GetCurrentInterpreterId();
1704
+ #elif CYTHON_COMPILING_IN_LIMITED_API
1705
+ PY_INT64_T current_id = PyInterpreterState_GetID(PyInterpreterState_Get());
1706
+ #else
1707
+ PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
1708
+ #endif
1709
+ if (unlikely(current_id == -1)) {
1710
+ return -1;
1711
+ }
1712
+ if (main_interpreter_id == -1) {
1713
+ main_interpreter_id = current_id;
1714
+ return 0;
1715
+ } else if (unlikely(main_interpreter_id != current_id)) {
1716
+ PyErr_SetString(
1717
+ PyExc_ImportError,
1718
+ "Interpreter change detected - this module can only be loaded into one interpreter per process.");
1719
+ return -1;
1720
+ }
1721
+ return 0;
1722
+ }
1723
+ #endif
1724
+
1725
+ static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none)
1726
+ {
1727
+ PyObject *value = PyObject_GetAttrString(spec, from_name);
1728
+ int result = 0;
1729
+ if (likely(value)) {
1730
+ if (allow_none || value != Py_None) {
1731
+ result = PyDict_SetItemString(moddict, to_name, value);
1732
+ }
1733
+ Py_DECREF(value);
1734
+ } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
1735
+ PyErr_Clear();
1736
+ } else {
1737
+ result = -1;
1738
+ }
1739
+ return result;
1740
+ }
1741
+
1742
+ static CYTHON_SMALL_CODE PyObject* ${pymodule_create_func_cname}(PyObject *spec, PyModuleDef *def) {
1743
+ PyObject *module = NULL, *moddict, *modname;
1744
+ CYTHON_UNUSED_VAR(def);
1745
+
1746
+ #if !CYTHON_USE_MODULE_STATE
1747
+ // For now, we only have exactly one module instance.
1748
+ if (__Pyx_check_single_interpreter())
1749
+ return NULL;
1750
+ #endif
1751
+ if (${module_cname})
1752
+ return __Pyx_NewRef(${module_cname});
1753
+
1754
+ modname = PyObject_GetAttrString(spec, "name");
1755
+ if (unlikely(!modname)) goto bad;
1756
+
1757
+ module = PyModule_NewObject(modname);
1758
+ Py_DECREF(modname);
1759
+ if (unlikely(!module)) goto bad;
1760
+
1761
+ moddict = PyModule_GetDict(module);
1762
+ if (unlikely(!moddict)) goto bad;
1763
+ // moddict is a borrowed reference
1764
+
1765
+ if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
1766
+ if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
1767
+ if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
1768
+ if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
1769
+
1770
+ return module;
1771
+ bad:
1772
+ Py_XDECREF(module);
1773
+ return NULL;
1774
+ }
1775
+ //#endif
1776
+
1777
+
1778
+ /////////////// CodeObjectCache.proto ///////////////
1779
+ //@requires: Synchronization.c::Atomics
1780
+
1781
+ #if CYTHON_COMPILING_IN_LIMITED_API
1782
+ typedef PyObject __Pyx_CachedCodeObjectType;
1783
+ #else
1784
+ typedef PyCodeObject __Pyx_CachedCodeObjectType;
1785
+ #endif
1786
+
1787
+ typedef struct {
1788
+ __Pyx_CachedCodeObjectType* code_object;
1789
+ int code_line;
1790
+ } __Pyx_CodeObjectCacheEntry;
1791
+
1792
+ struct __Pyx_CodeObjectCache {
1793
+ int count;
1794
+ int max_count;
1795
+ __Pyx_CodeObjectCacheEntry* entries;
1796
+ #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
1797
+ // 0 for none, +ve for readers, -ve for writers.
1798
+ //
1799
+ __pyx_atomic_int_type accessor_count;
1800
+ #endif
1801
+ };
1802
+
1803
+ static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
1804
+
1805
+ static __Pyx_CachedCodeObjectType *__pyx_find_code_object(int code_line);
1806
+ static void __pyx_insert_code_object(int code_line, __Pyx_CachedCodeObjectType* code_object);
1807
+
1808
+ /////////////// CodeObjectCache.module_state_decls ////////////////
1809
+
1810
+ struct __Pyx_CodeObjectCache __pyx_code_cache;
1811
+
1812
+ /////////////// CodeObjectCache ///////////////
1813
+ // Note that errors are simply ignored in the code below.
1814
+ // This is just a cache, if a lookup or insertion fails - so what?
1815
+
1816
+ static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
1817
+ int start = 0, mid = 0, end = count - 1;
1818
+ if (end >= 0 && code_line > entries[end].code_line) {
1819
+ return count;
1820
+ }
1821
+ while (start < end) {
1822
+ mid = start + (end - start) / 2;
1823
+ if (code_line < entries[mid].code_line) {
1824
+ end = mid;
1825
+ } else if (code_line > entries[mid].code_line) {
1826
+ start = mid + 1;
1827
+ } else {
1828
+ return mid;
1829
+ }
1830
+ }
1831
+ if (code_line <= entries[mid].code_line) {
1832
+ return mid;
1833
+ } else {
1834
+ return mid + 1;
1835
+ }
1836
+ }
1837
+
1838
+ static __Pyx_CachedCodeObjectType *__pyx__find_code_object(struct __Pyx_CodeObjectCache *code_cache, int code_line) {
1839
+ __Pyx_CachedCodeObjectType* code_object;
1840
+ int pos;
1841
+ if (unlikely(!code_line) || unlikely(!code_cache->entries)) {
1842
+ return NULL;
1843
+ }
1844
+ pos = __pyx_bisect_code_objects(code_cache->entries, code_cache->count, code_line);
1845
+ if (unlikely(pos >= code_cache->count) || unlikely(code_cache->entries[pos].code_line != code_line)) {
1846
+ return NULL;
1847
+ }
1848
+ code_object = code_cache->entries[pos].code_object;
1849
+ Py_INCREF(code_object);
1850
+ return code_object;
1851
+ }
1852
+
1853
+ static __Pyx_CachedCodeObjectType *__pyx_find_code_object(int code_line) {
1854
+ #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING && !CYTHON_ATOMICS
1855
+ (void)__pyx__find_code_object;
1856
+ return NULL; // Most implementation should have atomics. But otherwise, don't make it thread-safe, just miss.
1857
+ #else
1858
+ struct __Pyx_CodeObjectCache *code_cache = &CGLOBAL(__pyx_code_cache);
1859
+ #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
1860
+ __pyx_nonatomic_int_type old_count = __pyx_atomic_incr_acq_rel(&code_cache->accessor_count);
1861
+ if (old_count < 0) {
1862
+ // It's being written so currently unreadable.
1863
+ __pyx_atomic_decr_acq_rel(&code_cache->accessor_count);
1864
+ return NULL;
1865
+ }
1866
+ #endif
1867
+ __Pyx_CachedCodeObjectType *result = __pyx__find_code_object(code_cache, code_line);
1868
+ #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
1869
+ __pyx_atomic_decr_acq_rel(&code_cache->accessor_count);
1870
+ #endif
1871
+ return result;
1872
+ #endif
1873
+ }
1874
+
1875
+
1876
+ static void __pyx__insert_code_object(struct __Pyx_CodeObjectCache *code_cache, int code_line, __Pyx_CachedCodeObjectType* code_object)
1877
+ {
1878
+ int pos, i;
1879
+ __Pyx_CodeObjectCacheEntry* entries = code_cache->entries;
1880
+ if (unlikely(!code_line)) {
1881
+ return;
1882
+ }
1883
+ if (unlikely(!entries)) {
1884
+ entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
1885
+ if (likely(entries)) {
1886
+ code_cache->entries = entries;
1887
+ code_cache->max_count = 64;
1888
+ code_cache->count = 1;
1889
+ entries[0].code_line = code_line;
1890
+ entries[0].code_object = code_object;
1891
+ Py_INCREF(code_object);
1892
+ }
1893
+ return;
1894
+ }
1895
+ pos = __pyx_bisect_code_objects(code_cache->entries, code_cache->count, code_line);
1896
+ if ((pos < code_cache->count) && unlikely(code_cache->entries[pos].code_line == code_line)) {
1897
+ __Pyx_CachedCodeObjectType* tmp = entries[pos].code_object;
1898
+ entries[pos].code_object = code_object;
1899
+ Py_INCREF(code_object);
1900
+ Py_DECREF(tmp);
1901
+ return;
1902
+ }
1903
+ if (code_cache->count == code_cache->max_count) {
1904
+ int new_max = code_cache->max_count + 64;
1905
+ entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
1906
+ code_cache->entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry));
1907
+ if (unlikely(!entries)) {
1908
+ return;
1909
+ }
1910
+ code_cache->entries = entries;
1911
+ code_cache->max_count = new_max;
1912
+ }
1913
+ for (i=code_cache->count; i>pos; i--) {
1914
+ entries[i] = entries[i-1];
1915
+ }
1916
+ entries[pos].code_line = code_line;
1917
+ entries[pos].code_object = code_object;
1918
+ code_cache->count++;
1919
+ Py_INCREF(code_object);
1920
+ }
1921
+
1922
+ static void __pyx_insert_code_object(int code_line, __Pyx_CachedCodeObjectType* code_object) {
1923
+ #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING && !CYTHON_ATOMICS
1924
+ (void)__pyx__insert_code_object;
1925
+ return; // Most implementation should have atomics. But otherwise, don't make it thread-safe, just fail.
1926
+ #else
1927
+ struct __Pyx_CodeObjectCache *code_cache = &CGLOBAL(__pyx_code_cache);
1928
+ #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
1929
+ __pyx_nonatomic_int_type expected = 0;
1930
+ if (!__pyx_atomic_int_cmp_exchange(&code_cache->accessor_count, &expected, INT_MIN)) {
1931
+ // it's being written or read, Either way we can't do anything
1932
+ return;
1933
+ }
1934
+ #endif
1935
+ __pyx__insert_code_object(code_cache, code_line, code_object);
1936
+ #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
1937
+ __pyx_atomic_sub(&code_cache->accessor_count, INT_MIN);
1938
+ #endif
1939
+ #endif
1940
+ }
1941
+
1942
+ /////////////// CodeObjectCache.cleanup ///////////////
1943
+
1944
+ {
1945
+ struct __Pyx_CodeObjectCache *code_cache = &CGLOBAL(__pyx_code_cache);
1946
+ if (code_cache->entries) {
1947
+ __Pyx_CodeObjectCacheEntry* entries = code_cache->entries;
1948
+ int i, count = code_cache->count;
1949
+ code_cache->count = 0;
1950
+ code_cache->max_count = 0;
1951
+ code_cache->entries = NULL;
1952
+ for (i=0; i<count; i++) {
1953
+ Py_DECREF(entries[i].code_object);
1954
+ }
1955
+ PyMem_Free(entries);
1956
+ }
1957
+ }
1958
+
1959
+ /////////////// GetRuntimeVersion.proto ///////////////
1960
+
1961
+ #if __PYX_LIMITED_VERSION_HEX < 0x030b0000
1962
+ static unsigned long __Pyx_cached_runtime_version = 0;
1963
+
1964
+ static void __Pyx_init_runtime_version(void);
1965
+ #else
1966
+ #define __Pyx_init_runtime_version()
1967
+ #endif
1968
+
1969
+ // Does not require the GIL to be held
1970
+ static unsigned long __Pyx_get_runtime_version(void);
1971
+
1972
+ /////////////// GetRuntimeVersion ///////////////
1973
+
1974
+ #if __PYX_LIMITED_VERSION_HEX < 0x030b0000
1975
+ void __Pyx_init_runtime_version(void) {
1976
+ if (__Pyx_cached_runtime_version == 0) {
1977
+ const char* rt_version = Py_GetVersion();
1978
+ unsigned long version = 0;
1979
+ unsigned long factor = 0x01000000UL;
1980
+ unsigned int digit = 0;
1981
+ int i = 0;
1982
+ while (factor) {
1983
+ while ('0' <= rt_version[i] && rt_version[i] <= '9') {
1984
+ digit = digit * 10 + (unsigned int) (rt_version[i] - '0');
1985
+ ++i;
1986
+ }
1987
+ version += factor * digit;
1988
+ if (rt_version[i] != '.')
1989
+ break;
1990
+ digit = 0;
1991
+ factor >>= 8;
1992
+ ++i;
1993
+ }
1994
+ __Pyx_cached_runtime_version = version;
1995
+ }
1996
+ }
1997
+ #endif
1998
+
1999
+ static unsigned long __Pyx_get_runtime_version(void) {
2000
+ // We will probably never need the alpha/beta status, so avoid the complexity to parse it.
2001
+ #if __PYX_LIMITED_VERSION_HEX >= 0x030b0000
2002
+ return Py_Version & ~0xFFUL;
2003
+ #else
2004
+ return __Pyx_cached_runtime_version;
2005
+ #endif
2006
+ }
2007
+
2008
+ /////////////// CheckBinaryVersion.proto ///////////////
2009
+
2010
+ static int __Pyx_check_binary_version(unsigned long ct_version, unsigned long rt_version, int allow_newer);
2011
+
2012
+ /////////////// CheckBinaryVersion ///////////////
2013
+
2014
+ static int __Pyx_check_binary_version(unsigned long ct_version, unsigned long rt_version, int allow_newer) {
2015
+ // runtime version is: -1 => older, 0 => equal, 1 => newer
2016
+ const unsigned long MAJOR_MINOR = 0xFFFF0000UL;
2017
+ if ((rt_version & MAJOR_MINOR) == (ct_version & MAJOR_MINOR))
2018
+ return 0;
2019
+ if (likely(allow_newer && (rt_version & MAJOR_MINOR) > (ct_version & MAJOR_MINOR)))
2020
+ return 1;
2021
+
2022
+ {
2023
+ char message[200];
2024
+ PyOS_snprintf(message, sizeof(message),
2025
+ "compile time Python version %d.%d "
2026
+ "of module '%.100s' "
2027
+ "%s "
2028
+ "runtime version %d.%d",
2029
+ (int) (ct_version >> 24), (int) ((ct_version >> 16) & 0xFF),
2030
+ __Pyx_MODULE_NAME,
2031
+ (allow_newer) ? "was newer than" : "does not match",
2032
+ (int) (rt_version >> 24), (int) ((rt_version >> 16) & 0xFF)
2033
+ );
2034
+ // returns 0 or -1
2035
+ return PyErr_WarnEx(NULL, message, 1);
2036
+ }
2037
+ }
2038
+
2039
+ /////////////// IsLittleEndian.proto ///////////////
2040
+
2041
+ static CYTHON_INLINE int __Pyx_Is_Little_Endian(void);
2042
+
2043
+ /////////////// IsLittleEndian ///////////////
2044
+
2045
+ static CYTHON_INLINE int __Pyx_Is_Little_Endian(void)
2046
+ {
2047
+ union {
2048
+ uint32_t u32;
2049
+ uint8_t u8[4];
2050
+ } S;
2051
+ S.u32 = 0x01020304;
2052
+ return S.u8[0] == 4;
2053
+ }
2054
+
2055
+ /////////////// Refnanny.proto ///////////////
2056
+
2057
+ #ifndef CYTHON_REFNANNY
2058
+ #define CYTHON_REFNANNY 0
2059
+ #endif
2060
+
2061
+ #if CYTHON_REFNANNY
2062
+ typedef struct {
2063
+ void (*INCREF)(void*, PyObject*, Py_ssize_t);
2064
+ void (*DECREF)(void*, PyObject*, Py_ssize_t);
2065
+ void (*GOTREF)(void*, PyObject*, Py_ssize_t);
2066
+ void (*GIVEREF)(void*, PyObject*, Py_ssize_t);
2067
+ void* (*SetupContext)(const char*, Py_ssize_t, const char*);
2068
+ void (*FinishContext)(void**);
2069
+ } __Pyx_RefNannyAPIStruct;
2070
+ static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
2071
+ static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); /*proto*/
2072
+ #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
2073
+ #define __Pyx_RefNannySetupContext(name, acquire_gil) \
2074
+ if (acquire_gil) { \
2075
+ PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); \
2076
+ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), (__LINE__), (__FILE__)); \
2077
+ PyGILState_Release(__pyx_gilstate_save); \
2078
+ } else { \
2079
+ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), (__LINE__), (__FILE__)); \
2080
+ }
2081
+ #define __Pyx_RefNannyFinishContextNogil() { \
2082
+ PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); \
2083
+ __Pyx_RefNannyFinishContext(); \
2084
+ PyGILState_Release(__pyx_gilstate_save); \
2085
+ }
2086
+ #define __Pyx_RefNannyFinishContextNogil() { \
2087
+ PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); \
2088
+ __Pyx_RefNannyFinishContext(); \
2089
+ PyGILState_Release(__pyx_gilstate_save); \
2090
+ }
2091
+ #define __Pyx_RefNannyFinishContext() \
2092
+ __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
2093
+ #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), (__LINE__))
2094
+ #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), (__LINE__))
2095
+ #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), (__LINE__))
2096
+ #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), (__LINE__))
2097
+ #define __Pyx_XINCREF(r) do { if((r) == NULL); else {__Pyx_INCREF(r); }} while(0)
2098
+ #define __Pyx_XDECREF(r) do { if((r) == NULL); else {__Pyx_DECREF(r); }} while(0)
2099
+ #define __Pyx_XGOTREF(r) do { if((r) == NULL); else {__Pyx_GOTREF(r); }} while(0)
2100
+ #define __Pyx_XGIVEREF(r) do { if((r) == NULL); else {__Pyx_GIVEREF(r);}} while(0)
2101
+ #else
2102
+ #define __Pyx_RefNannyDeclarations
2103
+ #define __Pyx_RefNannySetupContext(name, acquire_gil)
2104
+ #define __Pyx_RefNannyFinishContextNogil()
2105
+ #define __Pyx_RefNannyFinishContext()
2106
+ #define __Pyx_INCREF(r) Py_INCREF(r)
2107
+ #define __Pyx_DECREF(r) Py_DECREF(r)
2108
+ #define __Pyx_GOTREF(r)
2109
+ #define __Pyx_GIVEREF(r)
2110
+ #define __Pyx_XINCREF(r) Py_XINCREF(r)
2111
+ #define __Pyx_XDECREF(r) Py_XDECREF(r)
2112
+ #define __Pyx_XGOTREF(r)
2113
+ #define __Pyx_XGIVEREF(r)
2114
+ #endif /* CYTHON_REFNANNY */
2115
+
2116
+ #define __Pyx_Py_XDECREF_SET(r, v) do { \
2117
+ PyObject *tmp = (PyObject *) r; \
2118
+ r = v; Py_XDECREF(tmp); \
2119
+ } while (0)
2120
+ #define __Pyx_XDECREF_SET(r, v) do { \
2121
+ PyObject *tmp = (PyObject *) r; \
2122
+ r = v; __Pyx_XDECREF(tmp); \
2123
+ } while (0)
2124
+ #define __Pyx_DECREF_SET(r, v) do { \
2125
+ PyObject *tmp = (PyObject *) r; \
2126
+ r = v; __Pyx_DECREF(tmp); \
2127
+ } while (0)
2128
+
2129
+ #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
2130
+ #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
2131
+
2132
+ /////////////// Refnanny ///////////////
2133
+
2134
+ #if CYTHON_REFNANNY
2135
+ static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
2136
+ PyObject *m = NULL, *p = NULL;
2137
+ void *r = NULL;
2138
+ m = PyImport_ImportModule(modname);
2139
+ if (!m) goto end;
2140
+ p = PyObject_GetAttrString(m, "RefNannyAPI");
2141
+ if (!p) goto end;
2142
+ r = PyLong_AsVoidPtr(p);
2143
+ end:
2144
+ Py_XDECREF(p);
2145
+ Py_XDECREF(m);
2146
+ return (__Pyx_RefNannyAPIStruct *)r;
2147
+ }
2148
+ #endif /* CYTHON_REFNANNY */
2149
+
2150
+
2151
+ /////////////// ImportRefnannyAPI ///////////////
2152
+
2153
+ #if CYTHON_REFNANNY
2154
+ __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
2155
+ if (!__Pyx_RefNanny) {
2156
+ if (PyErr_ExceptionMatches(PyExc_Exception)) {
2157
+ PyErr_Clear();
2158
+ __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
2159
+ }
2160
+ if (!__Pyx_RefNanny)
2161
+ Py_FatalError("failed to import 'refnanny' module");
2162
+ }
2163
+ #endif
2164
+
2165
+
2166
+ /////////////// RegisterModuleCleanup.proto ///////////////
2167
+ //@substitute: naming
2168
+
2169
+ static void ${cleanup_cname}(PyObject *self); /*proto*/
2170
+
2171
+ #if CYTHON_COMPILING_IN_PYPY
2172
+ static int __Pyx_RegisterCleanup(void); /*proto*/
2173
+ #else
2174
+ #define __Pyx_RegisterCleanup() (0)
2175
+ #endif
2176
+
2177
+ /////////////// RegisterModuleCleanup ///////////////
2178
+ //@substitute: naming
2179
+ //@requires: Exceptions.c::IgnoreException
2180
+
2181
+ #if CYTHON_COMPILING_IN_PYPY
2182
+ static PyObject* ${cleanup_cname}_atexit(PyObject *module, PyObject *unused) {
2183
+ CYTHON_UNUSED_VAR(unused);
2184
+ ${cleanup_cname}(module);
2185
+ Py_INCREF(Py_None); return Py_None;
2186
+ }
2187
+
2188
+ static int __Pyx_RegisterCleanup(void) {
2189
+ // Don't use Py_AtExit because that has a 32-call limit and is called
2190
+ // after python finalization.
2191
+ // Also, we try to prepend the cleanup function to "atexit._exithandlers"
2192
+ // in Py2 because CPython runs them last-to-first. Being run last allows
2193
+ // user exit code to run before us that may depend on the globals
2194
+ // and cached objects that we are about to clean up.
2195
+
2196
+ static PyMethodDef cleanup_def = {
2197
+ "__cleanup", (PyCFunction)${cleanup_cname}_atexit, METH_NOARGS, 0};
2198
+
2199
+ PyObject *cleanup_func = 0;
2200
+ PyObject *atexit = 0;
2201
+ PyObject *reg = 0;
2202
+ PyObject *args = 0;
2203
+ PyObject *res = 0;
2204
+ int ret = -1;
2205
+
2206
+ cleanup_func = PyCFunction_New(&cleanup_def, 0);
2207
+ if (!cleanup_func)
2208
+ goto bad;
2209
+
2210
+ atexit = PyImport_ImportModule("atexit");
2211
+ if (!atexit)
2212
+ goto bad;
2213
+ reg = PyObject_GetAttrString(atexit, "_exithandlers");
2214
+ if (reg && PyList_Check(reg)) {
2215
+ PyObject *a, *kw;
2216
+ a = PyTuple_New(0);
2217
+ if (!a)
2218
+ goto bad;
2219
+ kw = PyDict_New();
2220
+ if (!kw) {
2221
+ Py_DECREF(a);
2222
+ goto bad;
2223
+ }
2224
+ args = PyTuple_Pack(3, cleanup_func, a, kw);
2225
+ Py_DECREF(a);
2226
+ Py_DECREF(kw);
2227
+ if (!args)
2228
+ goto bad;
2229
+ ret = PyList_Insert(reg, 0, args);
2230
+ } else {
2231
+ if (!reg) {
2232
+ if (!__Pyx_IgnoreException(PyExc_AttributeError)) {
2233
+ goto bad;
2234
+ }
2235
+ } else {
2236
+ Py_DECREF(reg);
2237
+ }
2238
+ reg = PyObject_GetAttrString(atexit, "register");
2239
+ if (!reg)
2240
+ goto bad;
2241
+ args = PyTuple_Pack(1, cleanup_func);
2242
+ if (!args)
2243
+ goto bad;
2244
+ res = PyObject_CallObject(reg, args);
2245
+ if (!res)
2246
+ goto bad;
2247
+ ret = 0;
2248
+ }
2249
+ bad:
2250
+ Py_XDECREF(cleanup_func);
2251
+ Py_XDECREF(atexit);
2252
+ Py_XDECREF(reg);
2253
+ Py_XDECREF(args);
2254
+ Py_XDECREF(res);
2255
+ return ret;
2256
+ }
2257
+ #endif
2258
+
2259
+ /////////////// FastGil.init ///////////////
2260
+ __Pyx_FastGilFuncInit();
2261
+
2262
+ /////////////// NoFastGil.proto ///////////////
2263
+ //@proto_block: utility_code_proto_before_types
2264
+
2265
+ #define __Pyx_PyGILState_Ensure PyGILState_Ensure
2266
+ #define __Pyx_PyGILState_Release PyGILState_Release
2267
+ #define __Pyx_FastGIL_Remember()
2268
+ #define __Pyx_FastGIL_Forget()
2269
+ #define __Pyx_FastGilFuncInit()
2270
+
2271
+ /////////////// FastGil.proto ///////////////
2272
+ //@proto_block: utility_code_proto_before_types
2273
+
2274
+ #if CYTHON_FAST_GIL
2275
+
2276
+ struct __Pyx_FastGilVtab {
2277
+ PyGILState_STATE (*Fast_PyGILState_Ensure)(void);
2278
+ void (*Fast_PyGILState_Release)(PyGILState_STATE oldstate);
2279
+ void (*FastGIL_Remember)(void);
2280
+ void (*FastGIL_Forget)(void);
2281
+ };
2282
+
2283
+ static void __Pyx_FastGIL_Noop(void) {}
2284
+ static struct __Pyx_FastGilVtab __Pyx_FastGilFuncs = {
2285
+ PyGILState_Ensure,
2286
+ PyGILState_Release,
2287
+ __Pyx_FastGIL_Noop,
2288
+ __Pyx_FastGIL_Noop
2289
+ };
2290
+
2291
+ static void __Pyx_FastGilFuncInit(void);
2292
+
2293
+ #define __Pyx_PyGILState_Ensure __Pyx_FastGilFuncs.Fast_PyGILState_Ensure
2294
+ #define __Pyx_PyGILState_Release __Pyx_FastGilFuncs.Fast_PyGILState_Release
2295
+ #define __Pyx_FastGIL_Remember __Pyx_FastGilFuncs.FastGIL_Remember
2296
+ #define __Pyx_FastGIL_Forget __Pyx_FastGilFuncs.FastGIL_Forget
2297
+
2298
+ #ifndef CYTHON_THREAD_LOCAL
2299
+ #if defined(__cplusplus) && __cplusplus >= 201103L
2300
+ #define CYTHON_THREAD_LOCAL thread_local
2301
+ #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112
2302
+ #define CYTHON_THREAD_LOCAL _Thread_local
2303
+ #elif defined(__GNUC__)
2304
+ #define CYTHON_THREAD_LOCAL __thread
2305
+ #elif defined(_MSC_VER)
2306
+ #define CYTHON_THREAD_LOCAL __declspec(thread)
2307
+ #endif
2308
+ #endif
2309
+
2310
+ #else
2311
+ #define __Pyx_PyGILState_Ensure PyGILState_Ensure
2312
+ #define __Pyx_PyGILState_Release PyGILState_Release
2313
+ #define __Pyx_FastGIL_Remember()
2314
+ #define __Pyx_FastGIL_Forget()
2315
+ #define __Pyx_FastGilFuncInit()
2316
+ #endif
2317
+
2318
+ /////////////// FastGil ///////////////
2319
+ //@requires: AddModuleRef
2320
+ //@requires: Exceptions.c::IgnoreException
2321
+ // The implementations of PyGILState_Ensure/Release calls PyThread_get_key_value
2322
+ // several times which is turns out to be quite slow (slower in fact than
2323
+ // acquiring the GIL itself). Simply storing it in a thread local for the
2324
+ // common case is much faster.
2325
+ // To make optimal use of this thread local, we attempt to share it between
2326
+ // modules.
2327
+
2328
+ #if CYTHON_FAST_GIL
2329
+
2330
+ #define __Pyx_FastGIL_ABI_module __PYX_ABI_MODULE_NAME
2331
+ #define __Pyx_FastGIL_PyCapsuleName "FastGilFuncs"
2332
+ #define __Pyx_FastGIL_PyCapsule \
2333
+ __Pyx_FastGIL_ABI_module "." __Pyx_FastGIL_PyCapsuleName
2334
+
2335
+ #ifdef CYTHON_THREAD_LOCAL
2336
+
2337
+ #include "pythread.h"
2338
+ #include "pystate.h"
2339
+
2340
+ static CYTHON_THREAD_LOCAL PyThreadState *__Pyx_FastGil_tcur = NULL;
2341
+ static CYTHON_THREAD_LOCAL int __Pyx_FastGil_tcur_depth = 0;
2342
+ static int __Pyx_FastGil_autoTLSkey = -1;
2343
+
2344
+ static CYTHON_INLINE void __Pyx_FastGIL_Remember0(void) {
2345
+ ++__Pyx_FastGil_tcur_depth;
2346
+ }
2347
+
2348
+ static CYTHON_INLINE void __Pyx_FastGIL_Forget0(void) {
2349
+ if (--__Pyx_FastGil_tcur_depth == 0) {
2350
+ __Pyx_FastGil_tcur = NULL;
2351
+ }
2352
+ }
2353
+
2354
+ static CYTHON_INLINE PyThreadState *__Pyx_FastGil_get_tcur(void) {
2355
+ PyThreadState *tcur = __Pyx_FastGil_tcur;
2356
+ if (tcur == NULL) {
2357
+ tcur = __Pyx_FastGil_tcur = (PyThreadState*)PyThread_get_key_value(__Pyx_FastGil_autoTLSkey);
2358
+ }
2359
+ return tcur;
2360
+ }
2361
+
2362
+ static PyGILState_STATE __Pyx_FastGil_PyGILState_Ensure(void) {
2363
+ int current;
2364
+ PyThreadState *tcur;
2365
+ __Pyx_FastGIL_Remember0();
2366
+ tcur = __Pyx_FastGil_get_tcur();
2367
+ if (tcur == NULL) {
2368
+ // Uninitialized, need to initialize now.
2369
+ return PyGILState_Ensure();
2370
+ }
2371
+ current = tcur == __Pyx_PyThreadState_Current;
2372
+ if (current == 0) {
2373
+ PyEval_RestoreThread(tcur);
2374
+ }
2375
+ ++tcur->gilstate_counter;
2376
+ return current ? PyGILState_LOCKED : PyGILState_UNLOCKED;
2377
+ }
2378
+
2379
+ static void __Pyx_FastGil_PyGILState_Release(PyGILState_STATE oldstate) {
2380
+ PyThreadState *tcur = __Pyx_FastGil_get_tcur();
2381
+ __Pyx_FastGIL_Forget0();
2382
+ if (tcur->gilstate_counter == 1) {
2383
+ // This is the last lock, do all the cleanup as well.
2384
+ PyGILState_Release(oldstate);
2385
+ } else {
2386
+ --tcur->gilstate_counter;
2387
+ if (oldstate == PyGILState_UNLOCKED) {
2388
+ PyEval_SaveThread();
2389
+ }
2390
+ }
2391
+ }
2392
+
2393
+ static void __Pyx_FastGilFuncInit0(void) {
2394
+ /* Try to detect autoTLSkey. */
2395
+ int key;
2396
+ void* this_thread_state = (void*) PyGILState_GetThisThreadState();
2397
+ for (key = 0; key < 100; key++) {
2398
+ if (PyThread_get_key_value(key) == this_thread_state) {
2399
+ __Pyx_FastGil_autoTLSkey = key;
2400
+ break;
2401
+ }
2402
+ }
2403
+ if (__Pyx_FastGil_autoTLSkey != -1) {
2404
+ PyObject* capsule = NULL;
2405
+ PyObject* abi_module = NULL;
2406
+ __Pyx_PyGILState_Ensure = __Pyx_FastGil_PyGILState_Ensure;
2407
+ __Pyx_PyGILState_Release = __Pyx_FastGil_PyGILState_Release;
2408
+ __Pyx_FastGIL_Remember = __Pyx_FastGIL_Remember0;
2409
+ __Pyx_FastGIL_Forget = __Pyx_FastGIL_Forget0;
2410
+ capsule = PyCapsule_New(&__Pyx_FastGilFuncs, __Pyx_FastGIL_PyCapsule, NULL);
2411
+ if (capsule) {
2412
+ abi_module = __Pyx_PyImport_AddModuleRef(__Pyx_FastGIL_ABI_module);
2413
+ if (abi_module) {
2414
+ PyObject_SetAttrString(abi_module, __Pyx_FastGIL_PyCapsuleName, capsule);
2415
+ Py_DECREF(abi_module);
2416
+ }
2417
+ }
2418
+ Py_XDECREF(capsule);
2419
+ }
2420
+ }
2421
+
2422
+ #else
2423
+
2424
+ static void __Pyx_FastGilFuncInit0(void) {
2425
+ }
2426
+
2427
+ #endif
2428
+
2429
+ static void __Pyx_FastGilFuncInit(void) {
2430
+ struct __Pyx_FastGilVtab* shared = (struct __Pyx_FastGilVtab*)PyCapsule_Import(__Pyx_FastGIL_PyCapsule, 1);
2431
+ if (shared) {
2432
+ __Pyx_FastGilFuncs = *shared;
2433
+ } else if (__Pyx_IgnoreException(PyExc_Exception)) {
2434
+ return __Pyx_FastGilFuncInit0();
2435
+ }
2436
+ }
2437
+
2438
+ #endif
2439
+
2440
+ ///////////////////// PretendToInitialize ////////////////////////
2441
+
2442
+ #ifdef __cplusplus
2443
+ // In C++ a variable must actually be initialized to make returning
2444
+ // it defined behaviour, and there doesn't seem to be a viable compiler trick to
2445
+ // avoid that.
2446
+ #if __cplusplus > 201103L
2447
+ #include <type_traits>
2448
+ #endif
2449
+
2450
+ template <typename T>
2451
+ static void __Pyx_pretend_to_initialize(T* ptr) {
2452
+ // In C++11 we have enough introspection to work out which types it's actually
2453
+ // necessary to apply this to (non-trivial types will have been initialized by
2454
+ // the definition). Below C++11 just initialize everything.
2455
+ #if __cplusplus > 201103L
2456
+ if ((std::is_trivially_default_constructible<T>::value))
2457
+ #endif
2458
+ *ptr = T();
2459
+ (void)ptr;
2460
+ }
2461
+ #else
2462
+ // For C, taking an address of a variable is enough to make returning it
2463
+ // defined behaviour.
2464
+ static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
2465
+ #endif
2466
+
2467
+ ///////////////////// UtilityCodePragmas /////////////////////////
2468
+
2469
+ #ifdef _MSC_VER
2470
+ #pragma warning( push )
2471
+ /* Warning 4127: conditional expression is constant
2472
+ * Cython uses constant conditional expressions to allow in inline functions to be optimized at
2473
+ * compile-time, so this warning is not useful
2474
+ */
2475
+ #pragma warning( disable : 4127 )
2476
+ #endif
2477
+
2478
+ ///////////////////// UtilityCodePragmasEnd //////////////////////
2479
+
2480
+ #ifdef _MSC_VER
2481
+ #pragma warning( pop ) /* undo whatever Cython has done to warnings */
2482
+ #endif
2483
+
2484
+
2485
+ //////////////////// NewCodeObj.proto ////////////////////////
2486
+ //@proto_block: init_codeobjects
2487
+
2488
+ static PyObject* __Pyx_PyCode_New(
2489
+ //int argcount,
2490
+ //int num_posonly_args,
2491
+ //int num_kwonly_args,
2492
+ //int nlocals,
2493
+ // int s,
2494
+ //int flags,
2495
+ //int first_line,
2496
+ const __Pyx_PyCode_New_function_description descr,
2497
+ // PyObject *code,
2498
+ // PyObject *consts,
2499
+ // PyObject* n,
2500
+ // PyObject *varnames_tuple,
2501
+ PyObject * const *varnames,
2502
+ // PyObject *freevars,
2503
+ // PyObject *cellvars,
2504
+ PyObject *filename,
2505
+ PyObject *funcname,
2506
+ PyObject *line_table,
2507
+ PyObject *tuple_dedup_map
2508
+ );/*proto*/
2509
+
2510
+ //////////////////// NewCodeObj ////////////////////////
2511
+
2512
+ #if CYTHON_COMPILING_IN_LIMITED_API
2513
+ // Note that the limited API doesn't know about PyCodeObject, so the type of this
2514
+ // is PyObject (unlike for the main API)
2515
+ static PyObject* __Pyx__PyCode_New(int a, int p, int k, int l, int s, int f,
2516
+ PyObject *code, PyObject *c, PyObject* n, PyObject *v,
2517
+ PyObject *fv, PyObject *cell, PyObject* fn,
2518
+ PyObject *name, int fline, PyObject *lnos) {
2519
+ // Backup option for generating a code object.
2520
+ // PyCode_NewEmpty isn't in the limited API. Therefore the two options are
2521
+ // 1. Python call of the code type with a long list of positional args.
2522
+ // 2. Generate a code object by compiling some trivial code, and customize.
2523
+ // We use the first option here.
2524
+ PyObject *exception_table = NULL;
2525
+ PyObject *types_module=NULL, *code_type=NULL, *result=NULL;
2526
+ #if __PYX_LIMITED_VERSION_HEX < 0x030b0000
2527
+ PyObject *version_info; /* borrowed */
2528
+ PyObject *py_minor_version = NULL;
2529
+ #endif
2530
+ long minor_version = 0;
2531
+
2532
+ #if __PYX_LIMITED_VERSION_HEX >= 0x030b0000
2533
+ minor_version = 11;
2534
+ // we don't yet need to distinguish between versions > 11
2535
+ // Note that from 3.13, when we do, we can use Py_Version
2536
+ #else
2537
+ if (!(version_info = PySys_GetObject("version_info"))) goto end;
2538
+ if (!(py_minor_version = PySequence_GetItem(version_info, 1))) goto end;
2539
+ minor_version = PyLong_AsLong(py_minor_version);
2540
+ Py_DECREF(py_minor_version);
2541
+ if (minor_version == -1 && PyErr_Occurred()) goto end;
2542
+ #endif
2543
+
2544
+ if (!(types_module = PyImport_ImportModule("types"))) goto end;
2545
+ if (!(code_type = PyObject_GetAttrString(types_module, "CodeType"))) goto end;
2546
+
2547
+ if (minor_version <= 10) {
2548
+ // [3.8], 3.9, 3.10
2549
+ // code(argcount, posonlyargcount, kwonlyargcount, nlocals, stacksize,
2550
+ // flags, codestring, constants, names, varnames, filename, name,
2551
+ // firstlineno, lnotab[, freevars[, cellvars]])
2552
+ // 3.10 switches lnotab for linetable, but is otherwise the same
2553
+ result = PyObject_CallFunction(code_type, "iiiiiiOOOOOOiOOO", a,p, k, l, s, f, code,
2554
+ c, n, v, fn, name, fline, lnos, fv, cell);
2555
+ } else {
2556
+ // 3.11, 3.12
2557
+ // code(argcount, posonlyargcount, kwonlyargcount, nlocals, stacksize,
2558
+ // flags, codestring, constants, names, varnames, filename, name,
2559
+ // qualname, firstlineno, linetable, exceptiontable, freevars=(), cellvars=(), /)
2560
+ // We use name and qualname for simplicity
2561
+ if (!(exception_table = PyBytes_FromStringAndSize(NULL, 0))) goto end;
2562
+ result = PyObject_CallFunction(code_type, "iiiiiiOOOOOOOiOOOO", a,p, k, l, s, f, code,
2563
+ c, n, v, fn, name, name, fline, lnos, exception_table, fv, cell);
2564
+ }
2565
+
2566
+ end:
2567
+ Py_XDECREF(code_type);
2568
+ Py_XDECREF(exception_table);
2569
+ Py_XDECREF(types_module);
2570
+
2571
+ if (!result) {
2572
+ // We use private API to create code objects and so it could fail in future.
2573
+ // In this case it's probably best if they keep working with a warning:
2574
+ // they're mostly just introspection decoration.
2575
+ PyObject *exc_type, *exc_value, *exc_tb;
2576
+ PyErr_Fetch(&exc_type, &exc_value, &exc_tb);
2577
+ if (PyErr_WarnFormat(
2578
+ PyExc_RuntimeWarning, 1,
2579
+ "Code object creation failed in Cython module: %S\nTry recompiling with a more recent version of Cython.",
2580
+ exc_value ? exc_value : exc_type) == 0) {
2581
+ result = Py_None;
2582
+ Py_INCREF(result);
2583
+ }
2584
+ Py_DECREF(exc_type);
2585
+ Py_XDECREF(exc_value);
2586
+ Py_XDECREF(exc_tb);
2587
+ }
2588
+
2589
+ return result;
2590
+ }
2591
+
2592
+ #elif PY_VERSION_HEX >= 0x030B0000
2593
+ static PyCodeObject* __Pyx__PyCode_New(int a, int p, int k, int l, int s, int f,
2594
+ PyObject *code, PyObject *c, PyObject* n, PyObject *v,
2595
+ PyObject *fv, PyObject *cell, PyObject* fn,
2596
+ PyObject *name, int fline, PyObject *lnos) {
2597
+ // As earlier versions, but
2598
+ // 1. pass an empty bytes string as exception_table
2599
+ // 2. pass name as qualname (TODO this might implementing properly in future)
2600
+ PyCodeObject *result;
2601
+ result =
2602
+ #if PY_VERSION_HEX >= 0x030C0000
2603
+ PyUnstable_Code_NewWithPosOnlyArgs
2604
+ #else
2605
+ PyCode_NewWithPosOnlyArgs
2606
+ #endif
2607
+ (a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, name, fline, lnos, EMPTY(bytes));
2608
+
2609
+ #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030c00A1
2610
+ if (likely(result))
2611
+ result->_co_firsttraceable = 0;
2612
+ #endif
2613
+ return result;
2614
+ }
2615
+ #elif !CYTHON_COMPILING_IN_PYPY
2616
+ #define __Pyx__PyCode_New(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \
2617
+ PyCode_NewWithPosOnlyArgs(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
2618
+ #else
2619
+ #define __Pyx__PyCode_New(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \
2620
+ PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
2621
+ #endif
2622
+
2623
+ // This is a specialised helper function for creating Cython's function code objects.
2624
+ // It only receives the arguments that differ between the Cython functions of the module.
2625
+ // This minimises the calling code in the module init function.
2626
+ static PyObject* __Pyx_PyCode_New(
2627
+ //int argcount,
2628
+ //int num_posonly_args,
2629
+ //int num_kwonly_args,
2630
+ //int nlocals,
2631
+ // int s,
2632
+ //int flags,
2633
+ //int first_line,
2634
+ const __Pyx_PyCode_New_function_description descr,
2635
+ // PyObject *code,
2636
+ // PyObject *consts,
2637
+ // PyObject* n,
2638
+ // PyObject *varnames_tuple,
2639
+ PyObject * const *varnames,
2640
+ // PyObject *freevars,
2641
+ // PyObject *cellvars,
2642
+ PyObject *filename,
2643
+ PyObject *funcname,
2644
+ // line table replaced lnotab in Py3.11 (PEP-626)
2645
+ PyObject *line_table,
2646
+ PyObject *tuple_dedup_map
2647
+ ) {
2648
+
2649
+ PyObject *code_obj = NULL, *varnames_tuple_dedup = NULL, *code_bytes = NULL;
2650
+ Py_ssize_t var_count = (Py_ssize_t) descr.nlocals;
2651
+
2652
+ PyObject *varnames_tuple = PyTuple_New(var_count);
2653
+ if (unlikely(!varnames_tuple)) return NULL;
2654
+ for (Py_ssize_t i=0; i < var_count; i++) {
2655
+ Py_INCREF(varnames[i]);
2656
+ if (__Pyx_PyTuple_SET_ITEM(varnames_tuple, i, varnames[i]) != (0)) goto done;
2657
+ }
2658
+
2659
+ #if CYTHON_COMPILING_IN_LIMITED_API
2660
+ varnames_tuple_dedup = PyDict_GetItem(tuple_dedup_map, varnames_tuple);
2661
+ if (!varnames_tuple_dedup) {
2662
+ if (unlikely(PyDict_SetItem(tuple_dedup_map, varnames_tuple, varnames_tuple) < 0)) goto done;
2663
+ varnames_tuple_dedup = varnames_tuple;
2664
+ }
2665
+ #else
2666
+ varnames_tuple_dedup = PyDict_SetDefault(tuple_dedup_map, varnames_tuple, varnames_tuple);
2667
+ if (unlikely(!varnames_tuple_dedup)) goto done;
2668
+ #endif
2669
+
2670
+ #if CYTHON_AVOID_BORROWED_REFS
2671
+ Py_INCREF(varnames_tuple_dedup);
2672
+ #endif
2673
+
2674
+ if (__PYX_LIMITED_VERSION_HEX >= (0x030b0000) && line_table != NULL && !CYTHON_COMPILING_IN_GRAAL) {
2675
+ // Allocate a "byte code" array (oversized) to match the addresses in the line table.
2676
+ // Length and alignment must be a multiple of sizeof(_Py_CODEUNIT), which is CPython specific but currently 2.
2677
+ // CPython makes a copy of the code array internally, so make sure it's somewhat short (but not too short).
2678
+ Py_ssize_t line_table_length = __Pyx_PyBytes_GET_SIZE(line_table);
2679
+ #if !CYTHON_ASSUME_SAFE_SIZE
2680
+ if (unlikely(line_table_length == -1)) goto done;
2681
+ #endif
2682
+ Py_ssize_t code_len = (line_table_length * 2 + 4) & ~3LL;
2683
+ code_bytes = PyBytes_FromStringAndSize(NULL, code_len);
2684
+ if (unlikely(!code_bytes)) goto done;
2685
+ char* c_code_bytes = PyBytes_AsString(code_bytes);
2686
+ if (unlikely(!c_code_bytes)) goto done;
2687
+ // We initialise the code array to '\0' even though a NOP would be more accurate,
2688
+ // but NOP changes its byte code ID across Python versions/implementations.
2689
+ memset(c_code_bytes, 0, (size_t) code_len);
2690
+ }
2691
+
2692
+ code_obj = (PyObject*) __Pyx__PyCode_New(
2693
+ (int) descr.argcount,
2694
+ (int) descr.num_posonly_args,
2695
+ (int) descr.num_kwonly_args,
2696
+ (int) descr.nlocals,
2697
+ 0,
2698
+ (int) descr.flags,
2699
+ code_bytes ? code_bytes : EMPTY(bytes),
2700
+ EMPTY(tuple),
2701
+ EMPTY(tuple),
2702
+ varnames_tuple_dedup,
2703
+ EMPTY(tuple),
2704
+ EMPTY(tuple),
2705
+ filename,
2706
+ funcname,
2707
+ (int) descr.first_line,
2708
+ (__PYX_LIMITED_VERSION_HEX >= (0x030b0000) && line_table) ? line_table : EMPTY(bytes)
2709
+ );
2710
+
2711
+ done:
2712
+ Py_XDECREF(code_bytes);
2713
+ #if CYTHON_AVOID_BORROWED_REFS
2714
+ Py_XDECREF(varnames_tuple_dedup);
2715
+ #endif
2716
+ Py_DECREF(varnames_tuple);
2717
+ return code_obj;
2718
+ }
2719
+
2720
+
2721
+ ////////////////////////// MultiPhaseInitModuleState.proto /////////////
2722
+
2723
+ #if CYTHON_PEP489_MULTI_PHASE_INIT && CYTHON_USE_MODULE_STATE
2724
+ #include <stdlib.h>
2725
+
2726
+ // This defines an ad-hoc, single module version of PyState_FindModule that
2727
+ // works for multi-phase init modules. It's intended to be the last option
2728
+ // when all the other official ways of getting the module are unavailable.
2729
+ static PyObject *__Pyx_State_FindModule(void*); /* proto */
2730
+ static int __Pyx_State_AddModule(PyObject* module, void*); /* proto */
2731
+ static int __Pyx_State_RemoveModule(void*); /* proto */
2732
+
2733
+ #elif CYTHON_USE_MODULE_STATE
2734
+ #define __Pyx_State_FindModule PyState_FindModule
2735
+ #define __Pyx_State_AddModule PyState_AddModule
2736
+ #define __Pyx_State_RemoveModule PyState_RemoveModule
2737
+ #endif
2738
+
2739
+ ////////////////////////// MultiPhaseInitModuleState /////////////
2740
+ //@requires: Synchronization.c::Atomics
2741
+
2742
+
2743
+ // Code to maintain a mapping between (sub)interpreters and the module instance that they imported.
2744
+ // This is used to find the correct module state for the current interpreter.
2745
+
2746
+ #if CYTHON_PEP489_MULTI_PHASE_INIT && CYTHON_USE_MODULE_STATE
2747
+
2748
+ #ifndef CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
2749
+ // If you're using multiple interpreters but a single GIL then
2750
+ // this can be undefined for a bit of speed.
2751
+ // Isolated subinterpreters were added in 3.12, and nogil in 3.13, so before that
2752
+ // we can safely assume that we're protected by the GIL.
2753
+ // TODO - turn this off as appropriate when the user is able to set
2754
+ // Py_MOD_PER_INTERPRETER_GIL_SUPPORTED explicitly.
2755
+ #if (CYTHON_COMPILING_IN_LIMITED_API || PY_VERSION_HEX >= 0x030C0000)
2756
+ #define CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE 1
2757
+ #else
2758
+ #define CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE 0
2759
+ #endif
2760
+ #endif
2761
+
2762
+ #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE && !CYTHON_ATOMICS
2763
+ #error "Module state with PEP489 requires atomics. Currently that's one of\
2764
+ C11, C++11, gcc atomic intrinsics or MSVC atomic intrinsics"
2765
+ #endif
2766
+
2767
+ // We also need a lock. In order of preference:
2768
+ // - PyMutex
2769
+ // - a language standard library
2770
+ // - pthreads
2771
+ // - msvc
2772
+ // - PyThread_lock isn't acceptable since we can't initialize it in a thread safe way
2773
+ #if !CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
2774
+
2775
+ #define __Pyx_ModuleStateLookup_Lock()
2776
+ #define __Pyx_ModuleStateLookup_Unlock()
2777
+
2778
+ #elif !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d0000
2779
+
2780
+ static PyMutex __Pyx_ModuleStateLookup_mutex = {0};
2781
+ #define __Pyx_ModuleStateLookup_Lock() PyMutex_Lock(&__Pyx_ModuleStateLookup_mutex)
2782
+ #define __Pyx_ModuleStateLookup_Unlock() PyMutex_Unlock(&__Pyx_ModuleStateLookup_mutex)
2783
+
2784
+ #elif defined(__cplusplus) && __cplusplus >= 201103L
2785
+
2786
+ #include <mutex>
2787
+ static std::mutex __Pyx_ModuleStateLookup_mutex;
2788
+ #define __Pyx_ModuleStateLookup_Lock() __Pyx_ModuleStateLookup_mutex.lock()
2789
+ #define __Pyx_ModuleStateLookup_Unlock() __Pyx_ModuleStateLookup_mutex.unlock()
2790
+
2791
+ #elif defined(__STDC_VERSION__) && (__STDC_VERSION__ > 201112L) && !defined(__STDC_NO_THREADS__)
2792
+ #include <threads.h>
2793
+ static mtx_t __Pyx_ModuleStateLookup_mutex;
2794
+ static once_flag __Pyx_ModuleStateLookup_mutex_once_flag = ONCE_FLAG_INIT;
2795
+ static void __Pyx_ModuleStateLookup_initialize_mutex(void) {
2796
+ mtx_init(&__Pyx_ModuleStateLookup_mutex, mtx_plain);
2797
+ }
2798
+ #define __Pyx_ModuleStateLookup_Lock() \
2799
+ call_once(&__Pyx_ModuleStateLookup_mutex_once_flag, __Pyx_ModuleStateLookup_initialize_mutex); \
2800
+ mtx_lock(&__Pyx_ModuleStateLookup_mutex)
2801
+ #define __Pyx_ModuleStateLookup_Unlock() mtx_unlock(&__Pyx_ModuleStateLookup_mutex)
2802
+
2803
+ // HAVE_PTHREAD_H comes from pyconfig.h
2804
+ #elif defined(HAVE_PTHREAD_H)
2805
+
2806
+ #include <pthread.h>
2807
+ static pthread_mutex_t __Pyx_ModuleStateLookup_mutex = PTHREAD_MUTEX_INITIALIZER;
2808
+ #define __Pyx_ModuleStateLookup_Lock() pthread_mutex_lock(&__Pyx_ModuleStateLookup_mutex)
2809
+ #define __Pyx_ModuleStateLookup_Unlock() pthread_mutex_unlock(&__Pyx_ModuleStateLookup_mutex)
2810
+
2811
+ #elif defined(_WIN32)
2812
+
2813
+ #include <Windows.h> // synchapi.h on its own doesn't work
2814
+
2815
+ // Using a slim-read-write lock (instead of a mutex/critical section)
2816
+ // because it can be statically initialized.
2817
+ static SRWLOCK __Pyx_ModuleStateLookup_mutex = SRWLOCK_INIT;
2818
+ #define __Pyx_ModuleStateLookup_Lock() AcquireSRWLockExclusive(&__Pyx_ModuleStateLookup_mutex)
2819
+ #define __Pyx_ModuleStateLookup_Unlock() ReleaseSRWLockExclusive(&__Pyx_ModuleStateLookup_mutex)
2820
+
2821
+ #else
2822
+ #error "No suitable lock available for CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE.\
2823
+ Requires C standard >= C11, or C++ standard >= C++11,\
2824
+ or pthreads, or the Windows 32 API, or Python >= 3.13."
2825
+ #endif
2826
+
2827
+
2828
+ typedef struct {
2829
+ int64_t id;
2830
+ PyObject *module;
2831
+ } __Pyx_InterpreterIdAndModule;
2832
+
2833
+ typedef struct {
2834
+ char interpreter_id_as_index;
2835
+ Py_ssize_t count;
2836
+ Py_ssize_t allocated;
2837
+ __Pyx_InterpreterIdAndModule table[1];
2838
+ } __Pyx_ModuleStateLookupData;
2839
+
2840
+ #define __PYX_MODULE_STATE_LOOKUP_SMALL_SIZE 32
2841
+ // "interpreter_id_as_index" above means "the maximum interpreter ID ever seen is smaller than
2842
+ // __PYX_MODULE_STATE_LOOKUP_SMALL_SIZE and thus they're stored in an array
2843
+ // where the index corresponds to interpreter ID, and __Pyx_ModuleStateLookup_count
2844
+ // is the size of the array.
2845
+
2846
+ #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
2847
+ static __pyx_atomic_int_type __Pyx_ModuleStateLookup_read_counter = 0;
2848
+ #endif
2849
+
2850
+ // A sorted list of (sub)interpreter IDs and the module that was imported into that interpreter.
2851
+ // For now look this up via binary search.
2852
+ #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
2853
+ static __pyx_atomic_ptr_type __Pyx_ModuleStateLookup_data = 0;
2854
+ #else
2855
+ static __Pyx_ModuleStateLookupData* __Pyx_ModuleStateLookup_data = NULL;
2856
+ #endif
2857
+
2858
+
2859
+ static __Pyx_InterpreterIdAndModule* __Pyx_State_FindModuleStateLookupTableLowerBound(
2860
+ __Pyx_InterpreterIdAndModule* table,
2861
+ Py_ssize_t count,
2862
+ int64_t interpreterId) {
2863
+ __Pyx_InterpreterIdAndModule* begin = table;
2864
+ __Pyx_InterpreterIdAndModule* end = begin + count;
2865
+
2866
+ // fairly likely - e.g. single interpreter
2867
+ if (begin->id == interpreterId) {
2868
+ return begin;
2869
+ }
2870
+
2871
+ while ((end - begin) > __PYX_MODULE_STATE_LOOKUP_SMALL_SIZE) {
2872
+ __Pyx_InterpreterIdAndModule* halfway = begin + (end - begin)/2;
2873
+ if (halfway->id == interpreterId) {
2874
+ return halfway;
2875
+ }
2876
+ if (halfway->id < interpreterId) {
2877
+ begin = halfway;
2878
+ } else {
2879
+ end = halfway;
2880
+ }
2881
+ }
2882
+
2883
+ // Assume that for small ranges, it's quicker to do a linear search
2884
+ for (; begin < end; ++begin) {
2885
+ if (begin->id >= interpreterId) return begin;
2886
+ }
2887
+ return begin;
2888
+ }
2889
+
2890
+ static PyObject *__Pyx_State_FindModule(CYTHON_UNUSED void* dummy) {
2891
+ int64_t interpreter_id = PyInterpreterState_GetID(PyInterpreterState_Get());
2892
+ if (interpreter_id == -1) return NULL;
2893
+
2894
+ #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
2895
+ __Pyx_ModuleStateLookupData* data = (__Pyx_ModuleStateLookupData*)__pyx_atomic_pointer_load_relaxed(&__Pyx_ModuleStateLookup_data);
2896
+ {
2897
+ // Thread sanitizer says that this is OK relaxed, but I think it needs to be acquire-release
2898
+ __pyx_atomic_incr_acq_rel(&__Pyx_ModuleStateLookup_read_counter);
2899
+ // data == NULL can either mean we're writing, or it's uninitialized.
2900
+ // Uninitialized only happens infrequently on the first few calls, so it's fine
2901
+ // to be on the slow path.
2902
+ if (likely(data)) {
2903
+ __Pyx_ModuleStateLookupData* new_data = (__Pyx_ModuleStateLookupData*)__pyx_atomic_pointer_load_acquire(&__Pyx_ModuleStateLookup_data);
2904
+ if (likely(data == new_data)) {
2905
+ // Nothing has written the data between incrementing the read counter and loading the pointer.
2906
+ goto read_finished;
2907
+ }
2908
+ }
2909
+ // In principle DW believes this could be "relaxed", but it's on the unlikely slow path anyway
2910
+ // so let's not add more macros.
2911
+ // Undo our addition to the read counter.
2912
+ __pyx_atomic_decr_acq_rel(&__Pyx_ModuleStateLookup_read_counter);
2913
+ // Wait for the write to finish and try again
2914
+ __Pyx_ModuleStateLookup_Lock();
2915
+ __pyx_atomic_incr_relaxed(&__Pyx_ModuleStateLookup_read_counter);
2916
+ data = (__Pyx_ModuleStateLookupData*)__pyx_atomic_pointer_load_relaxed(&__Pyx_ModuleStateLookup_data);
2917
+ __Pyx_ModuleStateLookup_Unlock();
2918
+ }
2919
+ read_finished:;
2920
+
2921
+ #else
2922
+ __Pyx_ModuleStateLookupData* data = __Pyx_ModuleStateLookup_data;
2923
+ #endif
2924
+
2925
+ __Pyx_InterpreterIdAndModule* found = NULL;
2926
+
2927
+ // There's one "already imported" check that'll hit this
2928
+ if (unlikely(!data)) goto end;
2929
+
2930
+ if (data->interpreter_id_as_index) {
2931
+ if (interpreter_id < data->count) {
2932
+ found = data->table+interpreter_id;
2933
+ }
2934
+ } else {
2935
+ found = __Pyx_State_FindModuleStateLookupTableLowerBound(
2936
+ data->table, data->count, interpreter_id);
2937
+ }
2938
+
2939
+ end:
2940
+ {
2941
+ PyObject *result=NULL;
2942
+
2943
+ if (found && found->id == interpreter_id) {
2944
+ result = found->module;
2945
+ }
2946
+ #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
2947
+ __pyx_atomic_decr_acq_rel(&__Pyx_ModuleStateLookup_read_counter);
2948
+ #endif
2949
+ return result;
2950
+ }
2951
+ }
2952
+
2953
+ #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
2954
+ static void __Pyx_ModuleStateLookup_wait_until_no_readers(void) {
2955
+ // Wait for any readers still working on the old data. Spin-lock is
2956
+ // fine because readers should be much faster than memory allocation.
2957
+ while (__pyx_atomic_load(&__Pyx_ModuleStateLookup_read_counter) != 0);
2958
+ }
2959
+ #else
2960
+ #define __Pyx_ModuleStateLookup_wait_until_no_readers()
2961
+ #endif
2962
+
2963
+ static int __Pyx_State_AddModuleInterpIdAsIndex(__Pyx_ModuleStateLookupData **old_data, PyObject* module, int64_t interpreter_id) {
2964
+ Py_ssize_t to_allocate = (*old_data)->allocated;
2965
+ while (to_allocate <= interpreter_id) {
2966
+ if (to_allocate == 0) to_allocate = 1;
2967
+ else to_allocate *= 2;
2968
+ }
2969
+ __Pyx_ModuleStateLookupData *new_data = *old_data;
2970
+ if (to_allocate != (*old_data)->allocated) {
2971
+ new_data = (__Pyx_ModuleStateLookupData *)realloc(
2972
+ *old_data,
2973
+ sizeof(__Pyx_ModuleStateLookupData)+(to_allocate-1)*sizeof(__Pyx_InterpreterIdAndModule));
2974
+ if (!new_data) {
2975
+ PyErr_NoMemory();
2976
+ return -1;
2977
+ }
2978
+ for (Py_ssize_t i = new_data->allocated; i < to_allocate; ++i) {
2979
+ new_data->table[i].id = i;
2980
+ new_data->table[i].module = NULL;
2981
+ }
2982
+ new_data->allocated = to_allocate;
2983
+ }
2984
+ new_data->table[interpreter_id].module = module;
2985
+ if (new_data->count < interpreter_id+1) {
2986
+ new_data->count = interpreter_id+1;
2987
+ }
2988
+ *old_data = new_data;
2989
+ return 0;
2990
+ }
2991
+
2992
+ static void __Pyx_State_ConvertFromInterpIdAsIndex(__Pyx_ModuleStateLookupData *data) {
2993
+ __Pyx_InterpreterIdAndModule *read = data->table;
2994
+ __Pyx_InterpreterIdAndModule *write = data->table;
2995
+ __Pyx_InterpreterIdAndModule *end = read + data->count;
2996
+
2997
+ for (; read<end; ++read) {
2998
+ if (read->module) {
2999
+ write->id = read->id;
3000
+ write->module = read->module;
3001
+ ++write;
3002
+ }
3003
+ // Otherwise empty; don't copy
3004
+ }
3005
+ data->count = write - data->table;
3006
+ for (; write<end; ++write) {
3007
+ // clear rest of array
3008
+ write->id = 0;
3009
+ write->module = NULL;
3010
+ }
3011
+ data->interpreter_id_as_index = 0;
3012
+ }
3013
+
3014
+ static int __Pyx_State_AddModule(PyObject* module, CYTHON_UNUSED void* dummy) {
3015
+ int64_t interpreter_id = PyInterpreterState_GetID(PyInterpreterState_Get());
3016
+ if (interpreter_id == -1) return -1;
3017
+
3018
+ int result = 0;
3019
+
3020
+ __Pyx_ModuleStateLookup_Lock();
3021
+
3022
+ // Adding modules is the slow path so I've not thought about memory ordering much and
3023
+ // just made it strict.
3024
+ #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
3025
+ // we're working and maybe modifying it, swap for 0
3026
+ __Pyx_ModuleStateLookupData *old_data = (__Pyx_ModuleStateLookupData *)
3027
+ __pyx_atomic_pointer_exchange(&__Pyx_ModuleStateLookup_data, 0);
3028
+ #else
3029
+ __Pyx_ModuleStateLookupData *old_data = __Pyx_ModuleStateLookup_data;
3030
+ #endif
3031
+ __Pyx_ModuleStateLookupData *new_data = old_data;
3032
+
3033
+ if (!new_data) {
3034
+ // If we don't yet have anything, initialize
3035
+ new_data = (__Pyx_ModuleStateLookupData *)calloc(1, sizeof(__Pyx_ModuleStateLookupData));
3036
+ if (!new_data) {
3037
+ result = -1;
3038
+ PyErr_NoMemory();
3039
+ goto end;
3040
+ }
3041
+ new_data->allocated = 1;
3042
+ new_data->interpreter_id_as_index = 1;
3043
+ }
3044
+
3045
+ // Pretty much everything from here modifies the data, and so requires us to wait
3046
+ // until all existing readers have finished in order to be thread-safe.
3047
+ __Pyx_ModuleStateLookup_wait_until_no_readers();
3048
+ if (new_data->interpreter_id_as_index) {
3049
+ if (interpreter_id < __PYX_MODULE_STATE_LOOKUP_SMALL_SIZE) {
3050
+ result = __Pyx_State_AddModuleInterpIdAsIndex(&new_data, module, interpreter_id);
3051
+ goto end;
3052
+ }
3053
+ // otherwise we have to convert then proceed with a normal insertion
3054
+ __Pyx_State_ConvertFromInterpIdAsIndex(new_data);
3055
+ }
3056
+ {
3057
+ Py_ssize_t insert_at = 0;
3058
+ {
3059
+ __Pyx_InterpreterIdAndModule* lower_bound = __Pyx_State_FindModuleStateLookupTableLowerBound(
3060
+ new_data->table, new_data->count, interpreter_id);
3061
+
3062
+ assert(lower_bound);
3063
+
3064
+ insert_at = lower_bound - new_data->table;
3065
+
3066
+ if (unlikely(insert_at < new_data->count && lower_bound->id == interpreter_id)) {
3067
+ lower_bound->module = module;
3068
+ goto end; // already in table, nothing more to do
3069
+ }
3070
+
3071
+ }
3072
+
3073
+ if (new_data->count+1 >= new_data->allocated) {
3074
+ // Use C realloc. PyMem_RawMalloc is added to the limited API fairly late (3.13)
3075
+ // and we want allocation independent of the interpreter which I think excludes PyMem_Malloc.
3076
+ Py_ssize_t to_allocate = (new_data->count+1)*2;
3077
+ new_data =
3078
+ (__Pyx_ModuleStateLookupData*)realloc(
3079
+ new_data,
3080
+ sizeof(__Pyx_ModuleStateLookupData) +
3081
+ (to_allocate-1)*sizeof(__Pyx_InterpreterIdAndModule));
3082
+ if (!new_data) {
3083
+ result = -1;
3084
+ new_data = old_data;
3085
+ PyErr_NoMemory();
3086
+ goto end;
3087
+ }
3088
+ new_data->allocated = to_allocate;
3089
+ }
3090
+
3091
+ ++new_data->count;
3092
+
3093
+ int64_t last_id = interpreter_id;
3094
+ PyObject *last_module = module;
3095
+ for (Py_ssize_t i=insert_at; i<new_data->count; ++i) {
3096
+ int64_t current_id = new_data->table[i].id;
3097
+ new_data->table[i].id = last_id;
3098
+ last_id = current_id;
3099
+ PyObject *current_module = new_data->table[i].module;
3100
+ new_data->table[i].module = last_module;
3101
+ last_module = current_module;
3102
+ }
3103
+ }
3104
+
3105
+ end:
3106
+ #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
3107
+ __pyx_atomic_pointer_exchange(&__Pyx_ModuleStateLookup_data, new_data);
3108
+ #else
3109
+ __Pyx_ModuleStateLookup_data = new_data;
3110
+ #endif
3111
+
3112
+ __Pyx_ModuleStateLookup_Unlock();
3113
+ return result;
3114
+ }
3115
+
3116
+ static int __Pyx_State_RemoveModule(CYTHON_UNUSED void* dummy) {
3117
+ int64_t interpreter_id = PyInterpreterState_GetID(PyInterpreterState_Get());
3118
+ if (interpreter_id == -1) return -1;
3119
+
3120
+ __Pyx_ModuleStateLookup_Lock();
3121
+
3122
+ #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
3123
+ __Pyx_ModuleStateLookupData *data = (__Pyx_ModuleStateLookupData *)
3124
+ __pyx_atomic_pointer_exchange(&__Pyx_ModuleStateLookup_data, 0);
3125
+ #else
3126
+ __Pyx_ModuleStateLookupData *data = __Pyx_ModuleStateLookup_data;
3127
+ #endif
3128
+
3129
+ if (data->interpreter_id_as_index) {
3130
+ if (interpreter_id < data->count) {
3131
+ data->table[interpreter_id].module = NULL;
3132
+ }
3133
+ goto done;
3134
+ }
3135
+ {
3136
+ __Pyx_ModuleStateLookup_wait_until_no_readers();
3137
+
3138
+ __Pyx_InterpreterIdAndModule* lower_bound = __Pyx_State_FindModuleStateLookupTableLowerBound(
3139
+ data->table, data->count, interpreter_id);
3140
+
3141
+ // TODO Errors here?
3142
+ if (!lower_bound) goto done;
3143
+ if (lower_bound->id != interpreter_id) goto done;
3144
+
3145
+ __Pyx_InterpreterIdAndModule *end = data->table+data->count;
3146
+ for (;lower_bound<end-1; ++lower_bound) {
3147
+ lower_bound->id = (lower_bound+1)->id;
3148
+ lower_bound->module = (lower_bound+1)->module;
3149
+ }
3150
+ }
3151
+ --data->count;
3152
+ if (data->count == 0) {
3153
+ free(data);
3154
+ data = NULL;
3155
+ }
3156
+ // For now, never shrink the allocated table.
3157
+ done:
3158
+ #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
3159
+ __pyx_atomic_pointer_exchange(&__Pyx_ModuleStateLookup_data, data);
3160
+ #else
3161
+ __Pyx_ModuleStateLookup_data = data;
3162
+ #endif
3163
+ __Pyx_ModuleStateLookup_Unlock();
3164
+ return 0;
3165
+ }
3166
+
3167
+ #endif
3168
+
3169
+ ////////////////////// IncludeStdlibH.proto //////////////////////
3170
+
3171
+ #include <stdlib.h>
3172
+
3173
+ ////////////////////// ReleaseUnknownGil.proto ///////////////////
3174
+
3175
+ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030d0000
3176
+ typedef struct {
3177
+ PyThreadState* ts;
3178
+ PyGILState_STATE gil_state;
3179
+ } __Pyx_UnknownThreadState;
3180
+ #else
3181
+ #define __Pyx_UnknownThreadState PyThreadState*
3182
+ #endif
3183
+
3184
+ static __Pyx_UnknownThreadState __Pyx_SaveUnknownThread(void); /* proto */
3185
+ static void __Pyx_RestoreUnknownThread(__Pyx_UnknownThreadState state); /* proto */
3186
+
3187
+ // Note - may return false negatives for some versions of the Limited API
3188
+ static CYTHON_INLINE int __Pyx_UnknownThreadStateDefinitelyHadGil(__Pyx_UnknownThreadState state); /* proto */
3189
+ // Note - may return false positives for some versions of the Limited API
3190
+ static CYTHON_INLINE int __Pyx_UnknownThreadStateMayHaveHadGil(__Pyx_UnknownThreadState state); /* proto */
3191
+
3192
+ ////////////////////// ReleaseUnknownGil ///////////////////
3193
+
3194
+ static __Pyx_UnknownThreadState __Pyx_SaveUnknownThread(void) {
3195
+ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030d0000
3196
+ if (__Pyx_get_runtime_version() >= 0x030d0000) {
3197
+ // On Python 3.13+ we can just swap the thread state for NULL, and that's fine,
3198
+ // whether we have the GIL or not.
3199
+ PyThreadState *ts = PyThreadState_Swap(NULL);
3200
+ __Pyx_UnknownThreadState out = { ts, PyGILState_UNLOCKED /* arbitrary value */ };
3201
+ return out;
3202
+ } else {
3203
+ // On Python <3.13 there's no way of telling if we have the GIL in the Limited API.
3204
+ // Therefore, the only safe thing to do is to acquire it then release it.
3205
+ PyGILState_STATE gil_state = PyGILState_Ensure();
3206
+ PyThreadState *ts = PyEval_SaveThread();
3207
+ __Pyx_UnknownThreadState out = { ts, gil_state };
3208
+ return out;
3209
+ }
3210
+ #elif __PYX_LIMITED_VERSION_HEX >= 0x030d0000
3211
+ return PyThreadState_Swap(NULL);
3212
+ #else
3213
+ #if CYTHON_COMPILING_IN_PYPY || PY_VERSION_HEX < 0x030C0000
3214
+ if (PyGILState_Check())
3215
+ #else
3216
+ if (_PyThreadState_UncheckedGet()) // UncheckedGet is a reliable check for the GIL from 3.12 upwards
3217
+ #endif
3218
+ {
3219
+ return PyEval_SaveThread();
3220
+ }
3221
+ return NULL; // Nothing to release - we don't have the GIL
3222
+ #endif
3223
+ }
3224
+
3225
+ static void __Pyx_RestoreUnknownThread(__Pyx_UnknownThreadState state) {
3226
+ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030d0000
3227
+ if (!state.ts) return;
3228
+ PyEval_RestoreThread(state.ts);
3229
+ if (__Pyx_get_runtime_version() < 0x030d0000) {
3230
+ PyGILState_Release(state.gil_state);
3231
+ }
3232
+ #else
3233
+ if (state) {
3234
+ PyEval_RestoreThread(state);
3235
+ }
3236
+ #endif
3237
+ }
3238
+
3239
+ static CYTHON_INLINE int __Pyx_UnknownThreadStateDefinitelyHadGil(__Pyx_UnknownThreadState state) {
3240
+ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030d0000
3241
+ // For older Limited API versions we can't tell if we had the GIL
3242
+ return ((state.ts != NULL) && (__Pyx_get_runtime_version() >= 0x030d0000));
3243
+ #else
3244
+ return state != NULL;
3245
+ #endif
3246
+ }
3247
+
3248
+ static CYTHON_INLINE int __Pyx_UnknownThreadStateMayHaveHadGil(__Pyx_UnknownThreadState state) {
3249
+ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030d0000
3250
+ return state.ts != NULL;
3251
+ #else
3252
+ return state != NULL;
3253
+ #endif
3254
+ }
3255
+
3256
+ ///////////////////// AddModuleRef.proto ///////////////////////
3257
+
3258
+ #if ((CYTHON_COMPILING_IN_CPYTHON_FREETHREADING && PY_VERSION_HEX < 0x030F00a3) || \
3259
+ __PYX_LIMITED_VERSION_HEX < 0x030d0000)
3260
+ // https://github.com/python/cpython/issues/137422 - PyImport_AddModule(Ref) isn't thread safe!
3261
+ static PyObject *__Pyx_PyImport_AddModuleRef(const char *name); /* proto */
3262
+ #else
3263
+ #define __Pyx_PyImport_AddModuleRef(name) PyImport_AddModuleRef(name)
3264
+ #endif
3265
+
3266
+ ///////////////////// AddModuleRef ////////////////////////////
3267
+
3268
+ #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING && PY_VERSION_HEX < 0x030F00a3
3269
+ // https://github.com/python/cpython/issues/137422 - PyImport_AddModule(Ref) isn't thread safe!
3270
+ // TODO - if this gets used for anything other than implementing AddModuleRef then add a
3271
+ // runtime version check for fixed versions.
3272
+ static PyObject *__Pyx_PyImport_AddModuleObjectRef(PyObject *name) {
3273
+ // We're going to assume nobody is swapping the module dict out from under us
3274
+ // (even though they're allowed to) because we really can't write code that's
3275
+ // safe against that.
3276
+ PyObject *module_dict = PyImport_GetModuleDict();
3277
+ PyObject *m;
3278
+ if (PyMapping_GetOptionalItem(module_dict, name, &m) < 0) {
3279
+ return NULL;
3280
+ }
3281
+ if (m != NULL && PyModule_Check(m)) {
3282
+ return m;
3283
+ }
3284
+ Py_XDECREF(m);
3285
+ m = PyModule_NewObject(name);
3286
+ if (m == NULL)
3287
+ return NULL;
3288
+ if (PyDict_CheckExact(module_dict)) {
3289
+ PyObject *new_m;
3290
+ (void)PyDict_SetDefaultRef(module_dict, name, m, &new_m);
3291
+ Py_DECREF(m);
3292
+ return new_m;
3293
+ } else {
3294
+ // For non-dict sys-modules I don't think it's possible to reliably make thread-safe.
3295
+ if (PyObject_SetItem(module_dict, name, m) != 0) {
3296
+ Py_DECREF(m);
3297
+ return NULL;
3298
+ }
3299
+ return m;
3300
+ }
3301
+ }
3302
+ static PyObject *__Pyx_PyImport_AddModuleRef(const char *name) {
3303
+ if ((PY_VERSION_HEX >= 0x030E0000) && Py_Version >= 0x030E0100) {
3304
+ // Fixed here... their implementation is probably better
3305
+ return PyImport_AddModuleRef(name);
3306
+ }
3307
+ PyObject *py_name = PyUnicode_FromString(name);
3308
+ if (!py_name) return NULL;
3309
+ PyObject *module = __Pyx_PyImport_AddModuleObjectRef(py_name);
3310
+ Py_DECREF(py_name);
3311
+ return module;
3312
+ }
3313
+ #elif __PYX_LIMITED_VERSION_HEX < 0x030d0000
3314
+ static PyObject *__Pyx_PyImport_AddModuleRef(const char *name) {
3315
+ PyObject *module = PyImport_AddModule(name);
3316
+ Py_XINCREF(module);
3317
+ return module;
3318
+ }
3319
+ #endif