Cython 3.2.6__py3-none-any.whl → 3.3.0a2.dev0__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.

Potentially problematic release.


This version of Cython might be problematic. Click here for more details.

Files changed (112) hide show
  1. Cython/Build/BuildExecutable.py +1 -14
  2. Cython/Build/Dependencies.py +6 -44
  3. Cython/Build/Inline.py +7 -3
  4. Cython/Build/IpythonMagic.py +0 -1
  5. Cython/Build/SharedModule.py +1 -2
  6. Cython/Build/Tests/TestCythonizeArgsParser.py +6 -6
  7. Cython/Build/Tests/TestDependencies.py +3 -3
  8. Cython/Build/Tests/TestInline.py +3 -3
  9. Cython/Build/Tests/TestIpythonMagic.py +35 -19
  10. Cython/Build/Tests/TestStripLiterals.py +2 -2
  11. Cython/Compiler/Buffer.py +5 -5
  12. Cython/Compiler/Builtin.py +57 -46
  13. Cython/Compiler/Code.pxd +12 -9
  14. Cython/Compiler/Code.py +220 -94
  15. Cython/Compiler/Dataclass.py +78 -52
  16. Cython/Compiler/Errors.py +21 -8
  17. Cython/Compiler/ExprNodes.py +871 -459
  18. Cython/Compiler/FlowControl.pxd +8 -6
  19. Cython/Compiler/FlowControl.py +111 -8
  20. Cython/Compiler/FusedNode.py +17 -12
  21. Cython/Compiler/Lexicon.py +123 -122
  22. Cython/Compiler/Main.py +3 -4
  23. Cython/Compiler/MatchCaseNodes.py +1948 -10
  24. Cython/Compiler/MemoryView.py +62 -33
  25. Cython/Compiler/ModuleNode.py +559 -283
  26. Cython/Compiler/Naming.py +4 -0
  27. Cython/Compiler/Nodes.py +333 -197
  28. Cython/Compiler/Optimize.py +268 -112
  29. Cython/Compiler/Options.py +0 -5
  30. Cython/Compiler/ParseTreeTransforms.pxd +2 -1
  31. Cython/Compiler/ParseTreeTransforms.py +180 -76
  32. Cython/Compiler/Parsing.py +55 -38
  33. Cython/Compiler/PyrexTypes.py +364 -128
  34. Cython/Compiler/Scanning.pxd +27 -5
  35. Cython/Compiler/Scanning.py +24 -14
  36. Cython/Compiler/StringEncoding.py +1 -2
  37. Cython/Compiler/Symtab.py +27 -19
  38. Cython/Compiler/Tests/TestBuiltin.py +41 -6
  39. Cython/Compiler/Tests/TestCmdLine.py +3 -2
  40. Cython/Compiler/Tests/TestCode.py +4 -3
  41. Cython/Compiler/Tests/TestFlowControl.py +2 -2
  42. Cython/Compiler/Tests/TestParseTreeTransforms.py +2 -2
  43. Cython/Compiler/Tests/TestScanning.py +2 -4
  44. Cython/Compiler/Tests/TestSignatureMatching.py +3 -3
  45. Cython/Compiler/Tests/TestStringEncoding.py +2 -3
  46. Cython/Compiler/Tests/TestTypes.py +46 -3
  47. Cython/Compiler/Tests/TestUtilityLoad.py +4 -4
  48. Cython/Compiler/TypeInference.py +20 -0
  49. Cython/Compiler/TypeSlots.py +171 -16
  50. Cython/Compiler/UtilNodes.py +24 -0
  51. Cython/Compiler/UtilityCode.py +1 -0
  52. Cython/Compiler/Visitor.pxd +1 -1
  53. Cython/Compiler/Visitor.py +3 -2
  54. Cython/Debugger/Tests/TestLibCython.py +7 -2
  55. Cython/Debugger/Tests/test_libcython_in_gdb.py +4 -2
  56. Cython/Debugger/Tests/test_libpython_in_gdb.py +1 -1
  57. Cython/Includes/cpython/array.pxd +5 -5
  58. Cython/Includes/cpython/dict.pxd +1 -6
  59. Cython/Includes/cpython/float.pxd +19 -10
  60. Cython/Includes/cpython/frozendict.pxd +37 -0
  61. Cython/Includes/cpython/long.pxd +31 -0
  62. Cython/Includes/cpython/object.pxd +9 -12
  63. Cython/Includes/cpython/sentinel.pxd +17 -0
  64. Cython/Includes/cpython/type.pxd +93 -0
  65. Cython/Includes/libcpp/exception.pxd +90 -0
  66. Cython/LZSS.py +170 -0
  67. Cython/Shadow.py +550 -73
  68. Cython/StringIOTree.py +1 -2
  69. Cython/Tempita/_tempita.py +45 -46
  70. Cython/TestUtils.py +50 -8
  71. Cython/Tests/TestCythonUtils.py +2 -2
  72. Cython/Tests/TestJediTyper.py +1 -1
  73. Cython/Tests/TestShadow.py +7 -5
  74. Cython/Tests/TestStringIOTree.py +4 -3
  75. Cython/Tests/TestTestUtils.py +2 -3
  76. Cython/Utility/AsyncGen.c +59 -19
  77. Cython/Utility/Buffer.c +4 -3
  78. Cython/Utility/Builtins.c +139 -17
  79. Cython/Utility/CConvert.pyx +27 -12
  80. Cython/Utility/CommonStructures.c +55 -37
  81. Cython/Utility/Coroutine.c +112 -68
  82. Cython/Utility/CythonFunction.c +607 -330
  83. Cython/Utility/Embed.c +8 -0
  84. Cython/Utility/Exceptions.c +20 -3
  85. Cython/Utility/ExtensionTypes.c +414 -224
  86. Cython/Utility/FunctionArguments.c +83 -81
  87. Cython/Utility/ImportExport.c +72 -61
  88. Cython/Utility/MatchCase.c +979 -0
  89. Cython/Utility/MatchCase_Cy.pyx +12 -0
  90. Cython/Utility/MemoryView.pxd +9 -88
  91. Cython/Utility/MemoryView.pyx +173 -61
  92. Cython/Utility/MemoryView_C.c +3 -3
  93. Cython/Utility/ModuleSetupCode.c +306 -157
  94. Cython/Utility/ObjectHandling.c +483 -404
  95. Cython/Utility/Optimize.c +1117 -164
  96. Cython/Utility/Overflow.c +3 -9
  97. Cython/Utility/Profile.c +4 -0
  98. Cython/Utility/StringTools.c +187 -149
  99. Cython/Utility/Synchronization.c +39 -0
  100. Cython/Utility/TString.c +24 -13
  101. Cython/Utility/TypeConversion.c +405 -250
  102. Cython/Utility/arrayarray.h +24 -22
  103. Cython/Utils.py +11 -23
  104. Cython/__init__.py +3 -1
  105. {cython-3.2.6.dist-info → cython-3.3.0a2.dev0.dist-info}/METADATA +14 -33
  106. {cython-3.2.6.dist-info → cython-3.3.0a2.dev0.dist-info}/RECORD +109 -107
  107. {cython-3.2.6.dist-info → cython-3.3.0a2.dev0.dist-info}/WHEEL +1 -1
  108. Cython/Shadow.pyi +0 -521
  109. Cython/Utility/Printing.c +0 -86
  110. Cython/__init__.pyi +0 -7
  111. {cython-3.2.6.dist-info → cython-3.3.0a2.dev0.dist-info}/entry_points.txt +0 -0
  112. {cython-3.2.6.dist-info → cython-3.3.0a2.dev0.dist-info}/top_level.txt +0 -0
@@ -1,60 +1,70 @@
1
- //////////////////// CythonFunctionShared.module_state_decls ////////////////////
1
+ //////////////////// CythonFunctionPerModule.module_state_decls ////////////////////
2
2
 
3
3
  PyTypeObject *__pyx_CyFunctionType;
4
4
 
5
- //////////////////// CythonFunctionShared.module_state_traverse ///////////////////
5
+ //////////////////// CythonFunctionPerModule.module_state_traverse ///////////////////
6
6
 
7
7
  Py_VISIT(traverse_module_state->__pyx_CyFunctionType);
8
8
 
9
- //////////////////// CythonFunctionShared.module_state_clear ///////////////////
9
+ //////////////////// CythonFunctionPerModule.module_state_clear ///////////////////
10
10
 
11
11
  Py_CLEAR(clear_module_state->__pyx_CyFunctionType);
12
12
 
13
- //////////////////// CythonFunctionShared.init //////////////////
13
+ //////////////////// CythonFunctionPerModule.init //////////////////
14
14
  //@substitute: naming
15
+ //@init_block: init_after_shared_utility
15
16
 
16
17
  if (likely(__pyx_CyFunction_init($module_cname) == 0)); else
17
18
 
18
- //////////////////// CythonFunctionShared.proto ////////////////////
19
+ //////////////////// CythonFunctionPerModule.proto //////////////////////////
20
+ // This section always gets included whether we're using CythonFunction through
21
+ // shared utility code or not.
19
22
 
20
23
  #define __Pyx_CyFunction_USED
21
24
 
25
+ #if CYTHON_OPAQUE_SHARED_TYPES
26
+ #define __Pyx_as_CyFunctionObject(o) ((__pyx_CyFunctionObject *)PyObject_GetTypeData((o), CGLOBAL(__pyx_CyFunctionType)))
27
+ #else
28
+ #define __Pyx_as_CyFunctionObject(o) ((__pyx_CyFunctionObject *)o)
29
+ #endif
30
+
22
31
  #define __Pyx_CYFUNCTION_STATICMETHOD 0x01
23
32
  #define __Pyx_CYFUNCTION_CLASSMETHOD 0x02
24
33
  #define __Pyx_CYFUNCTION_CCLASS 0x04
25
34
  #define __Pyx_CYFUNCTION_COROUTINE 0x08
26
35
 
27
36
  #define __Pyx_CyFunction_GetClosure(f) \
28
- (((__pyx_CyFunctionObject *) (f))->func_closure)
37
+ ((__Pyx_as_CyFunctionObject(f))->func_closure)
29
38
 
30
- #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API
31
- #define __Pyx_CyFunction_GetClassObj(f) \
32
- (((__pyx_CyFunctionObject *) (f))->func_classobj)
39
+ #if CYTHON_COMPILING_IN_LIMITED_API
40
+ #define __Pyx__CyFunction_GetClassObj(f) \
41
+ ((f)->func_classobj)
33
42
  #else
34
- #define __Pyx_CyFunction_GetClassObj(f) \
43
+ #define __Pyx__CyFunction_GetClassObj(f) \
35
44
  ((PyObject*) ((PyCMethodObject *) (f))->mm_class)
36
45
  #endif
46
+ #define __Pyx_CyFunction_GetClassObj(f) \
47
+ __Pyx__CyFunction_GetClassObj(__Pyx_as_CyFunctionObject(f))
37
48
  #define __Pyx_CyFunction_SetClassObj(f, classobj) \
38
- __Pyx__CyFunction_SetClassObj((__pyx_CyFunctionObject *) (f), (classobj))
49
+ __Pyx__CyFunction_SetClassObj(__Pyx_as_CyFunctionObject(f), (classobj))
39
50
 
40
51
  #define __Pyx_CyFunction_Defaults(type, f) \
41
- ((type *)(((__pyx_CyFunctionObject *) (f))->defaults))
52
+ ((type *)((__Pyx_as_CyFunctionObject(f))->defaults))
42
53
  #define __Pyx_CyFunction_SetDefaultsGetter(f, g) \
43
- ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g)
44
-
54
+ (__Pyx_as_CyFunctionObject(f))->defaults_getter = (g)
45
55
 
46
56
  typedef struct {
47
57
  #if CYTHON_COMPILING_IN_LIMITED_API
58
+ #if !CYTHON_OPAQUE_OBJECTS
48
59
  PyObject_HEAD
49
- // We can't "inherit" from func, but we can use it as a data store
50
- PyObject *func;
51
- #elif PY_VERSION_HEX < 0x030900B1
52
- PyCFunctionObject func;
60
+ #endif
61
+ PyMethodDef *func_methoddef;
62
+ PyObject *func_module;
53
63
  #else
54
64
  // PEP-573: PyCFunctionObject + mm_class
55
65
  PyCMethodObject func;
56
66
  #endif
57
- #if CYTHON_COMPILING_IN_LIMITED_API && CYTHON_METH_FASTCALL
67
+ #if (CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_PYPY) && CYTHON_VECTORCALL
58
68
  __pyx_vectorcallfunc func_vectorcall;
59
69
  #endif
60
70
  #if CYTHON_COMPILING_IN_LIMITED_API
@@ -69,7 +79,7 @@ typedef struct {
69
79
  PyObject *func_globals;
70
80
  PyObject *func_code;
71
81
  PyObject *func_closure;
72
- #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API
82
+ #if CYTHON_COMPILING_IN_LIMITED_API
73
83
  // No-args super() class cell
74
84
  PyObject *func_classobj;
75
85
  #endif
@@ -83,24 +93,20 @@ typedef struct {
83
93
  PyObject *(*defaults_getter)(PyObject *);
84
94
  PyObject *func_annotations; /* function annotations dict */
85
95
 
96
+ #if __PYX_LIMITED_VERSION_HEX < 0x030B0000
86
97
  // Coroutine marker
87
98
  PyObject *func_is_coroutine;
99
+ #endif
88
100
  } __pyx_CyFunctionObject;
89
101
 
90
102
  #undef __Pyx_CyOrPyCFunction_Check
91
103
  #define __Pyx_CyFunction_Check(obj) __Pyx_TypeCheck(obj, CGLOBAL(__pyx_CyFunctionType))
92
104
  #define __Pyx_CyOrPyCFunction_Check(obj) __Pyx_TypeCheck2(obj, CGLOBAL(__pyx_CyFunctionType), &PyCFunction_Type)
93
- #define __Pyx_CyFunction_CheckExact(obj) __Pyx_IS_TYPE(obj, CGLOBAL(__pyx_CyFunctionType))
105
+ #define __Pyx_CyFunction_CheckExact(obj) Py_IS_TYPE(obj, CGLOBAL(__pyx_CyFunctionType))
94
106
  static CYTHON_INLINE int __Pyx__IsSameCyOrCFunction(PyObject *func, void (*cfunc)(void));/*proto*/
95
107
  #undef __Pyx_IsSameCFunction
96
108
  #define __Pyx_IsSameCFunction(func, cfunc) __Pyx__IsSameCyOrCFunction(func, cfunc)
97
109
 
98
- static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject* op, PyMethodDef *ml,
99
- int flags, PyObject* qualname,
100
- PyObject *closure,
101
- PyObject *module, PyObject *globals,
102
- PyObject* code);
103
-
104
110
  static CYTHON_INLINE void __Pyx__CyFunction_SetClassObj(__pyx_CyFunctionObject* f, PyObject* classobj);
105
111
  static CYTHON_INLINE PyObject *__Pyx_CyFunction_InitDefaults(PyObject *func,
106
112
  PyTypeObject *defaults_type);
@@ -111,37 +117,26 @@ static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m,
111
117
  static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m,
112
118
  PyObject *dict);
