oxython 0.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 (321) hide show
  1. Cython/Build/BuildExecutable.py +156 -0
  2. Cython/Build/Cache.py +198 -0
  3. Cython/Build/Cythonize.py +349 -0
  4. Cython/Build/Dependencies.py +1320 -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 +222 -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.pxd +154 -0
  26. Cython/Compiler/Code.py +3760 -0
  27. Cython/Compiler/CodeGeneration.py +33 -0
  28. Cython/Compiler/CythonScope.py +208 -0
  29. Cython/Compiler/Dataclass.py +890 -0
  30. Cython/Compiler/DebugFlags.py +24 -0
  31. Cython/Compiler/Errors.py +310 -0
  32. Cython/Compiler/ExprNodes.py +16319 -0
  33. Cython/Compiler/FlowControl.pxd +112 -0
  34. Cython/Compiler/FlowControl.py +1575 -0
  35. Cython/Compiler/FusedNode.py +978 -0
  36. Cython/Compiler/Future.py +16 -0
  37. Cython/Compiler/Interpreter.py +57 -0
  38. Cython/Compiler/Lexicon.py +442 -0
  39. Cython/Compiler/LineTable.py +114 -0
  40. Cython/Compiler/Main.py +879 -0
  41. Cython/Compiler/MatchCaseNodes.py +2200 -0
  42. Cython/Compiler/MemoryView.py +930 -0
  43. Cython/Compiler/ModuleNode.py +4558 -0
  44. Cython/Compiler/Naming.py +370 -0
  45. Cython/Compiler/Nodes.py +11334 -0
  46. Cython/Compiler/Optimize.py +5563 -0
  47. Cython/Compiler/Options.py +841 -0
  48. Cython/Compiler/ParseTreeTransforms.pxd +80 -0
  49. Cython/Compiler/ParseTreeTransforms.py +4808 -0
  50. Cython/Compiler/Parsing.pxd +9 -0
  51. Cython/Compiler/Parsing.py +5442 -0
  52. Cython/Compiler/Pipeline.py +439 -0
  53. Cython/Compiler/PyrexTypes.py +6588 -0
  54. Cython/Compiler/Pythran.py +232 -0
  55. Cython/Compiler/Scanning.pxd +74 -0
  56. Cython/Compiler/Scanning.py +771 -0
  57. Cython/Compiler/StringEncoding.py +354 -0
  58. Cython/Compiler/Symtab.py +3122 -0
  59. Cython/Compiler/Tests/TestBuffer.py +105 -0
  60. Cython/Compiler/Tests/TestBuiltin.py +196 -0
  61. Cython/Compiler/Tests/TestCmdLine.py +652 -0
  62. Cython/Compiler/Tests/TestCode.py +145 -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 +132 -0
  68. Cython/Compiler/Tests/TestSignatureMatching.py +73 -0
  69. Cython/Compiler/Tests/TestStringEncoding.py +20 -0
  70. Cython/Compiler/Tests/TestTreeFragment.py +63 -0
  71. Cython/Compiler/Tests/TestTreePath.py +103 -0
  72. Cython/Compiler/Tests/TestTypes.py +119 -0
  73. Cython/Compiler/Tests/TestUtilityLoad.py +112 -0
  74. Cython/Compiler/Tests/TestVisitor.py +119 -0
  75. Cython/Compiler/Tests/Utils.py +36 -0
  76. Cython/Compiler/Tests/__init__.py +1 -0
  77. Cython/Compiler/TreeFragment.py +279 -0
  78. Cython/Compiler/TreePath.py +303 -0
  79. Cython/Compiler/TypeInference.py +626 -0
  80. Cython/Compiler/TypeSlots.py +1330 -0
  81. Cython/Compiler/UFuncs.py +317 -0
  82. Cython/Compiler/UtilNodes.py +389 -0
  83. Cython/Compiler/UtilityCode.py +354 -0
  84. Cython/Compiler/Version.py +8 -0
  85. Cython/Compiler/Visitor.pxd +52 -0
  86. Cython/Compiler/Visitor.py +914 -0
  87. Cython/Compiler/__init__.py +1 -0
  88. Cython/Coverage.py +448 -0
  89. Cython/Debugger/Cygdb.py +214 -0
  90. Cython/Debugger/DebugWriter.py +82 -0
  91. Cython/Debugger/Tests/TestLibCython.py +280 -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 +580 -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 +143 -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 +159 -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 +268 -0
  120. Cython/Includes/cpython/exc.pxd +263 -0
  121. Cython/Includes/cpython/fileobject.pxd +57 -0
  122. Cython/Includes/cpython/float.pxd +56 -0
  123. Cython/Includes/cpython/frozendict.pxd +37 -0
  124. Cython/Includes/cpython/function.pxd +65 -0
  125. Cython/Includes/cpython/genobject.pxd +25 -0
  126. Cython/Includes/cpython/getargs.pxd +12 -0
  127. Cython/Includes/cpython/instance.pxd +25 -0
  128. Cython/Includes/cpython/iterator.pxd +36 -0
  129. Cython/Includes/cpython/iterobject.pxd +24 -0
  130. Cython/Includes/cpython/list.pxd +144 -0
  131. Cython/Includes/cpython/long.pxd +180 -0
  132. Cython/Includes/cpython/longintrepr.pxd +14 -0
  133. Cython/Includes/cpython/mapping.pxd +63 -0
  134. Cython/Includes/cpython/marshal.pxd +66 -0
  135. Cython/Includes/cpython/mem.pxd +120 -0
  136. Cython/Includes/cpython/memoryview.pxd +50 -0
  137. Cython/Includes/cpython/method.pxd +49 -0
  138. Cython/Includes/cpython/module.pxd +208 -0
  139. Cython/Includes/cpython/number.pxd +258 -0
  140. Cython/Includes/cpython/object.pxd +430 -0
  141. Cython/Includes/cpython/pycapsule.pxd +143 -0
  142. Cython/Includes/cpython/pylifecycle.pxd +68 -0
  143. Cython/Includes/cpython/pyport.pxd +8 -0
  144. Cython/Includes/cpython/pystate.pxd +95 -0
  145. Cython/Includes/cpython/pythread.pxd +53 -0
  146. Cython/Includes/cpython/ref.pxd +141 -0
  147. Cython/Includes/cpython/sentinel.pxd +17 -0
  148. Cython/Includes/cpython/sequence.pxd +134 -0
  149. Cython/Includes/cpython/set.pxd +119 -0
  150. Cython/Includes/cpython/slice.pxd +70 -0
  151. Cython/Includes/cpython/time.pxd +129 -0
  152. Cython/Includes/cpython/tuple.pxd +72 -0
  153. Cython/Includes/cpython/type.pxd +146 -0
  154. Cython/Includes/cpython/unicode.pxd +639 -0
  155. Cython/Includes/cpython/version.pxd +32 -0
  156. Cython/Includes/cpython/weakref.pxd +78 -0
  157. Cython/Includes/libc/__init__.pxd +1 -0
  158. Cython/Includes/libc/complex.pxd +35 -0
  159. Cython/Includes/libc/errno.pxd +127 -0
  160. Cython/Includes/libc/float.pxd +43 -0
  161. Cython/Includes/libc/limits.pxd +28 -0
  162. Cython/Includes/libc/locale.pxd +46 -0
  163. Cython/Includes/libc/math.pxd +209 -0
  164. Cython/Includes/libc/setjmp.pxd +10 -0
  165. Cython/Includes/libc/signal.pxd +64 -0
  166. Cython/Includes/libc/stdbool.pxd +5 -0
  167. Cython/Includes/libc/stddef.pxd +9 -0
  168. Cython/Includes/libc/stdint.pxd +105 -0
  169. Cython/Includes/libc/stdio.pxd +80 -0
  170. Cython/Includes/libc/stdlib.pxd +72 -0
  171. Cython/Includes/libc/string.pxd +50 -0
  172. Cython/Includes/libc/threads.pxd +234 -0
  173. Cython/Includes/libc/time.pxd +52 -0
  174. Cython/Includes/libcpp/__init__.pxd +4 -0
  175. Cython/Includes/libcpp/algorithm.pxd +320 -0
  176. Cython/Includes/libcpp/any.pxd +16 -0
  177. Cython/Includes/libcpp/atomic.pxd +59 -0
  178. Cython/Includes/libcpp/barrier.pxd +22 -0
  179. Cython/Includes/libcpp/bit.pxd +29 -0
  180. Cython/Includes/libcpp/cast.pxd +12 -0
  181. Cython/Includes/libcpp/cmath.pxd +518 -0
  182. Cython/Includes/libcpp/complex.pxd +106 -0
  183. Cython/Includes/libcpp/condition_variable.pxd +322 -0
  184. Cython/Includes/libcpp/deque.pxd +165 -0
  185. Cython/Includes/libcpp/exception.pxd +216 -0
  186. Cython/Includes/libcpp/execution.pxd +15 -0
  187. Cython/Includes/libcpp/forward_list.pxd +63 -0
  188. Cython/Includes/libcpp/functional.pxd +26 -0
  189. Cython/Includes/libcpp/future.pxd +103 -0
  190. Cython/Includes/libcpp/iterator.pxd +34 -0
  191. Cython/Includes/libcpp/latch.pxd +17 -0
  192. Cython/Includes/libcpp/limits.pxd +61 -0
  193. Cython/Includes/libcpp/list.pxd +117 -0
  194. Cython/Includes/libcpp/map.pxd +252 -0
  195. Cython/Includes/libcpp/memory.pxd +115 -0
  196. Cython/Includes/libcpp/mutex.pxd +387 -0
  197. Cython/Includes/libcpp/numbers.pxd +15 -0
  198. Cython/Includes/libcpp/numeric.pxd +131 -0
  199. Cython/Includes/libcpp/optional.pxd +34 -0
  200. Cython/Includes/libcpp/pair.pxd +1 -0
  201. Cython/Includes/libcpp/queue.pxd +25 -0
  202. Cython/Includes/libcpp/random.pxd +166 -0
  203. Cython/Includes/libcpp/semaphore.pxd +43 -0
  204. Cython/Includes/libcpp/set.pxd +228 -0
  205. Cython/Includes/libcpp/shared_mutex.pxd +96 -0
  206. Cython/Includes/libcpp/span.pxd +87 -0
  207. Cython/Includes/libcpp/stack.pxd +11 -0
  208. Cython/Includes/libcpp/stop_token.pxd +117 -0
  209. Cython/Includes/libcpp/string.pxd +355 -0
  210. Cython/Includes/libcpp/string_view.pxd +183 -0
  211. Cython/Includes/libcpp/typeindex.pxd +15 -0
  212. Cython/Includes/libcpp/typeinfo.pxd +10 -0
  213. Cython/Includes/libcpp/unordered_map.pxd +193 -0
  214. Cython/Includes/libcpp/unordered_set.pxd +152 -0
  215. Cython/Includes/libcpp/utility.pxd +30 -0
  216. Cython/Includes/libcpp/vector.pxd +186 -0
  217. Cython/Includes/numpy/math.pxd +150 -0
  218. Cython/Includes/openmp.pxd +50 -0
  219. Cython/Includes/posix/__init__.pxd +1 -0
  220. Cython/Includes/posix/dlfcn.pxd +14 -0
  221. Cython/Includes/posix/fcntl.pxd +86 -0
  222. Cython/Includes/posix/ioctl.pxd +4 -0
  223. Cython/Includes/posix/mman.pxd +101 -0
  224. Cython/Includes/posix/resource.pxd +57 -0
  225. Cython/Includes/posix/select.pxd +21 -0
  226. Cython/Includes/posix/signal.pxd +73 -0
  227. Cython/Includes/posix/stat.pxd +98 -0
  228. Cython/Includes/posix/stdio.pxd +37 -0
  229. Cython/Includes/posix/stdlib.pxd +29 -0
  230. Cython/Includes/posix/strings.pxd +9 -0
  231. Cython/Includes/posix/time.pxd +71 -0
  232. Cython/Includes/posix/types.pxd +30 -0
  233. Cython/Includes/posix/uio.pxd +26 -0
  234. Cython/Includes/posix/unistd.pxd +271 -0
  235. Cython/Includes/posix/wait.pxd +38 -0
  236. Cython/LZSS.py +184 -0
  237. Cython/Plex/Actions.pxd +24 -0
  238. Cython/Plex/Actions.py +119 -0
  239. Cython/Plex/DFA.pxd +14 -0
  240. Cython/Plex/DFA.py +164 -0
  241. Cython/Plex/Errors.py +48 -0
  242. Cython/Plex/Lexicons.py +178 -0
  243. Cython/Plex/Machines.pxd +36 -0
  244. Cython/Plex/Machines.py +238 -0
  245. Cython/Plex/Regexps.py +535 -0
  246. Cython/Plex/Scanners.pxd +45 -0
  247. Cython/Plex/Scanners.py +328 -0
  248. Cython/Plex/Transitions.pxd +14 -0
  249. Cython/Plex/Transitions.py +239 -0
  250. Cython/Plex/__init__.py +34 -0
  251. Cython/Runtime/__init__.py +1 -0
  252. Cython/Runtime/refnanny.pyx +237 -0
  253. Cython/Shadow.py +1172 -0
  254. Cython/StringIOTree.py +169 -0
  255. Cython/Tempita/__init__.py +4 -0
  256. Cython/Tempita/_looper.py +154 -0
  257. Cython/Tempita/_tempita.py +1087 -0
  258. Cython/TestUtils.py +472 -0
  259. Cython/Tests/TestCodeWriter.py +128 -0
  260. Cython/Tests/TestCythonUtils.py +237 -0
  261. Cython/Tests/TestJediTyper.py +223 -0
  262. Cython/Tests/TestShadow.py +125 -0
  263. Cython/Tests/TestStringIOTree.py +68 -0
  264. Cython/Tests/TestTestUtils.py +89 -0
  265. Cython/Tests/__init__.py +1 -0
  266. Cython/Tests/xmlrunner.py +390 -0
  267. Cython/Utility/AsyncGen.c +1152 -0
  268. Cython/Utility/Buffer.c +866 -0
  269. Cython/Utility/BufferFormatFromTypeInfo.pxd +2 -0
  270. Cython/Utility/Builtins.c +1068 -0
  271. Cython/Utility/CConvert.pyx +153 -0
  272. Cython/Utility/CMath.c +104 -0
  273. Cython/Utility/CommonStructures.c +244 -0
  274. Cython/Utility/Complex.c +378 -0
  275. Cython/Utility/Coroutine.c +2344 -0
  276. Cython/Utility/CpdefEnums.pyx +119 -0
  277. Cython/Utility/CppConvert.pyx +284 -0
  278. Cython/Utility/CppSupport.cpp +151 -0
  279. Cython/Utility/CythonFunction.c +2143 -0
  280. Cython/Utility/Dataclasses.c +101 -0
  281. Cython/Utility/Embed.c +129 -0
  282. Cython/Utility/Exceptions.c +1331 -0
  283. Cython/Utility/Exceptions_Cy.pyx +109 -0
  284. Cython/Utility/ExtensionTypes.c +1199 -0
  285. Cython/Utility/FunctionArguments.c +1052 -0
  286. Cython/Utility/FusedFunction.pyx +44 -0
  287. Cython/Utility/ImportExport.c +972 -0
  288. Cython/Utility/MatchCase.c +985 -0
  289. Cython/Utility/MatchCase_Cy.pyx +12 -0
  290. Cython/Utility/MemoryView.pxd +108 -0
  291. Cython/Utility/MemoryView.pyx +1499 -0
  292. Cython/Utility/MemoryView_C.c +1056 -0
  293. Cython/Utility/ModuleSetupCode.c +3349 -0
  294. Cython/Utility/NumpyImportArray.c +46 -0
  295. Cython/Utility/ObjectHandling.c +3404 -0
  296. Cython/Utility/Optimize.c +2575 -0
  297. Cython/Utility/Overflow.c +378 -0
  298. Cython/Utility/Profile.c +736 -0
  299. Cython/Utility/StringTools.c +1534 -0
  300. Cython/Utility/Synchronization.c +438 -0
  301. Cython/Utility/TString.c +369 -0
  302. Cython/Utility/TestCyUtilityLoader.pyx +8 -0
  303. Cython/Utility/TestCythonScope.pyx +75 -0
  304. Cython/Utility/TestUtilityLoader.c +12 -0
  305. Cython/Utility/TypeConversion.c +1588 -0
  306. Cython/Utility/UFuncs.pyx +50 -0
  307. Cython/Utility/UFuncs_C.c +89 -0
  308. Cython/Utility/__init__.py +28 -0
  309. Cython/Utility/arrayarray.h +190 -0
  310. Cython/Utils.py +682 -0
  311. Cython/__init__.py +12 -0
  312. Cython/py.typed +0 -0
  313. cython.py +29 -0
  314. oxython-0.1.0.dist-info/METADATA +138 -0
  315. oxython-0.1.0.dist-info/RECORD +321 -0
  316. oxython-0.1.0.dist-info/WHEEL +5 -0
  317. oxython-0.1.0.dist-info/entry_points.txt +4 -0
  318. oxython-0.1.0.dist-info/top_level.txt +3 -0
  319. pyximport/__init__.py +4 -0
  320. pyximport/pyxbuild.py +160 -0
  321. pyximport/pyximport.py +482 -0
