Cython 3.3.0__cp315-cp315-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (339) hide show
  1. Cython/Build/BuildExecutable.py +156 -0
  2. Cython/Build/Cache.py +199 -0
  3. Cython/Build/Cythonize.py +349 -0
  4. Cython/Build/Dependencies.py +1281 -0
  5. Cython/Build/Distutils.py +1 -0
  6. Cython/Build/Inline.py +467 -0
  7. Cython/Build/IpythonMagic.py +559 -0
  8. Cython/Build/SharedModule.py +165 -0
  9. Cython/Build/Tests/TestCyCache.py +195 -0
  10. Cython/Build/Tests/TestCythonizeArgsParser.py +480 -0
  11. Cython/Build/Tests/TestDependencies.py +133 -0
  12. Cython/Build/Tests/TestInline.py +177 -0
  13. Cython/Build/Tests/TestIpythonMagic.py +303 -0
  14. Cython/Build/Tests/TestRecythonize.py +212 -0
  15. Cython/Build/Tests/TestStripLiterals.py +155 -0
  16. Cython/Build/Tests/__init__.py +1 -0
  17. Cython/Build/__init__.py +11 -0
  18. Cython/CodeWriter.py +825 -0
  19. Cython/Compiler/AnalysedTreeTransforms.py +97 -0
  20. Cython/Compiler/Annotate.py +328 -0
  21. Cython/Compiler/AutoDocTransforms.py +320 -0
  22. Cython/Compiler/Buffer.py +679 -0
  23. Cython/Compiler/Builtin.py +1102 -0
  24. Cython/Compiler/CmdLine.py +373 -0
  25. Cython/Compiler/Code.cp315-win_amd64.pyd +0 -0
  26. Cython/Compiler/Code.pxd +154 -0
  27. Cython/Compiler/Code.py +3760 -0
  28. Cython/Compiler/CodeGeneration.py +33 -0
  29. Cython/Compiler/CythonScope.py +208 -0
  30. Cython/Compiler/Dataclass.py +890 -0
  31. Cython/Compiler/DebugFlags.py +24 -0
  32. Cython/Compiler/Errors.py +310 -0
  33. Cython/Compiler/ExprNodes.py +16273 -0
  34. Cython/Compiler/FlowControl.cp315-win_amd64.pyd +0 -0
  35. Cython/Compiler/FlowControl.pxd +112 -0
  36. Cython/Compiler/FlowControl.py +1573 -0
  37. Cython/Compiler/FusedNode.cp315-win_amd64.pyd +0 -0
  38. Cython/Compiler/FusedNode.py +978 -0
  39. Cython/Compiler/Future.py +16 -0
  40. Cython/Compiler/Interpreter.py +57 -0
  41. Cython/Compiler/Lexicon.py +422 -0
  42. Cython/Compiler/LineTable.cp315-win_amd64.pyd +0 -0
  43. Cython/Compiler/LineTable.py +114 -0
  44. Cython/Compiler/Main.py +856 -0
  45. Cython/Compiler/MatchCaseNodes.py +2200 -0
  46. Cython/Compiler/MemoryView.py +930 -0
  47. Cython/Compiler/ModuleNode.py +4548 -0
  48. Cython/Compiler/Naming.py +370 -0
  49. Cython/Compiler/Nodes.py +11304 -0
  50. Cython/Compiler/Optimize.py +5564 -0
  51. Cython/Compiler/Options.py +840 -0
  52. Cython/Compiler/ParseTreeTransforms.pxd +80 -0
  53. Cython/Compiler/ParseTreeTransforms.py +4808 -0
  54. Cython/Compiler/Parsing.cp315-win_amd64.pyd +0 -0
  55. Cython/Compiler/Parsing.pxd +9 -0
  56. Cython/Compiler/Parsing.py +4809 -0
  57. Cython/Compiler/Pipeline.py +439 -0
  58. Cython/Compiler/PyrexTypes.py +6588 -0
  59. Cython/Compiler/Pythran.py +232 -0
  60. Cython/Compiler/Scanning.cp315-win_amd64.pyd +0 -0
  61. Cython/Compiler/Scanning.pxd +70 -0
  62. Cython/Compiler/Scanning.py +720 -0
  63. Cython/Compiler/StringEncoding.cp315-win_amd64.pyd +0 -0
  64. Cython/Compiler/StringEncoding.py +354 -0
  65. Cython/Compiler/Symtab.py +3121 -0
  66. Cython/Compiler/Tests/TestBuffer.py +105 -0
  67. Cython/Compiler/Tests/TestBuiltin.py +196 -0
  68. Cython/Compiler/Tests/TestCmdLine.py +652 -0
  69. Cython/Compiler/Tests/TestCode.py +145 -0
  70. Cython/Compiler/Tests/TestFlowControl.py +65 -0
  71. Cython/Compiler/Tests/TestGrammar.py +202 -0
  72. Cython/Compiler/Tests/TestMemView.py +71 -0
  73. Cython/Compiler/Tests/TestParseTreeTransforms.py +285 -0
  74. Cython/Compiler/Tests/TestScanning.py +132 -0
  75. Cython/Compiler/Tests/TestSignatureMatching.py +73 -0
  76. Cython/Compiler/Tests/TestStringEncoding.py +20 -0
  77. Cython/Compiler/Tests/TestTreeFragment.py +63 -0
  78. Cython/Compiler/Tests/TestTreePath.py +103 -0
  79. Cython/Compiler/Tests/TestTypes.py +119 -0
  80. Cython/Compiler/Tests/TestUtilityLoad.py +112 -0
  81. Cython/Compiler/Tests/TestVisitor.py +119 -0
  82. Cython/Compiler/Tests/Utils.py +36 -0
  83. Cython/Compiler/Tests/__init__.py +1 -0
  84. Cython/Compiler/TreeFragment.py +279 -0
  85. Cython/Compiler/TreePath.py +303 -0
  86. Cython/Compiler/TypeInference.py +611 -0
  87. Cython/Compiler/TypeSlots.py +1329 -0
  88. Cython/Compiler/UFuncs.py +317 -0
  89. Cython/Compiler/UtilNodes.py +389 -0
  90. Cython/Compiler/UtilityCode.py +354 -0
  91. Cython/Compiler/Version.py +8 -0
  92. Cython/Compiler/Visitor.cp315-win_amd64.pyd +0 -0
  93. Cython/Compiler/Visitor.pxd +52 -0
  94. Cython/Compiler/Visitor.py +914 -0
  95. Cython/Compiler/__init__.py +1 -0
  96. Cython/Coverage.py +448 -0
  97. Cython/Debugger/Cygdb.py +214 -0
  98. Cython/Debugger/DebugWriter.py +82 -0
  99. Cython/Debugger/Tests/TestLibCython.py +280 -0
  100. Cython/Debugger/Tests/__init__.py +1 -0
  101. Cython/Debugger/Tests/cfuncs.c +8 -0
  102. Cython/Debugger/Tests/codefile +49 -0
  103. Cython/Debugger/Tests/test_libcython_in_gdb.py +580 -0
  104. Cython/Debugger/Tests/test_libpython_in_gdb.py +90 -0
  105. Cython/Debugger/__init__.py +1 -0
  106. Cython/Debugger/libcython.py +1548 -0
  107. Cython/Debugger/libpython.py +2821 -0
  108. Cython/Debugging.py +20 -0
  109. Cython/Distutils/__init__.py +2 -0
  110. Cython/Distutils/build_ext.py +143 -0
  111. Cython/Distutils/extension.py +96 -0
  112. Cython/Distutils/old_build_ext.py +351 -0
  113. Cython/Includes/cpython/__init__.pxd +173 -0
  114. Cython/Includes/cpython/array.pxd +152 -0
  115. Cython/Includes/cpython/bool.pxd +37 -0
  116. Cython/Includes/cpython/buffer.pxd +112 -0
  117. Cython/Includes/cpython/bytearray.pxd +33 -0
  118. Cython/Includes/cpython/bytes.pxd +200 -0
  119. Cython/Includes/cpython/cellobject.pxd +35 -0
  120. Cython/Includes/cpython/ceval.pxd +8 -0
  121. Cython/Includes/cpython/codecs.pxd +121 -0
  122. Cython/Includes/cpython/complex.pxd +60 -0
  123. Cython/Includes/cpython/contextvars.pxd +145 -0
  124. Cython/Includes/cpython/conversion.pxd +36 -0
  125. Cython/Includes/cpython/datetime.pxd +395 -0
  126. Cython/Includes/cpython/descr.pxd +26 -0
  127. Cython/Includes/cpython/dict.pxd +268 -0
  128. Cython/Includes/cpython/exc.pxd +263 -0
  129. Cython/Includes/cpython/fileobject.pxd +57 -0
  130. Cython/Includes/cpython/float.pxd +56 -0
  131. Cython/Includes/cpython/frozendict.pxd +37 -0
  132. Cython/Includes/cpython/function.pxd +65 -0
  133. Cython/Includes/cpython/genobject.pxd +25 -0
  134. Cython/Includes/cpython/getargs.pxd +12 -0
  135. Cython/Includes/cpython/instance.pxd +25 -0
  136. Cython/Includes/cpython/iterator.pxd +36 -0
  137. Cython/Includes/cpython/iterobject.pxd +24 -0
  138. Cython/Includes/cpython/list.pxd +144 -0
  139. Cython/Includes/cpython/long.pxd +180 -0
  140. Cython/Includes/cpython/longintrepr.pxd +14 -0
  141. Cython/Includes/cpython/mapping.pxd +63 -0
  142. Cython/Includes/cpython/marshal.pxd +66 -0
  143. Cython/Includes/cpython/mem.pxd +120 -0
  144. Cython/Includes/cpython/memoryview.pxd +50 -0
  145. Cython/Includes/cpython/method.pxd +49 -0
  146. Cython/Includes/cpython/module.pxd +208 -0
  147. Cython/Includes/cpython/number.pxd +258 -0
  148. Cython/Includes/cpython/object.pxd +430 -0
  149. Cython/Includes/cpython/pycapsule.pxd +143 -0
  150. Cython/Includes/cpython/pylifecycle.pxd +68 -0
  151. Cython/Includes/cpython/pyport.pxd +8 -0
  152. Cython/Includes/cpython/pystate.pxd +95 -0
  153. Cython/Includes/cpython/pythread.pxd +53 -0
  154. Cython/Includes/cpython/ref.pxd +141 -0
  155. Cython/Includes/cpython/sentinel.pxd +17 -0
  156. Cython/Includes/cpython/sequence.pxd +134 -0
  157. Cython/Includes/cpython/set.pxd +119 -0
  158. Cython/Includes/cpython/slice.pxd +70 -0
  159. Cython/Includes/cpython/time.pxd +129 -0
  160. Cython/Includes/cpython/tuple.pxd +72 -0
  161. Cython/Includes/cpython/type.pxd +146 -0
  162. Cython/Includes/cpython/unicode.pxd +639 -0
  163. Cython/Includes/cpython/version.pxd +32 -0
  164. Cython/Includes/cpython/weakref.pxd +78 -0
  165. Cython/Includes/libc/__init__.pxd +1 -0
  166. Cython/Includes/libc/complex.pxd +35 -0
  167. Cython/Includes/libc/errno.pxd +127 -0
  168. Cython/Includes/libc/float.pxd +43 -0
  169. Cython/Includes/libc/limits.pxd +28 -0
  170. Cython/Includes/libc/locale.pxd +46 -0
  171. Cython/Includes/libc/math.pxd +209 -0
  172. Cython/Includes/libc/setjmp.pxd +10 -0
  173. Cython/Includes/libc/signal.pxd +64 -0
  174. Cython/Includes/libc/stddef.pxd +9 -0
  175. Cython/Includes/libc/stdint.pxd +105 -0
  176. Cython/Includes/libc/stdio.pxd +80 -0
  177. Cython/Includes/libc/stdlib.pxd +72 -0
  178. Cython/Includes/libc/string.pxd +50 -0
  179. Cython/Includes/libc/threads.pxd +234 -0
  180. Cython/Includes/libc/time.pxd +52 -0
  181. Cython/Includes/libcpp/__init__.pxd +4 -0
  182. Cython/Includes/libcpp/algorithm.pxd +320 -0
  183. Cython/Includes/libcpp/any.pxd +16 -0
  184. Cython/Includes/libcpp/atomic.pxd +59 -0
  185. Cython/Includes/libcpp/barrier.pxd +22 -0
  186. Cython/Includes/libcpp/bit.pxd +29 -0
  187. Cython/Includes/libcpp/cast.pxd +12 -0
  188. Cython/Includes/libcpp/cmath.pxd +518 -0
  189. Cython/Includes/libcpp/complex.pxd +106 -0
  190. Cython/Includes/libcpp/condition_variable.pxd +322 -0
  191. Cython/Includes/libcpp/deque.pxd +165 -0
  192. Cython/Includes/libcpp/exception.pxd +216 -0
  193. Cython/Includes/libcpp/execution.pxd +15 -0
  194. Cython/Includes/libcpp/forward_list.pxd +63 -0
  195. Cython/Includes/libcpp/functional.pxd +26 -0
  196. Cython/Includes/libcpp/future.pxd +103 -0
  197. Cython/Includes/libcpp/iterator.pxd +34 -0
  198. Cython/Includes/libcpp/latch.pxd +17 -0
  199. Cython/Includes/libcpp/limits.pxd +61 -0
  200. Cython/Includes/libcpp/list.pxd +117 -0
  201. Cython/Includes/libcpp/map.pxd +252 -0
  202. Cython/Includes/libcpp/memory.pxd +115 -0
  203. Cython/Includes/libcpp/mutex.pxd +387 -0
  204. Cython/Includes/libcpp/numbers.pxd +15 -0
  205. Cython/Includes/libcpp/numeric.pxd +131 -0
  206. Cython/Includes/libcpp/optional.pxd +34 -0
  207. Cython/Includes/libcpp/pair.pxd +1 -0
  208. Cython/Includes/libcpp/queue.pxd +25 -0
  209. Cython/Includes/libcpp/random.pxd +166 -0
  210. Cython/Includes/libcpp/semaphore.pxd +43 -0
  211. Cython/Includes/libcpp/set.pxd +228 -0
  212. Cython/Includes/libcpp/shared_mutex.pxd +96 -0
  213. Cython/Includes/libcpp/span.pxd +87 -0
  214. Cython/Includes/libcpp/stack.pxd +11 -0
  215. Cython/Includes/libcpp/stop_token.pxd +117 -0
  216. Cython/Includes/libcpp/string.pxd +355 -0
  217. Cython/Includes/libcpp/string_view.pxd +183 -0
  218. Cython/Includes/libcpp/typeindex.pxd +15 -0
  219. Cython/Includes/libcpp/typeinfo.pxd +10 -0
  220. Cython/Includes/libcpp/unordered_map.pxd +193 -0
  221. Cython/Includes/libcpp/unordered_set.pxd +152 -0
  222. Cython/Includes/libcpp/utility.pxd +30 -0
  223. Cython/Includes/libcpp/vector.pxd +186 -0
  224. Cython/Includes/numpy/math.pxd +150 -0
  225. Cython/Includes/openmp.pxd +50 -0
  226. Cython/Includes/posix/__init__.pxd +1 -0
  227. Cython/Includes/posix/dlfcn.pxd +14 -0
  228. Cython/Includes/posix/fcntl.pxd +86 -0
  229. Cython/Includes/posix/ioctl.pxd +4 -0
  230. Cython/Includes/posix/mman.pxd +101 -0
  231. Cython/Includes/posix/resource.pxd +57 -0
  232. Cython/Includes/posix/select.pxd +21 -0
  233. Cython/Includes/posix/signal.pxd +73 -0
  234. Cython/Includes/posix/stat.pxd +98 -0
  235. Cython/Includes/posix/stdio.pxd +37 -0
  236. Cython/Includes/posix/stdlib.pxd +29 -0
  237. Cython/Includes/posix/strings.pxd +9 -0
  238. Cython/Includes/posix/time.pxd +71 -0
  239. Cython/Includes/posix/types.pxd +30 -0
  240. Cython/Includes/posix/uio.pxd +26 -0
  241. Cython/Includes/posix/unistd.pxd +271 -0
  242. Cython/Includes/posix/wait.pxd +38 -0
  243. Cython/LZSS.cp315-win_amd64.pyd +0 -0
  244. Cython/LZSS.py +184 -0
  245. Cython/Plex/Actions.cp315-win_amd64.pyd +0 -0
  246. Cython/Plex/Actions.pxd +24 -0
  247. Cython/Plex/Actions.py +119 -0
  248. Cython/Plex/DFA.cp315-win_amd64.pyd +0 -0
  249. Cython/Plex/DFA.pxd +14 -0
  250. Cython/Plex/DFA.py +164 -0
  251. Cython/Plex/Errors.py +48 -0
  252. Cython/Plex/Lexicons.py +178 -0
  253. Cython/Plex/Machines.cp315-win_amd64.pyd +0 -0
  254. Cython/Plex/Machines.pxd +36 -0
  255. Cython/Plex/Machines.py +238 -0
  256. Cython/Plex/Regexps.py +535 -0
  257. Cython/Plex/Scanners.cp315-win_amd64.pyd +0 -0
  258. Cython/Plex/Scanners.pxd +45 -0
  259. Cython/Plex/Scanners.py +328 -0
  260. Cython/Plex/Transitions.cp315-win_amd64.pyd +0 -0
  261. Cython/Plex/Transitions.pxd +14 -0
  262. Cython/Plex/Transitions.py +239 -0
  263. Cython/Plex/__init__.py +34 -0
  264. Cython/Runtime/__init__.py +1 -0
  265. Cython/Runtime/refnanny.cp315-win_amd64.pyd +0 -0
  266. Cython/Runtime/refnanny.pyx +237 -0
  267. Cython/Shadow.py +1174 -0
  268. Cython/StringIOTree.cp315-win_amd64.pyd +0 -0
  269. Cython/StringIOTree.py +169 -0
  270. Cython/Tempita/__init__.py +4 -0
  271. Cython/Tempita/_looper.py +154 -0
  272. Cython/Tempita/_tempita.cp315-win_amd64.pyd +0 -0
  273. Cython/Tempita/_tempita.py +1087 -0
  274. Cython/TestUtils.py +472 -0
  275. Cython/Tests/TestCodeWriter.py +128 -0
  276. Cython/Tests/TestCythonUtils.py +202 -0
  277. Cython/Tests/TestJediTyper.py +223 -0
  278. Cython/Tests/TestShadow.py +125 -0
  279. Cython/Tests/TestStringIOTree.py +68 -0
  280. Cython/Tests/TestTestUtils.py +89 -0
  281. Cython/Tests/__init__.py +1 -0
  282. Cython/Tests/xmlrunner.py +390 -0
  283. Cython/Utility/AsyncGen.c +1152 -0
  284. Cython/Utility/Buffer.c +866 -0
  285. Cython/Utility/BufferFormatFromTypeInfo.pxd +2 -0
  286. Cython/Utility/Builtins.c +1068 -0
  287. Cython/Utility/CConvert.pyx +153 -0
  288. Cython/Utility/CMath.c +104 -0
  289. Cython/Utility/CommonStructures.c +244 -0
  290. Cython/Utility/Complex.c +378 -0
  291. Cython/Utility/Coroutine.c +2344 -0
  292. Cython/Utility/CpdefEnums.pyx +119 -0
  293. Cython/Utility/CppConvert.pyx +282 -0
  294. Cython/Utility/CppSupport.cpp +151 -0
  295. Cython/Utility/CythonFunction.c +2185 -0
  296. Cython/Utility/Dataclasses.c +101 -0
  297. Cython/Utility/Embed.c +129 -0
  298. Cython/Utility/Exceptions.c +1331 -0
  299. Cython/Utility/Exceptions_Cy.pyx +109 -0
  300. Cython/Utility/ExtensionTypes.c +1199 -0
  301. Cython/Utility/FunctionArguments.c +1052 -0
  302. Cython/Utility/FusedFunction.pyx +44 -0
  303. Cython/Utility/ImportExport.c +972 -0
  304. Cython/Utility/MatchCase.c +981 -0
  305. Cython/Utility/MatchCase_Cy.pyx +12 -0
  306. Cython/Utility/MemoryView.pxd +108 -0
  307. Cython/Utility/MemoryView.pyx +1499 -0
  308. Cython/Utility/MemoryView_C.c +1056 -0
  309. Cython/Utility/ModuleSetupCode.c +3319 -0
  310. Cython/Utility/NumpyImportArray.c +46 -0
  311. Cython/Utility/ObjectHandling.c +3404 -0
  312. Cython/Utility/Optimize.c +2564 -0
  313. Cython/Utility/Overflow.c +378 -0
  314. Cython/Utility/Profile.c +736 -0
  315. Cython/Utility/StringTools.c +1534 -0
  316. Cython/Utility/Synchronization.c +438 -0
  317. Cython/Utility/TString.c +369 -0
  318. Cython/Utility/TestCyUtilityLoader.pyx +8 -0
  319. Cython/Utility/TestCythonScope.pyx +75 -0
  320. Cython/Utility/TestUtilityLoader.c +12 -0
  321. Cython/Utility/TypeConversion.c +1588 -0
  322. Cython/Utility/UFuncs.pyx +50 -0
  323. Cython/Utility/UFuncs_C.c +89 -0
  324. Cython/Utility/__init__.py +28 -0
  325. Cython/Utility/arrayarray.h +172 -0
  326. Cython/Utils.cp315-win_amd64.pyd +0 -0
  327. Cython/Utils.py +680 -0
  328. Cython/__init__.py +12 -0
  329. Cython/_shared.cp315-win_amd64.pyd +0 -0
  330. Cython/py.typed +0 -0
  331. cython-3.3.0.dist-info/METADATA +555 -0
  332. cython-3.3.0.dist-info/RECORD +339 -0
  333. cython-3.3.0.dist-info/WHEEL +5 -0
  334. cython-3.3.0.dist-info/entry_points.txt +4 -0
  335. cython-3.3.0.dist-info/top_level.txt +3 -0
  336. cython.py +29 -0
  337. pyximport/__init__.py +4 -0
  338. pyximport/pyxbuild.py +160 -0
  339. pyximport/pyximport.py +482 -0