113
119
 
114
-
120
+ // Note that the actual definition of __pyx_CyFunction_init is in a different
121
+ // utility code section and depends on if the utility code comes from a
122
+ // shared module.
115
123
  static int __pyx_CyFunction_init(PyObject *module);
116
124
 
117
- #if CYTHON_METH_FASTCALL
118
- static PyObject * __Pyx_CyFunction_Vectorcall_NOARGS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames);
119
- static PyObject * __Pyx_CyFunction_Vectorcall_O(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames);
120
- static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames);
121
- static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS_METHOD(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames);
122
- #if CYTHON_COMPILING_IN_LIMITED_API
123
- #define __Pyx_CyFunction_func_vectorcall(f) (((__pyx_CyFunctionObject*)f)->func_vectorcall)
125
+ #if CYTHON_VECTORCALL
126
+ #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_PYPY
127
+ #define __Pyx_CyFunction_func_vectorcall(f) ((f)->func_vectorcall)
124
128
  #else
125
129
  #define __Pyx_CyFunction_func_vectorcall(f) (((PyCFunctionObject*)f)->vectorcall)
126
130
  #endif
127
131
  #endif
128
132
 
129
- //////////////////// CythonFunctionShared ////////////////////
130
- //@requires: CommonStructures.c::FetchCommonType
131
- //@requires: CommonStructures.c::CommonTypesMetaclass
132
- //@requires: ObjectHandling.c::PyMethodNew
133
- //@requires: ObjectHandling.c::PyVectorcallFastCallDict
134
- //@requires: ModuleSetupCode.c::IncludeStructmemberH
135
- //@requires: ObjectHandling.c::PyObjectGetAttrStr
133
+ //////////////////// CythonFunctionPerModule /////////////////////
136
134
  //@requires: ObjectHandling.c::CachedMethodType
137
- //@requires: ExtensionTypes.c::CallTypeTraverse
138
- //@requires: Synchronization.c::CriticalSections
139
- //@substitute: naming
140
135
 
141
136
  #if CYTHON_COMPILING_IN_LIMITED_API
142
137
  static CYTHON_INLINE int __Pyx__IsSameCyOrCFunctionNoMethod(PyObject *func, void (*cfunc)(void)) {
143
138
  if (__Pyx_CyFunction_Check(func)) {
144
- return PyCFunction_GetFunction(((__pyx_CyFunctionObject*)func)->func) == (PyCFunction) cfunc;
139
+ return __Pyx_as_CyFunctionObject(func)->func_methoddef->ml_meth == (PyCFunction) cfunc;
145
140
  } else if (PyCFunction_Check(func)) {
146
141
  return PyCFunction_GetFunction(func) == (PyCFunction) cfunc;
147
142
  }
@@ -172,9 +167,9 @@ static CYTHON_INLINE int __Pyx__IsSameCyOrCFunction(PyObject *func, void (*cfunc
172
167
  #endif
173
168
 
174
169
  static CYTHON_INLINE void __Pyx__CyFunction_SetClassObj(__pyx_CyFunctionObject* f, PyObject* classobj) {
175
- #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API
170
+ #if CYTHON_COMPILING_IN_LIMITED_API
176
171
  __Pyx_Py_XDECREF_SET(
177
- __Pyx_CyFunction_GetClassObj(f),
172
+ __Pyx__CyFunction_GetClassObj(f),
178
173
  ((classobj) ? __Pyx_NewRef(classobj) : NULL));
179
174
  #else
180
175
  __Pyx_Py_XDECREF_SET(
@@ -184,48 +179,130 @@ static CYTHON_INLINE void __Pyx__CyFunction_SetClassObj(__pyx_CyFunctionObject*
184
179
  #endif
185
180
  }
186
181
 
182
+ static CYTHON_INLINE PyObject *__Pyx_CyFunction_InitDefaults(PyObject *func, PyTypeObject *defaults_type) {
183
+ __pyx_CyFunctionObject *m = __Pyx_as_CyFunctionObject(func);
184
+
185
+ m->defaults = PyObject_CallObject((PyObject*)defaults_type, NULL); // _PyObject_New(defaults_type);
186
+ if (unlikely(!m->defaults))
187
+ return NULL;
188
+ return m->defaults;
189
+ }
190
+
191
+ static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
192
+ __pyx_CyFunctionObject *m = __Pyx_as_CyFunctionObject(func);
193
+ m->defaults_tuple = tuple;
194
+ Py_INCREF(tuple);
195
+ }
196
+
197
+ static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) {
198
+ __pyx_CyFunctionObject *m = __Pyx_as_CyFunctionObject(func);
199
+ m->defaults_kwdict = dict;
200
+ Py_INCREF(dict);
201
+ }
202
+
203
+ static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) {
204
+ __pyx_CyFunctionObject *m = __Pyx_as_CyFunctionObject(func);
205
+ m->func_annotations = dict;
206
+ Py_INCREF(dict);
207
+ }
208
+
209
+ //////////////////// CythonFunctionFromSharedModule /////////////////
210
+ //@requires: CythonFunctionPerModule
211
+ //@requires: CythonFunction
212
+ //@requires: CommonStructures.c::VerifyCachedType
213
+ //@substitute: naming
214
+
215
+ // Cutdown version that's only used when importing from shared utility code
216
+ static int __pyx_CyFunction_init(PyObject *module) {
217
+ $modulestatetype_cname *mstate = __Pyx_PyModule_GetState(module);
218
+
219
+ PyTypeObject *tp = __Pyx_Get_CyFunction_Type();
220
+ if (!tp) return -1;
221
+
222
+ if (__Pyx_VerifyCachedType((PyObject*)tp,
223
+ __PYX_TYPE_MODULE_PREFIX "cython_function_or_method",
224
+ __PYX_SHARED_SIZEOF(__pyx_CyFunctionObject)) != 0) {
225
+ Py_DECREF((PyObject*)tp);
226
+ return -1;
227
+ }
228
+
229
+ mstate->__pyx_CyFunctionType = tp;
230
+ return 0;
231
+ }
232
+
233
+ //////////////////// CythonFunctionShared.proto ////////////////////
234
+ //@requires: CythonFunctionPerModule
235
+
236
+ static PyObject *__Pyx_CyFunction_Init(PyObject *op_in, PyMethodDef *ml,
237
+ int flags, PyObject* qualname,
238
+ PyObject *closure,
239
+ PyObject *module, PyObject *globals,
240
+ PyObject* code);
241
+
242
+ #if CYTHON_VECTORCALL
243
+ static PyObject * __Pyx_CyFunction_Vectorcall_NOARGS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames);
244
+ static PyObject * __Pyx_CyFunction_Vectorcall_O(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames);
245
+ static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames);
246
+ static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS_METHOD(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames);
247
+ #endif
248
+
249
+ //////////////////// CythonFunctionShared ////////////////////
250
+ //@requires: CommonStructures.c::FetchCommonType
251
+ //@requires: CommonStructures.c::CommonTypesMetaclass
252
+ //@requires: ObjectHandling.c::PyMethodNew
253
+ //@requires: ObjectHandling.c::PyVectorcallFastCallDict
254
+ //@requires: Exceptions.c::IgnoreException
255
+ //@requires: ModuleSetupCode.c::IncludeStructmemberH
256
+ //@requires: ObjectHandling.c::PyObjectGetAttrStr
257
+ //@requires: ObjectHandling.c::PyObjectCallOneArg
258
+ //@requires: ExtensionTypes.c::CallTypeTraverse
259
+ //@requires: Synchronization.c::CriticalSections
260
+ //@substitute: naming
261
+
187
262
  static PyObject *
188
263
  __Pyx_CyFunction_get_doc_locked(__pyx_CyFunctionObject *op)
189
264
  {
190
265
  if (unlikely(op->func_doc == NULL)) {
191
266
  #if CYTHON_COMPILING_IN_LIMITED_API
192
- op->func_doc = PyObject_GetAttrString(op->func, "__doc__");
193
- if (unlikely(!op->func_doc)) return NULL;
267
+ const char *doc = op->func_methoddef->ml_doc;
194
268
  #else
195
- if (((PyCFunctionObject*)op)->m_ml->ml_doc) {
196
- op->func_doc = PyUnicode_FromString(((PyCFunctionObject*)op)->m_ml->ml_doc);
269
+ const char *doc = ((PyCFunctionObject*)op)->m_ml->ml_doc;
270
+ #endif
271
+ if (doc) {
272
+ op->func_doc = PyUnicode_FromString(doc);
197
273
  if (unlikely(op->func_doc == NULL))
198
274
  return NULL;
199
275
  } else {
200
276
  Py_INCREF(Py_None);
201
277
  return Py_None;
202
278
  }
203
- #endif /* CYTHON_COMPILING_IN_LIMITED_API */
204
279
  }
205
280
  Py_INCREF(op->func_doc);
206
281
  return op->func_doc;
207
282
  }
208
283
 
209
284
  static PyObject *
210
- __Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, void *closure) {
285
+ __Pyx_CyFunction_get_doc(PyObject *op_in, void *closure) {
211
286
  PyObject *result;
287
+ __pyx_CyFunctionObject *op = __Pyx_as_CyFunctionObject(op_in);
212
288
  CYTHON_UNUSED_VAR(closure);
213
- __Pyx_BEGIN_CRITICAL_SECTION(op);
289
+ __Pyx_BEGIN_CRITICAL_SECTION(op_in);
214
290
  result = __Pyx_CyFunction_get_doc_locked(op);
215
291
  __Pyx_END_CRITICAL_SECTION();
216
292
  return result;
217
293
  }
218
294
 
219
295
  static int
220
- __Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value, void *context)
296
+ __Pyx_CyFunction_set_doc(PyObject *op_in, PyObject *value, void *context)
221
297
  {
298
+ __pyx_CyFunctionObject *op = __Pyx_as_CyFunctionObject(op_in);
222
299
  CYTHON_UNUSED_VAR(context);
223
300
  if (value == NULL) {
224
301
  // Mark as deleted
225
302
  value = Py_None;
226
303
  }
227
304
  Py_INCREF(value);
228
- __Pyx_BEGIN_CRITICAL_SECTION(op);
305
+ __Pyx_BEGIN_CRITICAL_SECTION(op_in);
229
306
  __Pyx_Py_XDECREF_SET(op->func_doc, value);
230
307
  __Pyx_END_CRITICAL_SECTION();
231
308
  return 0;
@@ -236,10 +313,11 @@ __Pyx_CyFunction_get_name_locked(__pyx_CyFunctionObject *op)
236
313
  {
237
314
  if (unlikely(op->func_name == NULL)) {
238
315
  #if CYTHON_COMPILING_IN_LIMITED_API
239
- op->func_name = PyObject_GetAttrString(op->func, "__name__");
316
+ const char *name = op->func_methoddef->ml_name;
240
317
  #else
241
- op->func_name = PyUnicode_InternFromString(((PyCFunctionObject*)op)->m_ml->ml_name);
242
- #endif /* CYTHON_COMPILING_IN_LIMITED_API */
318
+ const char *name = ((PyCFunctionObject*)op)->m_ml->ml_name;
319
+ #endif
320
+ op->func_name = PyUnicode_InternFromString(name);
243
321
  if (unlikely(op->func_name == NULL))
244
322
  return NULL;
245
323
  }
@@ -248,18 +326,18 @@ __Pyx_CyFunction_get_name_locked(__pyx_CyFunctionObject *op)
248
326
  }
249
327
 
250
328
  static PyObject *
251
- __Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op, void *context)
329
+ __Pyx_CyFunction_get_name(PyObject *op, void *context)
252
330
  {
253
331
  PyObject *result = NULL;
254
332
  CYTHON_UNUSED_VAR(context);
255
333
  __Pyx_BEGIN_CRITICAL_SECTION(op);
256
- result = __Pyx_CyFunction_get_name_locked(op);
334
+ result = __Pyx_CyFunction_get_name_locked(__Pyx_as_CyFunctionObject(op));
257
335
  __Pyx_END_CRITICAL_SECTION();
258
336
  return result;
259
337
  }
260
338
 
261
339
  static int
262
- __Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value, void *context)
340
+ __Pyx_CyFunction_set_name(PyObject *op_in, PyObject *value, void *context)
263
341
  {
264
342
  CYTHON_UNUSED_VAR(context);
265
343
  if (unlikely(value == NULL || !PyUnicode_Check(value))) {
@@ -267,19 +345,21 @@ __Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value, void *con
267
345
  "__name__ must be set to a string object");
268
346
  return -1;
269
347
  }
348
+ __pyx_CyFunctionObject *op = __Pyx_as_CyFunctionObject(op_in);
270
349
  Py_INCREF(value);
271
- __Pyx_BEGIN_CRITICAL_SECTION(op);
350
+ __Pyx_BEGIN_CRITICAL_SECTION(op_in);
272
351
  __Pyx_Py_XDECREF_SET(op->func_name, value);
273
352
  __Pyx_END_CRITICAL_SECTION();
274
353
  return 0;
275
354
  }
276
355
 
277
356
  static PyObject *
