Cython 3.1.0__py3-none-any.whl

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