Cython 3.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (316) hide show
  1. Cython/Build/BuildExecutable.py +169 -0
  2. Cython/Build/Cache.py +199 -0
  3. Cython/Build/Cythonize.py +323 -0
  4. Cython/Build/Dependencies.py +1306 -0
  5. Cython/Build/Distutils.py +1 -0
  6. Cython/Build/Inline.py +463 -0
  7. Cython/Build/IpythonMagic.py +560 -0
  8. Cython/Build/SharedModule.py +76 -0
  9. Cython/Build/Tests/TestCyCache.py +194 -0
  10. Cython/Build/Tests/TestCythonizeArgsParser.py +481 -0
  11. Cython/Build/Tests/TestDependencies.py +133 -0
  12. Cython/Build/Tests/TestInline.py +177 -0
  13. Cython/Build/Tests/TestIpythonMagic.py +287 -0
  14. Cython/Build/Tests/TestRecythonize.py +212 -0
  15. Cython/Build/Tests/TestStripLiterals.py +155 -0
  16. Cython/Build/Tests/__init__.py +1 -0
  17. Cython/Build/__init__.py +8 -0
  18. Cython/CodeWriter.py +811 -0
  19. Cython/Compiler/AnalysedTreeTransforms.py +97 -0
  20. Cython/Compiler/Annotate.py +326 -0
  21. Cython/Compiler/AutoDocTransforms.py +320 -0
  22. Cython/Compiler/Buffer.py +680 -0
  23. Cython/Compiler/Builtin.py +934 -0
  24. Cython/Compiler/CmdLine.py +259 -0
  25. Cython/Compiler/Code.pxd +148 -0
  26. Cython/Compiler/Code.py +3375 -0
  27. Cython/Compiler/CodeGeneration.py +33 -0
  28. Cython/Compiler/CythonScope.py +187 -0
  29. Cython/Compiler/Dataclass.py +868 -0
  30. Cython/Compiler/DebugFlags.py +24 -0
  31. Cython/Compiler/Errors.py +295 -0
  32. Cython/Compiler/ExprNodes.py +15267 -0
  33. Cython/Compiler/FlowControl.pxd +97 -0
  34. Cython/Compiler/FlowControl.py +1455 -0
  35. Cython/Compiler/FusedNode.py +1002 -0
  36. Cython/Compiler/Future.py +16 -0
  37. Cython/Compiler/Interpreter.py +57 -0
  38. Cython/Compiler/Lexicon.py +340 -0
  39. Cython/Compiler/LineTable.py +114 -0
  40. Cython/Compiler/Main.py +853 -0
  41. Cython/Compiler/MatchCaseNodes.py +259 -0
  42. Cython/Compiler/MemoryView.py +922 -0
  43. Cython/Compiler/ModuleNode.py +4024 -0
  44. Cython/Compiler/Naming.py +374 -0
  45. Cython/Compiler/Nodes.py +10826 -0
  46. Cython/Compiler/Optimize.py +5256 -0
  47. Cython/Compiler/Options.py +835 -0
  48. Cython/Compiler/ParseTreeTransforms.pxd +77 -0
  49. Cython/Compiler/ParseTreeTransforms.py +4509 -0
  50. Cython/Compiler/Parsing.pxd +9 -0
  51. Cython/Compiler/Parsing.py +4789 -0
  52. Cython/Compiler/Pipeline.py +439 -0
  53. Cython/Compiler/PyrexTypes.py +5762 -0
  54. Cython/Compiler/Pythran.py +232 -0
  55. Cython/Compiler/Scanning.pxd +40 -0
  56. Cython/Compiler/Scanning.py +577 -0
  57. Cython/Compiler/StringEncoding.py +347 -0
  58. Cython/Compiler/Symtab.py +3080 -0
  59. Cython/Compiler/Tests/TestBuffer.py +105 -0
  60. Cython/Compiler/Tests/TestBuiltin.py +72 -0
  61. Cython/Compiler/Tests/TestCmdLine.py +586 -0
  62. Cython/Compiler/Tests/TestCode.py +86 -0
  63. Cython/Compiler/Tests/TestFlowControl.py +65 -0
  64. Cython/Compiler/Tests/TestGrammar.py +202 -0
  65. Cython/Compiler/Tests/TestMemView.py +71 -0
  66. Cython/Compiler/Tests/TestParseTreeTransforms.py +285 -0
  67. Cython/Compiler/Tests/TestScanning.py +134 -0
  68. Cython/Compiler/Tests/TestSignatureMatching.py +73 -0
  69. Cython/Compiler/Tests/TestStringEncoding.py +33 -0
  70. Cython/Compiler/Tests/TestTreeFragment.py +63 -0
  71. Cython/Compiler/Tests/TestTreePath.py +103 -0
  72. Cython/Compiler/Tests/TestTypes.py +75 -0
  73. Cython/Compiler/Tests/TestUtilityLoad.py +112 -0
  74. Cython/Compiler/Tests/TestVisitor.py +61 -0
  75. Cython/Compiler/Tests/Utils.py +36 -0
  76. Cython/Compiler/Tests/__init__.py +1 -0
  77. Cython/Compiler/TreeFragment.py +278 -0
  78. Cython/Compiler/TreePath.py +303 -0
  79. Cython/Compiler/TypeInference.py +584 -0
  80. Cython/Compiler/TypeSlots.py +1181 -0
  81. Cython/Compiler/UFuncs.py +311 -0
  82. Cython/Compiler/UtilNodes.py +389 -0
  83. Cython/Compiler/UtilityCode.py +344 -0
  84. Cython/Compiler/Version.py +8 -0
  85. Cython/Compiler/Visitor.pxd +53 -0
  86. Cython/Compiler/Visitor.py +861 -0
  87. Cython/Compiler/__init__.py +1 -0
  88. Cython/Coverage.py +448 -0
  89. Cython/Debugger/Cygdb.py +175 -0
  90. Cython/Debugger/DebugWriter.py +82 -0
  91. Cython/Debugger/Tests/TestLibCython.py +275 -0
  92. Cython/Debugger/Tests/__init__.py +1 -0
  93. Cython/Debugger/Tests/cfuncs.c +8 -0
  94. Cython/Debugger/Tests/codefile +49 -0
  95. Cython/Debugger/Tests/test_libcython_in_gdb.py +578 -0
  96. Cython/Debugger/Tests/test_libpython_in_gdb.py +90 -0
  97. Cython/Debugger/__init__.py +1 -0
  98. Cython/Debugger/libcython.py +1548 -0
  99. Cython/Debugger/libpython.py +2821 -0
  100. Cython/Debugging.py +20 -0
  101. Cython/Distutils/__init__.py +2 -0
  102. Cython/Distutils/build_ext.py +139 -0
  103. Cython/Distutils/extension.py +96 -0
  104. Cython/Distutils/old_build_ext.py +351 -0
  105. Cython/Includes/cpython/__init__.pxd +173 -0
  106. Cython/Includes/cpython/array.pxd +174 -0
  107. Cython/Includes/cpython/bool.pxd +37 -0
  108. Cython/Includes/cpython/buffer.pxd +112 -0
  109. Cython/Includes/cpython/bytearray.pxd +33 -0
  110. Cython/Includes/cpython/bytes.pxd +200 -0
  111. Cython/Includes/cpython/cellobject.pxd +35 -0
  112. Cython/Includes/cpython/ceval.pxd +8 -0
  113. Cython/Includes/cpython/codecs.pxd +121 -0
  114. Cython/Includes/cpython/complex.pxd +60 -0
  115. Cython/Includes/cpython/contextvars.pxd +145 -0
  116. Cython/Includes/cpython/conversion.pxd +36 -0
  117. Cython/Includes/cpython/datetime.pxd +395 -0
  118. Cython/Includes/cpython/descr.pxd +26 -0
  119. Cython/Includes/cpython/dict.pxd +187 -0
  120. Cython/Includes/cpython/exc.pxd +263 -0
  121. Cython/Includes/cpython/fileobject.pxd +57 -0
  122. Cython/Includes/cpython/float.pxd +47 -0
  123. Cython/Includes/cpython/function.pxd +65 -0
  124. Cython/Includes/cpython/genobject.pxd +25 -0
  125. Cython/Includes/cpython/getargs.pxd +12 -0
  126. Cython/Includes/cpython/instance.pxd +25 -0
  127. Cython/Includes/cpython/iterator.pxd +36 -0
  128. Cython/Includes/cpython/iterobject.pxd +24 -0
  129. Cython/Includes/cpython/list.pxd +92 -0
  130. Cython/Includes/cpython/long.pxd +149 -0
  131. Cython/Includes/cpython/longintrepr.pxd +14 -0
  132. Cython/Includes/cpython/mapping.pxd +63 -0
  133. Cython/Includes/cpython/marshal.pxd +66 -0
  134. Cython/Includes/cpython/mem.pxd +120 -0
  135. Cython/Includes/cpython/memoryview.pxd +50 -0
  136. Cython/Includes/cpython/method.pxd +49 -0
  137. Cython/Includes/cpython/module.pxd +208 -0
  138. Cython/Includes/cpython/number.pxd +258 -0
  139. Cython/Includes/cpython/object.pxd +433 -0
  140. Cython/Includes/cpython/pycapsule.pxd +143 -0
  141. Cython/Includes/cpython/pylifecycle.pxd +68 -0
  142. Cython/Includes/cpython/pyport.pxd +8 -0
  143. Cython/Includes/cpython/pystate.pxd +95 -0
  144. Cython/Includes/cpython/pythread.pxd +53 -0
  145. Cython/Includes/cpython/ref.pxd +67 -0
  146. Cython/Includes/cpython/sequence.pxd +134 -0
  147. Cython/Includes/cpython/set.pxd +119 -0
  148. Cython/Includes/cpython/slice.pxd +70 -0
  149. Cython/Includes/cpython/time.pxd +129 -0
  150. Cython/Includes/cpython/tuple.pxd +72 -0
  151. Cython/Includes/cpython/type.pxd +53 -0
  152. Cython/Includes/cpython/unicode.pxd +639 -0
  153. Cython/Includes/cpython/version.pxd +32 -0
  154. Cython/Includes/cpython/weakref.pxd +78 -0
  155. Cython/Includes/libc/__init__.pxd +1 -0
  156. Cython/Includes/libc/complex.pxd +35 -0
  157. Cython/Includes/libc/errno.pxd +127 -0
  158. Cython/Includes/libc/float.pxd +43 -0
  159. Cython/Includes/libc/limits.pxd +28 -0
  160. Cython/Includes/libc/locale.pxd +46 -0
  161. Cython/Includes/libc/math.pxd +209 -0
  162. Cython/Includes/libc/setjmp.pxd +10 -0
  163. Cython/Includes/libc/signal.pxd +64 -0
  164. Cython/Includes/libc/stddef.pxd +9 -0
  165. Cython/Includes/libc/stdint.pxd +105 -0
  166. Cython/Includes/libc/stdio.pxd +80 -0
  167. Cython/Includes/libc/stdlib.pxd +72 -0
  168. Cython/Includes/libc/string.pxd +50 -0
  169. Cython/Includes/libc/threads.pxd +84 -0
  170. Cython/Includes/libc/time.pxd +51 -0
  171. Cython/Includes/libcpp/__init__.pxd +4 -0
  172. Cython/Includes/libcpp/algorithm.pxd +320 -0
  173. Cython/Includes/libcpp/any.pxd +16 -0
  174. Cython/Includes/libcpp/atomic.pxd +59 -0
  175. Cython/Includes/libcpp/barrier.pxd +22 -0
  176. Cython/Includes/libcpp/bit.pxd +29 -0
  177. Cython/Includes/libcpp/cast.pxd +12 -0
  178. Cython/Includes/libcpp/cmath.pxd +518 -0
  179. Cython/Includes/libcpp/complex.pxd +106 -0
  180. Cython/Includes/libcpp/deque.pxd +165 -0
  181. Cython/Includes/libcpp/exception.pxd +86 -0
  182. Cython/Includes/libcpp/execution.pxd +15 -0
  183. Cython/Includes/libcpp/forward_list.pxd +63 -0
  184. Cython/Includes/libcpp/functional.pxd +26 -0
  185. Cython/Includes/libcpp/future.pxd +103 -0
  186. Cython/Includes/libcpp/iterator.pxd +34 -0
  187. Cython/Includes/libcpp/latch.pxd +17 -0
  188. Cython/Includes/libcpp/limits.pxd +61 -0
  189. Cython/Includes/libcpp/list.pxd +117 -0
  190. Cython/Includes/libcpp/map.pxd +252 -0
  191. Cython/Includes/libcpp/memory.pxd +115 -0
  192. Cython/Includes/libcpp/mutex.pxd +130 -0
  193. Cython/Includes/libcpp/numbers.pxd +15 -0
  194. Cython/Includes/libcpp/numeric.pxd +131 -0
  195. Cython/Includes/libcpp/optional.pxd +34 -0
  196. Cython/Includes/libcpp/pair.pxd +1 -0
  197. Cython/Includes/libcpp/queue.pxd +25 -0
  198. Cython/Includes/libcpp/random.pxd +166 -0
  199. Cython/Includes/libcpp/semaphore.pxd +44 -0
  200. Cython/Includes/libcpp/set.pxd +228 -0
  201. Cython/Includes/libcpp/shared_mutex.pxd +72 -0
  202. Cython/Includes/libcpp/span.pxd +87 -0
  203. Cython/Includes/libcpp/stack.pxd +11 -0
  204. Cython/Includes/libcpp/stop_token.pxd +105 -0
  205. Cython/Includes/libcpp/string.pxd +355 -0
  206. Cython/Includes/libcpp/string_view.pxd +181 -0
  207. Cython/Includes/libcpp/typeindex.pxd +15 -0
  208. Cython/Includes/libcpp/typeinfo.pxd +10 -0
  209. Cython/Includes/libcpp/unordered_map.pxd +193 -0
  210. Cython/Includes/libcpp/unordered_set.pxd +152 -0
  211. Cython/Includes/libcpp/utility.pxd +30 -0
  212. Cython/Includes/libcpp/vector.pxd +186 -0
  213. Cython/Includes/openmp.pxd +50 -0
  214. Cython/Includes/posix/__init__.pxd +1 -0
  215. Cython/Includes/posix/dlfcn.pxd +14 -0
  216. Cython/Includes/posix/fcntl.pxd +86 -0
  217. Cython/Includes/posix/ioctl.pxd +4 -0
  218. Cython/Includes/posix/mman.pxd +101 -0
  219. Cython/Includes/posix/resource.pxd +57 -0
  220. Cython/Includes/posix/select.pxd +21 -0
  221. Cython/Includes/posix/signal.pxd +73 -0
  222. Cython/Includes/posix/stat.pxd +98 -0
  223. Cython/Includes/posix/stdio.pxd +37 -0
  224. Cython/Includes/posix/stdlib.pxd +29 -0
  225. Cython/Includes/posix/strings.pxd +9 -0
  226. Cython/Includes/posix/time.pxd +71 -0
  227. Cython/Includes/posix/types.pxd +30 -0
  228. Cython/Includes/posix/uio.pxd +26 -0
  229. Cython/Includes/posix/unistd.pxd +271 -0
  230. Cython/Includes/posix/wait.pxd +38 -0
  231. Cython/Plex/Actions.pxd +24 -0
  232. Cython/Plex/Actions.py +119 -0
  233. Cython/Plex/DFA.pxd +14 -0
  234. Cython/Plex/DFA.py +164 -0
  235. Cython/Plex/Errors.py +48 -0
  236. Cython/Plex/Lexicons.py +178 -0
  237. Cython/Plex/Machines.pxd +36 -0
  238. Cython/Plex/Machines.py +238 -0
  239. Cython/Plex/Regexps.py +539 -0
  240. Cython/Plex/Scanners.pxd +47 -0
  241. Cython/Plex/Scanners.py +360 -0
  242. Cython/Plex/Transitions.pxd +14 -0
  243. Cython/Plex/Transitions.py +239 -0
  244. Cython/Plex/__init__.py +34 -0
  245. Cython/Runtime/__init__.py +1 -0
  246. Cython/Runtime/refnanny.pyx +237 -0
  247. Cython/Shadow.py +690 -0
  248. Cython/Shadow.pyi +521 -0
  249. Cython/StringIOTree.py +170 -0
  250. Cython/Tempita/__init__.py +4 -0
  251. Cython/Tempita/_looper.py +154 -0
  252. Cython/Tempita/_tempita.py +1091 -0
  253. Cython/TestUtils.py +410 -0
  254. Cython/Tests/TestCodeWriter.py +128 -0
  255. Cython/Tests/TestCythonUtils.py +202 -0
  256. Cython/Tests/TestJediTyper.py +223 -0
  257. Cython/Tests/TestShadow.py +114 -0
  258. Cython/Tests/TestStringIOTree.py +67 -0
  259. Cython/Tests/TestTestUtils.py +90 -0
  260. Cython/Tests/__init__.py +1 -0
  261. Cython/Tests/xmlrunner.py +390 -0
  262. Cython/Utility/AsyncGen.c +1002 -0
  263. Cython/Utility/Buffer.c +875 -0
  264. Cython/Utility/BufferFormatFromTypeInfo.pxd +2 -0
  265. Cython/Utility/Builtins.c +776 -0
  266. Cython/Utility/CConvert.pyx +134 -0
  267. Cython/Utility/CMath.c +104 -0
  268. Cython/Utility/CommonStructures.c +118 -0
  269. Cython/Utility/Complex.c +378 -0
  270. Cython/Utility/Coroutine.c +2206 -0
  271. Cython/Utility/CpdefEnums.pyx +103 -0
  272. Cython/Utility/CppConvert.pyx +279 -0
  273. Cython/Utility/CppSupport.cpp +143 -0
  274. Cython/Utility/CythonFunction.c +1794 -0
  275. Cython/Utility/Dataclasses.c +185 -0
  276. Cython/Utility/Dataclasses.py +112 -0
  277. Cython/Utility/Embed.c +125 -0
  278. Cython/Utility/Exceptions.c +1012 -0
  279. Cython/Utility/ExtensionTypes.c +809 -0
  280. Cython/Utility/FunctionArguments.c +965 -0
  281. Cython/Utility/ImportExport.c +987 -0
  282. Cython/Utility/Lock.c +136 -0
  283. Cython/Utility/MemoryView.pxd +187 -0
  284. Cython/Utility/MemoryView.pyx +1481 -0
  285. Cython/Utility/MemoryView_C.c +1046 -0
  286. Cython/Utility/ModuleSetupCode.c +3059 -0
  287. Cython/Utility/NumpyImportArray.c +46 -0
  288. Cython/Utility/ObjectHandling.c +3342 -0
  289. Cython/Utility/Optimize.c +1589 -0
  290. Cython/Utility/Overflow.c +404 -0
  291. Cython/Utility/Printing.c +86 -0
  292. Cython/Utility/Profile.c +709 -0
  293. Cython/Utility/StringTools.c +1259 -0
  294. Cython/Utility/TestCyUtilityLoader.pyx +8 -0
  295. Cython/Utility/TestCythonScope.pyx +75 -0
  296. Cython/Utility/TestUtilityLoader.c +12 -0
  297. Cython/Utility/TypeConversion.c +1284 -0
  298. Cython/Utility/UFuncs.pyx +50 -0
  299. Cython/Utility/UFuncs_C.c +89 -0
  300. Cython/Utility/__init__.py +28 -0
  301. Cython/Utility/arrayarray.h +148 -0
  302. Cython/Utils.py +687 -0
  303. Cython/__init__.py +10 -0
  304. Cython/__init__.pyi +7 -0
  305. Cython/py.typed +0 -0
  306. cython-3.1.0.dist-info/COPYING.txt +19 -0
  307. cython-3.1.0.dist-info/LICENSE.txt +176 -0
  308. cython-3.1.0.dist-info/METADATA +636 -0
  309. cython-3.1.0.dist-info/RECORD +316 -0
  310. cython-3.1.0.dist-info/WHEEL +5 -0
  311. cython-3.1.0.dist-info/entry_points.txt +4 -0
  312. cython-3.1.0.dist-info/top_level.txt +3 -0
  313. cython.py +29 -0
  314. pyximport/__init__.py +4 -0
  315. pyximport/pyxbuild.py +160 -0
  316. pyximport/pyximport.py +482 -0