278
- __Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op, void *context)
357
+ __Pyx_CyFunction_get_qualname(PyObject *op_in, void *context)
279
358
  {
280
359
  CYTHON_UNUSED_VAR(context);
360
+ __pyx_CyFunctionObject *op = __Pyx_as_CyFunctionObject(op_in);
281
361
  PyObject *result;
282
- __Pyx_BEGIN_CRITICAL_SECTION(op);
362
+ __Pyx_BEGIN_CRITICAL_SECTION(op_in);
283
363
  Py_INCREF(op->func_qualname);
284
364
  result = op->func_qualname;
285
365
  __Pyx_END_CRITICAL_SECTION();
@@ -287,7 +367,7 @@ __Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op, void *context)
287
367
  }
288
368
 
289
369
  static int
290
- __Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value, void *context)
370
+ __Pyx_CyFunction_set_qualname(PyObject *op_in, PyObject *value, void *context)
291
371
  {
292
372
  CYTHON_UNUSED_VAR(context);
293
373
  if (unlikely(value == NULL || !PyUnicode_Check(value))) {
@@ -295,8 +375,9 @@ __Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value, void
295
375
  "__qualname__ must be set to a string object");
296
376
  return -1;
297
377
  }
378
+ __pyx_CyFunctionObject *op = __Pyx_as_CyFunctionObject(op_in);
298
379
  Py_INCREF(value);
299
- __Pyx_BEGIN_CRITICAL_SECTION(op);
380
+ __Pyx_BEGIN_CRITICAL_SECTION(op_in);
300
381
  __Pyx_Py_XDECREF_SET(op->func_qualname, value);
301
382
  __Pyx_END_CRITICAL_SECTION();
302
383
  return 0;
@@ -319,16 +400,17 @@ __Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op, void *context)
319
400
  #endif
320
401
 
321
402
  static PyObject *
322
- __Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op, void *context)
403
+ __Pyx_CyFunction_get_globals(PyObject *op_in, void *context)
323
404
  {
324
405
  CYTHON_UNUSED_VAR(context);
406
+ __pyx_CyFunctionObject *op = __Pyx_as_CyFunctionObject(op_in);
325
407
  // Globals is read-only so no critical sections
326
408
  Py_INCREF(op->func_globals);
327
409
  return op->func_globals;
328
410
  }
329
411
 
330
412
  static PyObject *
331
- __Pyx_CyFunction_get_closure(__pyx_CyFunctionObject *op, void *context)
413
+ __Pyx_CyFunction_get_closure(PyObject *op, void *context)
332
414
  {
333
415
  CYTHON_UNUSED_VAR(op);
334
416
  CYTHON_UNUSED_VAR(context);
@@ -337,9 +419,10 @@ __Pyx_CyFunction_get_closure(__pyx_CyFunctionObject *op, void *context)
337
419
  }
338
420
 
339
421
  static PyObject *
340
- __Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op, void *context)
422
+ __Pyx_CyFunction_get_code(PyObject *op_in, void *context)
341
423
  {
342
424
  // code is read-only so no critical sections
425
+ __pyx_CyFunctionObject *op = __Pyx_as_CyFunctionObject(op_in);
343
426
  PyObject* result = (op->func_code) ? op->func_code : Py_None;
344
427
  CYTHON_UNUSED_VAR(context);
345
428
  Py_INCREF(result);
@@ -347,9 +430,9 @@ __Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op, void *context)
347
430
  }
348
431
 
349
432
  static int
350
- __Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) {
433
+ __Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op, PyObject *op_obj) {
351
434
  int result = 0;
352
- PyObject *res = op->defaults_getter((PyObject *) op);
435
+ PyObject *res = op->defaults_getter(op_obj);
353
436
  if (unlikely(!res))
354
437
  return -1;
355
438
 
@@ -372,7 +455,8 @@ __Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) {
372
455
  }
373
456
 
374
457
  static int
