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