Cython/Shadow.py ADDED
@@ -0,0 +1,1174 @@
1
+ # cython.* namespace for pure mode.
2
+ from __future__ import annotations
3
+
4
+ # Possible version formats: "3.1.0", "3.1.0a1", "3.1.0a1.dev0"
5
+ __version__ = "3.3.0"
6
+
7
+ from types import TracebackType
8
+ from typing import (
9
+ TYPE_CHECKING,
10
+ Any, Iterable, Sequence, Optional, Type, TypeVar, Generic, Callable, overload,
11
+ )
12
+
13
+ if TYPE_CHECKING:
14
+ from builtins import (int as py_int, float as py_float,
15
+ bool as py_bool, str as py_str, complex as py_complex)
16
+ from typing import TypeAlias, Annotated, ParamSpec, Self
17
+ _P = ParamSpec('_P')
18
+
19
+ # TypeVars need to be defined at runtime for Generic types
20
+ _T = TypeVar('_T')
21
+ _C = TypeVar('_C', bound='Callable')
22
+ _TypeT = TypeVar('_TypeT', bound='Type')
23
+ _C_Or_TypeT = TypeVar('_C_Or_TypeT', _C, _TypeT)
24
+ _Decorator = Callable[[_C_Or_TypeT], _C_Or_TypeT]
25
+ _FuncDecorator = Callable[[_C], _C]
26
+ _ClassDecorator = Callable[[_TypeT], _TypeT]
27
+
28
+ # BEGIN shameless copy from Cython/minivect/minitypes.py
29
+
30
+ class _ArrayType(Generic[_T]):
31
+
32
+ is_array: bool = True
33
+ subtypes: Sequence[str] = ['dtype']
34
+ dtype: _T
35
+ ndim: int
36
+ is_c_contig: bool
37
+ is_f_contig: bool
38
+ inner_contig: bool
39
+ broadcasting: Any
40
+
41
+ # broadcasting is not used, so it's not clear about its type
42
+ def __init__(self, dtype: _T, ndim: int, is_c_contig: bool = False,
43
+ is_f_contig: bool = False, inner_contig: bool = False,
44
+ broadcasting: Any = None) -> None:
45
+ self.dtype = dtype
46
+ self.ndim = ndim
47
+ self.is_c_contig = is_c_contig
48
+ self.is_f_contig = is_f_contig
49
+ self.inner_contig = inner_contig or is_c_contig or is_f_contig
50
+ self.broadcasting = broadcasting
51
+
52
+ def __repr__(self) -> str:
53
+ axes = [":"] * self.ndim
54
+ if self.is_c_contig:
55
+ axes[-1] = "::1"
56
+ elif self.is_f_contig:
57
+ axes[0] = "::1"
58
+
59
+ return "%s[%s]" % (self.dtype, ", ".join(axes))
60
+
61
+
62
+ def index_type(base_type: _T, item: tuple | slice | int) -> _ArrayType[_T]:
63
+ """
64
+ Support array type creation by slicing, e.g. double[:, :] specifies
65
+ a 2D strided array of doubles. The syntax is the same as for
66
+ Cython memoryviews.
67
+ """
68
+ class InvalidTypeSpecification(Exception):
69
+ pass
70
+
71
+ def verify_slice(s):
72
+ if s.start or s.stop or s.step not in (None, 1):
73
+ raise InvalidTypeSpecification(
74
+ "Only a step of 1 may be provided to indicate C or "
75
+ "Fortran contiguity")
76
+
77
+ if isinstance(item, tuple):
78
+ step_idx = None
79
+ for idx, s in enumerate(item):
80
+ verify_slice(s)
81
+ if s.step and (step_idx or idx not in (0, len(item) - 1)):
82
+ raise InvalidTypeSpecification(
83
+ "Step may only be provided once, and only in the "
84
+ "first or last dimension.")
85
+
86
+ if s.step == 1:
87
+ step_idx = idx
88
+
89
+ return _ArrayType(base_type, len(item),
90
+ is_c_contig=step_idx == len(item) - 1,
91
+ is_f_contig=step_idx == 0)
92
+ elif isinstance(item, slice):
93
+ verify_slice(item)
94
+ return _ArrayType(base_type, 1, is_c_contig=bool(item.step))
95
+ else:
96
+ # int[8] etc.
97
+ assert int(item) == item # array size must be a plain integer
98
+ return array(base_type, item)
99
+
100
+ # END shameless copy
101
+
102
+
103
+ compiled: bool = False
104
+
105
+ _Unspecified = object()
106
+
107
+ # Function decorators
108
+
109
+ def _empty_decorator(x: _C_Or_TypeT) -> _C_Or_TypeT:
110
+ return x
111
+
112
+ _empty_func_decorator: _FuncDecorator = _empty_decorator
113
+ _empty_class_decorator: _ClassDecorator = _empty_decorator
114
+
115
+ def _compiler_directive(val: bool = ...) -> _Decorator:
116
+ return _empty_decorator
117
+
118
+ def locals(**arg_types: Any) -> _FuncDecorator:
119
+ return _empty_func_decorator
120
+
121
+ def test_assert_path_exists(*paths: str) -> _Decorator:
122
+ return _empty_decorator
123
+
124
+ def test_fail_if_path_exists(*paths: str) -> _Decorator:
125
+ return _empty_decorator
126
+
127
+ class _EmptyDecoratorAndManager:
128
+ @overload
129
+ def __call__(self, __val: bool) -> _Decorator: ...
130
+
131
+ @overload
132
+ def __call__(self, __func: _C) -> _C: ...
133
+
134
+ def __call__(self, x):
135
+ return x
136
+ def __enter__(self) -> None:
137
+ pass
138
+ def __exit__(self, exc_type: Optional[Type[BaseException]],
139
+ exc: Optional[BaseException],
140
+ tb: Optional[TracebackType]) -> None:
141
+ pass
142
+
143
+ class _Optimization:
144
+ def use_switch(val: bool) -> _Decorator:
145
+ return _EmptyDecoratorAndManager()
146
+
147
+ def unpack_method_calls(val: bool) -> _Decorator:
148
+ return _EmptyDecoratorAndManager()
149
+
150
+ cclass = cfunc = ccall = _EmptyDecoratorAndManager()
151
+
152
+ ufunc = _empty_func_decorator
153
+
154
+ internal = c_api_binop_methods = type_version_tag = no_gc_clear = \
155
+ no_gc = total_ordering = _empty_class_decorator
156
+
157
+ annotation_typing = returns = wraparound = boundscheck = initializedcheck = \
158
+ nonecheck = cdivision = cdivision_warnings = collection_type = \
159
+ profile = linetrace = infer_types = \
160
+ freelist = auto_pickle = cpow = trashcan = auto_cpdef = \
161
+ allow_none_for_extension_args = callspec = show_performance_hints = \
162
+ py2_import = iterable_coroutine = remove_unreachable = \
163
+ test_body_needs_exception_handling = \
164
+ lambda _: _EmptyDecoratorAndManager()
165
+
166
+ binding = embedsignature = always_allow_keywords = unraisable_tracebacks = \
167
+ cpp_locals = \
168
+ _compiler_directive
169
+
170
+ # Note that fast_getattr is untested and undocumented!
171
+ fast_getattr = lambda _: _EmptyDecoratorAndManager()
172
+ # c_compile_guard is largely for internal use
173
+ c_compile_guard = lambda _:_EmptyDecoratorAndManager()
174
+
175
+ exceptval = lambda _=None, check=True: _EmptyDecoratorAndManager()
176
+
177
+ optimize = _Optimization()
178
+
179
+ class _OverflowcheckClass:
180
+ def __call__(self, val: bool) -> _Decorator:
181
+ return _EmptyDecoratorAndManager()
182
+
183
+ def fold(self, val: bool) -> _Decorator:
184
+ return _EmptyDecoratorAndManager()
185
+
186
+ overflowcheck = _OverflowcheckClass()
187
+
188
+ if TYPE_CHECKING:
189
+ # May be a bit hard to read but essentially means:
190
+ # > Returns a callable that takes another callable with these parameters and *some*
191
+ # > return value, then returns another callable with the same parameters but
192
+ # > the return type is the previous 'type' parameter.
193
+ def returns(__type: Type[_T]) -> Callable[[Callable[_P, object]], Callable[_P, _T]]: ...
194
+
195
+ def exceptval(__val: Any, *, check: bool = False) -> _Decorator: ...
196
+
197
+
198
+ embedsignature.format = overflowcheck.fold = optimize.use_switch = \
199
+ optimize.unpack_method_calls = lambda arg: _EmptyDecoratorAndManager()
200
+
201
+ final = _empty_decorator
202
+
203
+ class warn:
204
+ @staticmethod
205
+ def undeclared(val: bool) -> _Decorator:
206
+ return _EmptyDecoratorAndManager()
207
+
208
+ @staticmethod
209
+ def unreachable(val: bool) -> _Decorator:
210
+ return _EmptyDecoratorAndManager()
211
+
212
+ @staticmethod
213
+ def maybe_uninitialized(val: bool) -> _Decorator:
214
+ return _EmptyDecoratorAndManager()
215
+
216
+ @staticmethod
217
+ def unused(val: bool) -> _Decorator:
218
+ return _EmptyDecoratorAndManager()
219
+
220
+ @staticmethod
221
+ def unused_argument(val: bool) -> _Decorator:
222
+ return _EmptyDecoratorAndManager()
223
+
224
+ @staticmethod
225
+ def multiple_declarators(val: bool) -> _Decorator:
226
+ return _EmptyDecoratorAndManager()
227
+
228
+
229
+ _cython_inline = None
230
+ @overload
231
+ def inline(__func: _C) -> _C: ...
232
+
233
+ @overload
234
+ def inline(__code: str, *, get_type: Callable[[object, object], str] = ...,
235
+ lib_dir: str = ..., cython_include_dirs: Iterable[str] = ...,
236
+ cython_compiler_directives: Iterable[str] = ..., force: bool = ...,
237
+ quiet: bool = ..., locals: dict[str, str] = ...,
238
+ globals: dict[str, str] = ..., language_level: str = ...) -> Any: ...
239
+
240
+ def inline(f, *args, **kwds):
241
+ if isinstance(f, str):
242
+ global _cython_inline
243
+ if _cython_inline is None:
244
+ from Cython.Build.Inline import cython_inline as _cython_inline
245
+ return _cython_inline(f, *args, **kwds)
246
+ else:
247
+ assert len(args) == len(kwds) == 0
248
+ return f
249
+
250
+
251
+ def compile(f: _C) -> _C:
252
+ from Cython.Build.Inline import RuntimeCompiledFunction
253
+ return RuntimeCompiledFunction(f)
254
+
255
+
256
+ # Special functions
257
+
258
+ def cdiv(a: int, b: int) -> int:
259
+ if a < 0:
260
+ a = -a
261
+ b = -b
262
+ if b < 0:
263
+ return (a + b + 1) // b
264
+ return a // b
265
+
266
+ def cmod(a: int, b: int) -> int:
267
+ r = a % b
268
+ if (a * b) < 0 and r:
269
+ r -= b
270
+ return r
271
+
272
+
273
+ # Emulated language constructs
274
+
275
+ @overload
276
+ def cast(__t: Type[_T], __value: Any) -> _T: ...
277
+
278
+ @overload
279
+ def cast(__t: Callable[_P, _T], *args: _P.args, **kwargs: _P.kwargs) -> _T: ...
280
+
281
+ def cast(t, *args, **kwargs):
282
+ kwargs.pop('typecheck', None)
283
+ assert not kwargs
284
+
285
+ if isinstance(t, typedef):
286
+ return t(*args)
287
+ elif isinstance(t, type): # Doesn't work with old-style classes of Python 2.x
288
+ if len(args) != 1 or not (args[0] is None or isinstance(args[0], t)):
289
+ return t(*args)
290
+
291
+ return args[0]
292
+
293
+ def likely(cond: _T) -> _T:
294
+ return cond
295
+
296
+ def unlikely(cond: _T) -> _T:
297
+ return cond
298
+
299
+ def sizeof(obj: object) -> int:
300
+ return 1
301
+
302
+ def typeof(obj: object) -> str:
303
+ return obj.__class__.__name__
304
+ # return type(arg)
305
+
306
+ def address(obj: object) -> PointerType:
307
+ return pointer(type(obj))([obj])
308
+
309
+ def _is_value_type(t):
310
+ if isinstance(t, typedef):
311
+ return _is_value_type(t._basetype)
312
+
313
+ return isinstance(t, type) and issubclass(t, (StructType, UnionType, ArrayType))
314
+
315
+ @overload
316
+ def declare(
317
+ t: Optional[Callable[..., _T]] = ...,
318
+ value: Any = ...,
319
+ ) -> _T:
320
+ ...
321
+
322
+ # This one is for attributes, they cannot have initializers through cython.declare() currently.
323
+ @overload
324
+ def declare(
325
+ t: Callable[..., _T],
326
+ *,
327
+ visibility: Literal['public', 'readonly', 'private'] = ...,
328
+ ) -> _T:
329
+ ...
330
+
331
+ @overload
332
+ def declare(**kwargs: type) -> None: ...
333
+
334
+ def declare(t=None, value=_Unspecified, **kwds):
335
+ if value is not _Unspecified:
336
+ return cast(t, value)
337
+ elif _is_value_type(t):
338
+ return t()
339
+ else:
340
+ return None
341
+
342
+ class _nogil:
343
+ """Support for 'with nogil' statement and @nogil decorator.
344
+ """
345
+ @overload
346
+ def __call__(self, __val: bool) -> _FuncDecorator: ...
347
+
348
+ @overload
349
+ def __call__(self, __func: _C) -> _C: ...
350
+
351
+ def __call__(self, x):
352
+ if callable(x):
353
+ # Used as function decorator => return the function unchanged.
354
+ return x
355
+ # Used as conditional context manager or to create an "@nogil(True/False)" decorator => keep going.
356
+ return self
357
+
358
+ def __enter__(self) -> None:
359
+ pass
360
+ def __exit__(self, exc_type: Optional[Type[BaseException]],
361
+ exc: Optional[BaseException],
362
+ tb: Optional[TracebackType]) -> bool:
363
+ return exc_type is None
364
+
365
+ nogil = _nogil()
366
+ gil = _nogil()
367
+ with_gil = _nogil() # Actually not a context manager, but compilation will give the right error.
368
+ del _nogil
369
+
370
+
371
+ class critical_section:
372
+ def __init__(self, arg0, arg1=None):
373
+ # It's ambiguous if this is being used as a decorator or context manager
374
+ # even with a callable arg.
375
+ self.arg0 = arg0
376
+ def __call__(self, *args, **kwds):
377
+ return self.arg0(*args, **kwds)
378
+ def __enter__(self) -> None:
379
+ pass
380
+ def __exit__(self, exc_type: Optional[Type[BaseException]],
381
+ exc: Optional[BaseException],
382
+ tb: Optional[TracebackType]) -> bool:
383
+ return False
384
+
385
+
386
+ # Emulated types
387
+
388
+ class CythonTypeObject:
389
+ def __class_getitem__(cls, ix: int) -> Type[ArrayType[Self, int]]:
390
+ return array(cls, ix)
391
+
392
+ class CythonType(CythonTypeObject):
393
+
394
+ def _pointer(self, n=1):
395
+ for i in range(n):
396
+ self = pointer(self)
397
+ return self
398
+
399
+ if TYPE_CHECKING:
400
+ class PointerType(CythonType, Generic[_T]):
401
+ def __init__(
402
+ self,
403
+ value: Optional[ArrayType[_T] | PointerType[_T] | list[_T] | int] = ...
404
+ ) -> None: ...
405
+ def __getitem__(self, ix: int) -> _T: ...
406
+ def __setitem__(self, ix: int, value: _T) -> None: ...
407
+ def __eq__(self, value: object) -> bool: ...
408
+ def __repr__(self) -> str: ...
409
+
410
+ class ArrayType(PointerType[_T]):
411
+ def __init__(self) -> None: ...
412
+
413
+ class PointerType(CythonType):
414
+
415
+ def __init__(self, value=None):
416
+ from .Shadow import cast
417
+ if isinstance(value, (ArrayType, PointerType)):
418
+ self._items = [cast(self._basetype, a) for a in value._items]
419
+ elif isinstance(value, list):
420
+ self._items = [cast(self._basetype, a) for a in value]
421
+ elif value is None or value == 0:
422
+ self._items = []
423
+ else:
424
+ raise ValueError
425
+
426
+ def __getitem__(self, ix):
427
+ if ix < 0:
428
+ raise IndexError("negative indexing not allowed in C")
429
+ return self._items[ix]
430
+
431
+ def __setitem__(self, ix, value):
432
+ if ix < 0:
433
+ raise IndexError("negative indexing not allowed in C")
434
+ from .Shadow import cast
435
+ self._items[ix] = cast(self._basetype, value)
436
+
437
+ def __eq__(self, value):
438
+ if value is None and not self._items:
439
+ return True
440
+ elif type(self) != type(value):
441
+ return False
442
+ else:
443
+ return not self._items and not value._items
444
+
445
+ def __repr__(self):
446
+ return f"{self._basetype} *"
447
+
448
+
449
+ class ArrayType(PointerType):
450
+
451
+ def __init__(self, value=None):
452
+ if value is None:
453
+ self._items = [None] * self._n
454
+ else:
455
+ super().__init__(value)
456
+
457
+
458
+ class StructType(CythonType):
459
+
460
+ def __init__(self, *posargs, **data):
461
+ if not (posargs or data):
462
+ return
463
+ if posargs and data:
464
+ raise ValueError('Cannot accept both positional and keyword arguments.')
465
+
466
+ # Allow 'cast_from' as single positional or keyword argument.
467
+ if data and len(data) == 1 and 'cast_from' in data:
468
+ cast_from = data.pop('cast_from')
469
+ elif len(posargs) == 1 and type(posargs[0]) is type(self):
470
+ cast_from, posargs = posargs[0], ()
471
+ elif posargs:
472
+ for key, arg in zip(self._members, posargs):
473
+ setattr(self, key, arg)
474
+ return
475
+ else:
476
+ for key, value in data.items():
477
+ if key not in self._members:
478
+ raise ValueError("Invalid struct attribute for %s: %s" % (
479
+ self.__class__.__name__, key))
480
+ setattr(self, key, value)
481
+ return
482
+
483
+ # do cast
484
+ if data:
485
+ raise ValueError('Cannot accept keyword arguments when casting.')
486
+ if type(cast_from) is not type(self):
487
+ raise ValueError('Cannot cast from %s' % cast_from)
488
+ for key, value in cast_from.__dict__.items():
489
+ setattr(self, key, value)
490
+
491
+ def __setattr__(self, key, value):
492
+ if key in self._members:
493
+ self.__dict__[key] = cast(self._members[key], value)
494
+ else:
495
+ raise AttributeError("Struct has no member '%s'" % key)
496
+
497
+
498
+ class UnionType(CythonType):
499
+
500
+ def __init__(self, cast_from=_Unspecified, **data):
501
+ if cast_from is not _Unspecified:
502
+ # do type cast
503
+ if len(data) > 0:
504
+ raise ValueError('Cannot accept keyword arguments when casting.')
505
+ if isinstance(cast_from, dict):
506
+ datadict = cast_from
507
+ elif type(cast_from) is type(self):
508
+ datadict = cast_from.__dict__
509
+ else:
510
+ raise ValueError('Cannot cast from %s' % cast_from)
511
+ else:
512
+ datadict = data
513
+ if len(datadict) > 1:
514
+ raise AttributeError("Union can only store one field at a time.")
515
+ for key, value in datadict.items():
516
+ setattr(self, key, value)
517
+
518
+ def __setattr__(self, key, value):
519
+ if key == '__dict__':
520
+ CythonType.__setattr__(self, key, value)
521
+ elif key in self._members:
522
+ self.__dict__ = {key: cast(self._members[key], value)}
523
+ else:
524
+ raise AttributeError("Union has no member '%s'" % key)
525
+
526
+
527
+ if TYPE_CHECKING:
528
+ class pointer(PointerType[_T]):
529
+ def __new__(cls, basetype: _T) -> Type[PointerType[_T]]: ...
530
+ def __class_getitem__(cls, basetype: _T) -> Type[PointerType[_T]]: ...
531
+
532
+ class array(ArrayType[_T]):
533
+ def __new__(basetype: _T, n: int) -> Type[ArrayType[_T, int]]: ...
534
+ def __class_getitem__(cls, item: tuple[_T, int]) -> Type[ArrayType[_T, int]]: ...
535
+
536
+ class pointer(PointerType):
537
+ # Implemented as class to support both 'pointer(int)' and 'pointer[int]'.
538
+ def __new__(cls, basetype):
539
+ class PointerInstance(PointerType):
540
+ _basetype = basetype
541
+ return PointerInstance
542
+
543
+ def __class_getitem__(cls, basetype):
544
+ return cls(basetype)
545
+
546
+
547
+ class array(ArrayType):
548
+ # Implemented as class to support both 'array(int, 5)' and 'array[int, 5]'.
549
+ def __new__(cls, basetype, n):
550
+ class ArrayInstance(ArrayType):
551
+ _basetype = basetype
552
+ _n = n
553
+ return ArrayInstance
554
+
555
+ def __class_getitem__(cls, item):
556
+ basetype, n = item
557
+ return cls(basetype, n)
558
+
559
+
560
+ def struct(**members: type) -> Type[Any]:
561
+ class StructInstance(StructType):
562
+ _members = members
563
+ for key in members:
564
+ setattr(StructInstance, key, None)
565
+ return StructInstance
566
+
567
+ def union(**members: type) -> Type[Any]:
568
+ class UnionInstance(UnionType):
569
+ _members = members
570
+ for key in members:
571
+ setattr(UnionInstance, key, None)
572
+ return UnionInstance
573
+
574
+
575
+ if TYPE_CHECKING:
576
+ class typedef(CythonType, Generic[_T]):
577
+ name: str
578
+
579
+ def __init__(self, type: _T, name: Optional[str] = ...) -> None: ...
580
+ def __call__(self, *arg: Any) -> _T: ...
581
+ def __repr__(self) -> str: ...
582
+ __getitem__ = index_type
583
+
584
+ class typedef(CythonType):
585
+ name: str
586
+
587
+ def __init__(self, type: _T, name: Optional[str] = None) -> None:
588
+ self._basetype = type
589
+ self.name = name
590
+
591
+ def __call__(self, *arg: Any) -> _T:
592
+ value = cast(self._basetype, *arg)
593
+ return value
594
+
595
+ def __repr__(self) -> str:
596
+ return self.name or str(self._basetype)
597
+
598
+ __getitem__ = index_type
599
+
600
+
601
+ if TYPE_CHECKING:
602
+ const: TypeAlias = Annotated[_T, "cython.const"]
603
+ volatile: TypeAlias = Annotated[_T, "cython.volatile"]
604
+ restrict: TypeAlias = Annotated[_T, "cython.restrict"]
605
+
606
+ class const(typedef):
607
+ def __init__(self, type, name=None):
608
+ name = f"const {name or repr(type)}"
609
+ super().__init__(type, name)
610
+
611
+ def __class_getitem__(cls, base_type):
612
+ return const(base_type)
613
+
614
+
615
+ class volatile(typedef):
616
+ def __init__(self, type, name=None):
617
+ name = f"volatile {name or repr(type)}"
618
+ super().__init__(type, name)
619
+
620
+ def __class_getitem__(cls, base_type):
621
+ return volatile(base_type)
622
+
623
+
624
+ class restrict(typedef):
625
+ def __init__(self, type, name=None):
626
+ name = f"restrict {name or repr(type)}"
627
+ super().__init__(type, name)
628
+
629
+ def __class_getitem__(cls, base_type):
630
+ return restrict(base_type)
631
+
632
+
633
+ class _FusedType(CythonType):
634
+ __getitem__ = index_type
635
+
636
+
637
+ def fused_type(*args: Any) -> Type[Any]:
638
+ if not args:
639
+ raise TypeError("Expected at least one type as argument")
640
+
641
+ # Find the numeric type with biggest rank if all types are numeric
642
+ rank = -1
643
+ for type in args:
644
+ if type not in (py_int, py_long, py_float, py_complex):
645
+ break
646
+
647
+ if type_ordering.index(type) > rank:
648
+ result_type = type
649
+ else:
650
+ return result_type
651
+
652
+ # Not a simple numeric type, return a fused type instance. The result
653
+ # isn't really meant to be used, as we can't keep track of the context in
654
+ # pure-mode. Casting won't do anything in this case.
655
+ return _FusedType()
656
+
657
+
658
+ py_int = typedef(int, "int")
659
+ py_long = typedef(int, "long") # for legacy Py2 code only
660
+ py_bool = typedef(bool, "bool")
661
+ py_float = typedef(float, "float")
662
+ py_complex = typedef(complex, "double complex")
663
+
664
+
665
+ # Predefined types
666
+
667
+ int_types = [
668
+ 'char',
669
+ 'short',
670
+ 'Py_UNICODE',
671
+ 'int',
672
+ 'Py_UCS4',
673
+ 'long',
674
+ 'longlong',
675
+ 'Py_hash_t',
676
+ 'Py_ssize_t',
677
+ 'size_t',
678
+ 'ssize_t',
679
+ 'ptrdiff_t',
680
+ ]
681
+ float_types = [
682
+ 'longdouble',
683
+ 'double',
684
+ 'float',
685
+ ]
686
+ complex_types = [
687
+ 'longdoublecomplex',
688
+ 'doublecomplex',
689
+ 'floatcomplex',
690
+ 'complex',
691
+ ]
692
+ other_types = [
693
+ 'bint',
694
+ 'void',
695
+ 'Py_tss_t',
696
+ ]
697
+
698
+ to_repr = {
699
+ 'longlong': 'long long',
700
+ 'longdouble': 'long double',
701
+ 'longdoublecomplex': 'long double complex',
702
+ 'doublecomplex': 'double complex',
703
+ 'floatcomplex': 'float complex',
704
+ }.get
705
+
706
+ gs = globals()
707
+
708
+ gs['unicode'] = typedef(str, 'unicode')
709
+
710
+ for name in int_types:
711
+ reprname = to_repr(name, name)
712
+ gs[name] = typedef(py_int, reprname)
713
+ if name not in ('Py_UNICODE', 'Py_UCS4', 'Py_hash_t', 'ptrdiff_t') and not name.endswith('size_t'):
714
+ gs['u'+name] = typedef(py_int, "unsigned " + reprname)
715
+ gs['s'+name] = typedef(py_int, "signed " + reprname)
716
+
717
+ for name in float_types:
718
+ gs[name] = typedef(py_float, to_repr(name, name))
719
+
720
+ for name in complex_types:
721
+ gs[name] = typedef(py_complex, to_repr(name, name))
722
+
723
+ del name, reprname
724
+
725
+ if TYPE_CHECKING:
726
+ Py_UCS4 = py_int | str
727
+ Py_UNICODE = py_int | str
728
+
729
+ bint = py_bool
730
+ void = Type[None]
731
+ basestring = py_str
732
+ unicode = py_str
733
+
734
+ bint = typedef(bool, "bint")
735
+ void = typedef(None, "void")
736
+ Py_tss_t = typedef(None, "Py_tss_t")
737
+
738
+ # Generate const types.
739
+ for t in int_types + float_types + complex_types + other_types:
740
+ for t in (t, f'u{t}', f's{t}'):
741
+ if t in gs:
742
+ gs[f"const_{t}"] = const(gs[t], t)
743
+
744
+ # Generate pointer types: p_int, p_const_char, etc.
745
+ for i in range(1, 4):
746
+ for const_ in ('', 'const_'):
747
+ for t in int_types:
748
+ for t in (t, f'u{t}', f's{t}'):
749
+ if t in gs:
750
+ gs[f"{'p'*i}_{const_}{t}"] = pointer(gs[f"{'p'*(i-1)}{'_' if i > 1 else ''}{const_}{t}"])
751
+
752
+ for t in float_types + complex_types:
753
+ gs[f"{'p'*i}_{const_}{t}"] = pointer(gs[f"{'p'*(i-1)}{'_' if i > 1 else ''}{const_}{t}"])
754
+
755
+ gs[f"{'p'*i}_const_bint"] = pointer(gs[f"{'p'*(i-1)}{'_' if i > 1 else ''}const_bint"])
756
+ for t in other_types:
757
+ gs[f"{'p'*i}_{t}"] = pointer(gs[f"{'p'*(i-1)}{'_' if i > 1 else ''}{t}"])
758
+
759
+ del t, const_, i
760
+
761
+ NULL: pointer[Any] = gs['p_void'](0)
762
+
763
+ del gs
764
+
765
+
766
+ def __getattr__(name):
767
+ # looks like 'gs' has some users out there by now...
768
+ if name == 'gs':
769
+ import warnings
770
+ warnings.warn(
771
+ "'gs' is not a publicly exposed name in cython.*. Use vars() or globals() instead.",
772
+ DeprecationWarning)
773
+ return globals()
774
+ raise AttributeError(f"'cython' has no attribute {name!r}")
775
+
776
+
777
+ integral = floating = numeric = _FusedType()
778
+
779
+ type_ordering = [py_int, py_long, py_float, py_complex]
780
+
781
+ class CythonDotParallel:
782
+ """
783
+ The cython.parallel module.
784
+ """
785
+
786
+ __all__ = ['parallel', 'prange', 'threadid']
787
+
788
+ def parallel(self, num_threads=None):
789
+ return nogil
790
+
791
+ def prange(self, start=0, stop=None, step=1, nogil=False, schedule=None, chunksize=None, num_threads=None):
792
+ if stop is None:
793
+ stop = start
794
+ start = 0
795
+ return range(start, stop, step)
796
+
797
+ def threadid(self):
798
+ return 0
799
+
800
+ # def threadsavailable(self):
801
+ # return 1
802
+
803
+ class CythonDotImportedFromElsewhere:
804
+ """
805
+ cython.dataclasses just shadows the standard library modules of the same name
806
+ """
807
+ def __init__(self, module):
808
+ self.__path__ = []
809
+ self.__file__ = None
810
+ self.__name__ = module
811
+ self.__package__ = module
812
+
813
+ def __getattr__(self, attr):
814
+ # we typically only expect this to be called once
815
+ from importlib import import_module
816
+ import sys
817
+ try:
818
+ mod = import_module(self.__name__)
819
+ except ImportError:
820
+ # but if they don't exist (Python is not sufficiently up-to-date) then
821
+ # you can't use them
822
+ raise AttributeError("%s: the standard library module %s is not available" %
823
+ (attr, self.__name__))
824
+ sys.modules['cython.%s' % self.__name__] = mod
825
+ return getattr(mod, attr)
826
+
827
+ class CythonCImports:
828
+ """
829
+ Simplistic module mock to make cimports sort-of work in Python code.
830
+ """
831
+ def __init__(self, module, **attributes):
832
+ self.__path__ = []
833
+ self.__file__ = None
834
+ self.__name__ = module
835
+ self.__package__ = module
836
+ if attributes:
837
+ self.__dict__.update(attributes)
838
+
839
+ def __getattr__(self, item):
840
+ if item.startswith('__') and item.endswith('__'):
841
+ raise AttributeError(item)
842
+
843
+ package = self.__package__[len('cython.cimports.'):]
844
+
845
+ from importlib import import_module
846
+ try:
847
+ return import_module(item, package or None)
848
+ except ImportError:
849
+ ex = AttributeError(item)
850
+ ex.__cause__ = None
851
+ raise ex
852
+
853
+
854
+ import math, sys
855
+ sys.modules['cython.parallel'] = CythonDotParallel()
856
+ sys.modules['cython.cimports.libc.math'] = math
857
+ sys.modules['cython.cimports.libc'] = CythonCImports('cython.cimports.libc', math=math)
858
+ sys.modules['cython.cimports'] = CythonCImports('cython.cimports', libc=sys.modules['cython.cimports.libc'])
859
+
860
+ # In pure Python mode @cython.dataclasses.dataclass and dataclass field should just
861
+ # shadow the standard library ones (if they are available)
862
+ if TYPE_CHECKING:
863
+ import dataclasses as dataclasses
864
+ dataclasses = sys.modules['cython.dataclasses'] = CythonDotImportedFromElsewhere('dataclasses')
865
+ del math, sys
866
+
867
+
868
+ class _pymutex_base:
869
+ def __init__(self) -> None:
870
+ import threading
871
+ self._l = threading.Lock()
872
+
873
+ def acquire(self) -> None:
874
+ return self._l.acquire()
875
+
876
+ def release(self) -> None:
877
+ return self._l.release()
878
+
879
+ def locked(self) -> bool:
880
+ """
881
+ Check if the lock is currently held.
882
+ Returns True if locked, False otherwise.
883
+ """
884
+ return self._l.locked()
885
+
886
+ def can_check_locked(self) -> bool:
887
+ """
888
+ Check if the locked() method is available.
889
+ Always returns True - locked() is available on all Python versions.
890
+ """
891
+ return True
892
+
893
+ def __enter__(self) -> None:
894
+ return self._l.__enter__()
895
+
896
+ def __exit__(self, exc_type: Optional[Type[BaseException]],
897
+ exc: Optional[BaseException],
898
+ tb: Optional[TracebackType]) -> None:
899
+ return self._l.__exit__(exc_type, exc, tb)
900
+
901
+ class pymutex(_pymutex_base):
902
+ """
903
+ A low-cost mutex lock type.
904
+ In Python 3.13+, it uses the fast PyMutex implementation. In older Python versions,
905
+ it falls back to the heavier "PyThread_type_lock".
906
+ Can be used in 'with' statements and supports nogil context.
907
+ """
908
+ pass
909
+
910
+ class pythread_type_lock(_pymutex_base):
911
+ """
912
+ A mutex lock type using PyThread_type_lock.
913
+ Can be used in 'with' statements and supports nogil context.
914
+ Compatible with the Limited API.
915
+ """
916
+ pass
917
+
918
+
919
+ if TYPE_CHECKING:
920
+ const: TypeAlias = Annotated[_T, "cython.const"]
921
+ volatile: TypeAlias = Annotated[_T, "cython.volatile"]
922
+ restrict: TypeAlias = Annotated[_T, "cython.restrict"]
923
+
924
+ ##### START: GENERATED LIST OF GENERATED TYPES #####
925
+ # Generated by "Tools/cython-generate-shadow-pyi.py" on 2025-12-01 19:08:04.502148
926
+
927
+ const_bint : TypeAlias = const[bint]
928
+ p_const_bint = pointer[const[bint]]
929
+ pp_const_bint = pointer[pointer[const[bint]]]
930
+ ppp_const_bint = pointer[pointer[pointer[const[bint]]]]
931
+ p_bint = pointer[bint]
932
+ pp_bint = pointer[pointer[bint]]
933
+ ppp_bint = pointer[pointer[pointer[bint]]]
934
+ char : TypeAlias = py_int
935
+ const_char : TypeAlias = const[py_int]
936
+ p_const_char = pointer[const[py_int]]
937
+ pp_const_char = pointer[pointer[const[py_int]]]
938
+ ppp_const_char = pointer[pointer[pointer[const[py_int]]]]
939
+ p_char = pointer[py_int]
940
+ pp_char = pointer[pointer[py_int]]
941
+ ppp_char = pointer[pointer[pointer[py_int]]]
942
+ complex : TypeAlias = py_complex
943
+ const_complex : TypeAlias = const[py_complex]
944
+ p_const_complex = pointer[const[py_complex]]
945
+ pp_const_complex = pointer[pointer[const[py_complex]]]
946
+ ppp_const_complex = pointer[pointer[pointer[const[py_complex]]]]
947
+ p_complex = pointer[py_complex]
948
+ pp_complex = pointer[pointer[py_complex]]
949
+ ppp_complex = pointer[pointer[pointer[py_complex]]]
950
+ double : TypeAlias = py_float
951
+ const_double : TypeAlias = const[py_float]
952
+ p_const_double = pointer[const[py_float]]
953
+ pp_const_double = pointer[pointer[const[py_float]]]
954
+ ppp_const_double = pointer[pointer[pointer[const[py_float]]]]
955
+ p_double = pointer[py_float]
956
+ pp_double = pointer[pointer[py_float]]
957
+ ppp_double = pointer[pointer[pointer[py_float]]]
958
+ doublecomplex : TypeAlias = py_complex
959
+ const_doublecomplex : TypeAlias = const[py_complex]
960
+ p_const_doublecomplex = pointer[const[py_complex]]
961
+ pp_const_doublecomplex = pointer[pointer[const[py_complex]]]
962
+ ppp_const_doublecomplex = pointer[pointer[pointer[const[py_complex]]]]
963
+ p_doublecomplex = pointer[py_complex]
964
+ pp_doublecomplex = pointer[pointer[py_complex]]
965
+ ppp_doublecomplex = pointer[pointer[pointer[py_complex]]]
966
+ float : TypeAlias = py_float
967
+ const_float : TypeAlias = const[py_float]
968
+ p_const_float = pointer[const[py_float]]
969
+ pp_const_float = pointer[pointer[const[py_float]]]
970
+ ppp_const_float = pointer[pointer[pointer[const[py_float]]]]
971
+ p_float = pointer[py_float]
972
+ pp_float = pointer[pointer[py_float]]
973
+ ppp_float = pointer[pointer[pointer[py_float]]]
974
+ floatcomplex : TypeAlias = py_complex
975
+ const_floatcomplex : TypeAlias = const[py_complex]
976
+ p_const_floatcomplex = pointer[const[py_complex]]
977
+ pp_const_floatcomplex = pointer[pointer[const[py_complex]]]
978
+ ppp_const_floatcomplex = pointer[pointer[pointer[const[py_complex]]]]
979
+ p_floatcomplex = pointer[py_complex]
980
+ pp_floatcomplex = pointer[pointer[py_complex]]
981
+ ppp_floatcomplex = pointer[pointer[pointer[py_complex]]]
982
+ int : TypeAlias = py_int
983
+ const_int : TypeAlias = const[py_int]
984
+ p_const_int = pointer[const[py_int]]
985
+ pp_const_int = pointer[pointer[const[py_int]]]
986
+ ppp_const_int = pointer[pointer[pointer[const[py_int]]]]
987
+ p_int = pointer[py_int]
988
+ pp_int = pointer[pointer[py_int]]
989
+ ppp_int = pointer[pointer[pointer[py_int]]]
990
+ long : TypeAlias = py_int
991
+ const_long : TypeAlias = const[py_int]
992
+ p_const_long = pointer[const[py_int]]
993
+ pp_const_long = pointer[pointer[const[py_int]]]
994
+ ppp_const_long = pointer[pointer[pointer[const[py_int]]]]
995
+ p_long = pointer[py_int]
996
+ pp_long = pointer[pointer[py_int]]
997
+ ppp_long = pointer[pointer[pointer[py_int]]]
998
+ longdouble : TypeAlias = py_float
999
+ const_longdouble : TypeAlias = const[py_float]
1000
+ p_const_longdouble = pointer[const[py_float]]
1001
+ pp_const_longdouble = pointer[pointer[const[py_float]]]
1002
+ ppp_const_longdouble = pointer[pointer[pointer[const[py_float]]]]
1003
+ p_longdouble = pointer[py_float]
1004
+ pp_longdouble = pointer[pointer[py_float]]
1005
+ ppp_longdouble = pointer[pointer[pointer[py_float]]]
1006
+ longdoublecomplex : TypeAlias = py_complex
1007
+ const_longdoublecomplex : TypeAlias = const[py_complex]
1008
+ p_const_longdoublecomplex = pointer[const[py_complex]]
1009
+ pp_const_longdoublecomplex = pointer[pointer[const[py_complex]]]
1010
+ ppp_const_longdoublecomplex = pointer[pointer[pointer[const[py_complex]]]]
1011
+ p_longdoublecomplex = pointer[py_complex]
1012
+ pp_longdoublecomplex = pointer[pointer[py_complex]]
1013
+ ppp_longdoublecomplex = pointer[pointer[pointer[py_complex]]]
1014
+ longlong : TypeAlias = py_int
1015
+ const_longlong : TypeAlias = const[py_int]
1016
+ p_const_longlong = pointer[const[py_int]]
1017
+ pp_const_longlong = pointer[pointer[const[py_int]]]
1018
+ ppp_const_longlong = pointer[pointer[pointer[const[py_int]]]]
1019
+ p_longlong = pointer[py_int]
1020
+ pp_longlong = pointer[pointer[py_int]]
1021
+ ppp_longlong = pointer[pointer[pointer[py_int]]]
1022
+ schar : TypeAlias = py_int
1023
+ const_schar : TypeAlias = const[py_int]
1024
+ p_const_schar = pointer[const[py_int]]
1025
+ pp_const_schar = pointer[pointer[const[py_int]]]
1026
+ ppp_const_schar = pointer[pointer[pointer[const[py_int]]]]
1027
+ p_schar = pointer[py_int]
1028
+ pp_schar = pointer[pointer[py_int]]
1029
+ ppp_schar = pointer[pointer[pointer[py_int]]]
1030
+ short : TypeAlias = py_int
1031
+ const_short : TypeAlias = const[py_int]
1032
+ p_const_short = pointer[const[py_int]]
1033
+ pp_const_short = pointer[pointer[const[py_int]]]
1034
+ ppp_const_short = pointer[pointer[pointer[const[py_int]]]]
1035
+ p_short = pointer[py_int]
1036
+ pp_short = pointer[pointer[py_int]]
1037
+ ppp_short = pointer[pointer[pointer[py_int]]]
1038
+ sint : TypeAlias = py_int
1039
+ const_sint : TypeAlias = const[py_int]
1040
+ p_const_sint = pointer[const[py_int]]
1041
+ pp_const_sint = pointer[pointer[const[py_int]]]
1042
+ ppp_const_sint = pointer[pointer[pointer[const[py_int]]]]
1043
+ p_sint = pointer[py_int]
1044
+ pp_sint = pointer[pointer[py_int]]
1045
+ ppp_sint = pointer[pointer[pointer[py_int]]]
1046
+ slong : TypeAlias = py_int
1047
+ const_slong : TypeAlias = const[py_int]
1048
+ p_const_slong = pointer[const[py_int]]
1049
+ pp_const_slong = pointer[pointer[const[py_int]]]
1050
+ ppp_const_slong = pointer[pointer[pointer[const[py_int]]]]
1051
+ p_slong = pointer[py_int]
1052
+ pp_slong = pointer[pointer[py_int]]
1053
+ ppp_slong = pointer[pointer[pointer[py_int]]]
1054
+ slonglong : TypeAlias = py_int
1055
+ const_slonglong : TypeAlias = const[py_int]
1056
+ p_const_slonglong = pointer[const[py_int]]
1057
+ pp_const_slonglong = pointer[pointer[const[py_int]]]
1058
+ ppp_const_slonglong = pointer[pointer[pointer[const[py_int]]]]
1059
+ p_slonglong = pointer[py_int]
1060
+ pp_slonglong = pointer[pointer[py_int]]
1061
+ ppp_slonglong = pointer[pointer[pointer[py_int]]]
1062
+ sshort : TypeAlias = py_int
1063
+ const_sshort : TypeAlias = const[py_int]
1064
+ p_const_sshort = pointer[const[py_int]]
1065
+ pp_const_sshort = pointer[pointer[const[py_int]]]
1066
+ ppp_const_sshort = pointer[pointer[pointer[const[py_int]]]]
1067
+ p_sshort = pointer[py_int]
1068
+ pp_sshort = pointer[pointer[py_int]]
1069
+ ppp_sshort = pointer[pointer[pointer[py_int]]]
1070
+ Py_hash_t : TypeAlias = py_int
1071
+ const_Py_hash_t : TypeAlias = const[py_int]
1072
+ p_const_Py_hash_t = pointer[const[py_int]]
1073
+ pp_const_Py_hash_t = pointer[pointer[const[py_int]]]
1074
+ ppp_const_Py_hash_t = pointer[pointer[pointer[const[py_int]]]]
1075
+ p_Py_hash_t = pointer[py_int]
1076
+ pp_Py_hash_t = pointer[pointer[py_int]]
1077
+ ppp_Py_hash_t = pointer[pointer[pointer[py_int]]]
1078
+ ptrdiff_t : TypeAlias = py_int
1079
+ const_ptrdiff_t : TypeAlias = const[py_int]
1080
+ p_const_ptrdiff_t = pointer[const[py_int]]
1081
+ pp_const_ptrdiff_t = pointer[pointer[const[py_int]]]
1082
+ ppp_const_ptrdiff_t = pointer[pointer[pointer[const[py_int]]]]
1083
+ p_ptrdiff_t = pointer[py_int]
1084
+ pp_ptrdiff_t = pointer[pointer[py_int]]
1085
+ ppp_ptrdiff_t = pointer[pointer[pointer[py_int]]]
1086
+ size_t : TypeAlias = py_int
1087
+ const_size_t : TypeAlias = const[py_int]
1088
+ p_const_size_t = pointer[const[py_int]]
1089
+ pp_const_size_t = pointer[pointer[const[py_int]]]
1090
+ ppp_const_size_t = pointer[pointer[pointer[const[py_int]]]]
1091
+ p_size_t = pointer[py_int]
1092
+ pp_size_t = pointer[pointer[py_int]]
1093
+ ppp_size_t = pointer[pointer[pointer[py_int]]]
1094
+ ssize_t : TypeAlias = py_int
1095
+ const_ssize_t : TypeAlias = const[py_int]
1096
+ p_const_ssize_t = pointer[const[py_int]]
1097
+ pp_const_ssize_t = pointer[pointer[const[py_int]]]
1098
+ ppp_const_ssize_t = pointer[pointer[pointer[const[py_int]]]]
1099
+ p_ssize_t = pointer[py_int]
1100
+ pp_ssize_t = pointer[pointer[py_int]]
1101
+ ppp_ssize_t = pointer[pointer[pointer[py_int]]]
1102
+ Py_ssize_t : TypeAlias = py_int
1103
+ const_Py_ssize_t : TypeAlias = const[py_int]
1104
+ p_const_Py_ssize_t = pointer[const[py_int]]
1105
+ pp_const_Py_ssize_t = pointer[pointer[const[py_int]]]
1106
+ ppp_const_Py_ssize_t = pointer[pointer[pointer[const[py_int]]]]
1107
+ p_Py_ssize_t = pointer[py_int]
1108
+ pp_Py_ssize_t = pointer[pointer[py_int]]
1109
+ ppp_Py_ssize_t = pointer[pointer[pointer[py_int]]]
1110
+ const_Py_tss_t : TypeAlias = const[Any]
1111
+ p_Py_tss_t = pointer[Any]
1112
+ pp_Py_tss_t = pointer[pointer[Any]]
1113
+ ppp_Py_tss_t = pointer[pointer[pointer[Any]]]
1114
+ uchar : TypeAlias = py_int
1115
+ const_uchar : TypeAlias = const[py_int]
1116
+ p_const_uchar = pointer[const[py_int]]
1117
+ pp_const_uchar = pointer[pointer[const[py_int]]]
1118
+ ppp_const_uchar = pointer[pointer[pointer[const[py_int]]]]
1119
+ p_uchar = pointer[py_int]
1120
+ pp_uchar = pointer[pointer[py_int]]
1121
+ ppp_uchar = pointer[pointer[pointer[py_int]]]
1122
+ const_Py_UCS4 : TypeAlias = const[py_int]
1123
+ p_const_Py_UCS4 = pointer[const[py_int]]
1124
+ pp_const_Py_UCS4 = pointer[pointer[const[py_int]]]
1125
+ ppp_const_Py_UCS4 = pointer[pointer[pointer[const[py_int]]]]
1126
+ p_Py_UCS4 = pointer[py_int]
1127
+ pp_Py_UCS4 = pointer[pointer[py_int]]
1128
+ ppp_Py_UCS4 = pointer[pointer[pointer[py_int]]]
1129
+ uint : TypeAlias = py_int
1130
+ const_uint : TypeAlias = const[py_int]
1131
+ p_const_uint = pointer[const[py_int]]
1132
+ pp_const_uint = pointer[pointer[const[py_int]]]
1133
+ ppp_const_uint = pointer[pointer[pointer[const[py_int]]]]
1134
+ p_uint = pointer[py_int]
1135
+ pp_uint = pointer[pointer[py_int]]
1136
+ ppp_uint = pointer[pointer[pointer[py_int]]]
1137
+ ulong : TypeAlias = py_int
1138
+ const_ulong : TypeAlias = const[py_int]
1139
+ p_const_ulong = pointer[const[py_int]]
1140
+ pp_const_ulong = pointer[pointer[const[py_int]]]
1141
+ ppp_const_ulong = pointer[pointer[pointer[const[py_int]]]]
1142
+ p_ulong = pointer[py_int]
1143
+ pp_ulong = pointer[pointer[py_int]]
1144
+ ppp_ulong = pointer[pointer[pointer[py_int]]]
1145
+ ulonglong : TypeAlias = py_int
1146
+ const_ulonglong : TypeAlias = const[py_int]
1147
+ p_const_ulonglong = pointer[const[py_int]]
1148
+ pp_const_ulonglong = pointer[pointer[const[py_int]]]
1149
+ ppp_const_ulonglong = pointer[pointer[pointer[const[py_int]]]]
1150
+ p_ulonglong = pointer[py_int]
1151
+ pp_ulonglong = pointer[pointer[py_int]]
1152
+ ppp_ulonglong = pointer[pointer[pointer[py_int]]]
1153
+ const_Py_UNICODE : TypeAlias = const[py_int]
1154
+ p_const_Py_UNICODE = pointer[const[py_int]]
1155
+ pp_const_Py_UNICODE = pointer[pointer[const[py_int]]]
1156
+ ppp_const_Py_UNICODE = pointer[pointer[pointer[const[py_int]]]]
1157
+ p_Py_UNICODE = pointer[py_int]
1158
+ pp_Py_UNICODE = pointer[pointer[py_int]]
1159
+ ppp_Py_UNICODE = pointer[pointer[pointer[py_int]]]
1160
+ ushort : TypeAlias = py_int
1161
+ const_ushort : TypeAlias = const[py_int]
1162
+ p_const_ushort = pointer[const[py_int]]
1163
+ pp_const_ushort = pointer[pointer[const[py_int]]]
1164
+ ppp_const_ushort = pointer[pointer[pointer[const[py_int]]]]
1165
+ p_ushort = pointer[py_int]
1166
+ pp_ushort = pointer[pointer[py_int]]
1167
+ ppp_ushort = pointer[pointer[pointer[py_int]]]
1168
+ const_void : TypeAlias = const[Any]
1169
+ p_void = pointer[Any]
1170
+ pp_void = pointer[pointer[Any]]
1171
+ ppp_void = pointer[pointer[pointer[Any]]]
1172
+
1173
+ ##### END: GENERATED LIST OF GENERATED TYPES #####
1174
+ pass