375
- __Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value, void *context) {
458
+ __Pyx_CyFunction_set_defaults(PyObject *op_in, PyObject* value, void *context) {
459
+ __pyx_CyFunctionObject *op = __Pyx_as_CyFunctionObject(op_in);
376
460
  CYTHON_UNUSED_VAR(context);
377
461
  if (!value) {
378
462
  // del => explicit None to prevent rebuilding
@@ -385,18 +469,19 @@ __Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value, void
385
469
  PyErr_WarnEx(PyExc_RuntimeWarning, "changes to cyfunction.__defaults__ will not "
386
470
  "currently affect the values used in function calls", 1);
387
471
  Py_INCREF(value);
388
- __Pyx_BEGIN_CRITICAL_SECTION(op);
472
+ __Pyx_BEGIN_CRITICAL_SECTION(op_in);
389
473
  __Pyx_Py_XDECREF_SET(op->defaults_tuple, value);
390
474
  __Pyx_END_CRITICAL_SECTION();
391
475
  return 0;
392
476
  }
393
477
 
394
478
  static PyObject *
395
- __Pyx_CyFunction_get_defaults_locked(__pyx_CyFunctionObject *op) {
479
+ __Pyx_CyFunction_get_defaults_locked(PyObject *op_in) {
480
+ __pyx_CyFunctionObject *op = __Pyx_as_CyFunctionObject(op_in);
396
481
  PyObject* result = op->defaults_tuple;
397
482
  if (unlikely(!result)) {
398
483
  if (op->defaults_getter) {
399
- if (unlikely(__Pyx_CyFunction_init_defaults(op) < 0)) return NULL;
484
+ if (unlikely(__Pyx_CyFunction_init_defaults(op, op_in) < 0)) return NULL;
400
485
  result = op->defaults_tuple;
401
486
  } else {
402
487
  result = Py_None;
@@ -407,7 +492,7 @@ __Pyx_CyFunction_get_defaults_locked(__pyx_CyFunctionObject *op) {
407
492
  }
408
493
 
409
494
  static PyObject *
410
- __Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op, void *context) {
495
+ __Pyx_CyFunction_get_defaults(PyObject *op, void *context) {
411
496
  PyObject* result = NULL;
412
497
  CYTHON_UNUSED_VAR(context);
413
498
  __Pyx_BEGIN_CRITICAL_SECTION(op);
@@ -417,7 +502,8 @@ __Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op, void *context) {
417
502
  }
418
503
 
419
504
  static int
420
- __Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value, void *context) {
505
+ __Pyx_CyFunction_set_kwdefaults(PyObject *op_in, PyObject* value, void *context) {
506
+ __pyx_CyFunctionObject *op = __Pyx_as_CyFunctionObject(op_in);
421
507
  CYTHON_UNUSED_VAR(context);
422
508
  if (!value) {
423
509
  // del => explicit None to prevent rebuilding
@@ -430,18 +516,19 @@ __Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value, voi
430
516
  PyErr_WarnEx(PyExc_RuntimeWarning, "changes to cyfunction.__kwdefaults__ will not "
431
517
  "currently affect the values used in function calls", 1);
432
518
  Py_INCREF(value);
433
- __Pyx_BEGIN_CRITICAL_SECTION(op);
519
+ __Pyx_BEGIN_CRITICAL_SECTION(op_in);
434
520
  __Pyx_Py_XDECREF_SET(op->defaults_kwdict, value);
435
521
  __Pyx_END_CRITICAL_SECTION();
436
522
  return 0;
437
523
  }
438
524
 
439
525
  static PyObject *
440
- __Pyx_CyFunction_get_kwdefaults_locked(__pyx_CyFunctionObject *op) {
526
+ __Pyx_CyFunction_get_kwdefaults_locked(PyObject *op_in) {
527
+ __pyx_CyFunctionObject *op = __Pyx_as_CyFunctionObject(op_in);
441
528
  PyObject* result = op->defaults_kwdict;
442
529
  if (unlikely(!result)) {
443
530
  if (op->defaults_getter) {
444
- if (unlikely(__Pyx_CyFunction_init_defaults(op) < 0)) return NULL;
531
+ if (unlikely(__Pyx_CyFunction_init_defaults(op, op_in) < 0)) return NULL;
445
532
  result = op->defaults_kwdict;
446
533
  } else {
447
534
  result = Py_None;
@@ -452,7 +539,7 @@ __Pyx_CyFunction_get_kwdefaults_locked(__pyx_CyFunctionObject *op) {
452
539
  }
453
540
 
454
541
  static PyObject *
455
- __Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op, void *context) {
542
+ __Pyx_CyFunction_get_kwdefaults(PyObject *op, void *context) {
456
543
  PyObject* result;
457
544
  CYTHON_UNUSED_VAR(context);
458
545
  __Pyx_BEGIN_CRITICAL_SECTION(op);
@@ -461,8 +548,10 @@ __Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op, void *context) {
461
548
  return result;
462
549
  }
463
550
 
551
+ static int __Pyx_CyFunction_set_annotate_in_dict_if_exists(PyObject *op_in, PyObject *value); /*proto*/
552
+
464
553
  static int
465
- __Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value, void *context) {
554
+ __Pyx_CyFunction_set_annotations(PyObject *op_in, PyObject* value, void *context) {
466
555
  CYTHON_UNUSED_VAR(context);
467
556
  if (!value || value == Py_None) {
468
557
  value = NULL;
@@ -471,13 +560,64 @@ __Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value, vo
471
560
  "__annotations__ must be set to a dict object");
472
561
  return -1;
473
562
  }
563
+ __pyx_CyFunctionObject *op = __Pyx_as_CyFunctionObject(op_in);
474
564
  Py_XINCREF(value);
475
- __Pyx_BEGIN_CRITICAL_SECTION(op);
565
+ __Pyx_BEGIN_CRITICAL_SECTION(op_in);
476
566
  __Pyx_Py_XDECREF_SET(op->func_annotations, value);
477
567
  __Pyx_END_CRITICAL_SECTION();
568
+ if (unlikely(__Pyx_CyFunction_set_annotate_in_dict_if_exists(op_in, Py_None) < 0)) return -1;
478
569
  return 0;
479
570
  }
480
571
 
572
+ static int
573
+ __Pyx_CyFunction_get_dict_if_exists(PyObject *op_in, PyObject **dict) {
574
+ /* Return 1 if the function dict exists, 0 otherwise. This cannot fail:
575
+ * _PyObject_GetDictPtr() may clear errors internally, but never reports them. */
576
+ #if CYTHON_COMPILING_IN_PYPY
577
+ *dict = PyObject_GenericGetDict(op_in, NULL);
578
+ #elif CYTHON_COMPILING_IN_LIMITED_API || PY_VERSION_HEX < 0x030C0000
579
+ *dict = __Pyx_as_CyFunctionObject(op_in)->func_dict;
580
+ #else
581
+ PyObject **dictptr = _PyObject_GetDictPtr(op_in);
582
+ *dict = likely(dictptr) ? *dictptr : NULL;
583
+ #endif
584
+ return *dict ? 1 : 0;
585
+ }
586
+
587
+ static int
588
+ __Pyx_CyFunction_get_annotate_from_dict_if_exists(PyObject *op_in, PyObject **annotate) {
589
+ PyObject *dict;
590
+ int dict_found;
591
+ *annotate = NULL;
592
+ dict_found = __Pyx_CyFunction_get_dict_if_exists(op_in, &dict);
593
+ if (!dict_found) return 0;
594
+ return __Pyx_PyDict_GetItemRef(dict, PYIDENT("__annotate__"), annotate);
595
+ }
596
+
597
+ static int
598
+ __Pyx_CyFunction_set_annotate_in_dict_if_exists(PyObject *op_in, PyObject *value) {
599
+ PyObject *dict;
600
+ int dict_found;
601
+ dict_found = __Pyx_CyFunction_get_dict_if_exists(op_in, &dict);
602
+ if (!dict_found) return 0;
603
+ return PyDict_SetItem(dict, PYIDENT("__annotate__"), value);
604
+ }
605
+
606
+ static int
607
+ __Pyx_CyFunction_set_annotate_in_dict(PyObject *op_in, PyObject *value) {
608
+ PyObject *dict;
609
+ int result;
610
+ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
611
+ dict = __Pyx_CyFunction_get_dict(__Pyx_as_CyFunctionObject(op_in), NULL);
612
+ #else
613
+ dict = PyObject_GenericGetDict(op_in, NULL);
614
+ #endif
615
+ if (unlikely(!dict)) return -1;
616
+ result = PyDict_SetItem(dict, PYIDENT("__annotate__"), value);
617
+ Py_DECREF(dict);
618
+ return result;
619
+ }
620
+
481
621
  static PyObject *
482
622
  __Pyx_CyFunction_get_annotations_locked(__pyx_CyFunctionObject *op) {
483
623
  PyObject* result = op->func_annotations;
@@ -491,19 +631,56 @@ __Pyx_CyFunction_get_annotations_locked(__pyx_CyFunctionObject *op) {
491
631
  }
492
632
 
493
633
  static PyObject *
494
- __Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op, void *context) {
495
- PyObject *result;
634
+ __Pyx_CyFunction_get_annotations(PyObject *op_in, void *context) {
635
+ PyObject *annotate = NULL;
636
+ PyObject *result = NULL;
637
+ __pyx_CyFunctionObject *op = __Pyx_as_CyFunctionObject(op_in);
496
638
  CYTHON_UNUSED_VAR(context);
497
- __Pyx_BEGIN_CRITICAL_SECTION(op);
498
- result = __Pyx_CyFunction_get_annotations_locked(op);
639
+ __Pyx_BEGIN_CRITICAL_SECTION(op_in);
640
+ result = __Pyx_XNewRef(op->func_annotations);
641
+ __Pyx_END_CRITICAL_SECTION();
642
+ if (result) return result;
643
+
644
+ if (unlikely(__Pyx_CyFunction_get_annotate_from_dict_if_exists(op_in, &annotate) < 0)) return NULL;
645
+ if (!annotate || annotate == Py_None) {
646
+ Py_XDECREF(annotate);
647
+ __Pyx_BEGIN_CRITICAL_SECTION(op_in);
648
+ result = __Pyx_CyFunction_get_annotations_locked(op);
649
+ __Pyx_END_CRITICAL_SECTION();
650
+ return result;
651
+ }
652
+
653
+ PyObject *format = PyLong_FromLong(1L); // annotationlib.Format.VALUE
654
+ if (likely(format)) {
655
+ result = __Pyx_PyObject_CallOneArg(annotate, format);
656
+ Py_DECREF(format);
657
+ }
658
+ Py_DECREF(annotate);
659
+ if (unlikely(!result)) return NULL;
660
+ if (unlikely(!PyDict_Check(result))) {
661
+ PyErr_SetString(PyExc_TypeError, "__annotate__ must return a dict");
662
+ Py_DECREF(result);
663
+ return NULL;
664
+ }
665
+ __Pyx_BEGIN_CRITICAL_SECTION(op_in);
666
+ __Pyx_Py_XDECREF_SET(op->func_annotations, __Pyx_NewRef(result));
499
667
  __Pyx_END_CRITICAL_SECTION();
500
668
  return result;
501
669
  }
502
670
 
503
- static PyObject *__Pyx_CyFunction_annotate_impl(PyObject *self, PyObject *args) {
671
+ static PyObject *__Pyx_CyFunction_annotate_impl(PyObject *self,
672
+ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
673
+ PyObject *args
674
+ #else
675
+ PyObject* const* args, Py_ssize_t nargs
676
+ #endif
677
+ ) {
504
678
  // The signature of this function is 0 or 1 args, where arg should be an int (if passed).
505
679
  // However, for this basic placeholder implementation, we don't care and don't check it.
506
680
  CYTHON_UNUSED_VAR(args);
681
+ #if !CYTHON_COMPILING_IN_LIMITED_API || __PYX_LIMITED_VERSION_HEX >= 0x030A0000
682
+ CYTHON_UNUSED_VAR(nargs);
683
+ #endif
507
684
  if (unlikely(!self)) {
508
685
  PyErr_SetString(PyExc_SystemError, "cython __annotate__ called without 'self' argument");
509
686
  }
@@ -514,19 +691,25 @@ static PyObject *__Pyx_CyFunction_annotate_impl(PyObject *self, PyObject *args)
514
691
  static PyMethodDef __Pyx_CyFunction_annotate_method = {
515
692
  "__annotate__",
516
693
  (PyCFunction)(void (*)(void))__Pyx_CyFunction_annotate_impl,
694
+ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
517
695
  METH_VARARGS,
696
+ #else
697
+ METH_FASTCALL,
698
+ #endif
518
699
  "Placeholder __annotate__ function to allow 'functools.wraps' to work "
519
700
  "on Cython functions."
520
701
  };
521
702
 
522
703
  // We don't yet support PEP649 properly, so __annotate__ is
523
704
  // implemented in a minimal way, just so that functools.wraps works.
524
- // Essentially the effect of doing func.__annotate__ = other.__annotate__
525
- // is to copy the annotations dictionary.
526
705
  static PyObject *
527
706
  __Pyx_CyFunction_get_annotate(PyObject *op_in, void *context) {
707
+ PyObject *annotate = NULL;
528
708
  CYTHON_UNUSED_VAR(context);
529
- PyObject *annotations = __Pyx_CyFunction_get_annotations((__pyx_CyFunctionObject *) op_in, NULL);
709
+ if (unlikely(__Pyx_CyFunction_get_annotate_from_dict_if_exists(op_in, &annotate) < 0)) return NULL;
710
+ if (annotate) return annotate;
711
+
712
+ PyObject *annotations = __Pyx_CyFunction_get_annotations(op_in, NULL);
530
713
  if (unlikely(!annotations)) return NULL;
531
714
  PyObject *method = PyCFunction_New(
532
715
  &__Pyx_CyFunction_annotate_method,
@@ -542,17 +725,20 @@ __Pyx_CyFunction_set_annotate(PyObject *op_in, PyObject* value, void *context) {
542
725
  PyErr_SetString(PyExc_TypeError, "__annotate__ cannot be deleted");
543
726
  return -1;
544
727
  }
545
- if (value == Py_None) {
546
- // PEP 649 says "Setting o.__annotate__ to None has no effect on the cached annotations dict."
547
- return 0;
728
+ if (unlikely(value != Py_None && !PyCallable_Check(value))) {
729
+ PyErr_SetString(PyExc_TypeError, "__annotate__ must be callable or None");
730
+ return -1;
548
731
  }
549
- PyObject *annotations = PyObject_CallObject(value, NULL);
550
- if (!annotations) return -1;
551
- int result = __Pyx_CyFunction_set_annotations((__pyx_CyFunctionObject *) op_in, annotations, NULL);
552
- Py_DECREF(annotations);
553
- return result;
732
+ if (value != Py_None) {
733
+ __pyx_CyFunctionObject *op = __Pyx_as_CyFunctionObject(op_in);
734
+ __Pyx_BEGIN_CRITICAL_SECTION(op_in);
735
+ Py_CLEAR(op->func_annotations);
736
+ __Pyx_END_CRITICAL_SECTION();
737
+ }
738
+ return __Pyx_CyFunction_set_annotate_in_dict(op_in, value);
554
739
  }
555
740
 
741
+ #if __PYX_LIMITED_VERSION_HEX < 0x030B0000
556
742
  static PyObject *
557
743
  __Pyx_CyFunction_get_is_coroutine_value(__pyx_CyFunctionObject *op) {
558
744
  int is_coroutine = op->flags & __Pyx_CYFUNCTION_COROUTINE;
@@ -571,21 +757,26 @@ __Pyx_CyFunction_get_is_coroutine_value(__pyx_CyFunctionObject *op) {
571
757
  #endif
572
758
  module = PyImport_ImportModuleLevelObject(PYIDENT("asyncio.coroutines"), NULL, NULL, fromlist, 0);
573
759
  Py_DECREF(fromlist);
574
- if (unlikely(!module)) goto ignore;
760
+ if (unlikely(!module)) {
761
+ goto ignore_or_error;
762
+ }
575
763
  is_coroutine_value = __Pyx_PyObject_GetAttrStr(module, marker);
576
764
  Py_DECREF(module);
577
765
  if (likely(is_coroutine_value)) {
578
766
  return is_coroutine_value;
579
767
  }
580
- ignore:
581
- PyErr_Clear();
768
+ ignore_or_error:
769
+ if (!__Pyx_IgnoreException(PyExc_Exception)) {
770
+ return NULL;
771
+ }
582
772
  }
583
773
 
584
774
  return __Pyx_PyBool_FromLong(is_coroutine);
585
775
  }
586
776
 
587
777
  static PyObject *
588
- __Pyx_CyFunction_get_is_coroutine(__pyx_CyFunctionObject *op, void *context) {
778
+ __Pyx_CyFunction_get_is_coroutine(PyObject *op_in, void *context) {
779
+ __pyx_CyFunctionObject *op = __Pyx_as_CyFunctionObject(op_in);
589
780
  PyObject *result;
590
781
  CYTHON_UNUSED_VAR(context);
591
782
  if (op->func_is_coroutine) {
@@ -596,7 +787,7 @@ __Pyx_CyFunction_get_is_coroutine(__pyx_CyFunctionObject *op, void *context) {
596
787
  if (unlikely(!result))
597
788
  return NULL;
598
789
 
599
- __Pyx_BEGIN_CRITICAL_SECTION(op);
790
+ __Pyx_BEGIN_CRITICAL_SECTION(op_in);
600
791
  // Guard against concurrent initialisation.
601
792
  if (op->func_is_coroutine) {
602
793
  Py_DECREF(result);
@@ -607,6 +798,7 @@ __Pyx_CyFunction_get_is_coroutine(__pyx_CyFunctionObject *op, void *context) {
607
798
  __Pyx_END_CRITICAL_SECTION();
608
799
  return result;
609
800
  }
801
+ #endif
610
802
 
611
803
  //static PyObject *
612
804
  //__Pyx_CyFunction_get_signature(__pyx_CyFunctionObject *op, void *context) {
@@ -632,7 +824,7 @@ __Pyx_CyFunction_get_is_coroutine(__pyx_CyFunctionObject *op, void *context) {
632
824
  // return NULL;
633
825
  //}
634
826
 
635
- static void __Pyx_CyFunction_raise_argument_count_error(__pyx_CyFunctionObject *func, const char* message, Py_ssize_t size) {
827
+ static void __Pyx_CyFunction_raise_argument_count_error(PyObject *func, const char* message, Py_ssize_t size) {
636
828
  #if CYTHON_COMPILING_IN_LIMITED_API
637
829
  PyObject *py_name = __Pyx_CyFunction_get_name(func, NULL);
638
830
  if (!py_name) return;
@@ -648,7 +840,7 @@ static void __Pyx_CyFunction_raise_argument_count_error(__pyx_CyFunctionObject *
648
840
  #endif
649
841
  }
650
842
 
651
- static void __Pyx_CyFunction_raise_type_error(__pyx_CyFunctionObject *func, const char* message) {
843
+ static void __Pyx_CyFunction_raise_type_error(PyObject *func, const char* message) {
652
844
  #if CYTHON_COMPILING_IN_LIMITED_API
653
845
  PyObject *py_name = __Pyx_CyFunction_get_name(func, NULL);
654
846
  if (!py_name) return;
@@ -664,21 +856,34 @@ static void __Pyx_CyFunction_raise_type_error(__pyx_CyFunctionObject *func, cons
664
856
  #endif
665
857
  }
666
858
 
667
-
668
859
  #if CYTHON_COMPILING_IN_LIMITED_API
860
+ // Note - for CyFunction alone it'd be easier to access this as a member
861
+ // rather than a getset. However, that's harder for fused functions
862
+ // where we have to override them again.
669
863
  static PyObject *
670
- __Pyx_CyFunction_get_module(__pyx_CyFunctionObject *op, void *context) {
864
+ __Pyx_CyFunction_get_module(PyObject *op_in, void *context) {
671
865
  CYTHON_UNUSED_VAR(context);
672
- return PyObject_GetAttrString(op->func, "__module__");
866
+ __pyx_CyFunctionObject *op = __Pyx_as_CyFunctionObject(op_in);
867
+ Py_INCREF(op->func_module);
868
+ return op->func_module;
673
869
  }
674
870
 
675
871
  static int
676
- __Pyx_CyFunction_set_module(__pyx_CyFunctionObject *op, PyObject* value, void *context) {
872
+ __Pyx_CyFunction_set_module(PyObject *op_in, PyObject* value, void *context) {
677
873
  CYTHON_UNUSED_VAR(context);
678
- return PyObject_SetAttrString(op->func, "__module__", value);
874
+ __pyx_CyFunctionObject *op = __Pyx_as_CyFunctionObject(op_in);
875
+ if (value == NULL) {
876
+ value = Py_None;
877
+ }
878
+ Py_INCREF(value);
879
+ PyObject *old = op->func_module;
880
+ op->func_module = value;
881
+ Py_DECREF(old);
882
+ return 0;
679
883
  }
680
884
  #endif
681
885
 
886
+
682
887
  static PyGetSetDef __pyx_CyFunction_getsets[] = {
683
888
  {"func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
684
889
  {"__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
@@ -703,7 +908,9 @@ static PyGetSetDef __pyx_CyFunction_getsets[] = {
703
908
  {"__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0},
704
909
  {"__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0},
705
910
  {"__annotate__", (getter)__Pyx_CyFunction_get_annotate, (setter)__Pyx_CyFunction_set_annotate, 0, 0},
911
+ #if __PYX_LIMITED_VERSION_HEX < 0x030B0000
706
912
  {"_is_coroutine", (getter)__Pyx_CyFunction_get_is_coroutine, 0, 0, 0},
913
+ #endif
707
914
  // {"__signature__", (getter)__Pyx_CyFunction_get_signature, 0, 0, 0},
708
915
  #if CYTHON_COMPILING_IN_LIMITED_API
709
916
  {"__module__", (getter)__Pyx_CyFunction_get_module, (setter)__Pyx_CyFunction_set_module, 0, 0},
@@ -716,16 +923,19 @@ static PyMemberDef __pyx_CyFunction_members[] = {
716
923
  {"__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), 0, 0},
717
924
  #endif
718
925
  #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
719
- {"__dictoffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_dict), READONLY, 0},
926
+ {"__dictoffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_dict),
927
+ __PYX_SHARED_RELATIVE_OFFSET | READONLY, 0},
720
928
  #endif
721
- #if CYTHON_METH_FASTCALL
722
- #if CYTHON_COMPILING_IN_LIMITED_API
723
- {"__vectorcalloffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_vectorcall), READONLY, 0},
929
+ #if CYTHON_VECTORCALL
930
+ #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_PYPY
931
+ {"__vectorcalloffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_vectorcall),
932
+ __PYX_SHARED_RELATIVE_OFFSET | READONLY, 0},
724
933
  #else
725
934
  {"__vectorcalloffset__", T_PYSSIZET, offsetof(PyCFunctionObject, vectorcall), READONLY, 0},
726
935
  #endif
727
936
  #if CYTHON_COMPILING_IN_LIMITED_API
728
- {"__weaklistoffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_weakreflist), READONLY, 0},
937
+ {"__weaklistoffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_weakreflist),
938
+ __PYX_SHARED_RELATIVE_OFFSET | READONLY, 0},
729
939
  #else
730
940
  {"__weaklistoffset__", T_PYSSIZET, offsetof(PyCFunctionObject, m_weakreflist), READONLY, 0},
731
941
  #endif
@@ -734,11 +944,12 @@ static PyMemberDef __pyx_CyFunction_members[] = {
734
944
  };
735
945
 
736
946
  static PyObject *
737
- __Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, PyObject *args)
947
+ __Pyx_CyFunction_reduce(PyObject *m_in, PyObject *args)
738
948
  {
739
949
  PyObject *result = NULL;
950
+ __pyx_CyFunctionObject *m = __Pyx_as_CyFunctionObject(m_in);
740
951
  CYTHON_UNUSED_VAR(args);
741
- __Pyx_BEGIN_CRITICAL_SECTION(m);
952
+ __Pyx_BEGIN_CRITICAL_SECTION(m_in);
742
953
  Py_INCREF(m->func_qualname);
743
954
  result = m->func_qualname;
744
955
  __Pyx_END_CRITICAL_SECTION();
@@ -746,7 +957,7 @@ __Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, PyObject *args)
746
957
  }
747
958
 
748
959
  static PyMethodDef __pyx_CyFunction_methods[] = {
749
- {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
960
+ {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_NOARGS, 0},
750
961
  {0, 0, 0, 0}
751
962
  };
752
963
 
@@ -757,23 +968,26 @@ static PyMethodDef __pyx_CyFunction_methods[] = {
757
968
  #define __Pyx_CyFunction_weakreflist(cyfunc) (((PyCFunctionObject*)cyfunc)->m_weakreflist)
758
969
  #endif
759
970
 
760
- static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject *op, PyMethodDef *ml, int flags, PyObject* qualname,
971
+ static PyObject *__Pyx_CyFunction_Init(PyObject *op_in,
972
+ PyMethodDef *ml, int flags, PyObject* qualname,
761
973
  PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
974
+ __pyx_CyFunctionObject* op = __Pyx_as_CyFunctionObject(op_in);
762
975
  #if !CYTHON_COMPILING_IN_LIMITED_API
763
976
  PyCFunctionObject *cf = (PyCFunctionObject*) op;
764
977
  #endif
765
978
  if (unlikely(op == NULL))
766
979
  return NULL;
767
980
  #if CYTHON_COMPILING_IN_LIMITED_API
768
- // Note that we end up with a circular reference to op. This isn't
769
- // a disaster, but in an ideal world it'd be nice to avoid it.
770
- op->func = PyCFunction_NewEx(ml, (PyObject*)op, module);
771
- if (unlikely(!op->func)) return NULL;
981
+ op->func_methoddef = ml;
982
+ Py_INCREF(module);
983
+ op->func_module = module;
772
984
  #endif
773
985
  op->flags = flags;
774
986
  __Pyx_CyFunction_weakreflist(op) = NULL;
775
987
  #if !CYTHON_COMPILING_IN_LIMITED_API
776
988
  cf->m_ml = ml;
989
+ // This is set for the benefit of __Pyx_CyOrPyCFunction_GET_SELF. It is never reassigned, so
990
+ // when we know an object is a CyFunction we don't even need to look it up.__Pyx_CyFunction_set_module
777
991
  cf->m_self = (PyObject *) op;
778
992
  #endif
779
993
  Py_XINCREF(closure);
@@ -789,7 +1003,7 @@ static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject *op, PyMethodDef *
789
1003
  Py_INCREF(qualname);
790
1004
  op->func_qualname = qualname;
791
1005
  op->func_doc = NULL;
792
- #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API
1006
+ #if CYTHON_COMPILING_IN_LIMITED_API
793
1007
  op->func_classobj = NULL;
794
1008
  #else
795
1009
  ((PyCMethodObject*)op)->mm_class = NULL;
@@ -804,8 +1018,10 @@ static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject *op, PyMethodDef *
804
1018
  op->defaults_kwdict = NULL;
805
1019
  op->defaults_getter = NULL;
806
1020
  op->func_annotations = NULL;
1021
+ #if __PYX_LIMITED_VERSION_HEX < 0x030B0000
807
1022
  op->func_is_coroutine = NULL;
808
- #if CYTHON_METH_FASTCALL
1023
+ #endif
1024
+ #if CYTHON_VECTORCALL
809
1025
  switch (ml->ml_flags & (METH_VARARGS | METH_FASTCALL | METH_NOARGS | METH_O | METH_KEYWORDS | METH_METHOD)) {
810
1026
  case METH_NOARGS:
811
1027
  __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_NOARGS;
@@ -826,19 +1042,18 @@ static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject *op, PyMethodDef *
826
1042
  break;
827
1043
  default:
828
1044
  PyErr_SetString(PyExc_SystemError, "Bad call flags for CyFunction");
829
- Py_DECREF(op);
1045
+ Py_DECREF(op_in);
830
1046
  return NULL;
831
1047
  }
832
1048
  #endif
833
- return (PyObject *) op;
1049
+ return op_in;
834
1050
  }
835
1051
 
836
- static int
837
- __Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
1052
+ static int __Pyx__CyFunction_clear(__pyx_CyFunctionObject *m)
838
1053
  {
839
1054
  Py_CLEAR(m->func_closure);
840
1055
  #if CYTHON_COMPILING_IN_LIMITED_API
841
- Py_CLEAR(m->func);
1056
+ Py_CLEAR(m->func_module);
842
1057
  #else
843
1058
  Py_CLEAR(((PyCFunctionObject*)m)->m_module);
844
1059
  #endif
@@ -854,8 +1069,8 @@ __Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
854
1069
  Py_CLEAR(m->func_doc);
855
1070
  Py_CLEAR(m->func_globals);
856
1071
  Py_CLEAR(m->func_code);
857
- #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API
858
- Py_CLEAR(__Pyx_CyFunction_GetClassObj(m));
1072
+ #if CYTHON_COMPILING_IN_LIMITED_API
1073
+ Py_CLEAR(m->func_classobj);
859
1074
  #else
860
1075
  {
861
1076
  PyObject *cls = (PyObject*) ((PyCMethodObject *) (m))->mm_class;
@@ -866,36 +1081,46 @@ __Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
866
1081
  Py_CLEAR(m->defaults_tuple);
867
1082
  Py_CLEAR(m->defaults_kwdict);
868
1083
  Py_CLEAR(m->func_annotations);
1084
+ #if __PYX_LIMITED_VERSION_HEX < 0x030B0000
869
1085
  Py_CLEAR(m->func_is_coroutine);
1086
+ #endif
870
1087
 
871
1088
  Py_CLEAR(m->defaults);
872
1089
 
873
1090
  return 0;
874
1091
  }
875
1092
 
876
- static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m)
1093
+ static int
1094
+ __Pyx_CyFunction_clear(PyObject *m)
1095
+ {
1096
+ return __Pyx__CyFunction_clear(__Pyx_as_CyFunctionObject(m));
1097
+ }
1098
+
1099
+ static void __Pyx__CyFunction_dealloc(PyObject *m)
877
1100
  {
878
- if (__Pyx_CyFunction_weakreflist(m) != NULL)
879
- PyObject_ClearWeakRefs((PyObject *) m);
880
- __Pyx_CyFunction_clear(m);
1101
+ __pyx_CyFunctionObject *cyfunc = __Pyx_as_CyFunctionObject(m);
1102
+ if (__Pyx_CyFunction_weakreflist(cyfunc) != NULL)
1103
+ PyObject_ClearWeakRefs(m);
1104
+ __Pyx__CyFunction_clear(cyfunc);
881
1105
  __Pyx_PyHeapTypeObject_GC_Del(m);
882
1106
  }
883
1107
 
884
- static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
1108
+ static void __Pyx_CyFunction_dealloc(PyObject *m)
885
1109
  {
886
1110
  PyObject_GC_UnTrack(m);
887
1111
  __Pyx__CyFunction_dealloc(m);
888
1112
  }
889
1113
 
890
- static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
1114
+ static int __Pyx_CyFunction_traverse(PyObject *m_in, visitproc visit, void *arg)
891
1115
  {
1116
+ __pyx_CyFunctionObject *m = __Pyx_as_CyFunctionObject(m_in);
892
1117
  {
893
- int e = __Pyx_call_type_traverse((PyObject*)m, 1, visit, arg);
1118
+ int e = __Pyx_call_type_traverse(m_in, 1, visit, arg);
894
1119
  if (e) return e;
895
1120
  }
896
1121
  Py_VISIT(m->func_closure);
897
1122
  #if CYTHON_COMPILING_IN_LIMITED_API
898
- Py_VISIT(m->func);
1123
+ Py_VISIT(m->func_module);
899
1124
  #else
900
1125
  Py_VISIT(((PyCFunctionObject*)m)->m_module);
901
1126
  #endif
@@ -919,21 +1144,24 @@ static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit,
919
1144
  Py_VISIT(m->func_globals);
920
1145
  // The code objects that we generate only contain plain constants and can never participate in reference cycles.
921
1146
  __Pyx_VISIT_CONST(m->func_code);
922
- Py_VISIT(__Pyx_CyFunction_GetClassObj(m));
1147
+ Py_VISIT(__Pyx__CyFunction_GetClassObj(m));
923
1148
  Py_VISIT(m->defaults_tuple);
924
1149
  Py_VISIT(m->defaults_kwdict);
925
1150
  Py_VISIT(m->func_annotations);
1151
+ #if __PYX_LIMITED_VERSION_HEX < 0x030B0000
926
1152
  Py_VISIT(m->func_is_coroutine);
1153
+ #endif
927
1154
  Py_VISIT(m->defaults);
928
1155
 
929
1156
  return 0;
930
1157
  }
931
1158
 
932
1159
  static PyObject*
933
- __Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
1160
+ __Pyx_CyFunction_repr(PyObject *op_in)
934
1161
  {
1162
+ __pyx_CyFunctionObject *op = __Pyx_as_CyFunctionObject(op_in);
935
1163
  PyObject *repr;
936
- __Pyx_BEGIN_CRITICAL_SECTION(op);
1164
+ __Pyx_BEGIN_CRITICAL_SECTION(op_in);
937
1165
  repr = PyUnicode_FromFormat("<cyfunction %U at %p>",
938
1166
  op->func_qualname, (void *)op);
939
1167
  __Pyx_END_CRITICAL_SECTION();
@@ -943,13 +1171,9 @@ __Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
943
1171
  static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) {
944
1172
  // originally copied from PyCFunction_Call() in CPython's Objects/methodobject.c
945
1173
  #if CYTHON_COMPILING_IN_LIMITED_API
946
- PyObject *f = ((__pyx_CyFunctionObject*)func)->func;
947
- PyCFunction meth;
948
- int flags;
949
- meth = PyCFunction_GetFunction(f);
950
- if (unlikely(!meth)) return NULL;
951
- flags = PyCFunction_GetFlags(f);
952
- if (unlikely(flags < 0)) return NULL;
1174
+ __pyx_CyFunctionObject *cyfunc = __Pyx_as_CyFunctionObject(func);
1175
+ PyCFunction meth = cyfunc->func_methoddef->ml_meth;
1176
+ int flags = cyfunc->func_methoddef->ml_flags;
953
1177
  #else
954
1178
  PyCFunctionObject* f = (PyCFunctionObject*)func;
955
1179
  PyCFunction meth = f->m_ml->ml_meth;
@@ -975,7 +1199,7 @@ static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, Py
975
1199
  if (likely(size == 0))
976
1200
  return (*meth)(self, NULL);
977
1201
  __Pyx_CyFunction_raise_argument_count_error(
978
- (__pyx_CyFunctionObject*)func,
1202
+ func,
979
1203
  "takes no arguments", size);
980
1204
  return NULL;
981
1205
  }
@@ -1002,7 +1226,7 @@ static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, Py
1002
1226
  return result;
1003
1227
  }
1004
1228
  __Pyx_CyFunction_raise_argument_count_error(
1005
- (__pyx_CyFunctionObject*)func,
1229
+ func,
1006
1230
  "takes exactly one argument", size);
1007
1231
  return NULL;
1008
1232
  }
@@ -1012,28 +1236,21 @@ static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, Py
1012
1236
  return NULL;
1013
1237
  }
1014
1238
  __Pyx_CyFunction_raise_type_error(
1015
- (__pyx_CyFunctionObject*)func, "takes no keyword arguments");
1239
+ func, "takes no keyword arguments");
1016
1240
  return NULL;
1017
1241
  }
1018
1242
 
1019
1243
  static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
1020
- PyObject *self, *result;
1021
- #if CYTHON_COMPILING_IN_LIMITED_API
1022
- // PyCFunction_GetSelf returns a borrowed reference
1023
- self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)func)->func);
1024
- if (unlikely(!self) && PyErr_Occurred()) return NULL;
1025
- #else
1026
- self = ((PyCFunctionObject*)func)->m_self;
1027
- #endif
1028
- result = __Pyx_CyFunction_CallMethod(func, self, arg, kw);
1244
+ PyObject *result;
1245
+ result = __Pyx_CyFunction_CallMethod(func, func, arg, kw);
1029
1246
  return result;
1030
1247
  }
1031
1248
 
1032
1249
  static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) {
1033
1250
  PyObject *result;
1034
- __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func;
1251
+ __pyx_CyFunctionObject *cyfunc = __Pyx_as_CyFunctionObject(func);
1035
1252
 
1036
- #if CYTHON_METH_FASTCALL && CYTHON_VECTORCALL
1253
+ #if CYTHON_VECTORCALL
1037
1254
  // Prefer vectorcall if available. This is not the typical case, as
1038
1255
  // CPython would normally use vectorcall directly instead of tp_call.
1039
1256
  __pyx_vectorcallfunc vc = __Pyx_CyFunction_func_vectorcall(cyfunc);
@@ -1081,27 +1298,27 @@ static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, P
1081
1298
  return result;
1082
1299
  }
1083
1300
 
1084
- #if CYTHON_METH_FASTCALL && CYTHON_VECTORCALL
1301
+ #if CYTHON_VECTORCALL
1085
1302
  // Check that kwnames is empty (if you want to allow keyword arguments,
1086
1303
  // simply pass kwnames=NULL) and figure out what to do with "self".
1087
1304
  // Return value:
1088
1305
  // 1: self = args[0]
1089
1306
  // 0: self = cyfunc->func.m_self
1090
1307
  // -1: error
1091
- static CYTHON_INLINE int __Pyx_CyFunction_Vectorcall_CheckArgs(__pyx_CyFunctionObject *cyfunc, Py_ssize_t nargs, PyObject *kwnames)
1308
+ static CYTHON_INLINE int __Pyx_CyFunction_Vectorcall_CheckArgs(PyObject *func, __pyx_CyFunctionObject *cyfunc, Py_ssize_t nargs, PyObject *kwnames)
1092
1309
  {
1093
1310
  int ret = 0;
1094
1311
  if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) {
1095
1312
  if (unlikely(nargs < 1)) {
1096
1313
  __Pyx_CyFunction_raise_type_error(
1097
- cyfunc, "needs an argument");
1314
+ func, "needs an argument");
1098
1315
  return -1;
1099
1316
  }
1100
1317
  ret = 1;
1101
1318
  }
1102
1319
  if (unlikely(kwnames) && unlikely(__Pyx_PyTuple_GET_SIZE(kwnames))) {
1103
1320
  __Pyx_CyFunction_raise_type_error(
1104
- cyfunc, "takes no keyword arguments");
1321
+ func, "takes no keyword arguments");
1105
1322
  return -1;
1106
1323
  }
1107
1324
  return ret;
@@ -1109,30 +1326,24 @@ static CYTHON_INLINE int __Pyx_CyFunction_Vectorcall_CheckArgs(__pyx_CyFunctionO
1109
1326
 
1110
1327
  static PyObject * __Pyx_CyFunction_Vectorcall_NOARGS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames)
1111
1328
  {
1112
- __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func;
1329
+ __pyx_CyFunctionObject *cyfunc = __Pyx_as_CyFunctionObject(func);
1113
1330
  Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
1114
1331
  PyObject *self;
1115
1332
  #if CYTHON_COMPILING_IN_LIMITED_API
1116
- PyCFunction meth = PyCFunction_GetFunction(cyfunc->func);
1333
+ PyCFunction meth = cyfunc->func_methoddef->ml_meth;
1117
1334
  if (unlikely(!meth)) return NULL;
1118
1335
  #else
1119
1336
  PyCFunction meth = ((PyCFunctionObject*)cyfunc)->m_ml->ml_meth;
1120
1337
  #endif
1121
1338
 
1122
- switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, kwnames)) {
1339
+ switch (__Pyx_CyFunction_Vectorcall_CheckArgs(func, cyfunc, nargs, kwnames)) {
1123
1340
  case 1:
1124
1341
  self = args[0];
1125
1342
  args += 1;
1126
1343
  nargs -= 1;
1127
1344
  break;
1128
1345
  case 0:
1129
- #if CYTHON_COMPILING_IN_LIMITED_API
1130
- // PyCFunction_GetSelf returns a borrowed reference
1131
- self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)cyfunc)->func);
1132
- if (unlikely(!self) && PyErr_Occurred()) return NULL;
1133
- #else
1134
- self = ((PyCFunctionObject*)cyfunc)->m_self;
1135
- #endif
1346
+ self = func;
1136
1347
  break;
1137
1348
  default:
1138
1349
  return NULL;
@@ -1140,7 +1351,7 @@ static PyObject * __Pyx_CyFunction_Vectorcall_NOARGS(PyObject *func, PyObject *c
1140
1351
 
1141
1352
  if (unlikely(nargs != 0)) {
1142
1353
  __Pyx_CyFunction_raise_argument_count_error(
1143
- cyfunc, "takes no arguments", nargs);
1354
+ func, "takes no arguments", nargs);
1144
1355
  return NULL;
1145
1356
  }
1146
1357
  return meth(self, NULL);
@@ -1148,30 +1359,24 @@ static PyObject * __Pyx_CyFunction_Vectorcall_NOARGS(PyObject *func, PyObject *c
1148
1359
 
1149
1360
  static PyObject * __Pyx_CyFunction_Vectorcall_O(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames)
1150
1361
  {
1151
- __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func;
1362
+ __pyx_CyFunctionObject *cyfunc = __Pyx_as_CyFunctionObject(func);
1152
1363
  Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
1153
1364
  PyObject *self;
1154
1365
  #if CYTHON_COMPILING_IN_LIMITED_API
1155
- PyCFunction meth = PyCFunction_GetFunction(cyfunc->func);
1366
+ PyCFunction meth = cyfunc->func_methoddef->ml_meth;
1156
1367
  if (unlikely(!meth)) return NULL;
1157
1368
  #else
1158
1369
  PyCFunction meth = ((PyCFunctionObject*)cyfunc)->m_ml->ml_meth;
1159
1370
  #endif
1160
1371
 
1161
- switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, kwnames)) {
1372
+ switch (__Pyx_CyFunction_Vectorcall_CheckArgs(func, cyfunc, nargs, kwnames)) {
1162
1373
  case 1:
1163
1374
  self = args[0];
1164
1375
  args += 1;
1165
1376
  nargs -= 1;
1166
1377
  break;
1167
1378
  case 0:
1168
- #if CYTHON_COMPILING_IN_LIMITED_API
1169
- // PyCFunction_GetSelf returns a borrowed reference
1170
- self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)cyfunc)->func);
1171
- if (unlikely(!self) && PyErr_Occurred()) return NULL;
1172
- #else
1173
- self = ((PyCFunctionObject*)cyfunc)->m_self;
1174
- #endif
1379
+ self = func;
1175
1380
  break;
1176
1381
  default:
1177
1382
  return NULL;
@@ -1179,7 +1384,7 @@ static PyObject * __Pyx_CyFunction_Vectorcall_O(PyObject *func, PyObject *const
1179
1384
 
1180
1385
  if (unlikely(nargs != 1)) {
1181
1386
  __Pyx_CyFunction_raise_argument_count_error(
1182
- cyfunc, "takes exactly one argument", nargs);
1387
+ func, "takes exactly one argument", nargs);
1183
1388
  return NULL;
1184
1389
  }
1185
1390
  return meth(self, args[0]);
@@ -1187,30 +1392,24 @@ static PyObject * __Pyx_CyFunction_Vectorcall_O(PyObject *func, PyObject *const
1187
1392
 
1188
1393
  static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames)
1189
1394
  {
1190
- __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func;
1395
+ __pyx_CyFunctionObject *cyfunc = __Pyx_as_CyFunctionObject(func);
1191
1396
  Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
1192
1397
  PyObject *self;
1193
1398
  #if CYTHON_COMPILING_IN_LIMITED_API
1194
- PyCFunction meth = PyCFunction_GetFunction(cyfunc->func);
1399
+ PyCFunction meth = cyfunc->func_methoddef->ml_meth;
1195
1400
  if (unlikely(!meth)) return NULL;
1196
1401
  #else
1197
1402
  PyCFunction meth = ((PyCFunctionObject*)cyfunc)->m_ml->ml_meth;
1198
1403
  #endif
1199
1404
 
1200
- switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, NULL)) {
1405
+ switch (__Pyx_CyFunction_Vectorcall_CheckArgs(func, cyfunc, nargs, NULL)) {
1201
1406
  case 1:
1202
1407
  self = args[0];
1203
1408
  args += 1;
1204
1409
  nargs -= 1;
1205
1410
  break;
1206
1411
  case 0:
1207
- #if CYTHON_COMPILING_IN_LIMITED_API
1208
- // PyCFunction_GetSelf returns a borrowed reference
1209
- self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)cyfunc)->func);
1210
- if (unlikely(!self) && PyErr_Occurred()) return NULL;
1211
- #else
1212
- self = ((PyCFunctionObject*)cyfunc)->m_self;
1213
- #endif
1412
+ self = func;
1214
1413
  break;
1215
1414
  default:
1216
1415
  return NULL;
@@ -1221,30 +1420,24 @@ static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS(PyObject *func,
1221
1420
 
1222
1421
  static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS_METHOD(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames)
1223
1422
  {
1224
- __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func;
1225
- PyTypeObject *cls = (PyTypeObject *) __Pyx_CyFunction_GetClassObj(cyfunc);
1423
+ __pyx_CyFunctionObject *cyfunc = __Pyx_as_CyFunctionObject(func);
1424
+ PyTypeObject *cls = (PyTypeObject *) __Pyx__CyFunction_GetClassObj(cyfunc);
1226
1425
  Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
1227
1426
  PyObject *self;
1228
1427
  #if CYTHON_COMPILING_IN_LIMITED_API
1229
- PyCFunction meth = PyCFunction_GetFunction(cyfunc->func);
1428
+ PyCFunction meth = cyfunc->func_methoddef->ml_meth;
1230
1429
  if (unlikely(!meth)) return NULL;
1231
1430
  #else
1232
1431
  PyCFunction meth = ((PyCFunctionObject*)cyfunc)->m_ml->ml_meth;
1233
1432
  #endif
1234
- switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, NULL)) {
1433
+ switch (__Pyx_CyFunction_Vectorcall_CheckArgs(func, cyfunc, nargs, NULL)) {
1235
1434
  case 1:
1236
1435
  self = args[0];
1237
1436
  args += 1;
1238
1437
  nargs -= 1;
1239
1438
  break;
1240
1439
  case 0:
1241
- #if CYTHON_COMPILING_IN_LIMITED_API
1242
- // PyCFunction_GetSelf returns a borrowed reference
1243
- self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)cyfunc)->func);
1244
- if (unlikely(!self) && PyErr_Occurred()) return NULL;
1245
- #else
1246
- self = ((PyCFunctionObject*)cyfunc)->m_self;
1247
- #endif
1440
+ self = func;
1248
1441
  break;
1249
1442
  default:
1250
1443
  return NULL;
@@ -1276,18 +1469,18 @@ static PyType_Slot __pyx_CyFunctionType_slots[] = {
1276
1469
 
1277
1470
  static PyType_Spec __pyx_CyFunctionType_spec = {
1278
1471
  __PYX_TYPE_MODULE_PREFIX "cython_function_or_method",
1279
- sizeof(__pyx_CyFunctionObject),
1472
+ __PYX_SHARED_SIZEOF(__pyx_CyFunctionObject),
1280
1473
  0,
1281
1474
  #ifdef Py_TPFLAGS_METHOD_DESCRIPTOR
1282
1475
  Py_TPFLAGS_METHOD_DESCRIPTOR |
1283
1476
  #endif
1284
- #if CYTHON_METH_FASTCALL
1477
+ #if CYTHON_VECTORCALL
1285
1478
  #if defined(Py_TPFLAGS_HAVE_VECTORCALL)
1286
1479
  Py_TPFLAGS_HAVE_VECTORCALL |
1287
1480
  #elif defined(_Py_TPFLAGS_HAVE_VECTORCALL)
1288
1481
  _Py_TPFLAGS_HAVE_VECTORCALL |
1289
1482
  #endif
1290
- #endif // CYTHON_METH_FASTCALL
1483
+ #endif // CYTHON_VECTORCALL
1291
1484
  #if PY_VERSION_HEX >= 0x030C0000 && !CYTHON_COMPILING_IN_LIMITED_API
1292
1485
  Py_TPFLAGS_MANAGED_DICT |
1293
1486
  #endif
@@ -1306,35 +1499,7 @@ static int __pyx_CyFunction_init(PyObject *module) {
1306
1499
  return 0;
1307
1500
  }
1308
1501
 
1309
- static CYTHON_INLINE PyObject *__Pyx_CyFunction_InitDefaults(PyObject *func, PyTypeObject *defaults_type) {
1310
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
1311
-
1312
- m->defaults = PyObject_CallObject((PyObject*)defaults_type, NULL); // _PyObject_New(defaults_type);
1313
- if (unlikely(!m->defaults))
1314
- return NULL;
1315
- return m->defaults;
1316
- }
1317
-
1318
- static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
1319
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
1320
- m->defaults_tuple = tuple;
1321
- Py_INCREF(tuple);
1322
- }
1323
-
1324
- static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) {
1325
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
1326
- m->defaults_kwdict = dict;
1327
- Py_INCREF(dict);
1328
- }
1329
-
1330
- static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) {
1331
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
1332
- m->func_annotations = dict;
1333
- Py_INCREF(dict);
1334
- }
1335
-
1336
-
1337
- //////////////////// CythonFunction.proto ////////////////////
1502
+ //////////////////// CythonFunction.export ////////////////////
1338
1503
 
1339
1504
  static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml,
1340
1505
  int flags, PyObject* qualname,
@@ -1342,13 +1507,18 @@ static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml,
1342
1507
  PyObject *module, PyObject *globals,
1343
1508
  PyObject* code);
1344
1509
 
1510
+ static PyTypeObject *__Pyx_Get_CyFunction_Type(void);
1511
+
1345
1512
  //////////////////// CythonFunction ////////////////////
1346
1513
  //@requires: CythonFunctionShared
1347
1514
 
1348
1515
  static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml, int flags, PyObject* qualname,
1349
1516
  PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
1517
+ // Only used when using shared utility module
1518
+ (void)&__Pyx_Get_CyFunction_Type;
1519
+
1350
1520
  PyObject *op = __Pyx_CyFunction_Init(
1351
- PyObject_GC_New(__pyx_CyFunctionObject, CGLOBAL(__pyx_CyFunctionType)),
1521
+ PyObject_GC_New(PyObject, CGLOBAL(__pyx_CyFunctionType)),
1352
1522
  ml, flags, qualname, closure, module, globals, code
1353
1523
  );
1354
1524
  if (likely(op)) {
@@ -1357,11 +1527,17 @@ static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml, int flags, PyObject* qual
1357
1527
  return op;
1358
1528
  }
1359
1529
 
1530
+ static PyTypeObject *__Pyx_Get_CyFunction_Type(void) {
1531
+ PyTypeObject *tp = CGLOBAL(__pyx_CyFunctionType);
1532
+ Py_INCREF((PyObject*)tp);
1533
+ return tp;
1534
+ }
1535
+
1360
1536
  //////////////////// CyFunctionClassCell.proto ////////////////////
1361
1537
  static int __Pyx_CyFunction_InitClassCell(PyObject *cyfunctions, PyObject *classobj);/*proto*/
1362
1538
 
1363
1539
  //////////////////// CyFunctionClassCell ////////////////////
1364
- //@requires: CythonFunctionShared
1540
+ //@requires: CythonFunctionPerModule
1365
1541
 
1366
1542
  static int __Pyx_CyFunction_InitClassCell(PyObject *cyfunctions, PyObject *classobj) {
1367
1543
  Py_ssize_t i, count = __Pyx_PyList_GET_SIZE(cyfunctions);
@@ -1370,7 +1546,7 @@ static int __Pyx_CyFunction_InitClassCell(PyObject *cyfunctions, PyObject *class
1370
1546
  #endif
1371
1547
 
1372
1548
  for (i = 0; i < count; i++) {
1373
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *)
1549
+ PyObject *m =
1374
1550
  #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && !CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS
1375
1551
  PyList_GET_ITEM(cyfunctions, i);
1376
1552
  #else
@@ -1380,33 +1556,44 @@ static int __Pyx_CyFunction_InitClassCell(PyObject *cyfunctions, PyObject *class
1380
1556
  #endif
1381
1557
  __Pyx_CyFunction_SetClassObj(m, classobj);
1382
1558
  #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && !CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS)
1383
- Py_DECREF((PyObject*)m);
1559
+ Py_DECREF(m);
1384
1560
  #endif
1385
1561
  }
1386
1562
  return 0;
1387
1563
  }
1388
1564
 
1389
- //////////////////// FusedFunction.module_state_decls ////////////////////
1565
+ //////////////////// FusedFunctionPerModule.module_state_decls ////////////////////
1390
1566
 
1391
1567
  PyTypeObject *__pyx_FusedFunctionType;
1392
1568
 
1393
- //////////////////// FusedFunction.module_state_traverse ///////////////////
1569
+ //////////////////// FusedFunctionPerModule.module_state_traverse ///////////////////
1394
1570
 
1395
1571
  Py_VISIT(traverse_module_state->__pyx_FusedFunctionType);
1396
1572
 
1397
- //////////////////// FusedFunction.module_state_clear ///////////////////
1573
+ //////////////////// FusedFunctionPerModule.module_state_clear ///////////////////
1398
1574
 
1399
1575
  Py_CLEAR(clear_module_state->__pyx_FusedFunctionType);
1400
1576
 
1401
- //////////////////// FusedFunction.init //////////////////
1577
+ //////////////////// FusedFunctionPerModule.init //////////////////
1402
1578
  //@substitute: naming
1579
+ //@init_block: init_after_shared_utility
1403
1580
 
1404
1581
  if (likely(__pyx_FusedFunction_init($module_cname) == 0)); else
1405
1582
 
1406
- //////////////////// FusedFunction.proto ////////////////////
1583
+ //////////////////// FusedFunctionPerModule.proto ////////////////
1584
+ //@requires: CythonFunctionPerModule
1585
+
1586
+ #if CYTHON_OPAQUE_SHARED_TYPES
1587
+ #define __Pyx_as_FusedFunctionObject(o) ((__pyx_FusedFunctionObject *)PyObject_GetTypeData((o), CGLOBAL(__pyx_FusedFunctionType)))
1588
+ #else
1589
+ #define __Pyx_as_FusedFunctionObject(o) ((__pyx_FusedFunctionObject*)o)
1590
+ #endif
1591
+
1407
1592
 
1408
1593
  typedef struct {
1594
+ #if !(CYTHON_COMPILING_IN_LIMITED_API && CYTHON_OPAQUE_OBJECTS)
1409
1595
  __pyx_CyFunctionObject func;
1596
+ #endif
1410
1597
  PyObject *__signatures__;
1411
1598
  PyObject *self;
1412
1599
  #if CYTHON_COMPILING_IN_LIMITED_API
@@ -1414,18 +1601,48 @@ typedef struct {
1414
1601
  #endif
1415
1602
  } __pyx_FusedFunctionObject;
1416
1603
 
1604
+ // Definition depends on whether we're using shared utility code or not
1605
+ static int __pyx_FusedFunction_init(PyObject *module);
1606
+
1607
+ #define __Pyx_FusedFunction_USED
1608
+
1609
+ //////////////////// FusedFunctionFromSharedModule /////////////////////
1610
+ //@requires: FusedFunctionPerModule
1611
+ //@requires: CythonFunctionFromSharedModule
1612
+ //@requires: CommonStructures.c::VerifyCachedType
1613
+ //@requires: FusedFunction
1614
+ //@substitute: naming
1615
+
1616
+ // Cutdown version that's only used when importing from shared utility code
1617
+ static int __pyx_FusedFunction_init(PyObject *module) {
1618
+ $modulestatetype_cname *mstate = __Pyx_PyModule_GetState(module);
1619
+
1620
+ PyTypeObject *tp = __Pyx_Get_FusedFunction_Type();
1621
+ if (!tp) return -1;
1622
+
1623
+ if (__Pyx_VerifyCachedType((PyObject*)tp,
1624
+ __PYX_TYPE_MODULE_PREFIX "fused_cython_function",
1625
+ __PYX_SHARED_SIZEOF(__pyx_FusedFunctionObject)) != 0) {
1626
+ Py_DECREF((PyObject*)tp);
1627
+ return -1;
1628
+ }
1629
+
1630
+ mstate->__pyx_CyFunctionType = tp;
1631
+ return 0;
1632
+ }
1633
+
1634
+ //////////////////// FusedFunction.export ////////////////////
1635
+
1417
1636
  static PyObject *__pyx_FusedFunction_New(PyMethodDef *ml, int flags,
1418
1637
  PyObject *qualname, PyObject *closure,
1419
1638
  PyObject *module, PyObject *globals,
1420
1639
  PyObject *code);
1421
1640
 
1422
- static int __pyx_FusedFunction_clear(__pyx_FusedFunctionObject *self);
1423
- static int __pyx_FusedFunction_init(PyObject *module);
1424
-
1425
- #define __Pyx_FusedFunction_USED
1641
+ static PyTypeObject *__Pyx_Get_FusedFunction_Type(void);
1426
1642
 
1427
1643
  //////////////////// FusedFunction ////////////////////
1428
1644
  //@requires: CythonFunctionShared
1645
+ //@requires: FusedFunctionPerModule
1429
1646
  //@substitute: naming
1430
1647
 
1431
1648
  static PyObject *
@@ -1435,12 +1652,11 @@ __pyx_FusedFunction_New(PyMethodDef *ml, int flags,
1435
1652
  PyObject *code)
1436
1653
  {
1437
1654
  PyObject *op = __Pyx_CyFunction_Init(
1438
- // __pyx_CyFunctionObject is correct below since that's the cast that we want.
1439
- PyObject_GC_New(__pyx_CyFunctionObject, CGLOBAL(__pyx_FusedFunctionType)),
1655
+ PyObject_GC_New(PyObject, CGLOBAL(__pyx_FusedFunctionType)),
1440
1656
  ml, flags, qualname, closure, module, globals, code
1441
1657
  );
1442
1658
  if (likely(op)) {
1443
- __pyx_FusedFunctionObject *fusedfunc = (__pyx_FusedFunctionObject *) op;
1659
+ __pyx_FusedFunctionObject *fusedfunc = __Pyx_as_FusedFunctionObject(op);
1444
1660
  fusedfunc->__signatures__ = NULL;
1445
1661
  fusedfunc->self = NULL;
1446
1662
  #if CYTHON_COMPILING_IN_LIMITED_API
@@ -1452,88 +1668,110 @@ __pyx_FusedFunction_New(PyMethodDef *ml, int flags,
1452
1668
  }
1453
1669
 
1454
1670
  static void
1455
- __pyx_FusedFunction_dealloc(__pyx_FusedFunctionObject *self)
1671
+ __pyx_FusedFunction_dealloc(PyObject *self)
1456
1672
  {
1673
+ __pyx_FusedFunctionObject *fused = __Pyx_as_FusedFunctionObject(self);
1457
1674
  PyObject_GC_UnTrack(self);
1458
- Py_CLEAR(self->self);
1459
- Py_CLEAR(self->__signatures__);
1460
- __Pyx__CyFunction_dealloc((__pyx_CyFunctionObject *) self);
1675
+ Py_CLEAR(fused->self);
1676
+ Py_CLEAR(fused->__signatures__);
1677
+ __Pyx__CyFunction_dealloc(self);
1461
1678
  }
1462
1679
 
1463
1680
  static int
1464
- __pyx_FusedFunction_traverse(__pyx_FusedFunctionObject *self,
1681
+ __pyx_FusedFunction_traverse(PyObject *self,
1465
1682
  visitproc visit,
1466
1683
  void *arg)
1467
1684
  {
1685
+ __pyx_FusedFunctionObject *fused = __Pyx_as_FusedFunctionObject(self);
1468
1686
  // Visiting the type is handled in the CyFunction traverse if needed
1469
- Py_VISIT(self->self);
1470
- Py_VISIT(self->__signatures__);
1471
- return __Pyx_CyFunction_traverse((__pyx_CyFunctionObject *) self, visit, arg);
1687
+ Py_VISIT(fused->self);
1688
+ Py_VISIT(fused->__signatures__);
1689
+ return __Pyx_CyFunction_traverse(self, visit, arg);
1472
1690
  }
1473
1691
 
1474
1692
  static int
1475
- __pyx_FusedFunction_clear(__pyx_FusedFunctionObject *self)
1693
+ __pyx_FusedFunction_clear(PyObject *self)
1476
1694
  {
1477
- Py_CLEAR(self->self);
1478
- Py_CLEAR(self->__signatures__);
1479
- return __Pyx_CyFunction_clear((__pyx_CyFunctionObject *) self);
1695
+ __pyx_FusedFunctionObject *fused = __Pyx_as_FusedFunctionObject(self);
1696
+ Py_CLEAR(fused->self);
1697
+ Py_CLEAR(fused->__signatures__);
1698
+ return __Pyx_CyFunction_clear(self);
1480
1699
  }
1481
1700
 
1482
1701
 
1483
- static __pyx_FusedFunctionObject *
1484
- __pyx_FusedFunction_descr_get_locked(__pyx_FusedFunctionObject *func, PyObject *obj)
1702
+ static PyObject *__Pyx_FusedFunction_get_signatures(PyObject *self, void *closure)
1485
1703
  {
1704
+ CYTHON_UNUSED_VAR(closure);
1705
+ // No critical section - signatures should not be reassigned
1706
+ __pyx_FusedFunctionObject *func = __Pyx_as_FusedFunctionObject(self);
1707
+ if (func->__signatures__) {
1708
+ // A dictproxy ensures that users can't (easily) mess with the internal data used in fused dispatch.
1709
+ // For this rarely-used introspection function, it is unlikely to be worth the memory to cache the proxy.
1710
+ return PyDictProxy_New(func->__signatures__);
1711
+ } else {
1712
+ Py_RETURN_NONE;
1713
+ }
1714
+ }
1715
+
1716
+ static PyObject *
1717
+ __pyx_FusedFunction_descr_get_locked(PyObject *self, PyObject *obj)
1718
+ {
1719
+ __pyx_FusedFunctionObject *func = __Pyx_as_FusedFunctionObject(self);
1720
+ __pyx_CyFunctionObject *cyfunc = __Pyx_as_CyFunctionObject(self);
1486
1721
  PyObject *module;
1487
- __pyx_FusedFunctionObject *meth;
1722
+ PyObject *meth;
1488
1723
  #if CYTHON_COMPILING_IN_LIMITED_API
1489
- module = __Pyx_CyFunction_get_module((__pyx_CyFunctionObject *) func, NULL);
1724
+ module = __Pyx_CyFunction_get_module(self, NULL);
1490
1725
  if ((unlikely(!module))) return NULL;
1491
1726
  #else
1492
1727
  module = ((PyCFunctionObject *) func)->m_module;
1493
1728
  #endif
1494
1729
 
1495
- meth = (__pyx_FusedFunctionObject *) __pyx_FusedFunction_New(
1730
+ meth = __pyx_FusedFunction_New(
1496
1731
  #if CYTHON_COMPILING_IN_LIMITED_API
1497
1732
  func->ml,
1498
1733
  #else
1499
1734
  ((PyCFunctionObject *) func)->m_ml,
1500
1735
  #endif
1501
- ((__pyx_CyFunctionObject *) func)->flags,
1502
- ((__pyx_CyFunctionObject *) func)->func_qualname,
1503
- ((__pyx_CyFunctionObject *) func)->func_closure,
1736
+ cyfunc->flags,
1737
+ cyfunc->func_qualname,
1738
+ cyfunc->func_closure,
1504
1739
  module,
1505
- ((__pyx_CyFunctionObject *) func)->func_globals,
1506
- ((__pyx_CyFunctionObject *) func)->func_code);
1740
+ cyfunc->func_globals,
1741
+ cyfunc->func_code);
1507
1742
  #if CYTHON_COMPILING_IN_LIMITED_API
1508
1743
  Py_DECREF(module);
1509
1744
  #endif
1510
1745
  if (unlikely(!meth))
1511
1746
  return NULL;
1512
1747
 
1513
- Py_XINCREF(func->func.defaults);
1514
- meth->func.defaults = func->func.defaults;
1515
1748
 
1516
- __Pyx_CyFunction_SetClassObj(meth, __Pyx_CyFunction_GetClassObj(func));
1749
+ __pyx_CyFunctionObject *meth_as_cyfunc = __Pyx_as_CyFunctionObject(meth);
1750
+ __pyx_FusedFunctionObject *meth_as_fused = __Pyx_as_FusedFunctionObject(meth);
1751
+ Py_XINCREF(cyfunc->defaults);
1752
+ meth_as_cyfunc->defaults = cyfunc->defaults;
1753
+
1754
+ __Pyx_CyFunction_SetClassObj(meth, __Pyx__CyFunction_GetClassObj(cyfunc));
1517
1755
 
1518
1756
  Py_XINCREF(func->__signatures__);
1519
- meth->__signatures__ = func->__signatures__;
1757
+ meth_as_fused->__signatures__ = func->__signatures__;
1520
1758
 
1521
- Py_XINCREF(func->func.defaults_tuple);
1522
- meth->func.defaults_tuple = func->func.defaults_tuple;
1759
+ Py_XINCREF(cyfunc->defaults_tuple);
1760
+ meth_as_cyfunc->defaults_tuple = cyfunc->defaults_tuple;
1523
1761
 
1524
1762
  Py_XINCREF(obj);
1525
- meth->self = obj;
1763
+ meth_as_fused->self = obj;
1526
1764
  return meth;
1527
1765
  }
1528
1766
 
1529
1767
  static PyObject *
1530
1768
  __pyx_FusedFunction_descr_get(PyObject *self, PyObject *obj, PyObject *type)
1531
1769
  {
1532
- __pyx_FusedFunctionObject *func, *meth;
1533
-
1534
- func = (__pyx_FusedFunctionObject *) self;
1770
+ __pyx_FusedFunctionObject *func = __Pyx_as_FusedFunctionObject(self);
1771
+ __pyx_CyFunctionObject *cyfunc = __Pyx_as_CyFunctionObject(self);
1772
+ PyObject *meth;
1535
1773
 
1536
- if (func->self || func->func.flags & __Pyx_CYFUNCTION_STATICMETHOD) {
1774
+ if (func->self || cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD) {
1537
1775
  // Do not allow rebinding and don't do anything for static methods
1538
1776
  Py_INCREF(self);
1539
1777
  return self;
@@ -1542,7 +1780,7 @@ __pyx_FusedFunction_descr_get(PyObject *self, PyObject *obj, PyObject *type)
1542
1780
  if (obj == Py_None)
1543
1781
  obj = NULL;
1544
1782
 
1545
- if (func->func.flags & __Pyx_CYFUNCTION_CLASSMETHOD)
1783
+ if (cyfunc->flags & __Pyx_CYFUNCTION_CLASSMETHOD)
1546
1784
  obj = type;
1547
1785
 
1548
1786
  if (obj == NULL) {
@@ -1551,15 +1789,15 @@ __pyx_FusedFunction_descr_get(PyObject *self, PyObject *obj, PyObject *type)
1551
1789
  return self;
1552
1790
  }
1553
1791
 
1554
- __Pyx_BEGIN_CRITICAL_SECTION(func);
1555
- meth = __pyx_FusedFunction_descr_get_locked(func, obj);
1792
+ __Pyx_BEGIN_CRITICAL_SECTION(self);
1793
+ meth = __pyx_FusedFunction_descr_get_locked(self, obj);
1556
1794
  __Pyx_END_CRITICAL_SECTION()
1557
1795
 
1558
- return (PyObject *) meth;
1796
+ return meth;
1559
1797
  }
1560
1798
 
1561
1799
  static PyObject *
1562
- _obj_to_string(PyObject *obj)
1800
+ __pyx_FusedFunction_obj_to_string(PyObject *obj)
1563
1801
  {
1564
1802
  if (PyUnicode_CheckExact(obj))
1565
1803
  return __Pyx_NewRef(obj);
@@ -1570,13 +1808,14 @@ _obj_to_string(PyObject *obj)
1570
1808
  }
1571
1809
 
1572
1810
  static PyObject *
1573
- __pyx_FusedFunction_getitem(__pyx_FusedFunctionObject *self, PyObject *idx)
1811
+ __pyx_FusedFunction_getitem(PyObject *self, PyObject *idx)
1574
1812
  {
1575
1813
  PyObject *signature = NULL;
1576
1814
  PyObject *unbound_result_func;
1577
1815
  PyObject *result_func = NULL;
1816
+ __pyx_FusedFunctionObject *fusedfunc = __Pyx_as_FusedFunctionObject(self);
1578
1817
 
1579
- if (unlikely(self->__signatures__ == NULL)) {
1818
+ if (unlikely(fusedfunc->__signatures__ == NULL)) {
1580
1819
  PyErr_SetString(PyExc_TypeError, "Function is not fused");
1581
1820
  return NULL;
1582
1821
  }
@@ -1600,7 +1839,7 @@ __pyx_FusedFunction_getitem(__pyx_FusedFunctionObject *self, PyObject *idx)
1600
1839
  #else
1601
1840
  PyObject *item = __Pyx_PySequence_ITEM(idx, i); if (unlikely(!item)) goto __pyx_err;
1602
1841
  #endif
1603
- string = _obj_to_string(item);
1842
+ string = __pyx_FusedFunction_obj_to_string(item);
1604
1843
  #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
1605
1844
  Py_DECREF(item);
1606
1845
  #endif
@@ -1612,20 +1851,20 @@ __pyx_FusedFunction_getitem(__pyx_FusedFunctionObject *self, PyObject *idx)
1612
1851
  __pyx_err:;
1613
1852
  Py_DECREF(list);
1614
1853
  } else {
1615
- signature = _obj_to_string(idx);
1854
+ signature = __pyx_FusedFunction_obj_to_string(idx);
1616
1855
  }
1617
1856
 
1618
1857
  if (unlikely(!signature))
1619
1858
  return NULL;
1620
1859
 
1621
- unbound_result_func = PyObject_GetItem(self->__signatures__, signature);
1860
+ unbound_result_func = PyObject_GetItem(fusedfunc->__signatures__, signature);
1622
1861
 
1623
1862
  if (likely(unbound_result_func)) {
1624
- if (self->self) {
1863
+ if (fusedfunc->self) {
1625
1864
  assert(__Pyx_CyFunction_GetClassObj(unbound_result_func) == __Pyx_CyFunction_GetClassObj(self));
1626
1865
 
1627
1866
  result_func = __pyx_FusedFunction_descr_get(unbound_result_func,
1628
- self->self, self->self);
1867
+ fusedfunc->self, fusedfunc->self);
1629
1868
  } else {
1630
1869
  result_func = unbound_result_func;
1631
1870
  Py_INCREF(result_func);
@@ -1641,9 +1880,11 @@ __pyx_err:;
1641
1880
  static PyObject *
1642
1881
  __pyx_FusedFunction_callfunction(PyObject *func, PyObject *args, PyObject *kw)
1643
1882
  {
1644
- __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func;
1883
+ __pyx_FusedFunctionObject *fusedfunc = __Pyx_as_FusedFunctionObject(func);
1884
+ __pyx_CyFunctionObject *cyfunc = __Pyx_as_CyFunctionObject(func);
1885
+
1645
1886
  int static_specialized = (cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD &&
1646
- !((__pyx_FusedFunctionObject *) func)->__signatures__);
1887
+ !fusedfunc->__signatures__);
1647
1888
 
1648
1889
  if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !static_specialized) {
1649
1890
  return __Pyx_CyFunction_CallAsMethod(func, args, kw);
@@ -1653,20 +1894,22 @@ __pyx_FusedFunction_callfunction(PyObject *func, PyObject *args, PyObject *kw)
1653
1894
  }
1654
1895
 
1655
1896
  // Note: the 'self' from method binding is passed in in the args tuple,
1656
- // whereas PyCFunctionObject's m_self is passed in as the first
1657
- // argument to the C function. For extension methods we need
1658
- // to pass 'self' as 'm_self' and not as the first element of the
1897
+ // whereas the FusedFunction object is passed in as the first
1898
+ // argument to the C function. For extension methods we
1899
+ // don't want to pass 'self' as the first element of the
1659
1900
  // args tuple.
1660
1901
 
1661
1902
  static PyObject *
1662
1903
  __pyx_FusedFunction_call(PyObject *func, PyObject *args, PyObject *kw)
1663
1904
  {
1664
- __pyx_FusedFunctionObject *binding_func = (__pyx_FusedFunctionObject *) func;
1905
+ __pyx_FusedFunctionObject *binding_func = __Pyx_as_FusedFunctionObject(func);
1906
+ __pyx_CyFunctionObject *cyfunc = __Pyx_as_CyFunctionObject(func);
1907
+
1665
1908
  Py_ssize_t argc = __Pyx_PyTuple_GET_SIZE(args);
1666
1909
  PyObject *new_args = NULL;
1667
- __pyx_FusedFunctionObject *new_func = NULL;
1910
+ PyObject *new_func = NULL;
1668
1911
  PyObject *result = NULL;
1669
- int is_staticmethod = binding_func->func.flags & __Pyx_CYFUNCTION_STATICMETHOD;
1912
+ int is_staticmethod = cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD;
1670
1913
  #if !CYTHON_ASSUME_SAFE_SIZE
1671
1914
  if (unlikely(argc < 0)) return NULL;
1672
1915
  #endif
@@ -1700,45 +1943,40 @@ __pyx_FusedFunction_call(PyObject *func, PyObject *args, PyObject *kw)
1700
1943
 
1701
1944
  if (binding_func->__signatures__) {
1702
1945
  PyObject *tup;
1703
- if (is_staticmethod && binding_func->func.flags & __Pyx_CYFUNCTION_CCLASS) {
1946
+ if (is_staticmethod && cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) {
1704
1947
  // FIXME: this seems wrong, but we must currently pass the signatures dict as 'self' argument
1705
1948
  tup = PyTuple_Pack(3, args,
1706
1949
  kw == NULL ? Py_None : kw,
1707
- binding_func->func.defaults_tuple);
1950
+ cyfunc->defaults_tuple);
1708
1951
  if (unlikely(!tup)) goto bad;
1709
- new_func = (__pyx_FusedFunctionObject *) __Pyx_CyFunction_CallMethod(
1952
+ new_func = __Pyx_CyFunction_CallMethod(
1710
1953
  func, binding_func->__signatures__, tup, NULL);
1711
1954
  } else {
1712
1955
  tup = PyTuple_Pack(4, binding_func->__signatures__, args,
1713
1956
  kw == NULL ? Py_None : kw,
1714
- binding_func->func.defaults_tuple);
1957
+ cyfunc->defaults_tuple);
1715
1958
  if (unlikely(!tup)) goto bad;
1716
- new_func = (__pyx_FusedFunctionObject *) __pyx_FusedFunction_callfunction(func, tup, NULL);
1959
+ new_func = __pyx_FusedFunction_callfunction(func, tup, NULL);
1717
1960
  }
1718
1961
  Py_DECREF(tup);
1719
1962
 
1720
1963
  if (unlikely(!new_func))
1721
1964
  goto bad;
1722
1965
 
1723
- assert(__Pyx_CyFunction_GetClassObj(new_func) == __Pyx_CyFunction_GetClassObj(binding_func));
1966
+ assert(__Pyx_CyFunction_GetClassObj(new_func) == __Pyx_CyFunction_GetClassObj(func));
1724
1967
 
1725
- func = (PyObject *) new_func;
1968
+ func = new_func;
1726
1969
  }
1727
1970
 
1728
1971
  result = __pyx_FusedFunction_callfunction(func, args, kw);
1729
1972
  bad:
1730
1973
  Py_XDECREF(new_args);
1731
- Py_XDECREF((PyObject *) new_func);
1974
+ Py_XDECREF(new_func);
1732
1975
  return result;
1733
1976
  }
1734
1977
 
1735
1978
  static PyMemberDef __pyx_FusedFunction_members[] = {
1736
- {"__signatures__",
1737
- T_OBJECT,
1738
- offsetof(__pyx_FusedFunctionObject, __signatures__),
1739
- READONLY,
1740
- 0},
1741
- {"__self__", T_OBJECT_EX, offsetof(__pyx_FusedFunctionObject, self), READONLY, 0},
1979
+ {"__self__", T_OBJECT_EX, offsetof(__pyx_FusedFunctionObject, self), __PYX_SHARED_RELATIVE_OFFSET | READONLY, 0},
1742
1980
  // For heap-types __module__ appears not to be inherited (so redeclare)
1743
1981
  #if !CYTHON_COMPILING_IN_LIMITED_API
1744
1982
  {"__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), 0, 0},
@@ -1755,6 +1993,7 @@ static PyGetSetDef __pyx_FusedFunction_getsets[] = {
1755
1993
  #if CYTHON_COMPILING_IN_LIMITED_API
1756
1994
  {"__module__", (getter)__Pyx_CyFunction_get_module, (setter)__Pyx_CyFunction_set_module, 0, 0},
1757
1995
  #endif
1996
+ {"__signatures__", (getter)__Pyx_FusedFunction_get_signatures, NULL, 0, 0},
1758
1997
  {0, 0, 0, 0, 0}
1759
1998
  };
1760
1999
 
@@ -1772,7 +2011,7 @@ static PyType_Slot __pyx_FusedFunctionType_slots[] = {
1772
2011
 
1773
2012
  static PyType_Spec __pyx_FusedFunctionType_spec = {
1774
2013
  __PYX_TYPE_MODULE_PREFIX "fused_cython_function",
1775
- sizeof(__pyx_FusedFunctionObject),
2014
+ __PYX_SHARED_SIZEOF(__pyx_FusedFunctionObject),
1776
2015
  0,
1777
2016
  Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_DISALLOW_INSTANTIATION |
1778
2017
  Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC , /*tp_flags*/
@@ -1780,6 +2019,9 @@ static PyType_Spec __pyx_FusedFunctionType_spec = {
1780
2019
  };
1781
2020
 
1782
2021
  static int __pyx_FusedFunction_init(PyObject *module) {
2022
+ // Silence unused warning when not in shared module.
2023
+ (void)__Pyx_Get_FusedFunction_Type;
2024
+
1783
2025
  $modulestatetype_cname *mstate = __Pyx_PyModule_GetState(module);
1784
2026
  PyObject *bases = PyTuple_Pack(1, mstate->__pyx_CyFunctionType);
1785
2027
  if (unlikely(!bases)) {
@@ -1794,6 +2036,41 @@ static int __pyx_FusedFunction_init(PyObject *module) {
1794
2036
  return 0;
1795
2037
  }
1796
2038
 
2039
+ static PyTypeObject *__Pyx_Get_FusedFunction_Type(void) {
2040
+ PyTypeObject *tp = CGLOBAL(__pyx_FusedFunctionType);
2041
+ Py_INCREF((PyObject*)tp);
2042
+ return tp;
2043
+ }
2044
+
2045
+
2046
+ //////////////////// FusedFunctionArgTypeError.proto ////////////////////
2047
+
2048
+ #define __Pyx_RaiseFusedFunctionArgTypeError(arg_name, arg_tuple_idx, min_positional_args, arg_count) \
2049
+ (__Pyx__RaiseFusedFunctionArgTypeError(arg_name, arg_tuple_idx, min_positional_args, arg_count), -1)
2050
+
2051
+ static void __Pyx__RaiseFusedFunctionArgTypeError(PyObject *arg_name, Py_ssize_t arg_tuple_idx, Py_ssize_t min_positional_args, Py_ssize_t arg_count); /*proto*/
2052
+
2053
+ //////////////////// FusedFunctionArgTypeError ////////////////////
2054
+
2055
+ static void __Pyx__RaiseFusedFunctionArgTypeError(PyObject *arg_name, Py_ssize_t arg_tuple_idx, Py_ssize_t min_positional_args, Py_ssize_t arg_count) {
2056
+ if (arg_tuple_idx < min_positional_args) {
2057
+ PyErr_Format(
2058
+ PyExc_TypeError,
2059
+ "Expected at least %zd argument%.1s, got %zd",
2060
+ min_positional_args,
2061
+ (min_positional_args != 1) ? "s" : "",
2062
+ arg_count
2063
+ );
2064
+ } else {
2065
+ PyErr_Format(
2066
+ PyExc_TypeError,
2067
+ "Missing keyword-only argument: '%U'",
2068
+ arg_name
2069
+ );
2070
+ }
2071
+ }
2072
+
2073
+
1797
2074
  //////////////////// ClassMethod.proto ////////////////////
1798
2075
 
1799
2076
  #if !CYTHON_COMPILING_IN_LIMITED_API