@@ -0,0 +1,2143 @@
1
+ //////////////////// CythonFunctionPerModule.module_state_decls ////////////////////
2
+
3
+ PyTypeObject *__pyx_CyFunctionType;
4
+
5
+ //////////////////// CythonFunctionPerModule.module_state_traverse ///////////////////
6
+
7
+ Py_VISIT(traverse_module_state->__pyx_CyFunctionType);
8
+
9
+ //////////////////// CythonFunctionPerModule.module_state_clear ///////////////////
10
+
11
+ Py_CLEAR(clear_module_state->__pyx_CyFunctionType);
12
+
13
+ //////////////////// CythonFunctionPerModule.init //////////////////
14
+ //@substitute: naming
15
+ //@init_block: init_after_shared_utility
16
+
17
+ if (likely(__pyx_CyFunction_init($module_cname) == 0)); else
18
+
19
+ //////////////////// CythonFunctionPerModule.proto //////////////////////////
20
+ // This section always gets included whether we're using CythonFunction through
21
+ // shared utility code or not.
22
+ //@requires: ModuleSetupCode.c::FastTypeChecks
23
+
24
+ #define __Pyx_CyFunction_USED
25
+
26
+ #if CYTHON_OPAQUE_SHARED_TYPES
27
+ #define __Pyx_as_CyFunctionObject(o) ((__pyx_CyFunctionObject *)PyObject_GetTypeData((o), CGLOBAL(__pyx_CyFunctionType)))
28
+ #else
29
+ #define __Pyx_as_CyFunctionObject(o) ((__pyx_CyFunctionObject *)o)
30
+ #endif
31
+
32
+ #define __Pyx_CYFUNCTION_STATICMETHOD 0x01
33
+ #define __Pyx_CYFUNCTION_CLASSMETHOD 0x02
34
+ #define __Pyx_CYFUNCTION_CCLASS 0x04
35
+ #define __Pyx_CYFUNCTION_COROUTINE 0x08
36
+
37
+ #define __Pyx_CyFunction_GetClosure(f) \
38
+ ((__Pyx_as_CyFunctionObject(f))->func_closure)
39
+
40
+ // These macros are intended to be used within this utility code
41
+ // as both rvalues and lvalues. They take a __pyx_CyFunctionObject pointer.
42
+ #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_GRAAL
43
+ #define __Pyx_CyFunction_ClassObj(f) \
44
+ ((f)->func_classobj)
45
+ #define __Pyx_CyFunction_MethodDef(cyfunc) ((cyfunc)->func_methoddef)
46
+ #define __Pyx_CyFunction_Module(cyfunc) ((cyfunc)->func_module)
47
+ #else
48
+ #define __Pyx_CyFunction_ClassObj(f) \
49
+ (((PyCMethodObject *) (f))->mm_class)
50
+ #define __Pyx_CyFunction_MethodDef(cyfunc) (((PyCFunctionObject*)(cyfunc))->m_ml)
51
+ #define __Pyx_CyFunction_Module(cyfunc) (((PyCFunctionObject*)(cyfunc))->m_module)
52
+ #endif
53
+
54
+ #define __Pyx_CyFunction_GetClassObj(f) \
55
+ ((PyObject*)__Pyx_CyFunction_ClassObj(__Pyx_as_CyFunctionObject(f)))
56
+ #define __Pyx_CyFunction_SetClassObj(f, classobj) \
57
+ __Pyx__CyFunction_SetClassObj(__Pyx_as_CyFunctionObject(f), (classobj))
58
+
59
+ #define __Pyx_CyFunction_Defaults(type, f) \
60
+ ((type *)((__Pyx_as_CyFunctionObject(f))->defaults))
61
+ #define __Pyx_CyFunction_SetDefaultsGetter(f, g) \
62
+ (__Pyx_as_CyFunctionObject(f))->defaults_getter = (g)
63
+
64
+ typedef struct {
65
+ #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_GRAAL
66
+ #if !CYTHON_OPAQUE_OBJECTS
67
+ PyObject_HEAD
68
+ #endif
69
+ PyMethodDef *func_methoddef;
70
+ PyObject *func_module;
71
+ #else
72
+ // PEP-573: PyCFunctionObject + mm_class
73
+ PyCMethodObject func;
74
+ #endif
75
+ #if (CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_GRAAL) && CYTHON_VECTORCALL
76
+ __pyx_vectorcallfunc func_vectorcall;
77
+ #endif
78
+ #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_GRAAL
79
+ PyObject *func_weakreflist;
80
+ #endif
81
+ #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
82
+ PyObject *func_dict;
83
+ #endif
84
+ PyObject *func_name;
85
+ PyObject *func_qualname;
86
+ PyObject *func_doc;
87
+ PyObject *func_globals;
88
+ PyObject *func_code;
89
+ PyObject *func_closure;
90
+ #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_GRAAL
91
+ // No-args super() class cell
92
+ PyObject *func_classobj;
93
+ #endif
94
+ // Dynamic default args and annotations
95
+ PyObject *defaults;
96
+ int flags;
97
+
98
+ // Defaults info
99
+ PyObject *defaults_tuple; /* Const defaults tuple */
100
+ PyObject *defaults_kwdict; /* Const kwonly defaults dict */
101
+ PyObject *(*defaults_getter)(PyObject *);
102
+ PyObject *func_annotations; /* function annotations dict */
103
+
104
+ #if __PYX_LIMITED_VERSION_HEX < 0x030B0000
105
+ // Coroutine marker
106
+ PyObject *func_is_coroutine;
107
+ #endif
108
+ } __pyx_CyFunctionObject;
109
+
110
+ #undef __Pyx_CyOrPyCFunction_Check
111
+ #define __Pyx_CyFunction_Check(obj) __Pyx_TypeCheck(obj, CGLOBAL(__pyx_CyFunctionType))
112
+ #define __Pyx_CyOrPyCFunction_Check(obj) __Pyx_TypeCheck2(obj, CGLOBAL(__pyx_CyFunctionType), &PyCFunction_Type)
113
+ #define __Pyx_CyFunction_CheckExact(obj) Py_IS_TYPE(obj, CGLOBAL(__pyx_CyFunctionType))
114
+ static CYTHON_INLINE int __Pyx__IsSameCyOrCFunction(PyObject *func, void (*cfunc)(void));/*proto*/
115
+ #undef __Pyx_IsSameCFunction
116
+ #define __Pyx_IsSameCFunction(func, cfunc) __Pyx__IsSameCyOrCFunction(func, cfunc)
117
+
118
+ static CYTHON_INLINE void __Pyx__CyFunction_SetClassObj(__pyx_CyFunctionObject* f, PyObject* classobj);
119
+ static CYTHON_INLINE PyObject *__Pyx_CyFunction_InitDefaults(PyObject *func,
120
+ PyTypeObject *defaults_type);
121
+ static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m,
122
+ PyObject *tuple);
123
+ static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m,
124
+ PyObject *dict);
125
+ static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m,
126
+ PyObject *dict);
127
+
128
+ // Note that the actual definition of __pyx_CyFunction_init is in a different
129
+ // utility code section and depends on if the utility code comes from a
130
+ // shared module.
131
+ static int __pyx_CyFunction_init(PyObject *module);
132
+
133
+ #if CYTHON_VECTORCALL
134
+ #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_GRAAL
135
+ #define __Pyx_CyFunction_func_vectorcall(f) ((f)->func_vectorcall)
136
+ #else
137
+ #define __Pyx_CyFunction_func_vectorcall(f) (((PyCFunctionObject*)f)->vectorcall)
138
+ #endif
139
+ #endif
140
+
141
+ //////////////////// CythonFunctionPerModule /////////////////////
142
+ //@requires: ObjectHandling.c::CachedMethodType
143
+
144
+ #if CYTHON_OPAQUE_SHARED_TYPES && CYTHON_USE_MODULE_STATE
145
+ // Slower version of "__Pyx_as_CyFunctionObject" that's safe to use in destructors
146
+ // (where the current module may have been lost).
147
+ static __pyx_CyFunctionObject *__Pyx_as_CyFunctionObject_safe(PyObject *o) {
148
+ PyTypeObject *cyfunctype = Py_TYPE(o);
149
+ while (1) {
150
+ PyTypeObject *base = (PyTypeObject *)PyType_GetSlot(cyfunctype, Py_tp_base);
151
+ if (base == &PyBaseObject_Type || base == NULL) {
152
+ break;
153
+ }
154
+ cyfunctype = base;
155
+ }
156
+ return (__pyx_CyFunctionObject *)PyObject_GetTypeData((o), cyfunctype);
157
+ }
158
+ #else
159
+ #define __Pyx_as_CyFunctionObject_safe __Pyx_as_CyFunctionObject
160
+ #endif
161
+
162
+ #if CYTHON_COMPILING_IN_LIMITED_API
163
+ static CYTHON_INLINE int __Pyx__IsSameCyOrCFunctionNoMethod(PyObject *func, void (*cfunc)(void)) {
164
+ if (__Pyx_CyFunction_Check(func)) {
165
+ return __Pyx_CyFunction_MethodDef(__Pyx_as_CyFunctionObject(func))->ml_meth == (PyCFunction) cfunc;
166
+ } else if (PyCFunction_Check(func)) {
167
+ return PyCFunction_GetFunction(func) == (PyCFunction) cfunc;
168
+ }
169
+ return 0;
170
+ }
171
+
172
+ static CYTHON_INLINE int __Pyx__IsSameCyOrCFunction(PyObject *func, void (*cfunc)(void)) {
173
+ if ((PyObject*)Py_TYPE(func) == CGLOBAL(__Pyx_CachedMethodType)) {
174
+ int result;
175
+ PyObject *newFunc = PyObject_GetAttr(func, PYIDENT("__func__"));
176
+ if (unlikely(!newFunc)) {
177
+ PyErr_Clear(); // It's only an optimization, so don't throw an error
178
+ return 0;
179
+ }
180
+ result = __Pyx__IsSameCyOrCFunctionNoMethod(newFunc, cfunc);
181
+ Py_DECREF(newFunc);
182
+ return result;
183
+ }
184
+ return __Pyx__IsSameCyOrCFunctionNoMethod(func, cfunc);
185
+ }
186
+ #else
187
+ static CYTHON_INLINE int __Pyx__IsSameCyOrCFunction(PyObject *func, void (*cfunc)(void)) {
188
+ if (PyMethod_Check(func)) {
189
+ func = PyMethod_GET_FUNCTION(func);
190
+ }
191
+ return __Pyx_CyOrPyCFunction_Check(func) && __Pyx_CyOrPyCFunction_GET_FUNCTION(func) == (PyCFunction) cfunc;
192
+ }
193
+ #endif
194
+
195
+ static CYTHON_INLINE void __Pyx__CyFunction_SetClassObj(__pyx_CyFunctionObject* f, PyObject* classobj) {
196
+ #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_GRAAL
197
+ __Pyx_Py_XDECREF_SET(
198
+ __Pyx_CyFunction_ClassObj(f),
199
+ ((classobj) ? __Pyx_NewRef(classobj) : NULL));
200
+ #else
201
+ __Pyx_Py_XDECREF_SET(
202
+ // assigning to "mm_class", which is a "PyTypeObject*"
203
+ ((PyCMethodObject *) (f))->mm_class,
204
+ (PyTypeObject*)((classobj) ? __Pyx_NewRef(classobj) : NULL));
205
+ #endif
206
+ }
207
+
208
+ static CYTHON_INLINE PyObject *__Pyx_CyFunction_InitDefaults(PyObject *func, PyTypeObject *defaults_type) {
209
+ __pyx_CyFunctionObject *m = __Pyx_as_CyFunctionObject(func);
210
+
211
+ m->defaults = PyObject_CallObject((PyObject*)defaults_type, NULL); // _PyObject_New(defaults_type);
212
+ if (unlikely(!m->defaults))
213
+ return NULL;
214
+ return m->defaults;
215
+ }
216
+
217
+ static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
218
+ __pyx_CyFunctionObject *m = __Pyx_as_CyFunctionObject(func);
219
+ m->defaults_tuple = tuple;
220
+ Py_INCREF(tuple);
221
+ }
222
+
223
+ static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) {
224
+ __pyx_CyFunctionObject *m = __Pyx_as_CyFunctionObject(func);
225
+ m->defaults_kwdict = dict;
226
+ Py_INCREF(dict);
227
+ }
228
+
229
+ static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) {
230
+ __pyx_CyFunctionObject *m = __Pyx_as_CyFunctionObject(func);
231
+ m->func_annotations = dict;
232
+ Py_INCREF(dict);
233
+ }
234
+
235
+ //////////////////// CythonFunctionFromSharedModule /////////////////
236
+ //@requires: CythonFunctionPerModule
237
+ //@requires: CythonFunction
238
+ //@requires: CommonStructures.c::VerifyCachedType
239
+ //@substitute: naming
240
+
241
+ // Cutdown version that's only used when importing from shared utility code
242
+ static int __pyx_CyFunction_init(PyObject *module) {
243
+ $modulestatetype_cname *mstate = __Pyx_PyModule_GetState(module);
244
+ if (mstate->__pyx_CyFunctionType != NULL) {
245
+ return 0;
246
+ }
247
+
248
+ PyTypeObject *tp = __Pyx_Get_CyFunction_Type();
249
+ if (!tp) return -1;
250
+
251
+ if (__Pyx_VerifyCachedType((PyObject*)tp,
252
+ __PYX_TYPE_MODULE_PREFIX "cython_function_or_method",
253
+ __PYX_SHARED_SIZEOF(__pyx_CyFunctionObject)) != 0) {
254
+ Py_DECREF((PyObject*)tp);
255
+ return -1;
256
+ }
257
+
258
+ mstate->__pyx_CyFunctionType = tp;
259
+ return 0;
260
+ }
261
+
262
+ //////////////////// CythonFunctionShared.proto ////////////////////
263
+ //@requires: CythonFunctionPerModule
264
+
265
+ static PyObject *__Pyx_CyFunction_Init(PyObject *op_in, PyMethodDef *ml,
266
+ int flags, PyObject* qualname,
267
+ PyObject *closure,
268
+ PyObject *module, PyObject *globals,
269
+ PyObject* code);
270
+
271
+ #if CYTHON_VECTORCALL
272
+ static PyObject * __Pyx_CyFunction_Vectorcall_NOARGS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames);
273
+ static PyObject * __Pyx_CyFunction_Vectorcall_O(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames);
274
+ static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames);
275
+ static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS_METHOD(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames);
276
+ #endif
277
+
278
+ //////////////////// CythonFunctionShared ////////////////////
279
+ //@requires: CommonStructures.c::FetchCommonType
280
+ //@requires: CommonStructures.c::CommonTypesMetaclass
281
+ //@requires: ObjectHandling.c::PyMethodNew
282
+ //@requires: ObjectHandling.c::PyVectorcallFastCallDict
283
+ //@requires: Exceptions.c::IgnoreException
284
+ //@requires: ModuleSetupCode.c::FastTypeChecks
285
+ //@requires: ModuleSetupCode.c::IncludeStructmemberH
286
+ //@requires: ObjectHandling.c::PyObjectGetAttrStr
287
+ //@requires: ObjectHandling.c::PyObjectCallOneArg
288
+ //@requires: ExtensionTypes.c::CallTypeTraverse
289
+ //@requires: Synchronization.c::CriticalSections
290
+ //@substitute: naming
291
+
292
+ static PyObject *
293
+ __Pyx_CyFunction_get_doc_locked(__pyx_CyFunctionObject *op)
294
+ {
295
+ if (unlikely(op->func_doc == NULL)) {
296
+ const char *doc = __Pyx_CyFunction_MethodDef(op)->ml_doc;
297
+ if (doc) {
298
+ op->func_doc = PyUnicode_FromString(doc);
299
+ if (unlikely(op->func_doc == NULL))
300
+ return NULL;
301
+ } else {
302
+ Py_INCREF(Py_None);
303
+ return Py_None;
304
+ }
305
+ }
306
+ Py_INCREF(op->func_doc);
307
+ return op->func_doc;
308
+ }
309
+
310
+ static PyObject *
311
+ __Pyx_CyFunction_get_doc(PyObject *op_in, void *closure) {
312
+ PyObject *result;
313
+ __pyx_CyFunctionObject *op = __Pyx_as_CyFunctionObject(op_in);
314
+ CYTHON_UNUSED_VAR(closure);
315
+ __Pyx_BEGIN_CRITICAL_SECTION(op_in);
316
+ result = __Pyx_CyFunction_get_doc_locked(op);
317
+ __Pyx_END_CRITICAL_SECTION();
318
+ return result;
319
+ }
320
+
321
+ static int
322
+ __Pyx_CyFunction_set_doc(PyObject *op_in, PyObject *value, void *context)
323
+ {
324
+ __pyx_CyFunctionObject *op = __Pyx_as_CyFunctionObject(op_in);
325
+ CYTHON_UNUSED_VAR(context);
326
+ if (value == NULL) {
327
+ // Mark as deleted
328
+ value = Py_None;
329
+ }
330
+ Py_INCREF(value);
331
+ __Pyx_BEGIN_CRITICAL_SECTION(op_in);
332
+ __Pyx_Py_XDECREF_SET(op->func_doc, value);
333
+ __Pyx_END_CRITICAL_SECTION();
334
+ return 0;
335
+ }
336
+
337
+ static PyObject *
338
+ __Pyx_CyFunction_get_name_locked(__pyx_CyFunctionObject *op)
339
+ {
340
+ if (unlikely(op->func_name == NULL)) {
341
+ const char *name = __Pyx_CyFunction_MethodDef(op)->ml_name;
342
+ op->func_name = PyUnicode_InternFromString(name);
343
+ if (unlikely(op->func_name == NULL))
344
+ return NULL;
345
+ }
346
+ Py_INCREF(op->func_name);
347
+ return op->func_name;
348
+ }
349
+
350
+ static PyObject *
351
+ __Pyx_CyFunction_get_name(PyObject *op, void *context)
352
+ {
353
+ PyObject *result = NULL;
354
+ CYTHON_UNUSED_VAR(context);
355
+ __Pyx_BEGIN_CRITICAL_SECTION(op);
356
+ result = __Pyx_CyFunction_get_name_locked(__Pyx_as_CyFunctionObject(op));
357
+ __Pyx_END_CRITICAL_SECTION();
358
+ return result;
359
+ }
360
+
361
+ static int
362
+ __Pyx_CyFunction_set_name(PyObject *op_in, PyObject *value, void *context)
363
+ {
364
+ CYTHON_UNUSED_VAR(context);
365
+ if (unlikely(value == NULL || !PyUnicode_Check(value))) {
366
+ PyErr_SetString(PyExc_TypeError,
367
+ "__name__ must be set to a string object");
368
+ return -1;
369
+ }
370
+ __pyx_CyFunctionObject *op = __Pyx_as_CyFunctionObject(op_in);
371
+ Py_INCREF(value);
372
+ __Pyx_BEGIN_CRITICAL_SECTION(op_in);
373
+ __Pyx_Py_XDECREF_SET(op->func_name, value);
374
+ __Pyx_END_CRITICAL_SECTION();
375
+ return 0;
376
+ }
377
+
378
+ static PyObject *
379
+ __Pyx_CyFunction_get_qualname(PyObject *op_in, void *context)
380
+ {
381
+ CYTHON_UNUSED_VAR(context);
382
+ __pyx_CyFunctionObject *op = __Pyx_as_CyFunctionObject(op_in);
383
+ PyObject *result;
384
+ __Pyx_BEGIN_CRITICAL_SECTION(op_in);
385
+ Py_INCREF(op->func_qualname);
386
+ result = op->func_qualname;
387
+ __Pyx_END_CRITICAL_SECTION();
388
+ return result;
389
+ }
390
+
391
+ static int
392
+ __Pyx_CyFunction_set_qualname(PyObject *op_in, PyObject *value, void *context)
393
+ {
394
+ CYTHON_UNUSED_VAR(context);
395
+ if (unlikely(value == NULL || !PyUnicode_Check(value))) {
396
+ PyErr_SetString(PyExc_TypeError,
397
+ "__qualname__ must be set to a string object");
398
+ return -1;
399
+ }
400
+ __pyx_CyFunctionObject *op = __Pyx_as_CyFunctionObject(op_in);
401
+ Py_INCREF(value);
402
+ __Pyx_BEGIN_CRITICAL_SECTION(op_in);
403
+ __Pyx_Py_XDECREF_SET(op->func_qualname, value);
404
+ __Pyx_END_CRITICAL_SECTION();
405
+ return 0;
406
+ }
407
+
408
+ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
409
+ static PyObject *
410
+ __Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op, void *context)
411
+ {
412
+ CYTHON_UNUSED_VAR(context);
413
+ // PyObject_GenericGetDict is not defined
414
+ if (unlikely(op->func_dict == NULL)) {
415
+ op->func_dict = PyDict_New();
416
+ if (unlikely(op->func_dict == NULL))
417
+ return NULL;
418
+ }
419
+ Py_INCREF(op->func_dict);
420
+ return op->func_dict;
421
+ }
422
+ #endif
423
+
424
+ static PyObject *
425
+ __Pyx_CyFunction_get_globals(PyObject *op_in, void *context)
426
+ {
427
+ CYTHON_UNUSED_VAR(context);
428
+ __pyx_CyFunctionObject *op = __Pyx_as_CyFunctionObject(op_in);
429
+ // Globals is read-only so no critical sections
430
+ Py_INCREF(op->func_globals);
431
+ return op->func_globals;
432
+ }
433
+
434
+ static PyObject *
435
+ __Pyx_CyFunction_get_closure(PyObject *op, void *context)
436
+ {
437
+ CYTHON_UNUSED_VAR(op);
438
+ CYTHON_UNUSED_VAR(context);
439
+ Py_INCREF(Py_None);
440
+ return Py_None;
441
+ }
442
+
443
+ static PyObject *
444
+ __Pyx_CyFunction_get_code(PyObject *op_in, void *context)
445
+ {
446
+ // code is read-only so no critical sections
447
+ __pyx_CyFunctionObject *op = __Pyx_as_CyFunctionObject(op_in);
448
+ PyObject* result = (op->func_code) ? op->func_code : Py_None;
449
+ CYTHON_UNUSED_VAR(context);
450
+ Py_INCREF(result);
451
+ return result;
452
+ }
453
+
454
+ static int
455
+ __Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op, PyObject *op_obj) {
456
+ int result = 0;
457
+ PyObject *res = op->defaults_getter(op_obj);
458
+ if (unlikely(!res))
459
+ return -1;
460
+
461
+ // Cache result
462
+ #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
463
+ op->defaults_tuple = PyTuple_GET_ITEM(res, 0);
464
+ Py_INCREF(op->defaults_tuple);
465
+ op->defaults_kwdict = PyTuple_GET_ITEM(res, 1);
466
+ Py_INCREF(op->defaults_kwdict);
467
+ #else
468
+ op->defaults_tuple = __Pyx_PySequence_ITEM(res, 0);
469
+ if (unlikely(!op->defaults_tuple)) result = -1;
470
+ else {
471
+ op->defaults_kwdict = __Pyx_PySequence_ITEM(res, 1);
472
+ if (unlikely(!op->defaults_kwdict)) result = -1;
473
+ }
474
+ #endif
475
+ Py_DECREF(res);
476
+ return result;
477
+ }
478
+
479
+ static int
480
+ __Pyx_CyFunction_set_defaults(PyObject *op_in, PyObject* value, void *context) {
481
+ __pyx_CyFunctionObject *op = __Pyx_as_CyFunctionObject(op_in);
482
+ CYTHON_UNUSED_VAR(context);
483
+ if (!value) {
484
+ // del => explicit None to prevent rebuilding
485
+ value = Py_None;
486
+ } else if (unlikely(value != Py_None && !PyTuple_Check(value))) {
487
+ PyErr_SetString(PyExc_TypeError,
488
+ "__defaults__ must be set to a tuple object");
489
+ return -1;
490
+ }
491
+ PyErr_WarnEx(PyExc_RuntimeWarning, "changes to cyfunction.__defaults__ will not "
492
+ "currently affect the values used in function calls", 1);
493
+ Py_INCREF(value);
494
+ __Pyx_BEGIN_CRITICAL_SECTION(op_in);
495
+ __Pyx_Py_XDECREF_SET(op->defaults_tuple, value);
496
+ __Pyx_END_CRITICAL_SECTION();
497
+ return 0;
498
+ }
499
+
500
+ static PyObject *
501
+ __Pyx_CyFunction_get_defaults_locked(PyObject *op_in) {
502
+ __pyx_CyFunctionObject *op = __Pyx_as_CyFunctionObject(op_in);
503
+ PyObject* result = op->defaults_tuple;
504
+ if (unlikely(!result)) {
505
+ if (op->defaults_getter) {
506
+ if (unlikely(__Pyx_CyFunction_init_defaults(op, op_in) < 0)) return NULL;
507
+ result = op->defaults_tuple;
508
+ } else {
509
+ result = Py_None;
510
+ }
511
+ }
512
+ Py_INCREF(result);
513
+ return result;
514
+ }
515
+
516
+ static PyObject *
517
+ __Pyx_CyFunction_get_defaults(PyObject *op, void *context) {
518
+ PyObject* result = NULL;
519
+ CYTHON_UNUSED_VAR(context);
520
+ __Pyx_BEGIN_CRITICAL_SECTION(op);
521
+ result = __Pyx_CyFunction_get_defaults_locked(op);
522
+ __Pyx_END_CRITICAL_SECTION();
523
+ return result;
524
+ }
525
+
526
+ static int
527
+ __Pyx_CyFunction_set_kwdefaults(PyObject *op_in, PyObject* value, void *context) {
528
+ __pyx_CyFunctionObject *op = __Pyx_as_CyFunctionObject(op_in);
529
+ CYTHON_UNUSED_VAR(context);
530
+ if (!value) {
531
+ // del => explicit None to prevent rebuilding
532
+ value = Py_None;
533
+ } else if (unlikely(value != Py_None && !PyDict_Check(value))) {
534
+ PyErr_SetString(PyExc_TypeError,
535
+ "__kwdefaults__ must be set to a dict object");
536
+ return -1;
537
+ }
538
+ PyErr_WarnEx(PyExc_RuntimeWarning, "changes to cyfunction.__kwdefaults__ will not "
539
+ "currently affect the values used in function calls", 1);
540
+ Py_INCREF(value);
541
+ __Pyx_BEGIN_CRITICAL_SECTION(op_in);
542
+ __Pyx_Py_XDECREF_SET(op->defaults_kwdict, value);
543
+ __Pyx_END_CRITICAL_SECTION();
544
+ return 0;
545
+ }
546
+
547
+ static PyObject *
548
+ __Pyx_CyFunction_get_kwdefaults_locked(PyObject *op_in) {
549
+ __pyx_CyFunctionObject *op = __Pyx_as_CyFunctionObject(op_in);
550
+ PyObject* result = op->defaults_kwdict;
551
+ if (unlikely(!result)) {
552
+ if (op->defaults_getter) {
553
+ if (unlikely(__Pyx_CyFunction_init_defaults(op, op_in) < 0)) return NULL;
554
+ result = op->defaults_kwdict;
555
+ } else {
556
+ result = Py_None;
557
+ }
558
+ }
559
+ Py_INCREF(result);
560
+ return result;
561
+ }
562
+
563
+ static PyObject *
564
+ __Pyx_CyFunction_get_kwdefaults(PyObject *op, void *context) {
565
+ PyObject* result;
566
+ CYTHON_UNUSED_VAR(context);
567
+ __Pyx_BEGIN_CRITICAL_SECTION(op);
568
+ result = __Pyx_CyFunction_get_kwdefaults_locked(op);
569
+ __Pyx_END_CRITICAL_SECTION();
570
+ return result;
571
+ }
572
+
573
+ static int __Pyx_CyFunction_set_annotate_in_dict_if_exists(PyObject *op_in, PyObject *value); /*proto*/
574
+
575
+ static int
576
+ __Pyx_CyFunction_set_annotations(PyObject *op_in, PyObject* value, void *context) {
577
+ CYTHON_UNUSED_VAR(context);
578
+ if (!value || value == Py_None) {
579
+ value = NULL;
580
+ } else if (unlikely(!PyDict_Check(value))) {
581
+ PyErr_SetString(PyExc_TypeError,
582
+ "__annotations__ must be set to a dict object");
583
+ return -1;
584
+ }
585
+ __pyx_CyFunctionObject *op = __Pyx_as_CyFunctionObject(op_in);
586
+ Py_XINCREF(value);
587
+ __Pyx_BEGIN_CRITICAL_SECTION(op_in);
588
+ __Pyx_Py_XDECREF_SET(op->func_annotations, value);
589
+ __Pyx_END_CRITICAL_SECTION();
590
+ if (unlikely(__Pyx_CyFunction_set_annotate_in_dict_if_exists(op_in, Py_None) < 0)) return -1;
591
+ return 0;
592
+ }
593
+
594
+ static int
595
+ __Pyx_CyFunction_get_dict_if_exists(PyObject *op_in, PyObject **dict) {
596
+ /* Return 1 if the function dict exists, 0 otherwise. This cannot fail:
597
+ * _PyObject_GetDictPtr() may clear errors internally, but never reports them. */
598
+ #if CYTHON_COMPILING_IN_PYPY
599
+ *dict = PyObject_GenericGetDict(op_in, NULL);
600
+ #elif CYTHON_COMPILING_IN_LIMITED_API || PY_VERSION_HEX < 0x030C0000
601
+ *dict = __Pyx_as_CyFunctionObject(op_in)->func_dict;
602
+ #else
603
+ PyObject **dictptr = _PyObject_GetDictPtr(op_in);
604
+ *dict = likely(dictptr) ? *dictptr : NULL;
605
+ #endif
606
+ return *dict ? 1 : 0;
607
+ }
608
+
609
+ static int
610
+ __Pyx_CyFunction_get_annotate_from_dict_if_exists(PyObject *op_in, PyObject **annotate) {
611
+ PyObject *dict;
612
+ int dict_found;
613
+ *annotate = NULL;
614
+ dict_found = __Pyx_CyFunction_get_dict_if_exists(op_in, &dict);
615
+ if (!dict_found) return 0;
616
+ return __Pyx_PyDict_GetItemRef(dict, PYIDENT("__annotate__"), annotate);
617
+ }
618
+
619
+ // if value==NULL, removes annotate from dict.
620
+ static int
621
+ __Pyx_CyFunction_set_annotate_in_dict_if_exists(PyObject *op_in, PyObject *value) {
622
+ PyObject *dict;
623
+ int dict_found;
624
+ dict_found = __Pyx_CyFunction_get_dict_if_exists(op_in, &dict);
625
+ if (!dict_found) return 0;
626
+ if (value) {
627
+ return PyDict_SetItem(dict, PYIDENT("__annotate__"), value);
628
+ } else {
629
+ #if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d0000
630
+ return PyDict_Pop(dict, PYIDENT("__annotate__"), NULL);
631
+ #else
632
+ int result = PyDict_Contains(dict, PYIDENT("__annotate__"));
633
+ if (result == 1) {
634
+ result = PyDict_DelItem(dict, PYIDENT("__annotate__"));
635
+ }
636
+ return result;
637
+ #endif
638
+ }
639
+ }
640
+
641
+ static int
642
+ __Pyx_CyFunction_set_annotate_in_dict(PyObject *op_in, PyObject *value) {
643
+ PyObject *dict;
644
+ int result;
645
+ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
646
+ dict = __Pyx_CyFunction_get_dict(__Pyx_as_CyFunctionObject(op_in), NULL);
647
+ #else
648
+ dict = PyObject_GenericGetDict(op_in, NULL);
649
+ #endif
650
+ if (unlikely(!dict)) return -1;
651
+ result = PyDict_SetItem(dict, PYIDENT("__annotate__"), value);
652
+ Py_DECREF(dict);
653
+ return result;
654
+ }
655
+
656
+ static PyObject *
657
+ __Pyx_CyFunction_get_annotations_locked(__pyx_CyFunctionObject *op) {
658
+ PyObject* result = op->func_annotations;
659
+ if (unlikely(!result)) {
660
+ result = PyDict_New();
661
+ if (unlikely(!result)) return NULL;
662
+ op->func_annotations = result;
663
+ }
664
+ Py_INCREF(result);
665
+ return result;
666
+ }
667
+
668
+ static PyObject *
669
+ __Pyx_CyFunction_get_annotations(PyObject *op_in, void *context) {
670
+ PyObject *annotate = NULL;
671
+ PyObject *result = NULL;
672
+ __pyx_CyFunctionObject *op = __Pyx_as_CyFunctionObject(op_in);
673
+ CYTHON_UNUSED_VAR(context);
674
+ __Pyx_BEGIN_CRITICAL_SECTION(op_in);
675
+ result = __Pyx_XNewRef(op->func_annotations);
676
+ __Pyx_END_CRITICAL_SECTION();
677
+ if (result) return result;
678
+
679
+ if (unlikely(__Pyx_CyFunction_get_annotate_from_dict_if_exists(op_in, &annotate) < 0)) return NULL;
680
+ if (!annotate || annotate == Py_None) {
681
+ Py_XDECREF(annotate);
682
+ __Pyx_BEGIN_CRITICAL_SECTION(op_in);
683
+ result = __Pyx_CyFunction_get_annotations_locked(op);
684
+ __Pyx_END_CRITICAL_SECTION();
685
+ return result;
686
+ }
687
+
688
+ PyObject *format = PyLong_FromLong(1L); // annotationlib.Format.VALUE
689
+ if (likely(format)) {
690
+ if (!Py_EnterRecursiveCall(" cyfunction __annotations__.__get__")) {
691
+ result = __Pyx_PyObject_CallOneArg(annotate, format);
692
+ Py_LeaveRecursiveCall();
693
+ Py_DECREF(format);
694
+ }
695
+ }
696
+ Py_DECREF(annotate);
697
+ if (unlikely(!result)) return NULL;
698
+ if (unlikely(!PyDict_Check(result))) {
699
+ PyErr_SetString(PyExc_TypeError, "__annotate__ must return a dict");
700
+ Py_DECREF(result);
701
+ return NULL;
702
+ }
703
+ __Pyx_BEGIN_CRITICAL_SECTION(op_in);
704
+ __Pyx_Py_XDECREF_SET(op->func_annotations, __Pyx_NewRef(result));
705
+ __Pyx_END_CRITICAL_SECTION();
706
+ return result;
707
+ }
708
+
709
+ static PyObject *__Pyx_CyFunction_annotate_impl(PyObject *self, PyObject *arg) {
710
+ CYTHON_UNUSED_VAR(arg);
711
+ if (unlikely(!self)) {
712
+ PyErr_SetString(PyExc_SystemError, "cython __annotate__ called without 'self' argument");
713
+ return NULL;
714
+ }
715
+ // Although we guard against trivial recursive calls from self.__annotate__ = self.__annotate__
716
+ // we can't guard against all recursive calls.
717
+ PyObject *result;
718
+ if (Py_EnterRecursiveCall(" in cyfunction annotate")) {
719
+ return NULL;
720
+ }
721
+ result = __Pyx_CyFunction_get_annotations(self, NULL);
722
+ Py_LeaveRecursiveCall();
723
+ return result;
724
+ }
725
+
726
+ // We don't yet support PEP649 properly, so __annotate__ is
727
+ // implemented in a minimal way, just so that functools.wraps works.
728
+ static PyObject *
729
+ __Pyx_CyFunction_get_annotate(PyObject *op_in, void *context);
730
+
731
+ static int
732
+ __Pyx_CyFunction_set_annotate(PyObject *op_in, PyObject* value, void *context) {
733
+ CYTHON_UNUSED_VAR(context);
734
+ if (value == NULL) {
735
+ PyErr_SetString(PyExc_TypeError, "__annotate__ cannot be deleted");
736
+ return -1;
737
+ }
738
+ if (unlikely(value != Py_None && !PyCallable_Check(value))) {
739
+ PyErr_SetString(PyExc_TypeError, "__annotate__ must be callable or None");
740
+ return -1;
741
+ }
742
+
743
+ if (unlikely(__Pyx_TypeCheck(value, &PyCFunction_Type))) {
744
+ #if !CYTHON_ASSUME_SAFE_MACROS && !CYTHON_COMPILING_IN_PYPY
745
+ PyCFunction cfunction = PyCFunction_GetFunction(value);
746
+ if (unlikely(!cfunction)) return -1;
747
+ PyObject *value_self = PyCFunction_GetSelf(value);
748
+ if (unlikely(!value_self && PyErr_Occurred())) return -1;
749
+ #else
750
+ PyCFunction cfunction = PyCFunction_GET_FUNCTION(value);
751
+ PyObject *value_self = PyCFunction_GET_SELF(value);
752
+ #endif
753
+ if (cfunction == __Pyx_CyFunction_annotate_impl && value_self == op_in) {
754
+ // We're doing self.__annotate__ == self.__annotate__ somehow.
755
+ // Just clear it from the dictionary to avoid an infinite recursive call.
756
+ return __Pyx_CyFunction_set_annotate_in_dict_if_exists(op_in, NULL);
757
+ }
758
+ }
759
+ if (value != Py_None) {
760
+ __pyx_CyFunctionObject *op = __Pyx_as_CyFunctionObject(op_in);
761
+ __Pyx_BEGIN_CRITICAL_SECTION(op_in);
762
+ Py_CLEAR(op->func_annotations);
763
+ __Pyx_END_CRITICAL_SECTION();
764
+ }
765
+ return __Pyx_CyFunction_set_annotate_in_dict(op_in, value);
766
+ }
767
+
768
+ #if __PYX_LIMITED_VERSION_HEX < 0x030B0000
769
+ static PyObject *
770
+ __Pyx_CyFunction_get_is_coroutine_value(__pyx_CyFunctionObject *op) {
771
+ int is_coroutine = op->flags & __Pyx_CYFUNCTION_COROUTINE;
772
+ if (is_coroutine) {
773
+ PyObject *is_coroutine_value, *module, *fromlist, *marker = PYIDENT("_is_coroutine");
774
+ fromlist = PyList_New(1);
775
+ if (unlikely(!fromlist)) return NULL;
776
+ Py_INCREF(marker);
777
+ #if CYTHON_ASSUME_SAFE_MACROS
778
+ PyList_SET_ITEM(fromlist, 0, marker);
779
+ #else
780
+ if (unlikely(PyList_SetItem(fromlist, 0, marker) < 0)) {
781
+ Py_DECREF(fromlist);
782
+ return NULL;
783
+ }
784
+ #endif
785
+ module = PyImport_ImportModuleLevelObject(PYIDENT("asyncio.coroutines"), NULL, NULL, fromlist, 0);
786
+ Py_DECREF(fromlist);
787
+ if (unlikely(!module)) {
788
+ goto ignore_or_error;
789
+ }
790
+ is_coroutine_value = __Pyx_PyObject_GetAttrStr(module, marker);
791
+ Py_DECREF(module);
792
+ if (likely(is_coroutine_value)) {
793
+ return is_coroutine_value;
794
+ }
795
+ ignore_or_error:
796
+ if (!__Pyx_IgnoreException(PyExc_Exception)) {
797
+ return NULL;
798
+ }
799
+ }
800
+
801
+ return __Pyx_PyBool_FromLong(is_coroutine);
802
+ }
803
+
804
+ static PyObject *
805
+ __Pyx_CyFunction_get_is_coroutine(PyObject *op_in, void *context) {
806
+ __pyx_CyFunctionObject *op = __Pyx_as_CyFunctionObject(op_in);
807
+ PyObject *result;
808
+ CYTHON_UNUSED_VAR(context);
809
+ if (op->func_is_coroutine) {
810
+ return __Pyx_NewRef(op->func_is_coroutine);
811
+ }
812
+
813
+ result = __Pyx_CyFunction_get_is_coroutine_value(op);
814
+ if (unlikely(!result))
815
+ return NULL;
816
+
817
+ __Pyx_BEGIN_CRITICAL_SECTION(op_in);
818
+ // Guard against concurrent initialisation.
819
+ if (op->func_is_coroutine) {
820
+ Py_DECREF(result);
821
+ result = __Pyx_NewRef(op->func_is_coroutine);
822
+ } else {
823
+ op->func_is_coroutine = __Pyx_NewRef(result);
824
+ }
825
+ __Pyx_END_CRITICAL_SECTION();
826
+ return result;
827
+ }
828
+ #endif
829
+
830
+ //static PyObject *
831
+ //__Pyx_CyFunction_get_signature(__pyx_CyFunctionObject *op, void *context) {
832
+ // PyObject *inspect_module, *signature_class, *signature;
833
+ // CYTHON_UNUSED_VAR(context);
834
+ // // from inspect import Signature
835
+ // inspect_module = PyImport_ImportModuleLevelObject(PYIDENT("inspect"), NULL, NULL, NULL, 0);
836
+ // if (unlikely(!inspect_module))
837
+ // goto bad;
838
+ // signature_class = __Pyx_PyObject_GetAttrStr(inspect_module, PYIDENT("Signature"));
839
+ // Py_DECREF(inspect_module);
840
+ // if (unlikely(!signature_class))
841
+ // goto bad;
842
+ // // return Signature.from_function(op)
843
+ // signature = PyObject_CallMethodObjArgs(signature_class, PYIDENT("from_function"), op, NULL);
844
+ // Py_DECREF(signature_class);
845
+ // if (likely(signature))
846
+ // return signature;
847
+ //bad:
848
+ // // make sure we raise an AttributeError from this property on any errors
849
+ // if (!PyErr_ExceptionMatches(PyExc_AttributeError))
850
+ // PyErr_SetString(PyExc_AttributeError, "failed to calculate __signature__");
851
+ // return NULL;
852
+ //}
853
+
854
+ static void __Pyx_CyFunction_raise_argument_count_error(PyObject *func, const char* message, Py_ssize_t size) {
855
+ const char* name = __Pyx_CyFunction_MethodDef(__Pyx_as_CyFunctionObject(func))->ml_name;
856
+ PyErr_Format(PyExc_TypeError,
857
+ "%.200s() %s (%" CYTHON_FORMAT_SSIZE_T "d given)",
858
+ name, message, size);
859
+ }
860
+
861
+ static void __Pyx_CyFunction_raise_type_error(PyObject *func, const char* message) {
862
+ const char* name = __Pyx_CyFunction_MethodDef(__Pyx_as_CyFunctionObject(func))->ml_name;
863
+ PyErr_Format(PyExc_TypeError,
864
+ "%.200s() %s",
865
+ name, message);
866
+ }
867
+
868
+ #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_GRAAL
869
+ // Note - for CyFunction alone it'd be easier to access this as a member
870
+ // rather than a getset. However, that's harder for fused functions
871
+ // where we have to override them again.
872
+ static PyObject *
873
+ __Pyx_CyFunction_get_module(PyObject *op_in, void *context) {
874
+ CYTHON_UNUSED_VAR(context);
875
+ __pyx_CyFunctionObject *op = __Pyx_as_CyFunctionObject(op_in);
876
+ Py_INCREF(op->func_module);
877
+ return op->func_module;
878
+ }
879
+
880
+ static int
881
+ __Pyx_CyFunction_set_module(PyObject *op_in, PyObject* value, void *context) {
882
+ CYTHON_UNUSED_VAR(context);
883
+ __pyx_CyFunctionObject *op = __Pyx_as_CyFunctionObject(op_in);
884
+ if (value == NULL) {
885
+ value = Py_None;
886
+ }
887
+ Py_INCREF(value);
888
+ PyObject *old = op->func_module;
889
+ op->func_module = value;
890
+ Py_DECREF(old);
891
+ return 0;
892
+ }
893
+ #endif
894
+
895
+
896
+ static PyGetSetDef __pyx_CyFunction_getsets[] = {
897
+ {"func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
898
+ {"__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
899
+ {"func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
900
+ {"__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
901
+ {"__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0},
902
+ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
903
+ {"func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)PyObject_GenericSetDict, 0, 0},
904
+ {"__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)PyObject_GenericSetDict, 0, 0},
905
+ #else
906
+ {"func_dict", (getter)PyObject_GenericGetDict, (setter)PyObject_GenericSetDict, 0, 0},
907
+ {"__dict__", (getter)PyObject_GenericGetDict, (setter)PyObject_GenericSetDict, 0, 0},
908
+ #endif
909
+ {"func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
910
+ {"__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
911
+ {"func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
912
+ {"__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
913
+ {"func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
914
+ {"__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
915
+ {"func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
916
+ {"__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
917
+ {"__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0},
918
+ {"__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0},
919
+ {"__annotate__", (getter)__Pyx_CyFunction_get_annotate, (setter)__Pyx_CyFunction_set_annotate, 0, 0},
920
+ #if __PYX_LIMITED_VERSION_HEX < 0x030B0000
921
+ {"_is_coroutine", (getter)__Pyx_CyFunction_get_is_coroutine, 0, 0, 0},
922
+ #endif
923
+ // {"__signature__", (getter)__Pyx_CyFunction_get_signature, 0, 0, 0},
924
+ #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_GRAAL
925
+ {"__module__", (getter)__Pyx_CyFunction_get_module, (setter)__Pyx_CyFunction_set_module, 0, 0},
926
+ #endif
927
+ {0, 0, 0, 0, 0}
928
+ };
929
+
930
+ static PyMemberDef __pyx_CyFunction_members[] = {
931
+ #if !(CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_GRAAL)
932
+ {"__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), 0, 0},
933
+ #endif
934
+ #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
935
+ {"__dictoffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_dict),
936
+ __PYX_SHARED_RELATIVE_OFFSET | READONLY, 0},
937
+ #endif
938
+ #if CYTHON_VECTORCALL
939
+ #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_GRAAL
940
+ {"__vectorcalloffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_vectorcall),
941
+ __PYX_SHARED_RELATIVE_OFFSET | READONLY, 0},
942
+ #else
943
+ {"__vectorcalloffset__", T_PYSSIZET, offsetof(PyCFunctionObject, vectorcall), READONLY, 0},
944
+ #endif
945
+ #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_GRAAL
946
+ {"__weaklistoffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_weakreflist),
947
+ __PYX_SHARED_RELATIVE_OFFSET | READONLY, 0},
948
+ #else
949
+ {"__weaklistoffset__", T_PYSSIZET, offsetof(PyCFunctionObject, m_weakreflist), READONLY, 0},
950
+ #endif
951
+ #endif
952
+ {0, 0, 0, 0, 0}
953
+ };
954
+
955
+ static PyObject *
956
+ __Pyx_CyFunction_reduce(PyObject *m_in, PyObject *args)
957
+ {
958
+ PyObject *result = NULL;
959
+ __pyx_CyFunctionObject *m = __Pyx_as_CyFunctionObject(m_in);
960
+ CYTHON_UNUSED_VAR(args);
961
+ __Pyx_BEGIN_CRITICAL_SECTION(m_in);
962
+ Py_INCREF(m->func_qualname);
963
+ result = m->func_qualname;
964
+ __Pyx_END_CRITICAL_SECTION();
965
+ return result;
966
+ }
967
+
968
+ static PyMethodDef __pyx_CyFunction_methods[] = {
969
+ // Having __annotate_cython__ as an attribute makes it pickleable.
970
+ // Keep it as the first element to make access easier.
971
+ {"__annotate_cython__", __Pyx_CyFunction_annotate_impl, METH_O,
972
+ "Placeholder __annotate__ function to allow 'functools.wraps' to work "
973
+ "on Cython functions."},
974
+ {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_NOARGS, 0},
975
+ {0, 0, 0, 0}
976
+ };
977
+
978
+ // We don't yet support PEP649 properly, so __annotate__ is
979
+ // implemented in a minimal way, just so that functools.wraps works.
980
+ static PyObject *
981
+ __Pyx_CyFunction_get_annotate(PyObject *op_in, void *context) {
982
+ PyObject *annotate = NULL;
983
+ CYTHON_UNUSED_VAR(context);
984
+ if (unlikely(__Pyx_CyFunction_get_annotate_from_dict_if_exists(op_in, &annotate) < 0)) return NULL;
985
+ if (annotate) return annotate;
986
+
987
+ PyObject *method = PyCFunction_New(
988
+ &__pyx_CyFunction_methods[0],
989
+ op_in);
990
+ return method;
991
+ }
992
+
993
+
994
+
995
+ #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_GRAAL
996
+ #define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist)
997
+ #else
998
+ #define __Pyx_CyFunction_weakreflist(cyfunc) (((PyCFunctionObject*)cyfunc)->m_weakreflist)
999
+ #endif
1000
+
1001
+ static PyObject *__Pyx_CyFunction_Init(PyObject *op_in,
1002
+ PyMethodDef *ml, int flags, PyObject* qualname,
1003
+ PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
1004
+ __pyx_CyFunctionObject* op = __Pyx_as_CyFunctionObject(op_in);
1005
+ #if !(CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_GRAAL)
1006
+ PyCFunctionObject *cf = (PyCFunctionObject*) op;
1007
+ #endif
1008
+ if (unlikely(op == NULL))
1009
+ return NULL;
1010
+ __Pyx_CyFunction_MethodDef(op) = ml;
1011
+ Py_XINCREF(module);
1012
+ __Pyx_CyFunction_Module(op) = module;
1013
+ op->flags = flags;
1014
+ __Pyx_CyFunction_weakreflist(op) = NULL;
1015
+ #if !(CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_GRAAL)
1016
+ // This is set for the benefit of __Pyx_CyOrPyCFunction_GET_SELF. It is never reassigned, so
1017
+ // when we know an object is a CyFunction we don't even need to look it up.__Pyx_CyFunction_set_module
1018
+ cf->m_self = (PyObject *) op;
1019
+ #endif
1020
+ Py_XINCREF(closure);
1021
+ op->func_closure = closure;
1022
+ #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
1023
+ op->func_dict = NULL;
1024
+ #endif
1025
+ op->func_name = NULL;
1026
+ Py_INCREF(qualname);
1027
+ op->func_qualname = qualname;
1028
+ op->func_doc = NULL;
1029
+ __Pyx_CyFunction_ClassObj(op) = NULL;
1030
+ op->func_globals = globals;
1031
+ Py_INCREF(op->func_globals);
1032
+ Py_XINCREF(code);
1033
+ op->func_code = code;
1034
+ // Dynamic Default args
1035
+ op->defaults = NULL;
1036
+ op->defaults_tuple = NULL;
1037
+ op->defaults_kwdict = NULL;
1038
+ op->defaults_getter = NULL;
1039
+ op->func_annotations = NULL;
1040
+ #if __PYX_LIMITED_VERSION_HEX < 0x030B0000
1041
+ op->func_is_coroutine = NULL;
1042
+ #endif
1043
+ #if CYTHON_VECTORCALL
1044
+ switch (ml->ml_flags & (METH_VARARGS | METH_FASTCALL | METH_NOARGS | METH_O | METH_KEYWORDS | METH_METHOD)) {
1045
+ case METH_NOARGS:
1046
+ __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_NOARGS;
1047
+ break;
1048
+ case METH_O:
1049
+ __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_O;
1050
+ break;
1051
+ // case METH_FASTCALL is not used
1052
+ case METH_METHOD | METH_FASTCALL | METH_KEYWORDS:
1053
+ __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS_METHOD;
1054
+ break;
1055
+ case METH_FASTCALL | METH_KEYWORDS:
1056
+ __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS;
1057
+ break;
1058
+ // case METH_VARARGS is not used
1059
+ case METH_VARARGS | METH_KEYWORDS:
1060
+ __Pyx_CyFunction_func_vectorcall(op) = NULL;
1061
+ break;
1062
+ default:
1063
+ PyErr_SetString(PyExc_SystemError, "Bad call flags for CyFunction");
1064
+ Py_DECREF(op_in);
1065
+ return NULL;
1066
+ }
1067
+ #endif
1068
+ return op_in;
1069
+ }
1070
+
1071
+ static int __Pyx__CyFunction_clear(__pyx_CyFunctionObject *m)
1072
+ {
1073
+ Py_CLEAR(m->func_closure);
1074
+ Py_CLEAR(__Pyx_CyFunction_Module(m));
1075
+ #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
1076
+ Py_CLEAR(m->func_dict);
1077
+ #elif PY_VERSION_HEX < 0x030d0000
1078
+ _PyObject_ClearManagedDict((PyObject*)m);
1079
+ #else
1080
+ PyObject_ClearManagedDict((PyObject*)m);
1081
+ #endif
1082
+ Py_CLEAR(m->func_name);
1083
+ Py_CLEAR(m->func_qualname);
1084
+ Py_CLEAR(m->func_doc);
1085
+ Py_CLEAR(m->func_globals);
1086
+ Py_CLEAR(m->func_code);
1087
+ Py_CLEAR(__Pyx_CyFunction_ClassObj(m));
1088
+ Py_CLEAR(m->defaults_tuple);
1089
+ Py_CLEAR(m->defaults_kwdict);
1090
+ Py_CLEAR(m->func_annotations);
1091
+ #if __PYX_LIMITED_VERSION_HEX < 0x030B0000
1092
+ Py_CLEAR(m->func_is_coroutine);
1093
+ #endif
1094
+
1095
+ Py_CLEAR(m->defaults);
1096
+
1097
+ return 0;
1098
+ }
1099
+
1100
+ static int
1101
+ __Pyx_CyFunction_clear(PyObject *m)
1102
+ {
1103
+ return __Pyx__CyFunction_clear(__Pyx_as_CyFunctionObject_safe(m));
1104
+ }
1105
+
1106
+ static void __Pyx__CyFunction_dealloc(PyObject *m)
1107
+ {
1108
+ __pyx_CyFunctionObject *cyfunc = __Pyx_as_CyFunctionObject_safe(m);
1109
+ if (__Pyx_CyFunction_weakreflist(cyfunc) != NULL)
1110
+ PyObject_ClearWeakRefs(m);
1111
+ __Pyx__CyFunction_clear(cyfunc);
1112
+ __Pyx_PyHeapTypeObject_GC_Del(m);
1113
+ }
1114
+
1115
+ static void __Pyx_CyFunction_dealloc(PyObject *m)
1116
+ {
1117
+ PyObject_GC_UnTrack(m);
1118
+ __Pyx__CyFunction_dealloc(m);
1119
+ }
1120
+
1121
+ static int __Pyx_CyFunction_traverse(PyObject *m_in, visitproc visit, void *arg)
1122
+ {
1123
+ __pyx_CyFunctionObject *m = __Pyx_as_CyFunctionObject_safe(m_in);
1124
+ {
1125
+ int e = __Pyx_call_type_traverse(m_in, 1, visit, arg);
1126
+ if (e) return e;
1127
+ }
1128
+ Py_VISIT(m->func_closure);
1129
+ Py_VISIT(__Pyx_CyFunction_Module(m));
1130
+ #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
1131
+ Py_VISIT(m->func_dict);
1132
+ #else
1133
+ {
1134
+ int e =
1135
+ #if PY_VERSION_HEX < 0x030d0000
1136
+ _PyObject_VisitManagedDict
1137
+ #else
1138
+ PyObject_VisitManagedDict
1139
+ #endif
1140
+ ((PyObject*)m, visit, arg);
1141
+ if (e != 0) return e;
1142
+ }
1143
+ #endif
1144
+ __Pyx_VISIT_CONST(m->func_name);
1145
+ __Pyx_VISIT_CONST(m->func_qualname);
1146
+ Py_VISIT(m->func_doc);
1147
+ Py_VISIT(m->func_globals);
1148
+ // The code objects that we generate only contain plain constants and can never participate in reference cycles.
1149
+ __Pyx_VISIT_CONST(m->func_code);
1150
+ Py_VISIT(__Pyx_CyFunction_ClassObj(m));
1151
+ Py_VISIT(m->defaults_tuple);
1152
+ Py_VISIT(m->defaults_kwdict);
1153
+ Py_VISIT(m->func_annotations);
1154
+ #if __PYX_LIMITED_VERSION_HEX < 0x030B0000
1155
+ Py_VISIT(m->func_is_coroutine);
1156
+ #endif
1157
+ Py_VISIT(m->defaults);
1158
+
1159
+ return 0;
1160
+ }
1161
+
1162
+ static PyObject*
1163
+ __Pyx_CyFunction_repr(PyObject *op_in)
1164
+ {
1165
+ __pyx_CyFunctionObject *op = __Pyx_as_CyFunctionObject(op_in);
1166
+ PyObject *repr;
1167
+ __Pyx_BEGIN_CRITICAL_SECTION(op_in);
1168
+ repr = PyUnicode_FromFormat("<cyfunction %U at %p>",
1169
+ op->func_qualname, (void *)op);
1170
+ __Pyx_END_CRITICAL_SECTION();
1171
+ return repr;
1172
+ }
1173
+
1174
+ static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) {
1175
+ // originally copied from PyCFunction_Call() in CPython's Objects/methodobject.c
1176
+ PyMethodDef *methoddef = __Pyx_CyFunction_MethodDef(__Pyx_as_CyFunctionObject(func));
1177
+ PyCFunction meth = methoddef->ml_meth;
1178
+ int flags = methoddef->ml_flags;
1179
+ Py_ssize_t size;
1180
+
1181
+ switch (flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) {
1182
+ case METH_VARARGS:
1183
+ if (likely(kw == NULL || PyDict_Size(kw) == 0))
1184
+ return (*meth)(self, arg);
1185
+ break;
1186
+ case METH_VARARGS | METH_KEYWORDS:
1187
+ return (*(PyCFunctionWithKeywords)(void(*)(void))meth)(self, arg, kw);
1188
+ case METH_NOARGS:
1189
+ if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
1190
+ #if CYTHON_ASSUME_SAFE_SIZE
1191
+ size = PyTuple_GET_SIZE(arg);
1192
+ #else
1193
+ size = PyTuple_Size(arg);
1194
+ if (unlikely(size < 0)) return NULL;
1195
+ #endif
1196
+ if (likely(size == 0))
1197
+ return (*meth)(self, NULL);
1198
+ __Pyx_CyFunction_raise_argument_count_error(
1199
+ func,
1200
+ "takes no arguments", size);
1201
+ return NULL;
1202
+ }
1203
+ break;
1204
+ case METH_O:
1205
+ if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
1206
+ #if CYTHON_ASSUME_SAFE_SIZE
1207
+ size = PyTuple_GET_SIZE(arg);
1208
+ #else
1209
+ size = PyTuple_Size(arg);
1210
+ if (unlikely(size < 0)) return NULL;
1211
+ #endif
1212
+ if (likely(size == 1)) {
1213
+ PyObject *result, *arg0;
1214
+ #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
1215
+ arg0 = PyTuple_GET_ITEM(arg, 0);
1216
+ #else
1217
+ arg0 = __Pyx_PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL;
1218
+ #endif
1219
+ result = (*meth)(self, arg0);
1220
+ #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
1221
+ Py_DECREF(arg0);
1222
+ #endif
1223
+ return result;
1224
+ }
1225
+ __Pyx_CyFunction_raise_argument_count_error(
1226
+ func,
1227
+ "takes exactly one argument", size);
1228
+ return NULL;
1229
+ }
1230
+ break;
1231
+ default:
1232
+ PyErr_SetString(PyExc_SystemError, "Bad call flags for CyFunction");
1233
+ return NULL;
1234
+ }
1235
+ __Pyx_CyFunction_raise_type_error(
1236
+ func, "takes no keyword arguments");
1237
+ return NULL;
1238
+ }
1239
+
1240
+ static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
1241
+ PyObject *result;
1242
+ result = __Pyx_CyFunction_CallMethod(func, func, arg, kw);
1243
+ return result;
1244
+ }
1245
+
1246
+ static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) {
1247
+ PyObject *result;
1248
+ __pyx_CyFunctionObject *cyfunc = __Pyx_as_CyFunctionObject(func);
1249
+
1250
+ #if CYTHON_VECTORCALL
1251
+ // Prefer vectorcall if available. This is not the typical case, as
1252
+ // CPython would normally use vectorcall directly instead of tp_call.
1253
+ __pyx_vectorcallfunc vc = __Pyx_CyFunction_func_vectorcall(cyfunc);
1254
+ if (vc) {
1255
+ #if CYTHON_ASSUME_SAFE_MACROS && CYTHON_ASSUME_SAFE_SIZE
1256
+ return __Pyx_PyVectorcall_FastCallDict(func, vc, &PyTuple_GET_ITEM(args, 0), (size_t)PyTuple_GET_SIZE(args), kw);
1257
+ #else
1258
+ // avoid unused function warning
1259
+ (void) &__Pyx_PyVectorcall_FastCallDict;
1260
+ return PyVectorcall_Call(func, args, kw);
1261
+ #endif
1262
+ }
1263
+ #endif
1264
+
1265
+ if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) {
1266
+ Py_ssize_t argc;
1267
+ PyObject *new_args;
1268
+ PyObject *self;
1269
+
1270
+ #if CYTHON_ASSUME_SAFE_SIZE
1271
+ argc = PyTuple_GET_SIZE(args);
1272
+ #else
1273
+ argc = PyTuple_Size(args);
1274
+ if (unlikely(argc < 0)) return NULL;
1275
+ #endif
1276
+ new_args = PyTuple_GetSlice(args, 1, argc);
1277
+
1278
+ if (unlikely(!new_args))
1279
+ return NULL;
1280
+
1281
+ self = PyTuple_GetItem(args, 0);
1282
+ if (unlikely(!self)) {
1283
+ Py_DECREF(new_args);
1284
+ PyErr_Format(PyExc_TypeError,
1285
+ "unbound method %.200S() needs an argument",
1286
+ cyfunc->func_qualname);
1287
+ return NULL;
1288
+ }
1289
+
1290
+ result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw);
1291
+ Py_DECREF(new_args);
1292
+ } else {
1293
+ result = __Pyx_CyFunction_Call(func, args, kw);
1294
+ }
1295
+ return result;
1296
+ }
1297
+
1298
+ #if CYTHON_VECTORCALL
1299
+ // Check that kwnames is empty (if you want to allow keyword arguments,
1300
+ // simply pass kwnames=NULL) and figure out what to do with "self".
1301
+ // Return value:
1302
+ // 1: self = args[0]
1303
+ // 0: self = cyfunc->func.m_self
1304
+ // -1: error
1305
+ static CYTHON_INLINE int __Pyx_CyFunction_Vectorcall_CheckArgs(PyObject *func, __pyx_CyFunctionObject *cyfunc, Py_ssize_t nargs, PyObject *kwnames)
1306
+ {
1307
+ int ret = 0;
1308
+ if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) {
1309
+ if (unlikely(nargs < 1)) {
1310
+ __Pyx_CyFunction_raise_type_error(
1311
+ func, "needs an argument");
1312
+ return -1;
1313
+ }
1314
+ ret = 1;
1315
+ }
1316
+ if (unlikely(kwnames) && unlikely(__Pyx_PyTuple_GET_SIZE(kwnames))) {
1317
+ __Pyx_CyFunction_raise_type_error(
1318
+ func, "takes no keyword arguments");
1319
+ return -1;
1320
+ }
1321
+ return ret;
1322
+ }
1323
+
1324
+ static PyObject * __Pyx_CyFunction_Vectorcall_NOARGS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames)
1325
+ {
1326
+ __pyx_CyFunctionObject *cyfunc = __Pyx_as_CyFunctionObject(func);
1327
+ Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
1328
+ PyObject *self;
1329
+ PyCFunction meth = __Pyx_CyFunction_MethodDef(cyfunc)->ml_meth;
1330
+
1331
+ switch (__Pyx_CyFunction_Vectorcall_CheckArgs(func, cyfunc, nargs, kwnames)) {
1332
+ case 1:
1333
+ self = args[0];
1334
+ args += 1;
1335
+ nargs -= 1;
1336
+ break;
1337
+ case 0:
1338
+ self = func;
1339
+ break;
1340
+ default:
1341
+ return NULL;
1342
+ }
1343
+
1344
+ if (unlikely(nargs != 0)) {
1345
+ __Pyx_CyFunction_raise_argument_count_error(
1346
+ func, "takes no arguments", nargs);
1347
+ return NULL;
1348
+ }
1349
+ return meth(self, NULL);
1350
+ }
1351
+
1352
+ static PyObject * __Pyx_CyFunction_Vectorcall_O(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames)
1353
+ {
1354
+ __pyx_CyFunctionObject *cyfunc = __Pyx_as_CyFunctionObject(func);
1355
+ Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
1356
+ PyObject *self;
1357
+ PyCFunction meth = __Pyx_CyFunction_MethodDef(cyfunc)->ml_meth;
1358
+
1359
+ switch (__Pyx_CyFunction_Vectorcall_CheckArgs(func, cyfunc, nargs, kwnames)) {
1360
+ case 1:
1361
+ self = args[0];
1362
+ args += 1;
1363
+ nargs -= 1;
1364
+ break;
1365
+ case 0:
1366
+ self = func;
1367
+ break;
1368
+ default:
1369
+ return NULL;
1370
+ }
1371
+
1372
+ if (unlikely(nargs != 1)) {
1373
+ __Pyx_CyFunction_raise_argument_count_error(
1374
+ func, "takes exactly one argument", nargs);
1375
+ return NULL;
1376
+ }
1377
+ return meth(self, args[0]);
1378
+ }
1379
+
1380
+ static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames)
1381
+ {
1382
+ __pyx_CyFunctionObject *cyfunc = __Pyx_as_CyFunctionObject(func);
1383
+ Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
1384
+ PyObject *self;
1385
+ PyCFunction meth = __Pyx_CyFunction_MethodDef(cyfunc)->ml_meth;
1386
+
1387
+ switch (__Pyx_CyFunction_Vectorcall_CheckArgs(func, cyfunc, nargs, NULL)) {
1388
+ case 1:
1389
+ self = args[0];
1390
+ args += 1;
1391
+ nargs -= 1;
1392
+ break;
1393
+ case 0:
1394
+ self = func;
1395
+ break;
1396
+ default:
1397
+ return NULL;
1398
+ }
1399
+
1400
+ return ((__Pyx_PyCFunctionFastWithKeywords)(void(*)(void))meth)(self, args, nargs, kwnames);
1401
+ }
1402
+
1403
+ static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS_METHOD(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames)
1404
+ {
1405
+ __pyx_CyFunctionObject *cyfunc = __Pyx_as_CyFunctionObject(func);
1406
+ PyTypeObject *cls = (PyTypeObject *) __Pyx_CyFunction_ClassObj(cyfunc);
1407
+ Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
1408
+ PyObject *self;
1409
+ PyCFunction meth = __Pyx_CyFunction_MethodDef(cyfunc)->ml_meth;
1410
+
1411
+ switch (__Pyx_CyFunction_Vectorcall_CheckArgs(func, cyfunc, nargs, NULL)) {
1412
+ case 1:
1413
+ self = args[0];
1414
+ args += 1;
1415
+ nargs -= 1;
1416
+ break;
1417
+ case 0:
1418
+ self = func;
1419
+ break;
1420
+ default:
1421
+ return NULL;
1422
+ }
1423
+
1424
+ #if PY_VERSION_HEX < 0x030e00A6
1425
+ // See https://github.com/python/cpython/pull/131135
1426
+ size_t nargs_value = (size_t) nargs;
1427
+ #else
1428
+ Py_ssize_t nargs_value = nargs;
1429
+ #endif
1430
+
1431
+ return ((__Pyx_PyCMethod)(void(*)(void))meth)(self, cls, args, nargs_value, kwnames);
1432
+ }
1433
+ #endif
1434
+
1435
+ static PyType_Slot __pyx_CyFunctionType_slots[] = {
1436
+ {Py_tp_dealloc, (void *)__Pyx_CyFunction_dealloc},
1437
+ {Py_tp_repr, (void *)__Pyx_CyFunction_repr},
1438
+ {Py_tp_call, (void *)__Pyx_CyFunction_CallAsMethod},
1439
+ {Py_tp_traverse, (void *)__Pyx_CyFunction_traverse},
1440
+ {Py_tp_clear, (void *)__Pyx_CyFunction_clear},
1441
+ {Py_tp_methods, (void *)__pyx_CyFunction_methods},
1442
+ {Py_tp_members, (void *)__pyx_CyFunction_members},
1443
+ {Py_tp_getset, (void *)__pyx_CyFunction_getsets},
1444
+ {Py_tp_descr_get, (void *)__Pyx_PyMethod_New},
1445
+ {0, 0},
1446
+ };
1447
+
1448
+ static PyType_Spec __pyx_CyFunctionType_spec = {
1449
+ __PYX_TYPE_MODULE_PREFIX "cython_function_or_method",
1450
+ __PYX_SHARED_SIZEOF(__pyx_CyFunctionObject),
1451
+ 0,
1452
+ #ifdef Py_TPFLAGS_METHOD_DESCRIPTOR
1453
+ Py_TPFLAGS_METHOD_DESCRIPTOR |
1454
+ #endif
1455
+ #if CYTHON_VECTORCALL
1456
+ #if defined(Py_TPFLAGS_HAVE_VECTORCALL)
1457
+ Py_TPFLAGS_HAVE_VECTORCALL |
1458
+ #elif defined(_Py_TPFLAGS_HAVE_VECTORCALL)
1459
+ _Py_TPFLAGS_HAVE_VECTORCALL |
1460
+ #endif
1461
+ #endif // CYTHON_VECTORCALL
1462
+ #if PY_VERSION_HEX >= 0x030C0000 && !CYTHON_COMPILING_IN_LIMITED_API
1463
+ Py_TPFLAGS_MANAGED_DICT |
1464
+ #endif
1465
+ Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_DISALLOW_INSTANTIATION |
1466
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, /*tp_flags*/
1467
+ __pyx_CyFunctionType_slots
1468
+ };
1469
+
1470
+ static int __pyx_CyFunction_init(PyObject *module) {
1471
+ $modulestatetype_cname *mstate = __Pyx_PyModule_GetState(module);
1472
+ if (mstate->__pyx_CyFunctionType != NULL) {
1473
+ return 0;
1474
+ }
1475
+ mstate->__pyx_CyFunctionType = __Pyx_FetchCommonTypeFromSpec(
1476
+ mstate->__pyx_CommonTypesMetaclassType, module, &__pyx_CyFunctionType_spec, NULL);
1477
+ if (unlikely(mstate->__pyx_CyFunctionType == NULL)) {
1478
+ return -1;
1479
+ }
1480
+ return 0;
1481
+ }
1482
+
1483
+ //////////////////// CythonFunction.export ////////////////////
1484
+
1485
+ static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml,
1486
+ int flags, PyObject* qualname,
1487
+ PyObject *closure,
1488
+ PyObject *module, PyObject *globals,
1489
+ PyObject* code);
1490
+
1491
+ static PyTypeObject *__Pyx_Get_CyFunction_Type(void);
1492
+
1493
+ //////////////////// CythonFunction ////////////////////
1494
+ //@requires: CythonFunctionShared
1495
+
1496
+ static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml, int flags, PyObject* qualname,
1497
+ PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
1498
+ // Only used when using shared utility module
1499
+ (void)&__Pyx_Get_CyFunction_Type;
1500
+
1501
+ PyObject *op = __Pyx_CyFunction_Init(
1502
+ PyObject_GC_New(PyObject, CGLOBAL(__pyx_CyFunctionType)),
1503
+ ml, flags, qualname, closure, module, globals, code
1504
+ );
1505
+ if (likely(op)) {
1506
+ PyObject_GC_Track(op);
1507
+ }
1508
+ return op;
1509
+ }
1510
+
1511
+ static PyTypeObject *__Pyx_Get_CyFunction_Type(void) {
1512
+ PyTypeObject *tp = CGLOBAL(__pyx_CyFunctionType);
1513
+ Py_INCREF((PyObject*)tp);
1514
+ return tp;
1515
+ }
1516
+
1517
+ //////////////////// CyFunctionClassCell.proto ////////////////////
1518
+ static int __Pyx_CyFunction_InitClassCell(PyObject *cyfunctions, PyObject *classobj);/*proto*/
1519
+
1520
+ //////////////////// CyFunctionClassCell ////////////////////
1521
+ //@requires: CythonFunctionPerModule
1522
+
1523
+ static int __Pyx_CyFunction_InitClassCell(PyObject *cyfunctions, PyObject *classobj) {
1524
+ Py_ssize_t i, count = __Pyx_PyList_GET_SIZE(cyfunctions);
1525
+ #if !CYTHON_ASSUME_SAFE_SIZE
1526
+ if (unlikely(count < 0)) return -1;
1527
+ #endif
1528
+
1529
+ for (i = 0; i < count; i++) {
1530
+ PyObject *m =
1531
+ #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && !CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS
1532
+ PyList_GET_ITEM(cyfunctions, i);
1533
+ #else
1534
+ __Pyx_PySequence_ITEM(cyfunctions, i);
1535
+ if (unlikely(!m))
1536
+ return -1;
1537
+ #endif
1538
+ __Pyx_CyFunction_SetClassObj(m, classobj);
1539
+ #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && !CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS)
1540
+ Py_DECREF(m);
1541
+ #endif
1542
+ }
1543
+ return 0;
1544
+ }
1545
+
1546
+ //////////////////// FusedFunctionPerModule.module_state_decls ////////////////////
1547
+
1548
+ PyTypeObject *__pyx_FusedFunctionType;
1549
+
1550
+ //////////////////// FusedFunctionPerModule.module_state_traverse ///////////////////
1551
+
1552
+ Py_VISIT(traverse_module_state->__pyx_FusedFunctionType);
1553
+
1554
+ //////////////////// FusedFunctionPerModule.module_state_clear ///////////////////
1555
+
1556
+ Py_CLEAR(clear_module_state->__pyx_FusedFunctionType);
1557
+
1558
+ //////////////////// FusedFunctionPerModule.init //////////////////
1559
+ //@substitute: naming
1560
+ //@init_block: init_after_shared_utility
1561
+
1562
+ if (likely(__pyx_FusedFunction_init($module_cname) == 0)); else
1563
+
1564
+ //////////////////// FusedFunctionPerModule.proto ////////////////
1565
+ //@requires: CythonFunctionPerModule
1566
+
1567
+ #if CYTHON_OPAQUE_SHARED_TYPES
1568
+ // Fused function can't be inherited so Py_TYPE is the fastest way to look it up.
1569
+ // This means we need no _safe version for destructors.
1570
+ #define __Pyx_as_FusedFunctionObject(o) ((__pyx_FusedFunctionObject *)PyObject_GetTypeData((o), Py_TYPE((o))))
1571
+ #else
1572
+ #define __Pyx_as_FusedFunctionObject(o) ((__pyx_FusedFunctionObject*)o)
1573
+ #endif
1574
+
1575
+
1576
+ typedef struct {
1577
+ #if !(CYTHON_COMPILING_IN_LIMITED_API && CYTHON_OPAQUE_OBJECTS)
1578
+ __pyx_CyFunctionObject func;
1579
+ #endif
1580
+ PyObject *__signatures__;
1581
+ PyObject *self;
1582
+ } __pyx_FusedFunctionObject;
1583
+
1584
+ // Definition depends on whether we're using shared utility code or not
1585
+ static int __pyx_FusedFunction_init(PyObject *module);
1586
+
1587
+ #define __Pyx_FusedFunction_USED
1588
+
1589
+ //////////////////// FusedFunctionFromSharedModule /////////////////////
1590
+ //@requires: FusedFunctionPerModule
1591
+ //@requires: CythonFunctionFromSharedModule
1592
+ //@requires: CommonStructures.c::VerifyCachedType
1593
+ //@requires: FusedFunction
1594
+ //@substitute: naming
1595
+
1596
+ // Cutdown version that's only used when importing from shared utility code
1597
+ static int __pyx_FusedFunction_init(PyObject *module) {
1598
+ $modulestatetype_cname *mstate = __Pyx_PyModule_GetState(module);
1599
+ if (mstate->__pyx_FusedFunctionType != NULL) {
1600
+ return 0;
1601
+ }
1602
+
1603
+ PyTypeObject *tp = __Pyx_Get_FusedFunction_Type();
1604
+ if (!tp) return -1;
1605
+
1606
+ if (__Pyx_VerifyCachedType((PyObject*)tp,
1607
+ __PYX_TYPE_MODULE_PREFIX "fused_cython_function",
1608
+ __PYX_SHARED_SIZEOF(__pyx_FusedFunctionObject)) != 0) {
1609
+ Py_DECREF((PyObject*)tp);
1610
+ return -1;
1611
+ }
1612
+
1613
+ mstate->__pyx_FusedFunctionType = tp;
1614
+ return 0;
1615
+ }
1616
+
1617
+ //////////////////// FusedFunction.export ////////////////////
1618
+
1619
+ static PyObject *__pyx_FusedFunction_New(PyMethodDef *ml, int flags,
1620
+ PyObject *qualname, PyObject *closure,
1621
+ PyObject *module, PyObject *globals,
1622
+ PyObject *code);
1623
+
1624
+ static PyTypeObject *__Pyx_Get_FusedFunction_Type(void);
1625
+
1626
+ //////////////////// FusedFunction ////////////////////
1627
+ //@requires: CythonFunctionShared
1628
+ //@requires: FusedFunctionPerModule
1629
+ //@substitute: naming
1630
+
1631
+ static PyObject *
1632
+ __pyx_FusedFunction_New(PyMethodDef *ml, int flags,
1633
+ PyObject *qualname, PyObject *closure,
1634
+ PyObject *module, PyObject *globals,
1635
+ PyObject *code)
1636
+ {
1637
+ PyObject *op = __Pyx_CyFunction_Init(
1638
+ PyObject_GC_New(PyObject, CGLOBAL(__pyx_FusedFunctionType)),
1639
+ ml, flags, qualname, closure, module, globals, code
1640
+ );
1641
+ if (likely(op)) {
1642
+ __pyx_FusedFunctionObject *fusedfunc = __Pyx_as_FusedFunctionObject(op);
1643
+ fusedfunc->__signatures__ = NULL;
1644
+ fusedfunc->self = NULL;
1645
+ PyObject_GC_Track(op);
1646
+ }
1647
+ return op;
1648
+ }
1649
+
1650
+ static void
1651
+ __pyx_FusedFunction_dealloc(PyObject *self)
1652
+ {
1653
+ __pyx_FusedFunctionObject *fused = __Pyx_as_FusedFunctionObject(self);
1654
+ PyObject_GC_UnTrack(self);
1655
+ Py_CLEAR(fused->self);
1656
+ Py_CLEAR(fused->__signatures__);
1657
+ __Pyx__CyFunction_dealloc(self);
1658
+ }
1659
+
1660
+ static int
1661
+ __pyx_FusedFunction_traverse(PyObject *self,
1662
+ visitproc visit,
1663
+ void *arg)
1664
+ {
1665
+ __pyx_FusedFunctionObject *fused = __Pyx_as_FusedFunctionObject(self);
1666
+ // Visiting the type is handled in the CyFunction traverse if needed
1667
+ Py_VISIT(fused->self);
1668
+ Py_VISIT(fused->__signatures__);
1669
+ return __Pyx_CyFunction_traverse(self, visit, arg);
1670
+ }
1671
+
1672
+ static int
1673
+ __pyx_FusedFunction_clear(PyObject *self)
1674
+ {
1675
+ __pyx_FusedFunctionObject *fused = __Pyx_as_FusedFunctionObject(self);
1676
+ Py_CLEAR(fused->self);
1677
+ Py_CLEAR(fused->__signatures__);
1678
+ return __Pyx_CyFunction_clear(self);
1679
+ }
1680
+
1681
+
1682
+ static PyObject *__Pyx_FusedFunction_get_signatures(PyObject *self, void *closure)
1683
+ {
1684
+ CYTHON_UNUSED_VAR(closure);
1685
+ // No critical section - signatures should not be reassigned
1686
+ __pyx_FusedFunctionObject *func = __Pyx_as_FusedFunctionObject(self);
1687
+ if (func->__signatures__) {
1688
+ // A dictproxy ensures that users can't (easily) mess with the internal data used in fused dispatch.
1689
+ // For this rarely-used introspection function, it is unlikely to be worth the memory to cache the proxy.
1690
+ return PyDictProxy_New(func->__signatures__);
1691
+ } else {
1692
+ Py_RETURN_NONE;
1693
+ }
1694
+ }
1695
+
1696
+ static PyObject *
1697
+ __pyx_FusedFunction_descr_get_locked(PyObject *self, PyObject *obj)
1698
+ {
1699
+ __pyx_FusedFunctionObject *func = __Pyx_as_FusedFunctionObject(self);
1700
+ __pyx_CyFunctionObject *cyfunc = __Pyx_as_CyFunctionObject(self);
1701
+ PyObject *module, *qualname;
1702
+ PyObject *meth;
1703
+ module = __Pyx_CyFunction_Module(cyfunc);
1704
+ qualname = cyfunc->func_qualname;
1705
+ // In principle, both module and qualname can be modified externally.
1706
+ // In modern Python (>=3.11) there should be nothing that can
1707
+ // release the GIL or break a critical section when allocating a new fused function.
1708
+ // In older versions or possibly other implementations allocation can release
1709
+ // the GIL. In this case,
1710
+ // it doesn't hurt to hold a reference to module and qualname to be certain.
1711
+ #if !CYTHON_COMPILING_IN_CPYTHON || PY_VERSION_HEX < 0x030B0000
1712
+ Py_INCREF(module);
1713
+ Py_INCREF(qualname);
1714
+ #endif
1715
+
1716
+ meth = __pyx_FusedFunction_New(
1717
+ __Pyx_CyFunction_MethodDef(cyfunc),
1718
+ cyfunc->flags,
1719
+ qualname,
1720
+ cyfunc->func_closure,
1721
+ module,
1722
+ cyfunc->func_globals,
1723
+ cyfunc->func_code);
1724
+ #if !CYTHON_COMPILING_IN_CPYTHON || PY_VERSION_HEX < 0x030B0000
1725
+ Py_DECREF(module);
1726
+ Py_DECREF(qualname);
1727
+ #endif
1728
+ if (unlikely(!meth))
1729
+ return NULL;
1730
+
1731
+
1732
+ __pyx_CyFunctionObject *meth_as_cyfunc = __Pyx_as_CyFunctionObject(meth);
1733
+ __pyx_FusedFunctionObject *meth_as_fused = __Pyx_as_FusedFunctionObject(meth);
1734
+ Py_XINCREF(cyfunc->defaults);
1735
+ meth_as_cyfunc->defaults = cyfunc->defaults;
1736
+
1737
+ __Pyx_CyFunction_SetClassObj(meth, (PyObject*)__Pyx_CyFunction_ClassObj(cyfunc));
1738
+
1739
+ Py_XINCREF(func->__signatures__);
1740
+ meth_as_fused->__signatures__ = func->__signatures__;
1741
+
1742
+ Py_XINCREF(cyfunc->defaults_tuple);
1743
+ meth_as_cyfunc->defaults_tuple = cyfunc->defaults_tuple;
1744
+
1745
+ Py_XINCREF(obj);
1746
+ meth_as_fused->self = obj;
1747
+ return meth;
1748
+ }
1749
+
1750
+ static PyObject *
1751
+ __pyx_FusedFunction_descr_get(PyObject *self, PyObject *obj, PyObject *type)
1752
+ {
1753
+ __pyx_FusedFunctionObject *func = __Pyx_as_FusedFunctionObject(self);
1754
+ __pyx_CyFunctionObject *cyfunc = __Pyx_as_CyFunctionObject(self);
1755
+ PyObject *meth;
1756
+
1757
+ if (func->self || cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD) {
1758
+ // Do not allow rebinding and don't do anything for static methods
1759
+ Py_INCREF(self);
1760
+ return self;
1761
+ }
1762
+
1763
+ if (obj == Py_None)
1764
+ obj = NULL;
1765
+
1766
+ if (cyfunc->flags & __Pyx_CYFUNCTION_CLASSMETHOD)
1767
+ obj = type;
1768
+
1769
+ if (obj == NULL) {
1770
+ // We aren't actually binding to anything, save the effort of rebinding
1771
+ Py_INCREF(self);
1772
+ return self;
1773
+ }
1774
+
1775
+ __Pyx_BEGIN_CRITICAL_SECTION(self);
1776
+ meth = __pyx_FusedFunction_descr_get_locked(self, obj);
1777
+ __Pyx_END_CRITICAL_SECTION()
1778
+
1779
+ return meth;
1780
+ }
1781
+
1782
+ static PyObject *
1783
+ __pyx_FusedFunction_obj_to_string(PyObject *obj)
1784
+ {
1785
+ if (PyUnicode_CheckExact(obj))
1786
+ return __Pyx_NewRef(obj);
1787
+ else if (PyType_Check(obj))
1788
+ return PyObject_GetAttr(obj, PYIDENT("__name__"));
1789
+ else
1790
+ return PyObject_Str(obj);
1791
+ }
1792
+
1793
+ static PyObject *
1794
+ __pyx_FusedFunction_getitem(PyObject *self, PyObject *idx)
1795
+ {
1796
+ PyObject *signature = NULL;
1797
+ PyObject *unbound_result_func;
1798
+ PyObject *result_func = NULL;
1799
+ __pyx_FusedFunctionObject *fusedfunc = __Pyx_as_FusedFunctionObject(self);
1800
+
1801
+ if (unlikely(fusedfunc->__signatures__ == NULL)) {
1802
+ PyErr_SetString(PyExc_TypeError, "Function is not fused");
1803
+ return NULL;
1804
+ }
1805
+
1806
+ if (PyTuple_Check(idx)) {
1807
+ Py_ssize_t n = __Pyx_PyTuple_GET_SIZE(idx);
1808
+ PyObject *list;
1809
+ int i;
1810
+ #if !CYTHON_ASSUME_SAFE_SIZE
1811
+ if (unlikely(n < 0)) return NULL;
1812
+ #endif
1813
+
1814
+ list = PyList_New(n);
1815
+ if (unlikely(!list))
1816
+ return NULL;
1817
+
1818
+ for (i = 0; i < n; i++) {
1819
+ PyObject *string;
1820
+ #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
1821
+ PyObject *item = PyTuple_GET_ITEM(idx, i);
1822
+ #else
1823
+ PyObject *item = __Pyx_PySequence_ITEM(idx, i); if (unlikely(!item)) goto __pyx_err;
1824
+ #endif
1825
+ string = __pyx_FusedFunction_obj_to_string(item);
1826
+ #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
1827
+ Py_DECREF(item);
1828
+ #endif
1829
+ if (unlikely(!string)) goto __pyx_err;
1830
+ if (__Pyx_PyList_SET_ITEM(list, i, string) < (0)) goto __pyx_err;
1831
+ }
1832
+
1833
+ signature = PyUnicode_Join(PYUNICODE("|"), list);
1834
+ __pyx_err:;
1835
+ Py_DECREF(list);
1836
+ } else {
1837
+ signature = __pyx_FusedFunction_obj_to_string(idx);
1838
+ }
1839
+
1840
+ if (unlikely(!signature))
1841
+ return NULL;
1842
+
1843
+ unbound_result_func = PyObject_GetItem(fusedfunc->__signatures__, signature);
1844
+
1845
+ if (likely(unbound_result_func)) {
1846
+ if (fusedfunc->self) {
1847
+ assert(__Pyx_CyFunction_GetClassObj(unbound_result_func) == __Pyx_CyFunction_GetClassObj(self));
1848
+
1849
+ result_func = __pyx_FusedFunction_descr_get(unbound_result_func,
1850
+ fusedfunc->self, fusedfunc->self);
1851
+ } else {
1852
+ result_func = unbound_result_func;
1853
+ Py_INCREF(result_func);
1854
+ }
1855
+ }
1856
+
1857
+ Py_DECREF(signature);
1858
+ Py_XDECREF(unbound_result_func);
1859
+
1860
+ return result_func;
1861
+ }
1862
+
1863
+ static PyObject *
1864
+ __pyx_FusedFunction_callfunction(PyObject *func, PyObject *args, PyObject *kw)
1865
+ {
1866
+ __pyx_FusedFunctionObject *fusedfunc = __Pyx_as_FusedFunctionObject(func);
1867
+ __pyx_CyFunctionObject *cyfunc = __Pyx_as_CyFunctionObject(func);
1868
+
1869
+ int static_specialized = (cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD &&
1870
+ !fusedfunc->__signatures__);
1871
+
1872
+ if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !static_specialized) {
1873
+ return __Pyx_CyFunction_CallAsMethod(func, args, kw);
1874
+ } else {
1875
+ return __Pyx_CyFunction_Call(func, args, kw);
1876
+ }
1877
+ }
1878
+
1879
+ // Note: the 'self' from method binding is passed in in the args tuple,
1880
+ // whereas the FusedFunction object is passed in as the first
1881
+ // argument to the C function. For extension methods we
1882
+ // don't want to pass 'self' as the first element of the
1883
+ // args tuple.
1884
+
1885
+ static PyObject *
1886
+ __pyx_FusedFunction_call(PyObject *func, PyObject *args, PyObject *kw)
1887
+ {
1888
+ __pyx_FusedFunctionObject *binding_func = __Pyx_as_FusedFunctionObject(func);
1889
+ __pyx_CyFunctionObject *cyfunc = __Pyx_as_CyFunctionObject(func);
1890
+
1891
+ Py_ssize_t argc = __Pyx_PyTuple_GET_SIZE(args);
1892
+ PyObject *new_args = NULL;
1893
+ PyObject *new_func = NULL;
1894
+ PyObject *result = NULL;
1895
+ int is_staticmethod = cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD;
1896
+ #if !CYTHON_ASSUME_SAFE_SIZE
1897
+ if (unlikely(argc < 0)) return NULL;
1898
+ #endif
1899
+
1900
+ if (binding_func->self) {
1901
+ // Bound method call, put 'self' in the args tuple
1902
+ PyObject *self;
1903
+ Py_ssize_t i;
1904
+ new_args = PyTuple_New(argc + 1);
1905
+ if (unlikely(!new_args))
1906
+ return NULL;
1907
+
1908
+ self = binding_func->self;
1909
+
1910
+ Py_INCREF(self);
1911
+ if (__Pyx_PyTuple_SET_ITEM(new_args, 0, self) < (0)) goto bad;
1912
+ self = NULL;
1913
+
1914
+ for (i = 0; i < argc; i++) {
1915
+ #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
1916
+ PyObject *item = PyTuple_GET_ITEM(args, i);
1917
+ Py_INCREF(item);
1918
+ #else
1919
+ PyObject *item = __Pyx_PySequence_ITEM(args, i); if (unlikely(!item)) goto bad;
1920
+ #endif
1921
+ if (__Pyx_PyTuple_SET_ITEM(new_args, i + 1, item) < (0)) goto bad;
1922
+ }
1923
+
1924
+ args = new_args;
1925
+ }
1926
+
1927
+ if (binding_func->__signatures__) {
1928
+ PyObject *tup;
1929
+ if (is_staticmethod && cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) {
1930
+ // FIXME: this seems wrong, but we must currently pass the signatures dict as 'self' argument
1931
+ tup = PyTuple_Pack(3, args,
1932
+ kw == NULL ? Py_None : kw,
1933
+ cyfunc->defaults_tuple);
1934
+ if (unlikely(!tup)) goto bad;
1935
+ new_func = __Pyx_CyFunction_CallMethod(
1936
+ func, binding_func->__signatures__, tup, NULL);
1937
+ } else {
1938
+ tup = PyTuple_Pack(4, binding_func->__signatures__, args,
1939
+ kw == NULL ? Py_None : kw,
1940
+ cyfunc->defaults_tuple);
1941
+ if (unlikely(!tup)) goto bad;
1942
+ new_func = __pyx_FusedFunction_callfunction(func, tup, NULL);
1943
+ }
1944
+ Py_DECREF(tup);
1945
+
1946
+ if (unlikely(!new_func))
1947
+ goto bad;
1948
+
1949
+ assert(__Pyx_CyFunction_GetClassObj(new_func) == __Pyx_CyFunction_GetClassObj(func));
1950
+
1951
+ func = new_func;
1952
+ }
1953
+
1954
+ result = __pyx_FusedFunction_callfunction(func, args, kw);
1955
+ bad:
1956
+ Py_XDECREF(new_args);
1957
+ Py_XDECREF(new_func);
1958
+ return result;
1959
+ }
1960
+
1961
+ static PyMemberDef __pyx_FusedFunction_members[] = {
1962
+ {"__self__", T_OBJECT_EX, offsetof(__pyx_FusedFunctionObject, self), __PYX_SHARED_RELATIVE_OFFSET | READONLY, 0},
1963
+ // For heap-types __module__ appears not to be inherited (so redeclare)
1964
+ #if !(CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_GRAAL)
1965
+ {"__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), 0, 0},
1966
+ #endif
1967
+ {0, 0, 0, 0, 0},
1968
+ };
1969
+
1970
+ static PyGetSetDef __pyx_FusedFunction_getsets[] = {
1971
+ // __doc__ is None for the fused function type, but we need it to be
1972
+ // a descriptor for the instance's __doc__, so rebuild the descriptor in our subclass
1973
+ // (all other descriptors are inherited)
1974
+ {"__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
1975
+ // For heap-types __module__ appears not to be inherited (so redeclare)
1976
+ #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_GRAAL
1977
+ {"__module__", (getter)__Pyx_CyFunction_get_module, (setter)__Pyx_CyFunction_set_module, 0, 0},
1978
+ #endif
1979
+ {"__signatures__", (getter)__Pyx_FusedFunction_get_signatures, NULL, 0, 0},
1980
+ {0, 0, 0, 0, 0}
1981
+ };
1982
+
1983
+ static PyType_Slot __pyx_FusedFunctionType_slots[] = {
1984
+ {Py_tp_dealloc, (void *)__pyx_FusedFunction_dealloc},
1985
+ {Py_tp_call, (void *)__pyx_FusedFunction_call},
1986
+ {Py_tp_traverse, (void *)__pyx_FusedFunction_traverse},
1987
+ {Py_tp_clear, (void *)__pyx_FusedFunction_clear},
1988
+ {Py_tp_members, (void *)__pyx_FusedFunction_members},
1989
+ {Py_tp_getset, (void *)__pyx_FusedFunction_getsets},
1990
+ {Py_tp_descr_get, (void *)__pyx_FusedFunction_descr_get},
1991
+ {Py_mp_subscript, (void *)__pyx_FusedFunction_getitem},
1992
+ {0, 0},
1993
+ };
1994
+
1995
+ static PyType_Spec __pyx_FusedFunctionType_spec = {
1996
+ __PYX_TYPE_MODULE_PREFIX "fused_cython_function",
1997
+ __PYX_SHARED_SIZEOF(__pyx_FusedFunctionObject),
1998
+ 0,
1999
+ Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_DISALLOW_INSTANTIATION |
2000
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC , /*tp_flags*/
2001
+ __pyx_FusedFunctionType_slots
2002
+ };
2003
+
2004
+ static int __pyx_FusedFunction_init(PyObject *module) {
2005
+ // Silence unused warning when not in shared module.
2006
+ (void)&__Pyx_Get_FusedFunction_Type;
2007
+
2008
+ $modulestatetype_cname *mstate = __Pyx_PyModule_GetState(module);
2009
+ if (mstate->__pyx_FusedFunctionType != NULL) {
2010
+ return 0;
2011
+ }
2012
+ PyObject *bases = PyTuple_Pack(1, mstate->__pyx_CyFunctionType);
2013
+ if (unlikely(!bases)) {
2014
+ return -1;
2015
+ }
2016
+ mstate->__pyx_FusedFunctionType = __Pyx_FetchCommonTypeFromSpec(
2017
+ mstate->__pyx_CommonTypesMetaclassType, module, &__pyx_FusedFunctionType_spec, bases);
2018
+ Py_DECREF(bases);
2019
+ if (unlikely(mstate->__pyx_FusedFunctionType == NULL)) {
2020
+ return -1;
2021
+ }
2022
+ return 0;
2023
+ }
2024
+
2025
+ static PyTypeObject *__Pyx_Get_FusedFunction_Type(void) {
2026
+ PyTypeObject *tp = CGLOBAL(__pyx_FusedFunctionType);
2027
+ Py_INCREF((PyObject*)tp);
2028
+ return tp;
2029
+ }
2030
+
2031
+
2032
+ //////////////////// FusedFunctionArgTypeError.proto ////////////////////
2033
+
2034
+ #define __Pyx_RaiseFusedFunctionArgTypeError(arg_name, arg_tuple_idx, min_positional_args, arg_count) \
2035
+ (__Pyx__RaiseFusedFunctionArgTypeError(arg_name, arg_tuple_idx, min_positional_args, arg_count), -1)
2036
+
2037
+ static void __Pyx__RaiseFusedFunctionArgTypeError(PyObject *arg_name, Py_ssize_t arg_tuple_idx, Py_ssize_t min_positional_args, Py_ssize_t arg_count); /*proto*/
2038
+
2039
+ //////////////////// FusedFunctionArgTypeError ////////////////////
2040
+
2041
+ static void __Pyx__RaiseFusedFunctionArgTypeError(PyObject *arg_name, Py_ssize_t arg_tuple_idx, Py_ssize_t min_positional_args, Py_ssize_t arg_count) {
2042
+ if (arg_tuple_idx < min_positional_args) {
2043
+ PyErr_Format(
2044
+ PyExc_TypeError,
2045
+ "Expected at least %zd argument%.1s, got %zd",
2046
+ min_positional_args,
2047
+ (min_positional_args != 1) ? "s" : "",
2048
+ arg_count
2049
+ );
2050
+ } else {
2051
+ PyErr_Format(
2052
+ PyExc_TypeError,
2053
+ "Missing keyword-only argument: '%U'",
2054
+ arg_name
2055
+ );
2056
+ }
2057
+ }
2058
+
2059
+
2060
+ //////////////////// ClassMethod.proto ////////////////////
2061
+
2062
+ #if !CYTHON_COMPILING_IN_LIMITED_API
2063
+ #include "descrobject.h"
2064
+ #endif
2065
+ CYTHON_UNUSED static PyObject* __Pyx_Method_ClassMethod(PyObject *method); /*proto*/
2066
+
2067
+ //////////////////// ClassMethod ////////////////////
2068
+ //@requires: ObjectHandling.c::CachedMethodType
2069
+ //@requires: ModuleSetupCode.c::FastTypeChecks
2070
+
2071
+ static PyObject* __Pyx_Method_ClassMethod(PyObject *method) {
2072
+ #if CYTHON_COMPILING_IN_PYPY && PYPY_VERSION_NUM <= 0x05080000
2073
+ if (PyObject_TypeCheck(method, &PyWrapperDescr_Type)) {
2074
+ // cdef classes
2075
+ return PyClassMethod_New(method);
2076
+ }
2077
+ #else
2078
+ #if CYTHON_COMPILING_IN_PYPY
2079
+ // special C-API function only in PyPy >= 5.9
2080
+ if (PyMethodDescr_Check(method))
2081
+ #else
2082
+ if (__Pyx_TypeCheck(method, &PyMethodDescr_Type))
2083
+ #endif
2084
+ {
2085
+ #if CYTHON_COMPILING_IN_LIMITED_API
2086
+ return PyErr_Format(
2087
+ PyExc_SystemError,
2088
+ "Cython cannot yet handle classmethod on a MethodDescriptorType (%S) in limited API mode. "
2089
+ "This is most likely a classmethod in a cdef class method with binding=False. "
2090
+ "Try setting 'binding' to True.",
2091
+ method);
2092
+ #elif CYTHON_COMPILING_IN_GRAAL && defined(GRAALPY_VERSION_NUM) && GRAALPY_VERSION_NUM > 0x19000000
2093
+ // cdef classes
2094
+ PyTypeObject *d_type = GraalPyDescrObject_GetType(method);
2095
+ return PyDescr_NewClassMethod(d_type, GraalPyMethodDescrObject_GetMethod(method));
2096
+ #elif CYTHON_COMPILING_IN_GRAAL
2097
+ // Remove when GraalPy 24 goes EOL
2098
+ PyTypeObject *d_type = PyDescrObject_GetType(method);
2099
+ return PyDescr_NewClassMethod(d_type, PyMethodDescrObject_GetMethod(method));
2100
+ #else
2101
+ // cdef classes
2102
+ PyMethodDescrObject *descr = (PyMethodDescrObject *)method;
2103
+ PyTypeObject *d_type = descr->d_common.d_type;
2104
+ return PyDescr_NewClassMethod(d_type, descr->d_method);
2105
+ #endif
2106
+ }
2107
+ #endif
2108
+ #if !CYTHON_COMPILING_IN_LIMITED_API
2109
+ else if (PyMethod_Check(method)) {
2110
+ // python classes
2111
+ return PyClassMethod_New(PyMethod_GET_FUNCTION(method));
2112
+ }
2113
+ else {
2114
+ return PyClassMethod_New(method);
2115
+ }
2116
+ #else
2117
+ {
2118
+ PyObject *func=NULL;
2119
+ PyObject *builtins, *classmethod, *classmethod_str, *result=NULL;
2120
+ if (__Pyx_TypeCheck(method, CGLOBAL(__Pyx_CachedMethodType))) {
2121
+ func = PyObject_GetAttrString(method, "__func__");
2122
+ if (!func) goto bad;
2123
+ } else {
2124
+ func = method;
2125
+ Py_INCREF(func);
2126
+ }
2127
+ builtins = PyEval_GetBuiltins(); // borrowed
2128
+ if (unlikely(!builtins)) goto bad;
2129
+ classmethod_str = PyUnicode_FromString("classmethod");
2130
+ if (unlikely(!classmethod_str)) goto bad;
2131
+ classmethod = PyObject_GetItem(builtins, classmethod_str);
2132
+ Py_DECREF(classmethod_str);
2133
+ if (unlikely(!classmethod)) goto bad;
2134
+ result = PyObject_CallFunctionObjArgs(classmethod, func, NULL);
2135
+ Py_DECREF(classmethod);
2136
+
2137
+ bad:
2138
+ Py_XDECREF(func);
2139
+ return result;
2140
+ }
2141
+ #endif
2142
+
2143
+ }