@@ -0,0 +1,1794 @@
1
+
2
+ //////////////////// CythonFunctionShared.proto ////////////////////
3
+
4
+ #define __Pyx_CyFunction_USED
5
+
6
+ #define __Pyx_CYFUNCTION_STATICMETHOD 0x01
7
+ #define __Pyx_CYFUNCTION_CLASSMETHOD 0x02
8
+ #define __Pyx_CYFUNCTION_CCLASS 0x04
9
+ #define __Pyx_CYFUNCTION_COROUTINE 0x08
10
+
11
+ #define __Pyx_CyFunction_GetClosure(f) \
12
+ (((__pyx_CyFunctionObject *) (f))->func_closure)
13
+
14
+ #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API
15
+ #define __Pyx_CyFunction_GetClassObj(f) \
16
+ (((__pyx_CyFunctionObject *) (f))->func_classobj)
17
+ #else
18
+ #define __Pyx_CyFunction_GetClassObj(f) \
19
+ ((PyObject*) ((PyCMethodObject *) (f))->mm_class)
20
+ #endif
21
+ #define __Pyx_CyFunction_SetClassObj(f, classobj) \
22
+ __Pyx__CyFunction_SetClassObj((__pyx_CyFunctionObject *) (f), (classobj))
23
+
24
+ #define __Pyx_CyFunction_Defaults(type, f) \
25
+ ((type *)(((__pyx_CyFunctionObject *) (f))->defaults))
26
+ #define __Pyx_CyFunction_SetDefaultsGetter(f, g) \
27
+ ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g)
28
+
29
+
30
+ typedef struct {
31
+ #if CYTHON_COMPILING_IN_LIMITED_API
32
+ PyObject_HEAD
33
+ // We can't "inherit" from func, but we can use it as a data store
34
+ PyObject *func;
35
+ #elif PY_VERSION_HEX < 0x030900B1
36
+ PyCFunctionObject func;
37
+ #else
38
+ // PEP-573: PyCFunctionObject + mm_class
39
+ PyCMethodObject func;
40
+ #endif
41
+ #if CYTHON_BACKPORT_VECTORCALL || \
42
+ (CYTHON_COMPILING_IN_LIMITED_API && CYTHON_METH_FASTCALL)
43
+ __pyx_vectorcallfunc func_vectorcall;
44
+ #endif
45
+ #if CYTHON_COMPILING_IN_LIMITED_API
46
+ PyObject *func_weakreflist;
47
+ #endif
48
+ PyObject *func_dict;
49
+ PyObject *func_name;
50
+ PyObject *func_qualname;
51
+ PyObject *func_doc;
52
+ PyObject *func_globals;
53
+ PyObject *func_code;
54
+ PyObject *func_closure;
55
+ #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API
56
+ // No-args super() class cell
57
+ PyObject *func_classobj;
58
+ #endif
59
+ // Dynamic default args and annotations
60
+ PyObject *defaults;
61
+ int flags;
62
+
63
+ // Defaults info
64
+ PyObject *defaults_tuple; /* Const defaults tuple */
65
+ PyObject *defaults_kwdict; /* Const kwonly defaults dict */
66
+ PyObject *(*defaults_getter)(PyObject *);
67
+ PyObject *func_annotations; /* function annotations dict */
68
+
69
+ // Coroutine marker
70
+ PyObject *func_is_coroutine;
71
+ } __pyx_CyFunctionObject;
72
+
73
+ #undef __Pyx_CyOrPyCFunction_Check
74
+ #define __Pyx_CyFunction_Check(obj) __Pyx_TypeCheck(obj, CGLOBAL(__pyx_CyFunctionType))
75
+ #define __Pyx_CyOrPyCFunction_Check(obj) __Pyx_TypeCheck2(obj, CGLOBAL(__pyx_CyFunctionType), &PyCFunction_Type)
76
+ #define __Pyx_CyFunction_CheckExact(obj) __Pyx_IS_TYPE(obj, CGLOBAL(__pyx_CyFunctionType))
77
+ static CYTHON_INLINE int __Pyx__IsSameCyOrCFunction(PyObject *func, void (*cfunc)(void));/*proto*/
78
+ #undef __Pyx_IsSameCFunction
79
+ #define __Pyx_IsSameCFunction(func, cfunc) __Pyx__IsSameCyOrCFunction(func, cfunc)
80
+
81
+ static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject* op, PyMethodDef *ml,
82
+ int flags, PyObject* qualname,
83
+ PyObject *closure,
84
+ PyObject *module, PyObject *globals,
85
+ PyObject* code);
86
+
87
+ static CYTHON_INLINE void __Pyx__CyFunction_SetClassObj(__pyx_CyFunctionObject* f, PyObject* classobj);
88
+ static CYTHON_INLINE PyObject *__Pyx_CyFunction_InitDefaults(PyObject *func,
89
+ PyTypeObject *defaults_type);
90
+ static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m,
91
+ PyObject *tuple);
92
+ static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m,
93
+ PyObject *dict);
94
+ static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m,
95
+ PyObject *dict);
96
+
97
+
98
+ static int __pyx_CyFunction_init(PyObject *module);
99
+
100
+ #if CYTHON_METH_FASTCALL
101
+ static PyObject * __Pyx_CyFunction_Vectorcall_NOARGS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames);
102
+ static PyObject * __Pyx_CyFunction_Vectorcall_O(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames);
103
+ static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames);
104
+ static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS_METHOD(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames);
105
+ #if CYTHON_BACKPORT_VECTORCALL || CYTHON_COMPILING_IN_LIMITED_API
106
+ #define __Pyx_CyFunction_func_vectorcall(f) (((__pyx_CyFunctionObject*)f)->func_vectorcall)
107
+ #else
108
+ #define __Pyx_CyFunction_func_vectorcall(f) (((PyCFunctionObject*)f)->vectorcall)
109
+ #endif
110
+ #endif
111
+
112
+ //////////////////// CythonFunctionShared ////////////////////
113
+ //@requires: CommonStructures.c::FetchCommonType
114
+ //@requires: ObjectHandling.c::PyMethodNew
115
+ //@requires: ObjectHandling.c::PyVectorcallFastCallDict
116
+ //@requires: ModuleSetupCode.c::IncludeStructmemberH
117
+ //@requires: ObjectHandling.c::PyObjectGetAttrStr
118
+ //@requires: ObjectHandling.c::CachedMethodType
119
+ //@requires: ExtensionTypes.c::CallTypeTraverse
120
+ //@requires: ModuleSetupCode.c::CriticalSections
121
+ //@substitute: naming
122
+
123
+ #if CYTHON_COMPILING_IN_LIMITED_API
124
+ static CYTHON_INLINE int __Pyx__IsSameCyOrCFunctionNoMethod(PyObject *func, void (*cfunc)(void)) {
125
+ if (__Pyx_CyFunction_Check(func)) {
126
+ return PyCFunction_GetFunction(((__pyx_CyFunctionObject*)func)->func) == (PyCFunction) cfunc;
127
+ } else if (PyCFunction_Check(func)) {
128
+ return PyCFunction_GetFunction(func) == (PyCFunction) cfunc;
129
+ }
130
+ return 0;
131
+ }
132
+
133
+ static CYTHON_INLINE int __Pyx__IsSameCyOrCFunction(PyObject *func, void (*cfunc)(void)) {
134
+ if ((PyObject*)Py_TYPE(func) == CGLOBAL(__Pyx_CachedMethodType)) {
135
+ int result;
136
+ PyObject *newFunc = PyObject_GetAttr(func, PYIDENT("__func__"));
137
+ if (unlikely(!newFunc)) {
138
+ PyErr_Clear(); // It's only an optimization, so don't throw an error
139
+ return 0;
140
+ }
141
+ result = __Pyx__IsSameCyOrCFunctionNoMethod(newFunc, cfunc);
142
+ Py_DECREF(newFunc);
143
+ return result;
144
+ }
145
+ return __Pyx__IsSameCyOrCFunctionNoMethod(func, cfunc);
146
+ }
147
+ #else
148
+ static CYTHON_INLINE int __Pyx__IsSameCyOrCFunction(PyObject *func, void (*cfunc)(void)) {
149
+ if (PyMethod_Check(func)) {
150
+ func = PyMethod_GET_FUNCTION(func);
151
+ }
152
+ return __Pyx_CyOrPyCFunction_Check(func) && __Pyx_CyOrPyCFunction_GET_FUNCTION(func) == (PyCFunction) cfunc;
153
+ }
154
+ #endif
155
+
156
+ static CYTHON_INLINE void __Pyx__CyFunction_SetClassObj(__pyx_CyFunctionObject* f, PyObject* classobj) {
157
+ #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API
158
+ __Pyx_Py_XDECREF_SET(
159
+ __Pyx_CyFunction_GetClassObj(f),
160
+ ((classobj) ? __Pyx_NewRef(classobj) : NULL));
161
+ #else
162
+ __Pyx_Py_XDECREF_SET(
163
+ // assigning to "mm_class", which is a "PyTypeObject*"
164
+ ((PyCMethodObject *) (f))->mm_class,
165
+ (PyTypeObject*)((classobj) ? __Pyx_NewRef(classobj) : NULL));
166
+ #endif
167
+ }
168
+
169
+ static PyObject *
170
+ __Pyx_CyFunction_get_doc_locked(__pyx_CyFunctionObject *op)
171
+ {
172
+ if (unlikely(op->func_doc == NULL)) {
173
+ #if CYTHON_COMPILING_IN_LIMITED_API
174
+ op->func_doc = PyObject_GetAttrString(op->func, "__doc__");
175
+ if (unlikely(!op->func_doc)) return NULL;
176
+ #else
177
+ if (((PyCFunctionObject*)op)->m_ml->ml_doc) {
178
+ op->func_doc = PyUnicode_FromString(((PyCFunctionObject*)op)->m_ml->ml_doc);
179
+ if (unlikely(op->func_doc == NULL))
180
+ return NULL;
181
+ } else {
182
+ Py_INCREF(Py_None);
183
+ return Py_None;
184
+ }
185
+ #endif /* CYTHON_COMPILING_IN_LIMITED_API */
186
+ }
187
+ Py_INCREF(op->func_doc);
188
+ return op->func_doc;
189
+ }
190
+
191
+ static PyObject *
192
+ __Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, void *closure) {
193
+ PyObject *result;
194
+ CYTHON_UNUSED_VAR(closure);
195
+ __Pyx_BEGIN_CRITICAL_SECTION(op);
196
+ result = __Pyx_CyFunction_get_doc_locked(op);
197
+ __Pyx_END_CRITICAL_SECTION();
198
+ return result;
199
+ }
200
+
201
+ static int
202
+ __Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value, void *context)
203
+ {
204
+ CYTHON_UNUSED_VAR(context);
205
+ if (value == NULL) {
206
+ // Mark as deleted
207
+ value = Py_None;
208
+ }
209
+ Py_INCREF(value);
210
+ __Pyx_BEGIN_CRITICAL_SECTION(op);
211
+ __Pyx_Py_XDECREF_SET(op->func_doc, value);
212
+ __Pyx_END_CRITICAL_SECTION();
213
+ return 0;
214
+ }
215
+
216
+ static PyObject *
217
+ __Pyx_CyFunction_get_name_locked(__pyx_CyFunctionObject *op)
218
+ {
219
+ if (unlikely(op->func_name == NULL)) {
220
+ #if CYTHON_COMPILING_IN_LIMITED_API
221
+ op->func_name = PyObject_GetAttrString(op->func, "__name__");
222
+ #else
223
+ op->func_name = PyUnicode_InternFromString(((PyCFunctionObject*)op)->m_ml->ml_name);
224
+ #endif /* CYTHON_COMPILING_IN_LIMITED_API */
225
+ if (unlikely(op->func_name == NULL))
226
+ return NULL;
227
+ }
228
+ Py_INCREF(op->func_name);
229
+ return op->func_name;
230
+ }
231
+
232
+ static PyObject *
233
+ __Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op, void *context)
234
+ {
235
+ PyObject *result = NULL;
236
+ CYTHON_UNUSED_VAR(context);
237
+ __Pyx_BEGIN_CRITICAL_SECTION(op);
238
+ result = __Pyx_CyFunction_get_name_locked(op);
239
+ __Pyx_END_CRITICAL_SECTION();
240
+ return result;
241
+ }
242
+
243
+ static int
244
+ __Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value, void *context)
245
+ {
246
+ CYTHON_UNUSED_VAR(context);
247
+ if (unlikely(value == NULL || !PyUnicode_Check(value))) {
248
+ PyErr_SetString(PyExc_TypeError,
249
+ "__name__ must be set to a string object");
250
+ return -1;
251
+ }
252
+ Py_INCREF(value);
253
+ __Pyx_BEGIN_CRITICAL_SECTION(op);
254
+ __Pyx_Py_XDECREF_SET(op->func_name, value);
255
+ __Pyx_END_CRITICAL_SECTION();
256
+ return 0;
257
+ }
258
+
259
+ static PyObject *
260
+ __Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op, void *context)
261
+ {
262
+ CYTHON_UNUSED_VAR(context);
263
+ PyObject *result;
264
+ __Pyx_BEGIN_CRITICAL_SECTION(op);
265
+ Py_INCREF(op->func_qualname);
266
+ result = op->func_qualname;
267
+ __Pyx_END_CRITICAL_SECTION();
268
+ return result;
269
+ }
270
+
271
+ static int
272
+ __Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value, void *context)
273
+ {
274
+ CYTHON_UNUSED_VAR(context);
275
+ if (unlikely(value == NULL || !PyUnicode_Check(value))) {
276
+ PyErr_SetString(PyExc_TypeError,
277
+ "__qualname__ must be set to a string object");
278
+ return -1;
279
+ }
280
+ Py_INCREF(value);
281
+ __Pyx_BEGIN_CRITICAL_SECTION(op);
282
+ __Pyx_Py_XDECREF_SET(op->func_qualname, value);
283
+ __Pyx_END_CRITICAL_SECTION();
284
+ return 0;
285
+ }
286
+
287
+ static PyObject *
288
+ __Pyx_CyFunction_get_dict_locked(__pyx_CyFunctionObject *op)
289
+ {
290
+ if (unlikely(op->func_dict == NULL)) {
291
+ op->func_dict = PyDict_New();
292
+ if (unlikely(op->func_dict == NULL))
293
+ return NULL;
294
+ }
295
+ Py_INCREF(op->func_dict);
296
+ return op->func_dict;
297
+ }
298
+
299
+ static PyObject *
300
+ __Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op, void *context)
301
+ {
302
+ CYTHON_UNUSED_VAR(context);
303
+ PyObject *result;
304
+ __Pyx_BEGIN_CRITICAL_SECTION(op);
305
+ result = __Pyx_CyFunction_get_dict_locked(op);
306
+ __Pyx_END_CRITICAL_SECTION();
307
+ return result;
308
+ }
309
+
310
+ static int
311
+ __Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value, void *context)
312
+ {
313
+ CYTHON_UNUSED_VAR(context);
314
+ if (unlikely(value == NULL)) {
315
+ PyErr_SetString(PyExc_TypeError,
316
+ "function's dictionary may not be deleted");
317
+ return -1;
318
+ }
319
+ if (unlikely(!PyDict_Check(value))) {
320
+ PyErr_SetString(PyExc_TypeError,
321
+ "setting function's dictionary to a non-dict");
322
+ return -1;
323
+ }
324
+ Py_INCREF(value);
325
+ __Pyx_BEGIN_CRITICAL_SECTION(op);
326
+ __Pyx_Py_XDECREF_SET(op->func_dict, value);
327
+ __Pyx_END_CRITICAL_SECTION();
328
+ return 0;
329
+ }
330
+
331
+ static PyObject *
332
+ __Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op, void *context)
333
+ {
334
+ CYTHON_UNUSED_VAR(context);
335
+ // Globals is read-only so no critical sections
336
+ Py_INCREF(op->func_globals);
337
+ return op->func_globals;
338
+ }
339
+
340
+ static PyObject *
341
+ __Pyx_CyFunction_get_closure(__pyx_CyFunctionObject *op, void *context)
342
+ {
343
+ CYTHON_UNUSED_VAR(op);
344
+ CYTHON_UNUSED_VAR(context);
345
+ Py_INCREF(Py_None);
346
+ return Py_None;
347
+ }
348
+
349
+ static PyObject *
350
+ __Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op, void *context)
351
+ {
352
+ // code is read-only so no critical sections
353
+ PyObject* result = (op->func_code) ? op->func_code : Py_None;
354
+ CYTHON_UNUSED_VAR(context);
355
+ Py_INCREF(result);
356
+ return result;
357
+ }
358
+
359
+ static int
360
+ __Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) {
361
+ int result = 0;
362
+ PyObject *res = op->defaults_getter((PyObject *) op);
363
+ if (unlikely(!res))
364
+ return -1;
365
+
366
+ // Cache result
367
+ #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
368
+ op->defaults_tuple = PyTuple_GET_ITEM(res, 0);
369
+ Py_INCREF(op->defaults_tuple);
370
+ op->defaults_kwdict = PyTuple_GET_ITEM(res, 1);
371
+ Py_INCREF(op->defaults_kwdict);
372
+ #else
373
+ op->defaults_tuple = __Pyx_PySequence_ITEM(res, 0);
374
+ if (unlikely(!op->defaults_tuple)) result = -1;
375
+ else {
376
+ op->defaults_kwdict = __Pyx_PySequence_ITEM(res, 1);
377
+ if (unlikely(!op->defaults_kwdict)) result = -1;
378
+ }
379
+ #endif
380
+ Py_DECREF(res);
381
+ return result;
382
+ }
383
+
384
+ static int
385
+ __Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value, void *context) {
386
+ CYTHON_UNUSED_VAR(context);
387
+ if (!value) {
388
+ // del => explicit None to prevent rebuilding
389
+ value = Py_None;
390
+ } else if (unlikely(value != Py_None && !PyTuple_Check(value))) {
391
+ PyErr_SetString(PyExc_TypeError,
392
+ "__defaults__ must be set to a tuple object");
393
+ return -1;
394
+ }
395
+ PyErr_WarnEx(PyExc_RuntimeWarning, "changes to cyfunction.__defaults__ will not "
396
+ "currently affect the values used in function calls", 1);
397
+ Py_INCREF(value);
398
+ __Pyx_BEGIN_CRITICAL_SECTION(op);
399
+ __Pyx_Py_XDECREF_SET(op->defaults_tuple, value);
400
+ __Pyx_END_CRITICAL_SECTION();
401
+ return 0;
402
+ }
403
+
404
+ static PyObject *
405
+ __Pyx_CyFunction_get_defaults_locked(__pyx_CyFunctionObject *op) {
406
+ PyObject* result = op->defaults_tuple;
407
+ if (unlikely(!result)) {
408
+ if (op->defaults_getter) {
409
+ if (unlikely(__Pyx_CyFunction_init_defaults(op) < 0)) return NULL;
410
+ result = op->defaults_tuple;
411
+ } else {
412
+ result = Py_None;
413
+ }
414
+ }
415
+ Py_INCREF(result);
416
+ return result;
417
+ }
418
+
419
+ static PyObject *
420
+ __Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op, void *context) {
421
+ PyObject* result = NULL;
422
+ CYTHON_UNUSED_VAR(context);
423
+ __Pyx_BEGIN_CRITICAL_SECTION(op);
424
+ result = __Pyx_CyFunction_get_defaults_locked(op);
425
+ __Pyx_END_CRITICAL_SECTION();
426
+ return result;
427
+ }
428
+
429
+ static int
430
+ __Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value, void *context) {
431
+ CYTHON_UNUSED_VAR(context);
432
+ if (!value) {
433
+ // del => explicit None to prevent rebuilding
434
+ value = Py_None;
435
+ } else if (unlikely(value != Py_None && !PyDict_Check(value))) {
436
+ PyErr_SetString(PyExc_TypeError,
437
+ "__kwdefaults__ must be set to a dict object");
438
+ return -1;
439
+ }
440
+ PyErr_WarnEx(PyExc_RuntimeWarning, "changes to cyfunction.__kwdefaults__ will not "
441
+ "currently affect the values used in function calls", 1);
442
+ Py_INCREF(value);
443
+ __Pyx_BEGIN_CRITICAL_SECTION(op);
444
+ __Pyx_Py_XDECREF_SET(op->defaults_kwdict, value);
445
+ __Pyx_END_CRITICAL_SECTION();
446
+ return 0;
447
+ }
448
+
449
+ static PyObject *
450
+ __Pyx_CyFunction_get_kwdefaults_locked(__pyx_CyFunctionObject *op) {
451
+ PyObject* result = op->defaults_kwdict;
452
+ if (unlikely(!result)) {
453
+ if (op->defaults_getter) {
454
+ if (unlikely(__Pyx_CyFunction_init_defaults(op) < 0)) return NULL;
455
+ result = op->defaults_kwdict;
456
+ } else {
457
+ result = Py_None;
458
+ }
459
+ }
460
+ Py_INCREF(result);
461
+ return result;
462
+ }
463
+
464
+ static PyObject *
465
+ __Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op, void *context) {
466
+ PyObject* result;
467
+ CYTHON_UNUSED_VAR(context);
468
+ __Pyx_BEGIN_CRITICAL_SECTION(op);
469
+ result = __Pyx_CyFunction_get_kwdefaults_locked(op);
470
+ __Pyx_END_CRITICAL_SECTION();
471
+ return result;
472
+ }
473
+
474
+ static int
475
+ __Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value, void *context) {
476
+ CYTHON_UNUSED_VAR(context);
477
+ if (!value || value == Py_None) {
478
+ value = NULL;
479
+ } else if (unlikely(!PyDict_Check(value))) {
480
+ PyErr_SetString(PyExc_TypeError,
481
+ "__annotations__ must be set to a dict object");
482
+ return -1;
483
+ }
484
+ Py_XINCREF(value);
485
+ __Pyx_BEGIN_CRITICAL_SECTION(op);
486
+ __Pyx_Py_XDECREF_SET(op->func_annotations, value);
487
+ __Pyx_END_CRITICAL_SECTION();
488
+ return 0;
489
+ }
490
+
491
+ static PyObject *
492
+ __Pyx_CyFunction_get_annotations_locked(__pyx_CyFunctionObject *op) {
493
+ PyObject* result = op->func_annotations;
494
+ if (unlikely(!result)) {
495
+ result = PyDict_New();
496
+ if (unlikely(!result)) return NULL;
497
+ op->func_annotations = result;
498
+ }
499
+ Py_INCREF(result);
500
+ return result;
501
+ }
502
+
503
+ static PyObject *
504
+ __Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op, void *context) {
505
+ PyObject *result;
506
+ CYTHON_UNUSED_VAR(context);
507
+ __Pyx_BEGIN_CRITICAL_SECTION(op);
508
+ result = __Pyx_CyFunction_get_annotations_locked(op);
509
+ __Pyx_END_CRITICAL_SECTION();
510
+ return result;
511
+ }
512
+
513
+ static PyObject *
514
+ __Pyx_CyFunction_get_is_coroutine_value(__pyx_CyFunctionObject *op) {
515
+ int is_coroutine = op->flags & __Pyx_CYFUNCTION_COROUTINE;
516
+ if (is_coroutine) {
517
+ PyObject *is_coroutine_value, *module, *fromlist, *marker = PYIDENT("_is_coroutine");
518
+ fromlist = PyList_New(1);
519
+ if (unlikely(!fromlist)) return NULL;
520
+ Py_INCREF(marker);
521
+ #if CYTHON_ASSUME_SAFE_MACROS
522
+ PyList_SET_ITEM(fromlist, 0, marker);
523
+ #else
524
+ if (unlikely(PyList_SetItem(fromlist, 0, marker) < 0)) {
525
+ Py_DECREF(marker);
526
+ Py_DECREF(fromlist);
527
+ return NULL;
528
+ }
529
+ #endif
530
+ module = PyImport_ImportModuleLevelObject(PYIDENT("asyncio.coroutines"), NULL, NULL, fromlist, 0);
531
+ Py_DECREF(fromlist);
532
+ if (unlikely(!module)) goto ignore;
533
+ is_coroutine_value = __Pyx_PyObject_GetAttrStr(module, marker);
534
+ Py_DECREF(module);
535
+ if (likely(is_coroutine_value)) {
536
+ return is_coroutine_value;
537
+ }
538
+ ignore:
539
+ PyErr_Clear();
540
+ }
541
+
542
+ return __Pyx_PyBool_FromLong(is_coroutine);
543
+ }
544
+
545
+ static PyObject *
546
+ __Pyx_CyFunction_get_is_coroutine(__pyx_CyFunctionObject *op, void *context) {
547
+ PyObject *result;
548
+ CYTHON_UNUSED_VAR(context);
549
+ if (op->func_is_coroutine) {
550
+ return __Pyx_NewRef(op->func_is_coroutine);
551
+ }
552
+
553
+ result = __Pyx_CyFunction_get_is_coroutine_value(op);
554
+ if (unlikely(!result))
555
+ return NULL;
556
+
557
+ __Pyx_BEGIN_CRITICAL_SECTION(op);
558
+ // Guard against concurrent initialisation.
559
+ if (op->func_is_coroutine) {
560
+ Py_DECREF(result);
561
+ result = __Pyx_NewRef(op->func_is_coroutine);
562
+ } else {
563
+ op->func_is_coroutine = __Pyx_NewRef(result);
564
+ }
565
+ __Pyx_END_CRITICAL_SECTION();
566
+ return result;
567
+ }
568
+
569
+ //static PyObject *
570
+ //__Pyx_CyFunction_get_signature(__pyx_CyFunctionObject *op, void *context) {
571
+ // PyObject *inspect_module, *signature_class, *signature;
572
+ // CYTHON_UNUSED_VAR(context);
573
+ // // from inspect import Signature
574
+ // inspect_module = PyImport_ImportModuleLevelObject(PYIDENT("inspect"), NULL, NULL, NULL, 0);
575
+ // if (unlikely(!inspect_module))
576
+ // goto bad;
577
+ // signature_class = __Pyx_PyObject_GetAttrStr(inspect_module, PYIDENT("Signature"));
578
+ // Py_DECREF(inspect_module);
579
+ // if (unlikely(!signature_class))
580
+ // goto bad;
581
+ // // return Signature.from_function(op)
582
+ // signature = PyObject_CallMethodObjArgs(signature_class, PYIDENT("from_function"), op, NULL);
583
+ // Py_DECREF(signature_class);
584
+ // if (likely(signature))
585
+ // return signature;
586
+ //bad:
587
+ // // make sure we raise an AttributeError from this property on any errors
588
+ // if (!PyErr_ExceptionMatches(PyExc_AttributeError))
589
+ // PyErr_SetString(PyExc_AttributeError, "failed to calculate __signature__");
590
+ // return NULL;
591
+ //}
592
+
593
+ static void __Pyx_CyFunction_raise_argument_count_error(__pyx_CyFunctionObject *func, const char* message, Py_ssize_t size) {
594
+ #if CYTHON_COMPILING_IN_LIMITED_API
595
+ PyObject *py_name = __Pyx_CyFunction_get_name(func, NULL);
596
+ if (!py_name) return;
597
+ PyErr_Format(PyExc_TypeError,
598
+ "%.200S() %s (%" CYTHON_FORMAT_SSIZE_T "d given)",
599
+ py_name, message, size);
600
+ Py_DECREF(py_name);
601
+ #else
602
+ const char* name = ((PyCFunctionObject*)func)->m_ml->ml_name;
603
+ PyErr_Format(PyExc_TypeError,
604
+ "%.200s() %s (%" CYTHON_FORMAT_SSIZE_T "d given)",
605
+ name, message, size);
606
+ #endif
607
+ }
608
+
609
+ static void __Pyx_CyFunction_raise_type_error(__pyx_CyFunctionObject *func, const char* message) {
610
+ #if CYTHON_COMPILING_IN_LIMITED_API
611
+ PyObject *py_name = __Pyx_CyFunction_get_name(func, NULL);
612
+ if (!py_name) return;
613
+ PyErr_Format(PyExc_TypeError,
614
+ "%.200S() %s",
615
+ py_name, message);
616
+ Py_DECREF(py_name);
617
+ #else
618
+ const char* name = ((PyCFunctionObject*)func)->m_ml->ml_name;
619
+ PyErr_Format(PyExc_TypeError,
620
+ "%.200s() %s",
621
+ name, message);
622
+ #endif
623
+ }
624
+
625
+
626
+ #if CYTHON_COMPILING_IN_LIMITED_API
627
+ static PyObject *
628
+ __Pyx_CyFunction_get_module(__pyx_CyFunctionObject *op, void *context) {
629
+ CYTHON_UNUSED_VAR(context);
630
+ return PyObject_GetAttrString(op->func, "__module__");
631
+ }
632
+
633
+ static int
634
+ __Pyx_CyFunction_set_module(__pyx_CyFunctionObject *op, PyObject* value, void *context) {
635
+ CYTHON_UNUSED_VAR(context);
636
+ return PyObject_SetAttrString(op->func, "__module__", value);
637
+ }
638
+ #endif
639
+
640
+ static PyGetSetDef __pyx_CyFunction_getsets[] = {
641
+ {"func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
642
+ {"__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
643
+ {"func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
644
+ {"__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
645
+ {"__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0},
646
+ {"func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
647
+ {"__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
648
+ {"func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
649
+ {"__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
650
+ {"func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
651
+ {"__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
652
+ {"func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
653
+ {"__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
654
+ {"func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
655
+ {"__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
656
+ {"__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0},
657
+ {"__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0},
658
+ {"_is_coroutine", (getter)__Pyx_CyFunction_get_is_coroutine, 0, 0, 0},
659
+ // {"__signature__", (getter)__Pyx_CyFunction_get_signature, 0, 0, 0},
660
+ #if CYTHON_COMPILING_IN_LIMITED_API
661
+ {"__module__", (getter)__Pyx_CyFunction_get_module, (setter)__Pyx_CyFunction_set_module, 0, 0},
662
+ #endif
663
+ {0, 0, 0, 0, 0}
664
+ };
665
+
666
+ static PyMemberDef __pyx_CyFunction_members[] = {
667
+ #if !CYTHON_COMPILING_IN_LIMITED_API
668
+ {"__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), 0, 0},
669
+ #endif
670
+ {"__dictoffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_dict), READONLY, 0},
671
+ #if CYTHON_METH_FASTCALL
672
+ #if CYTHON_BACKPORT_VECTORCALL || CYTHON_COMPILING_IN_LIMITED_API
673
+ {"__vectorcalloffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_vectorcall), READONLY, 0},
674
+ #else
675
+ {"__vectorcalloffset__", T_PYSSIZET, offsetof(PyCFunctionObject, vectorcall), READONLY, 0},
676
+ #endif
677
+ #if CYTHON_COMPILING_IN_LIMITED_API
678
+ {"__weaklistoffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_weakreflist), READONLY, 0},
679
+ #else
680
+ {"__weaklistoffset__", T_PYSSIZET, offsetof(PyCFunctionObject, m_weakreflist), READONLY, 0},
681
+ #endif
682
+ #endif
683
+ {0, 0, 0, 0, 0}
684
+ };
685
+
686
+ static PyObject *
687
+ __Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, PyObject *args)
688
+ {
689
+ PyObject *result = NULL;
690
+ CYTHON_UNUSED_VAR(args);
691
+ __Pyx_BEGIN_CRITICAL_SECTION(m);
692
+ Py_INCREF(m->func_qualname);
693
+ result = m->func_qualname;
694
+ __Pyx_END_CRITICAL_SECTION();
695
+ return result;
696
+ }
697
+
698
+ static PyMethodDef __pyx_CyFunction_methods[] = {
699
+ {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
700
+ {0, 0, 0, 0}
701
+ };
702
+
703
+
704
+ #if CYTHON_COMPILING_IN_LIMITED_API
705
+ #define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist)
706
+ #else
707
+ #define __Pyx_CyFunction_weakreflist(cyfunc) (((PyCFunctionObject*)cyfunc)->m_weakreflist)
708
+ #endif
709
+
710
+ static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject *op, PyMethodDef *ml, int flags, PyObject* qualname,
711
+ PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
712
+ #if !CYTHON_COMPILING_IN_LIMITED_API
713
+ PyCFunctionObject *cf = (PyCFunctionObject*) op;
714
+ #endif
715
+ if (unlikely(op == NULL))
716
+ return NULL;
717
+ #if CYTHON_COMPILING_IN_LIMITED_API
718
+ // Note that we end up with a circular reference to op. This isn't
719
+ // a disaster, but in an ideal world it'd be nice to avoid it.
720
+ op->func = PyCFunction_NewEx(ml, (PyObject*)op, module);
721
+ if (unlikely(!op->func)) return NULL;
722
+ #endif
723
+ op->flags = flags;
724
+ __Pyx_CyFunction_weakreflist(op) = NULL;
725
+ #if !CYTHON_COMPILING_IN_LIMITED_API
726
+ cf->m_ml = ml;
727
+ cf->m_self = (PyObject *) op;
728
+ #endif
729
+ Py_XINCREF(closure);
730
+ op->func_closure = closure;
731
+ #if !CYTHON_COMPILING_IN_LIMITED_API
732
+ Py_XINCREF(module);
733
+ cf->m_module = module;
734
+ #endif
735
+ op->func_dict = NULL;
736
+ op->func_name = NULL;
737
+ Py_INCREF(qualname);
738
+ op->func_qualname = qualname;
739
+ op->func_doc = NULL;
740
+ #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API
741
+ op->func_classobj = NULL;
742
+ #else
743
+ ((PyCMethodObject*)op)->mm_class = NULL;
744
+ #endif
745
+ op->func_globals = globals;
746
+ Py_INCREF(op->func_globals);
747
+ Py_XINCREF(code);
748
+ op->func_code = code;
749
+ // Dynamic Default args
750
+ op->defaults = NULL;
751
+ op->defaults_tuple = NULL;
752
+ op->defaults_kwdict = NULL;
753
+ op->defaults_getter = NULL;
754
+ op->func_annotations = NULL;
755
+ op->func_is_coroutine = NULL;
756
+ #if CYTHON_METH_FASTCALL
757
+ switch (ml->ml_flags & (METH_VARARGS | METH_FASTCALL | METH_NOARGS | METH_O | METH_KEYWORDS | METH_METHOD)) {
758
+ case METH_NOARGS:
759
+ __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_NOARGS;
760
+ break;
761
+ case METH_O:
762
+ __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_O;
763
+ break;
764
+ // case METH_FASTCALL is not used
765
+ case METH_METHOD | METH_FASTCALL | METH_KEYWORDS:
766
+ __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS_METHOD;
767
+ break;
768
+ case METH_FASTCALL | METH_KEYWORDS:
769
+ __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS;
770
+ break;
771
+ // case METH_VARARGS is not used
772
+ case METH_VARARGS | METH_KEYWORDS:
773
+ __Pyx_CyFunction_func_vectorcall(op) = NULL;
774
+ break;
775
+ default:
776
+ PyErr_SetString(PyExc_SystemError, "Bad call flags for CyFunction");
777
+ Py_DECREF(op);
778
+ return NULL;
779
+ }
780
+ #endif
781
+ return (PyObject *) op;
782
+ }
783
+
784
+ static int
785
+ __Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
786
+ {
787
+ Py_CLEAR(m->func_closure);
788
+ #if CYTHON_COMPILING_IN_LIMITED_API
789
+ Py_CLEAR(m->func);
790
+ #else
791
+ Py_CLEAR(((PyCFunctionObject*)m)->m_module);
792
+ #endif
793
+ Py_CLEAR(m->func_dict);
794
+ Py_CLEAR(m->func_name);
795
+ Py_CLEAR(m->func_qualname);
796
+ Py_CLEAR(m->func_doc);
797
+ Py_CLEAR(m->func_globals);
798
+ Py_CLEAR(m->func_code);
799
+ #if !CYTHON_COMPILING_IN_LIMITED_API
800
+ #if PY_VERSION_HEX < 0x030900B1
801
+ Py_CLEAR(__Pyx_CyFunction_GetClassObj(m));
802
+ #else
803
+ {
804
+ PyObject *cls = (PyObject*) ((PyCMethodObject *) (m))->mm_class;
805
+ ((PyCMethodObject *) (m))->mm_class = NULL;
806
+ Py_XDECREF(cls);
807
+ }
808
+ #endif
809
+ #endif
810
+ Py_CLEAR(m->defaults_tuple);
811
+ Py_CLEAR(m->defaults_kwdict);
812
+ Py_CLEAR(m->func_annotations);
813
+ Py_CLEAR(m->func_is_coroutine);
814
+
815
+ Py_CLEAR(m->defaults);
816
+
817
+ return 0;
818
+ }
819
+
820
+ static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m)
821
+ {
822
+ if (__Pyx_CyFunction_weakreflist(m) != NULL)
823
+ PyObject_ClearWeakRefs((PyObject *) m);
824
+ __Pyx_CyFunction_clear(m);
825
+ __Pyx_PyHeapTypeObject_GC_Del(m);
826
+ }
827
+
828
+ static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
829
+ {
830
+ PyObject_GC_UnTrack(m);
831
+ __Pyx__CyFunction_dealloc(m);
832
+ }
833
+
834
+ static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
835
+ {
836
+ {
837
+ int e = __Pyx_call_type_traverse((PyObject*)m, 1, visit, arg);
838
+ if (e) return e;
839
+ }
840
+ Py_VISIT(m->func_closure);
841
+ #if CYTHON_COMPILING_IN_LIMITED_API
842
+ Py_VISIT(m->func);
843
+ #else
844
+ Py_VISIT(((PyCFunctionObject*)m)->m_module);
845
+ #endif
846
+ Py_VISIT(m->func_dict);
847
+ __Pyx_VISIT_CONST(m->func_name);
848
+ __Pyx_VISIT_CONST(m->func_qualname);
849
+ Py_VISIT(m->func_doc);
850
+ Py_VISIT(m->func_globals);
851
+ // The code objects that we generate only contain plain constants and can never participate in reference cycles.
852
+ __Pyx_VISIT_CONST(m->func_code);
853
+ #if !CYTHON_COMPILING_IN_LIMITED_API
854
+ Py_VISIT(__Pyx_CyFunction_GetClassObj(m));
855
+ #endif
856
+ Py_VISIT(m->defaults_tuple);
857
+ Py_VISIT(m->defaults_kwdict);
858
+ Py_VISIT(m->func_is_coroutine);
859
+ Py_VISIT(m->defaults);
860
+
861
+ return 0;
862
+ }
863
+
864
+ static PyObject*
865
+ __Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
866
+ {
867
+ PyObject *repr;
868
+ __Pyx_BEGIN_CRITICAL_SECTION(op);
869
+ repr = PyUnicode_FromFormat("<cyfunction %U at %p>",
870
+ op->func_qualname, (void *)op);
871
+ __Pyx_END_CRITICAL_SECTION();
872
+ return repr;
873
+ }
874
+
875
+ static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) {
876
+ // originally copied from PyCFunction_Call() in CPython's Objects/methodobject.c
877
+ #if CYTHON_COMPILING_IN_LIMITED_API
878
+ PyObject *f = ((__pyx_CyFunctionObject*)func)->func;
879
+ PyCFunction meth;
880
+ int flags;
881
+ meth = PyCFunction_GetFunction(f);
882
+ if (unlikely(!meth)) return NULL;
883
+ flags = PyCFunction_GetFlags(f);
884
+ if (unlikely(flags < 0)) return NULL;
885
+ #else
886
+ PyCFunctionObject* f = (PyCFunctionObject*)func;
887
+ PyCFunction meth = f->m_ml->ml_meth;
888
+ int flags = f->m_ml->ml_flags;
889
+ #endif
890
+ Py_ssize_t size;
891
+
892
+ switch (flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) {
893
+ case METH_VARARGS:
894
+ if (likely(kw == NULL || PyDict_Size(kw) == 0))
895
+ return (*meth)(self, arg);
896
+ break;
897
+ case METH_VARARGS | METH_KEYWORDS:
898
+ return (*(PyCFunctionWithKeywords)(void(*)(void))meth)(self, arg, kw);
899
+ case METH_NOARGS:
900
+ if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
901
+ #if CYTHON_ASSUME_SAFE_SIZE
902
+ size = PyTuple_GET_SIZE(arg);
903
+ #else
904
+ size = PyTuple_Size(arg);
905
+ if (unlikely(size < 0)) return NULL;
906
+ #endif
907
+ if (likely(size == 0))
908
+ return (*meth)(self, NULL);
909
+ __Pyx_CyFunction_raise_argument_count_error(
910
+ (__pyx_CyFunctionObject*)func,
911
+ "takes no arguments", size);
912
+ return NULL;
913
+ }
914
+ break;
915
+ case METH_O:
916
+ if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
917
+ #if CYTHON_ASSUME_SAFE_SIZE
918
+ size = PyTuple_GET_SIZE(arg);
919
+ #else
920
+ size = PyTuple_Size(arg);
921
+ if (unlikely(size < 0)) return NULL;
922
+ #endif
923
+ if (likely(size == 1)) {
924
+ PyObject *result, *arg0;
925
+ #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
926
+ arg0 = PyTuple_GET_ITEM(arg, 0);
927
+ #else
928
+ arg0 = __Pyx_PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL;
929
+ #endif
930
+ result = (*meth)(self, arg0);
931
+ #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
932
+ Py_DECREF(arg0);
933
+ #endif
934
+ return result;
935
+ }
936
+ __Pyx_CyFunction_raise_argument_count_error(
937
+ (__pyx_CyFunctionObject*)func,
938
+ "takes exactly one argument", size);
939
+ return NULL;
940
+ }
941
+ break;
942
+ default:
943
+ PyErr_SetString(PyExc_SystemError, "Bad call flags for CyFunction");
944
+ return NULL;
945
+ }
946
+ __Pyx_CyFunction_raise_type_error(
947
+ (__pyx_CyFunctionObject*)func, "takes no keyword arguments");
948
+ return NULL;
949
+ }
950
+
951
+ static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
952
+ PyObject *self, *result;
953
+ #if CYTHON_COMPILING_IN_LIMITED_API
954
+ // PyCFunction_GetSelf returns a borrowed reference
955
+ self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)func)->func);
956
+ if (unlikely(!self) && PyErr_Occurred()) return NULL;
957
+ #else
958
+ self = ((PyCFunctionObject*)func)->m_self;
959
+ #endif
960
+ result = __Pyx_CyFunction_CallMethod(func, self, arg, kw);
961
+ return result;
962
+ }
963
+
964
+ static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) {
965
+ PyObject *result;
966
+ __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func;
967
+
968
+ #if CYTHON_METH_FASTCALL && (CYTHON_VECTORCALL || CYTHON_BACKPORT_VECTORCALL)
969
+ // Prefer vectorcall if available. This is not the typical case, as
970
+ // CPython would normally use vectorcall directly instead of tp_call.
971
+ __pyx_vectorcallfunc vc = __Pyx_CyFunction_func_vectorcall(cyfunc);
972
+ if (vc) {
973
+ #if CYTHON_ASSUME_SAFE_MACROS && CYTHON_ASSUME_SAFE_SIZE
974
+ return __Pyx_PyVectorcall_FastCallDict(func, vc, &PyTuple_GET_ITEM(args, 0), (size_t)PyTuple_GET_SIZE(args), kw);
975
+ #else
976
+ // avoid unused function warning
977
+ (void) &__Pyx_PyVectorcall_FastCallDict;
978
+ return PyVectorcall_Call(func, args, kw);
979
+ #endif
980
+ }
981
+ #endif
982
+
983
+ if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) {
984
+ Py_ssize_t argc;
985
+ PyObject *new_args;
986
+ PyObject *self;
987
+
988
+ #if CYTHON_ASSUME_SAFE_SIZE
989
+ argc = PyTuple_GET_SIZE(args);
990
+ #else
991
+ argc = PyTuple_Size(args);
992
+ if (unlikely(argc < 0)) return NULL;
993
+ #endif
994
+ new_args = PyTuple_GetSlice(args, 1, argc);
995
+
996
+ if (unlikely(!new_args))
997
+ return NULL;
998
+
999
+ self = PyTuple_GetItem(args, 0);
1000
+ if (unlikely(!self)) {
1001
+ Py_DECREF(new_args);
1002
+ PyErr_Format(PyExc_TypeError,
1003
+ "unbound method %.200S() needs an argument",
1004
+ cyfunc->func_qualname);
1005
+ return NULL;
1006
+ }
1007
+
1008
+ result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw);
1009
+ Py_DECREF(new_args);
1010
+ } else {
1011
+ result = __Pyx_CyFunction_Call(func, args, kw);
1012
+ }
1013
+ return result;
1014
+ }
1015
+
1016
+ #if CYTHON_METH_FASTCALL && (CYTHON_VECTORCALL || CYTHON_BACKPORT_VECTORCALL)
1017
+ // Check that kwnames is empty (if you want to allow keyword arguments,
1018
+ // simply pass kwnames=NULL) and figure out what to do with "self".
1019
+ // Return value:
1020
+ // 1: self = args[0]
1021
+ // 0: self = cyfunc->func.m_self
1022
+ // -1: error
1023
+ static CYTHON_INLINE int __Pyx_CyFunction_Vectorcall_CheckArgs(__pyx_CyFunctionObject *cyfunc, Py_ssize_t nargs, PyObject *kwnames)
1024
+ {
1025
+ int ret = 0;
1026
+ if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) {
1027
+ if (unlikely(nargs < 1)) {
1028
+ __Pyx_CyFunction_raise_type_error(
1029
+ cyfunc, "needs an argument");
1030
+ return -1;
1031
+ }
1032
+ ret = 1;
1033
+ }
1034
+ if (unlikely(kwnames) && unlikely(__Pyx_PyTuple_GET_SIZE(kwnames))) {
1035
+ __Pyx_CyFunction_raise_type_error(
1036
+ cyfunc, "takes no keyword arguments");
1037
+ return -1;
1038
+ }
1039
+ return ret;
1040
+ }
1041
+
1042
+ static PyObject * __Pyx_CyFunction_Vectorcall_NOARGS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames)
1043
+ {
1044
+ __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func;
1045
+ #if CYTHON_BACKPORT_VECTORCALL
1046
+ Py_ssize_t nargs = (Py_ssize_t)nargsf;
1047
+ #else
1048
+ Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
1049
+ #endif
1050
+ PyObject *self;
1051
+ #if CYTHON_COMPILING_IN_LIMITED_API
1052
+ PyCFunction meth = PyCFunction_GetFunction(cyfunc->func);
1053
+ if (unlikely(!meth)) return NULL;
1054
+ #else
1055
+ PyCFunction meth = ((PyCFunctionObject*)cyfunc)->m_ml->ml_meth;
1056
+ #endif
1057
+
1058
+ switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, kwnames)) {
1059
+ case 1:
1060
+ self = args[0];
1061
+ args += 1;
1062
+ nargs -= 1;
1063
+ break;
1064
+ case 0:
1065
+ #if CYTHON_COMPILING_IN_LIMITED_API
1066
+ // PyCFunction_GetSelf returns a borrowed reference
1067
+ self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)cyfunc)->func);
1068
+ if (unlikely(!self) && PyErr_Occurred()) return NULL;
1069
+ #else
1070
+ self = ((PyCFunctionObject*)cyfunc)->m_self;
1071
+ #endif
1072
+ break;
1073
+ default:
1074
+ return NULL;
1075
+ }
1076
+
1077
+ if (unlikely(nargs != 0)) {
1078
+ __Pyx_CyFunction_raise_argument_count_error(
1079
+ cyfunc, "takes no arguments", nargs);
1080
+ return NULL;
1081
+ }
1082
+ return meth(self, NULL);
1083
+ }
1084
+
1085
+ static PyObject * __Pyx_CyFunction_Vectorcall_O(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames)
1086
+ {
1087
+ __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func;
1088
+ #if CYTHON_BACKPORT_VECTORCALL
1089
+ Py_ssize_t nargs = (Py_ssize_t)nargsf;
1090
+ #else
1091
+ Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
1092
+ #endif
1093
+ PyObject *self;
1094
+ #if CYTHON_COMPILING_IN_LIMITED_API
1095
+ PyCFunction meth = PyCFunction_GetFunction(cyfunc->func);
1096
+ if (unlikely(!meth)) return NULL;
1097
+ #else
1098
+ PyCFunction meth = ((PyCFunctionObject*)cyfunc)->m_ml->ml_meth;
1099
+ #endif
1100
+
1101
+ switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, kwnames)) {
1102
+ case 1:
1103
+ self = args[0];
1104
+ args += 1;
1105
+ nargs -= 1;
1106
+ break;
1107
+ case 0:
1108
+ #if CYTHON_COMPILING_IN_LIMITED_API
1109
+ // PyCFunction_GetSelf returns a borrowed reference
1110
+ self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)cyfunc)->func);
1111
+ if (unlikely(!self) && PyErr_Occurred()) return NULL;
1112
+ #else
1113
+ self = ((PyCFunctionObject*)cyfunc)->m_self;
1114
+ #endif
1115
+ break;
1116
+ default:
1117
+ return NULL;
1118
+ }
1119
+
1120
+ if (unlikely(nargs != 1)) {
1121
+ __Pyx_CyFunction_raise_argument_count_error(
1122
+ cyfunc, "takes exactly one argument", nargs);
1123
+ return NULL;
1124
+ }
1125
+ return meth(self, args[0]);
1126
+ }
1127
+
1128
+ static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames)
1129
+ {
1130
+ __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func;
1131
+ #if CYTHON_BACKPORT_VECTORCALL
1132
+ Py_ssize_t nargs = (Py_ssize_t)nargsf;
1133
+ #else
1134
+ Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
1135
+ #endif
1136
+ PyObject *self;
1137
+ #if CYTHON_COMPILING_IN_LIMITED_API
1138
+ PyCFunction meth = PyCFunction_GetFunction(cyfunc->func);
1139
+ if (unlikely(!meth)) return NULL;
1140
+ #else
1141
+ PyCFunction meth = ((PyCFunctionObject*)cyfunc)->m_ml->ml_meth;
1142
+ #endif
1143
+
1144
+ switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, NULL)) {
1145
+ case 1:
1146
+ self = args[0];
1147
+ args += 1;
1148
+ nargs -= 1;
1149
+ break;
1150
+ case 0:
1151
+ #if CYTHON_COMPILING_IN_LIMITED_API
1152
+ // PyCFunction_GetSelf returns a borrowed reference
1153
+ self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)cyfunc)->func);
1154
+ if (unlikely(!self) && PyErr_Occurred()) return NULL;
1155
+ #else
1156
+ self = ((PyCFunctionObject*)cyfunc)->m_self;
1157
+ #endif
1158
+ break;
1159
+ default:
1160
+ return NULL;
1161
+ }
1162
+
1163
+ return ((__Pyx_PyCFunctionFastWithKeywords)(void(*)(void))meth)(self, args, nargs, kwnames);
1164
+ }
1165
+
1166
+ static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS_METHOD(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames)
1167
+ {
1168
+ __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func;
1169
+ PyTypeObject *cls = (PyTypeObject *) __Pyx_CyFunction_GetClassObj(cyfunc);
1170
+ #if CYTHON_BACKPORT_VECTORCALL
1171
+ Py_ssize_t nargs = (Py_ssize_t)nargsf;
1172
+ #else
1173
+ Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
1174
+ #endif
1175
+ PyObject *self;
1176
+ #if CYTHON_COMPILING_IN_LIMITED_API
1177
+ PyCFunction meth = PyCFunction_GetFunction(cyfunc->func);
1178
+ if (unlikely(!meth)) return NULL;
1179
+ #else
1180
+ PyCFunction meth = ((PyCFunctionObject*)cyfunc)->m_ml->ml_meth;
1181
+ #endif
1182
+ switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, NULL)) {
1183
+ case 1:
1184
+ self = args[0];
1185
+ args += 1;
1186
+ nargs -= 1;
1187
+ break;
1188
+ case 0:
1189
+ #if CYTHON_COMPILING_IN_LIMITED_API
1190
+ // PyCFunction_GetSelf returns a borrowed reference
1191
+ self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)cyfunc)->func);
1192
+ if (unlikely(!self) && PyErr_Occurred()) return NULL;
1193
+ #else
1194
+ self = ((PyCFunctionObject*)cyfunc)->m_self;
1195
+ #endif
1196
+ break;
1197
+ default:
1198
+ return NULL;
1199
+ }
1200
+
1201
+ return ((__Pyx_PyCMethod)(void(*)(void))meth)(self, cls, args, (size_t)nargs, kwnames);
1202
+ }
1203
+ #endif
1204
+
1205
+ static PyType_Slot __pyx_CyFunctionType_slots[] = {
1206
+ {Py_tp_dealloc, (void *)__Pyx_CyFunction_dealloc},
1207
+ {Py_tp_repr, (void *)__Pyx_CyFunction_repr},
1208
+ {Py_tp_call, (void *)__Pyx_CyFunction_CallAsMethod},
1209
+ {Py_tp_traverse, (void *)__Pyx_CyFunction_traverse},
1210
+ {Py_tp_clear, (void *)__Pyx_CyFunction_clear},
1211
+ {Py_tp_methods, (void *)__pyx_CyFunction_methods},
1212
+ {Py_tp_members, (void *)__pyx_CyFunction_members},
1213
+ {Py_tp_getset, (void *)__pyx_CyFunction_getsets},
1214
+ {Py_tp_descr_get, (void *)__Pyx_PyMethod_New},
1215
+ {0, 0},
1216
+ };
1217
+
1218
+ static PyType_Spec __pyx_CyFunctionType_spec = {
1219
+ __PYX_TYPE_MODULE_PREFIX "cython_function_or_method",
1220
+ sizeof(__pyx_CyFunctionObject),
1221
+ 0,
1222
+ #ifdef Py_TPFLAGS_METHOD_DESCRIPTOR
1223
+ Py_TPFLAGS_METHOD_DESCRIPTOR |
1224
+ #endif
1225
+ #if CYTHON_METH_FASTCALL
1226
+ #if defined(Py_TPFLAGS_HAVE_VECTORCALL)
1227
+ Py_TPFLAGS_HAVE_VECTORCALL |
1228
+ #elif defined(_Py_TPFLAGS_HAVE_VECTORCALL)
1229
+ _Py_TPFLAGS_HAVE_VECTORCALL |
1230
+ #endif
1231
+ #endif // CYTHON_METH_FASTCALL
1232
+ #if PY_VERSION_HEX >= 0x030A0000
1233
+ Py_TPFLAGS_IMMUTABLETYPE |
1234
+ #endif
1235
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, /*tp_flags*/
1236
+ __pyx_CyFunctionType_slots
1237
+ };
1238
+
1239
+ static int __pyx_CyFunction_init(PyObject *module) {
1240
+ $modulestatetype_cname *mstate = __Pyx_PyModule_GetState(module);
1241
+ mstate->__pyx_CyFunctionType = __Pyx_FetchCommonTypeFromSpec(module, &__pyx_CyFunctionType_spec, NULL);
1242
+ if (unlikely(mstate->__pyx_CyFunctionType == NULL)) {
1243
+ return -1;
1244
+ }
1245
+ return 0;
1246
+ }
1247
+
1248
+ static CYTHON_INLINE PyObject *__Pyx_CyFunction_InitDefaults(PyObject *func, PyTypeObject *defaults_type) {
1249
+ __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
1250
+
1251
+ m->defaults = PyObject_CallObject((PyObject*)defaults_type, NULL); // _PyObject_New(defaults_type);
1252
+ if (unlikely(!m->defaults))
1253
+ return NULL;
1254
+ return m->defaults;
1255
+ }
1256
+
1257
+ static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
1258
+ __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
1259
+ m->defaults_tuple = tuple;
1260
+ Py_INCREF(tuple);
1261
+ }
1262
+
1263
+ static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) {
1264
+ __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
1265
+ m->defaults_kwdict = dict;
1266
+ Py_INCREF(dict);
1267
+ }
1268
+
1269
+ static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) {
1270
+ __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
1271
+ m->func_annotations = dict;
1272
+ Py_INCREF(dict);
1273
+ }
1274
+
1275
+
1276
+ //////////////////// CythonFunction.proto ////////////////////
1277
+
1278
+ static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml,
1279
+ int flags, PyObject* qualname,
1280
+ PyObject *closure,
1281
+ PyObject *module, PyObject *globals,
1282
+ PyObject* code);
1283
+
1284
+ //////////////////// CythonFunction ////////////////////
1285
+ //@requires: CythonFunctionShared
1286
+
1287
+ static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml, int flags, PyObject* qualname,
1288
+ PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
1289
+ PyObject *op = __Pyx_CyFunction_Init(
1290
+ PyObject_GC_New(__pyx_CyFunctionObject, CGLOBAL(__pyx_CyFunctionType)),
1291
+ ml, flags, qualname, closure, module, globals, code
1292
+ );
1293
+ if (likely(op)) {
1294
+ PyObject_GC_Track(op);
1295
+ }
1296
+ return op;
1297
+ }
1298
+
1299
+ //////////////////// CyFunctionClassCell.proto ////////////////////
1300
+ static int __Pyx_CyFunction_InitClassCell(PyObject *cyfunctions, PyObject *classobj);/*proto*/
1301
+
1302
+ //////////////////// CyFunctionClassCell ////////////////////
1303
+ //@requires: CythonFunctionShared
1304
+
1305
+ static int __Pyx_CyFunction_InitClassCell(PyObject *cyfunctions, PyObject *classobj) {
1306
+ Py_ssize_t i, count = __Pyx_PyList_GET_SIZE(cyfunctions);
1307
+ #if !CYTHON_ASSUME_SAFE_SIZE
1308
+ if (unlikely(count < 0)) return -1;
1309
+ #endif
1310
+
1311
+ for (i = 0; i < count; i++) {
1312
+ __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *)
1313
+ #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && !CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS
1314
+ PyList_GET_ITEM(cyfunctions, i);
1315
+ #else
1316
+ __Pyx_PySequence_ITEM(cyfunctions, i);
1317
+ if (unlikely(!m))
1318
+ return -1;
1319
+ #endif
1320
+ __Pyx_CyFunction_SetClassObj(m, classobj);
1321
+ #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && !CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS)
1322
+ Py_DECREF((PyObject*)m);
1323
+ #endif
1324
+ }
1325
+ return 0;
1326
+ }
1327
+
1328
+
1329
+ //////////////////// FusedFunction.proto ////////////////////
1330
+
1331
+ typedef struct {
1332
+ __pyx_CyFunctionObject func;
1333
+ PyObject *__signatures__;
1334
+ PyObject *self;
1335
+ #if CYTHON_COMPILING_IN_LIMITED_API
1336
+ PyMethodDef *ml;
1337
+ #endif
1338
+ } __pyx_FusedFunctionObject;
1339
+
1340
+ static PyObject *__pyx_FusedFunction_New(PyMethodDef *ml, int flags,
1341
+ PyObject *qualname, PyObject *closure,
1342
+ PyObject *module, PyObject *globals,
1343
+ PyObject *code);
1344
+
1345
+ static int __pyx_FusedFunction_clear(__pyx_FusedFunctionObject *self);
1346
+ static int __pyx_FusedFunction_init(PyObject *module);
1347
+
1348
+ #define __Pyx_FusedFunction_USED
1349
+
1350
+ //////////////////// FusedFunction ////////////////////
1351
+ //@requires: CythonFunctionShared
1352
+ //@substitute: naming
1353
+
1354
+ static PyObject *
1355
+ __pyx_FusedFunction_New(PyMethodDef *ml, int flags,
1356
+ PyObject *qualname, PyObject *closure,
1357
+ PyObject *module, PyObject *globals,
1358
+ PyObject *code)
1359
+ {
1360
+ PyObject *op = __Pyx_CyFunction_Init(
1361
+ // __pyx_CyFunctionObject is correct below since that's the cast that we want.
1362
+ PyObject_GC_New(__pyx_CyFunctionObject, CGLOBAL(__pyx_FusedFunctionType)),
1363
+ ml, flags, qualname, closure, module, globals, code
1364
+ );
1365
+ if (likely(op)) {
1366
+ __pyx_FusedFunctionObject *fusedfunc = (__pyx_FusedFunctionObject *) op;
1367
+ fusedfunc->__signatures__ = NULL;
1368
+ fusedfunc->self = NULL;
1369
+ #if CYTHON_COMPILING_IN_LIMITED_API
1370
+ fusedfunc->ml = ml;
1371
+ #endif
1372
+ PyObject_GC_Track(op);
1373
+ }
1374
+ return op;
1375
+ }
1376
+
1377
+ static void
1378
+ __pyx_FusedFunction_dealloc(__pyx_FusedFunctionObject *self)
1379
+ {
1380
+ PyObject_GC_UnTrack(self);
1381
+ Py_CLEAR(self->self);
1382
+ Py_CLEAR(self->__signatures__);
1383
+ __Pyx__CyFunction_dealloc((__pyx_CyFunctionObject *) self);
1384
+ }
1385
+
1386
+ static int
1387
+ __pyx_FusedFunction_traverse(__pyx_FusedFunctionObject *self,
1388
+ visitproc visit,
1389
+ void *arg)
1390
+ {
1391
+ // Visiting the type is handled in the CyFunction traverse if needed
1392
+ Py_VISIT(self->self);
1393
+ Py_VISIT(self->__signatures__);
1394
+ return __Pyx_CyFunction_traverse((__pyx_CyFunctionObject *) self, visit, arg);
1395
+ }
1396
+
1397
+ static int
1398
+ __pyx_FusedFunction_clear(__pyx_FusedFunctionObject *self)
1399
+ {
1400
+ Py_CLEAR(self->self);
1401
+ Py_CLEAR(self->__signatures__);
1402
+ return __Pyx_CyFunction_clear((__pyx_CyFunctionObject *) self);
1403
+ }
1404
+
1405
+
1406
+ static __pyx_FusedFunctionObject *
1407
+ __pyx_FusedFunction_descr_get_locked(__pyx_FusedFunctionObject *func, PyObject *obj)
1408
+ {
1409
+ PyObject *module;
1410
+ __pyx_FusedFunctionObject *meth;
1411
+ #if CYTHON_COMPILING_IN_LIMITED_API
1412
+ module = __Pyx_CyFunction_get_module((__pyx_CyFunctionObject *) func, NULL);
1413
+ if ((unlikely(!module))) return NULL;
1414
+ #else
1415
+ module = ((PyCFunctionObject *) func)->m_module;
1416
+ #endif
1417
+
1418
+ meth = (__pyx_FusedFunctionObject *) __pyx_FusedFunction_New(
1419
+ #if CYTHON_COMPILING_IN_LIMITED_API
1420
+ func->ml,
1421
+ #else
1422
+ ((PyCFunctionObject *) func)->m_ml,
1423
+ #endif
1424
+ ((__pyx_CyFunctionObject *) func)->flags,
1425
+ ((__pyx_CyFunctionObject *) func)->func_qualname,
1426
+ ((__pyx_CyFunctionObject *) func)->func_closure,
1427
+ module,
1428
+ ((__pyx_CyFunctionObject *) func)->func_globals,
1429
+ ((__pyx_CyFunctionObject *) func)->func_code);
1430
+ #if CYTHON_COMPILING_IN_LIMITED_API
1431
+ Py_DECREF(module);
1432
+ #endif
1433
+ if (unlikely(!meth))
1434
+ return NULL;
1435
+
1436
+ Py_XINCREF(func->func.defaults);
1437
+ meth->func.defaults = func->func.defaults;
1438
+
1439
+ __Pyx_CyFunction_SetClassObj(meth, __Pyx_CyFunction_GetClassObj(func));
1440
+
1441
+ Py_XINCREF(func->__signatures__);
1442
+ meth->__signatures__ = func->__signatures__;
1443
+
1444
+ Py_XINCREF(func->func.defaults_tuple);
1445
+ meth->func.defaults_tuple = func->func.defaults_tuple;
1446
+
1447
+ Py_XINCREF(obj);
1448
+ meth->self = obj;
1449
+ return meth;
1450
+ }
1451
+
1452
+ static PyObject *
1453
+ __pyx_FusedFunction_descr_get(PyObject *self, PyObject *obj, PyObject *type)
1454
+ {
1455
+ __pyx_FusedFunctionObject *func, *meth;
1456
+
1457
+ func = (__pyx_FusedFunctionObject *) self;
1458
+
1459
+ if (func->self || func->func.flags & __Pyx_CYFUNCTION_STATICMETHOD) {
1460
+ // Do not allow rebinding and don't do anything for static methods
1461
+ Py_INCREF(self);
1462
+ return self;
1463
+ }
1464
+
1465
+ if (obj == Py_None)
1466
+ obj = NULL;
1467
+
1468
+ if (func->func.flags & __Pyx_CYFUNCTION_CLASSMETHOD)
1469
+ obj = type;
1470
+
1471
+ if (obj == NULL) {
1472
+ // We aren't actually binding to anything, save the effort of rebinding
1473
+ Py_INCREF(self);
1474
+ return self;
1475
+ }
1476
+
1477
+ __Pyx_BEGIN_CRITICAL_SECTION(func);
1478
+ meth = __pyx_FusedFunction_descr_get_locked(func, obj);
1479
+ __Pyx_END_CRITICAL_SECTION()
1480
+
1481
+ return (PyObject *) meth;
1482
+ }
1483
+
1484
+ static PyObject *
1485
+ _obj_to_string(PyObject *obj)
1486
+ {
1487
+ if (PyUnicode_CheckExact(obj))
1488
+ return __Pyx_NewRef(obj);
1489
+ else if (PyType_Check(obj))
1490
+ return PyObject_GetAttr(obj, PYIDENT("__name__"));
1491
+ else
1492
+ return PyObject_Str(obj);
1493
+ }
1494
+
1495
+ static PyObject *
1496
+ __pyx_FusedFunction_getitem(__pyx_FusedFunctionObject *self, PyObject *idx)
1497
+ {
1498
+ PyObject *signature = NULL;
1499
+ PyObject *unbound_result_func;
1500
+ PyObject *result_func = NULL;
1501
+
1502
+ if (unlikely(self->__signatures__ == NULL)) {
1503
+ PyErr_SetString(PyExc_TypeError, "Function is not fused");
1504
+ return NULL;
1505
+ }
1506
+
1507
+ if (PyTuple_Check(idx)) {
1508
+ Py_ssize_t n = __Pyx_PyTuple_GET_SIZE(idx);
1509
+ PyObject *list;
1510
+ int i;
1511
+ #if !CYTHON_ASSUME_SAFE_SIZE
1512
+ if (unlikely(n < 0)) return NULL;
1513
+ #endif
1514
+
1515
+ list = PyList_New(n);
1516
+ if (unlikely(!list))
1517
+ return NULL;
1518
+
1519
+ for (i = 0; i < n; i++) {
1520
+ PyObject *string;
1521
+ #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
1522
+ PyObject *item = PyTuple_GET_ITEM(idx, i);
1523
+ #else
1524
+ PyObject *item = __Pyx_PySequence_ITEM(idx, i); if (unlikely(!item)) goto __pyx_err;
1525
+ #endif
1526
+ string = _obj_to_string(item);
1527
+ #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
1528
+ Py_DECREF(item);
1529
+ #endif
1530
+ if (unlikely(!string)) goto __pyx_err;
1531
+ if (__Pyx_PyList_SET_ITEM(list, i, string) < 0) goto __pyx_err;
1532
+ }
1533
+
1534
+ signature = PyUnicode_Join(PYUNICODE("|"), list);
1535
+ __pyx_err:;
1536
+ Py_DECREF(list);
1537
+ } else {
1538
+ signature = _obj_to_string(idx);
1539
+ }
1540
+
1541
+ if (unlikely(!signature))
1542
+ return NULL;
1543
+
1544
+ unbound_result_func = PyObject_GetItem(self->__signatures__, signature);
1545
+
1546
+ if (likely(unbound_result_func)) {
1547
+ if (self->self) {
1548
+ __pyx_FusedFunctionObject *unbound = (__pyx_FusedFunctionObject *) unbound_result_func;
1549
+
1550
+ // TODO: move this to InitClassCell
1551
+ __Pyx_CyFunction_SetClassObj(unbound, __Pyx_CyFunction_GetClassObj(self));
1552
+
1553
+ result_func = __pyx_FusedFunction_descr_get(unbound_result_func,
1554
+ self->self, self->self);
1555
+ } else {
1556
+ result_func = unbound_result_func;
1557
+ Py_INCREF(result_func);
1558
+ }
1559
+ }
1560
+
1561
+ Py_DECREF(signature);
1562
+ Py_XDECREF(unbound_result_func);
1563
+
1564
+ return result_func;
1565
+ }
1566
+
1567
+ static PyObject *
1568
+ __pyx_FusedFunction_callfunction(PyObject *func, PyObject *args, PyObject *kw)
1569
+ {
1570
+ __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func;
1571
+ int static_specialized = (cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD &&
1572
+ !((__pyx_FusedFunctionObject *) func)->__signatures__);
1573
+
1574
+ if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !static_specialized) {
1575
+ return __Pyx_CyFunction_CallAsMethod(func, args, kw);
1576
+ } else {
1577
+ return __Pyx_CyFunction_Call(func, args, kw);
1578
+ }
1579
+ }
1580
+
1581
+ // Note: the 'self' from method binding is passed in in the args tuple,
1582
+ // whereas PyCFunctionObject's m_self is passed in as the first
1583
+ // argument to the C function. For extension methods we need
1584
+ // to pass 'self' as 'm_self' and not as the first element of the
1585
+ // args tuple.
1586
+
1587
+ static PyObject *
1588
+ __pyx_FusedFunction_call(PyObject *func, PyObject *args, PyObject *kw)
1589
+ {
1590
+ __pyx_FusedFunctionObject *binding_func = (__pyx_FusedFunctionObject *) func;
1591
+ Py_ssize_t argc = __Pyx_PyTuple_GET_SIZE(args);
1592
+ PyObject *new_args = NULL;
1593
+ __pyx_FusedFunctionObject *new_func = NULL;
1594
+ PyObject *result = NULL;
1595
+ int is_staticmethod = binding_func->func.flags & __Pyx_CYFUNCTION_STATICMETHOD;
1596
+ #if !CYTHON_ASSUME_SAFE_SIZE
1597
+ if (unlikely(argc < 0)) return NULL;
1598
+ #endif
1599
+
1600
+ if (binding_func->self) {
1601
+ // Bound method call, put 'self' in the args tuple
1602
+ PyObject *self;
1603
+ Py_ssize_t i;
1604
+ new_args = PyTuple_New(argc + 1);
1605
+ if (unlikely(!new_args))
1606
+ return NULL;
1607
+
1608
+ self = binding_func->self;
1609
+
1610
+ Py_INCREF(self);
1611
+ if (__Pyx_PyTuple_SET_ITEM(new_args, 0, self)) goto bad;
1612
+ self = NULL;
1613
+
1614
+ for (i = 0; i < argc; i++) {
1615
+ #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
1616
+ PyObject *item = PyTuple_GET_ITEM(args, i);
1617
+ Py_INCREF(item);
1618
+ #else
1619
+ PyObject *item = __Pyx_PySequence_ITEM(args, i); if (unlikely(!item)) goto bad;
1620
+ #endif
1621
+ if (__Pyx_PyTuple_SET_ITEM(new_args, i + 1, item)) goto bad;
1622
+ }
1623
+
1624
+ args = new_args;
1625
+ }
1626
+
1627
+ if (binding_func->__signatures__) {
1628
+ PyObject *tup;
1629
+ if (is_staticmethod && binding_func->func.flags & __Pyx_CYFUNCTION_CCLASS) {
1630
+ // FIXME: this seems wrong, but we must currently pass the signatures dict as 'self' argument
1631
+ tup = PyTuple_Pack(3, args,
1632
+ kw == NULL ? Py_None : kw,
1633
+ binding_func->func.defaults_tuple);
1634
+ if (unlikely(!tup)) goto bad;
1635
+ new_func = (__pyx_FusedFunctionObject *) __Pyx_CyFunction_CallMethod(
1636
+ func, binding_func->__signatures__, tup, NULL);
1637
+ } else {
1638
+ tup = PyTuple_Pack(4, binding_func->__signatures__, args,
1639
+ kw == NULL ? Py_None : kw,
1640
+ binding_func->func.defaults_tuple);
1641
+ if (unlikely(!tup)) goto bad;
1642
+ new_func = (__pyx_FusedFunctionObject *) __pyx_FusedFunction_callfunction(func, tup, NULL);
1643
+ }
1644
+ Py_DECREF(tup);
1645
+
1646
+ if (unlikely(!new_func))
1647
+ goto bad;
1648
+
1649
+ __Pyx_CyFunction_SetClassObj(new_func, __Pyx_CyFunction_GetClassObj(binding_func));
1650
+
1651
+ func = (PyObject *) new_func;
1652
+ }
1653
+
1654
+ result = __pyx_FusedFunction_callfunction(func, args, kw);
1655
+ bad:
1656
+ Py_XDECREF(new_args);
1657
+ Py_XDECREF((PyObject *) new_func);
1658
+ return result;
1659
+ }
1660
+
1661
+ static PyMemberDef __pyx_FusedFunction_members[] = {
1662
+ {"__signatures__",
1663
+ T_OBJECT,
1664
+ offsetof(__pyx_FusedFunctionObject, __signatures__),
1665
+ READONLY,
1666
+ 0},
1667
+ {"__self__", T_OBJECT_EX, offsetof(__pyx_FusedFunctionObject, self), READONLY, 0},
1668
+ {0, 0, 0, 0, 0},
1669
+ };
1670
+
1671
+ static PyGetSetDef __pyx_FusedFunction_getsets[] = {
1672
+ // __doc__ is None for the fused function type, but we need it to be
1673
+ // a descriptor for the instance's __doc__, so rebuild the descriptor in our subclass
1674
+ // (all other descriptors are inherited)
1675
+ {"__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
1676
+ {0, 0, 0, 0, 0}
1677
+ };
1678
+
1679
+ static PyType_Slot __pyx_FusedFunctionType_slots[] = {
1680
+ {Py_tp_dealloc, (void *)__pyx_FusedFunction_dealloc},
1681
+ {Py_tp_call, (void *)__pyx_FusedFunction_call},
1682
+ {Py_tp_traverse, (void *)__pyx_FusedFunction_traverse},
1683
+ {Py_tp_clear, (void *)__pyx_FusedFunction_clear},
1684
+ {Py_tp_members, (void *)__pyx_FusedFunction_members},
1685
+ {Py_tp_getset, (void *)__pyx_FusedFunction_getsets},
1686
+ {Py_tp_descr_get, (void *)__pyx_FusedFunction_descr_get},
1687
+ {Py_mp_subscript, (void *)__pyx_FusedFunction_getitem},
1688
+ {0, 0},
1689
+ };
1690
+
1691
+ static PyType_Spec __pyx_FusedFunctionType_spec = {
1692
+ __PYX_TYPE_MODULE_PREFIX "fused_cython_function",
1693
+ sizeof(__pyx_FusedFunctionObject),
1694
+ 0,
1695
+ #if PY_VERSION_HEX >= 0x030A0000
1696
+ Py_TPFLAGS_IMMUTABLETYPE |
1697
+ #endif
1698
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /*tp_flags*/
1699
+ __pyx_FusedFunctionType_slots
1700
+ };
1701
+
1702
+ static int __pyx_FusedFunction_init(PyObject *module) {
1703
+ $modulestatetype_cname *mstate = __Pyx_PyModule_GetState(module);
1704
+ PyObject *bases = PyTuple_Pack(1, mstate->__pyx_CyFunctionType);
1705
+ if (unlikely(!bases)) {
1706
+ return -1;
1707
+ }
1708
+ mstate->__pyx_FusedFunctionType = __Pyx_FetchCommonTypeFromSpec(module, &__pyx_FusedFunctionType_spec, bases);
1709
+ Py_DECREF(bases);
1710
+ if (unlikely(mstate->__pyx_FusedFunctionType == NULL)) {
1711
+ return -1;
1712
+ }
1713
+ return 0;
1714
+ }
1715
+
1716
+ //////////////////// ClassMethod.proto ////////////////////
1717
+
1718
+ #if !CYTHON_COMPILING_IN_LIMITED_API
1719
+ #include "descrobject.h"
1720
+ #endif
1721
+ CYTHON_UNUSED static PyObject* __Pyx_Method_ClassMethod(PyObject *method); /*proto*/
1722
+
1723
+ //////////////////// ClassMethod ////////////////////
1724
+ //@requires: ObjectHandling.c::CachedMethodType
1725
+
1726
+ static PyObject* __Pyx_Method_ClassMethod(PyObject *method) {
1727
+ #if CYTHON_COMPILING_IN_PYPY && PYPY_VERSION_NUM <= 0x05080000
1728
+ if (PyObject_TypeCheck(method, &PyWrapperDescr_Type)) {
1729
+ // cdef classes
1730
+ return PyClassMethod_New(method);
1731
+ }
1732
+ #else
1733
+ #if CYTHON_COMPILING_IN_PYPY
1734
+ // special C-API function only in PyPy >= 5.9
1735
+ if (PyMethodDescr_Check(method))
1736
+ #else
1737
+ if (__Pyx_TypeCheck(method, &PyMethodDescr_Type))
1738
+ #endif
1739
+ {
1740
+ #if CYTHON_COMPILING_IN_LIMITED_API
1741
+ return PyErr_Format(
1742
+ PyExc_SystemError,
1743
+ "Cython cannot yet handle classmethod on a MethodDescriptorType (%S) in limited API mode. "
1744
+ "This is most likely a classmethod in a cdef class method with binding=False. "
1745
+ "Try setting 'binding' to True.",
1746
+ method);
1747
+ #elif CYTHON_COMPILING_IN_GRAAL
1748
+ // cdef classes
1749
+ PyTypeObject *d_type = PyDescrObject_GetType(method);
1750
+ return PyDescr_NewClassMethod(d_type, PyMethodDescrObject_GetMethod(method));
1751
+ #else
1752
+ // cdef classes
1753
+ PyMethodDescrObject *descr = (PyMethodDescrObject *)method;
1754
+ PyTypeObject *d_type = descr->d_common.d_type;
1755
+ return PyDescr_NewClassMethod(d_type, descr->d_method);
1756
+ #endif
1757
+ }
1758
+ #endif
1759
+ #if !CYTHON_COMPILING_IN_LIMITED_API
1760
+ else if (PyMethod_Check(method)) {
1761
+ // python classes
1762
+ return PyClassMethod_New(PyMethod_GET_FUNCTION(method));
1763
+ }
1764
+ else {
1765
+ return PyClassMethod_New(method);
1766
+ }
1767
+ #else
1768
+ {
1769
+ PyObject *func=NULL;
1770
+ PyObject *builtins, *classmethod, *classmethod_str, *result=NULL;
1771
+ if (__Pyx_TypeCheck(method, CGLOBAL(__Pyx_CachedMethodType))) {
1772
+ func = PyObject_GetAttrString(method, "__func__");
1773
+ if (!func) goto bad;
1774
+ } else {
1775
+ func = method;
1776
+ Py_INCREF(func);
1777
+ }
1778
+ builtins = PyEval_GetBuiltins(); // borrowed
1779
+ if (unlikely(!builtins)) goto bad;
1780
+ classmethod_str = PyUnicode_FromString("classmethod");
1781
+ if (unlikely(!classmethod_str)) goto bad;
1782
+ classmethod = PyObject_GetItem(builtins, classmethod_str);
1783
+ Py_DECREF(classmethod_str);
1784
+ if (unlikely(!classmethod)) goto bad;
1785
+ result = PyObject_CallFunctionObjArgs(classmethod, func, NULL);
1786
+ Py_DECREF(classmethod);
1787
+
1788
+ bad:
1789
+ Py_XDECREF(func);
1790
+ return result;
1791
+ }
1792
+ #endif
1793
+
1794
+ }