Cython 3.1.0a1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- Cython/Build/BuildExecutable.py +169 -0
- Cython/Build/Cache.py +199 -0
- Cython/Build/Cythonize.py +250 -0
- Cython/Build/Dependencies.py +1275 -0
- Cython/Build/Distutils.py +1 -0
- Cython/Build/Inline.py +342 -0
- Cython/Build/IpythonMagic.py +560 -0
- Cython/Build/Tests/TestCyCache.py +119 -0
- Cython/Build/Tests/TestCythonizeArgsParser.py +481 -0
- Cython/Build/Tests/TestDependencies.py +133 -0
- Cython/Build/Tests/TestInline.py +112 -0
- Cython/Build/Tests/TestIpythonMagic.py +287 -0
- Cython/Build/Tests/TestRecythonize.py +212 -0
- Cython/Build/Tests/TestStripLiterals.py +155 -0
- Cython/Build/Tests/__init__.py +1 -0
- Cython/Build/__init__.py +8 -0
- Cython/CodeWriter.py +811 -0
- Cython/Compiler/AnalysedTreeTransforms.py +97 -0
- Cython/Compiler/Annotate.py +326 -0
- Cython/Compiler/AutoDocTransforms.py +314 -0
- Cython/Compiler/Buffer.py +680 -0
- Cython/Compiler/Builtin.py +862 -0
- Cython/Compiler/CmdLine.py +243 -0
- Cython/Compiler/Code.pxd +145 -0
- Cython/Compiler/Code.py +3328 -0
- Cython/Compiler/CodeGeneration.py +33 -0
- Cython/Compiler/CythonScope.py +179 -0
- Cython/Compiler/Dataclass.py +868 -0
- Cython/Compiler/DebugFlags.py +21 -0
- Cython/Compiler/Errors.py +295 -0
- Cython/Compiler/ExprNodes.py +15051 -0
- Cython/Compiler/FlowControl.pxd +97 -0
- Cython/Compiler/FlowControl.py +1438 -0
- Cython/Compiler/FusedNode.py +998 -0
- Cython/Compiler/Future.py +16 -0
- Cython/Compiler/Interpreter.py +57 -0
- Cython/Compiler/Lexicon.py +340 -0
- Cython/Compiler/LineTable.py +114 -0
- Cython/Compiler/Main.py +779 -0
- Cython/Compiler/MatchCaseNodes.py +259 -0
- Cython/Compiler/MemoryView.py +860 -0
- Cython/Compiler/ModuleNode.py +4065 -0
- Cython/Compiler/Naming.py +369 -0
- Cython/Compiler/Nodes.py +10557 -0
- Cython/Compiler/Optimize.py +5269 -0
- Cython/Compiler/Options.py +828 -0
- Cython/Compiler/ParseTreeTransforms.pxd +78 -0
- Cython/Compiler/ParseTreeTransforms.py +4441 -0
- Cython/Compiler/Parsing.pxd +9 -0
- Cython/Compiler/Parsing.py +4797 -0
- Cython/Compiler/Pipeline.py +425 -0
- Cython/Compiler/PyrexTypes.py +5572 -0
- Cython/Compiler/Pythran.py +223 -0
- Cython/Compiler/Scanning.pxd +40 -0
- Cython/Compiler/Scanning.py +574 -0
- Cython/Compiler/StringEncoding.py +347 -0
- Cython/Compiler/Symtab.py +2998 -0
- Cython/Compiler/Tests/TestBuffer.py +105 -0
- Cython/Compiler/Tests/TestBuiltin.py +72 -0
- Cython/Compiler/Tests/TestCmdLine.py +573 -0
- Cython/Compiler/Tests/TestCode.py +86 -0
- Cython/Compiler/Tests/TestFlowControl.py +65 -0
- Cython/Compiler/Tests/TestGrammar.py +202 -0
- Cython/Compiler/Tests/TestMemView.py +71 -0
- Cython/Compiler/Tests/TestParseTreeTransforms.py +285 -0
- Cython/Compiler/Tests/TestScanning.py +134 -0
- Cython/Compiler/Tests/TestSignatureMatching.py +73 -0
- Cython/Compiler/Tests/TestStringEncoding.py +33 -0
- Cython/Compiler/Tests/TestTreeFragment.py +63 -0
- Cython/Compiler/Tests/TestTreePath.py +93 -0
- Cython/Compiler/Tests/TestTypes.py +75 -0
- Cython/Compiler/Tests/TestUtilityLoad.py +112 -0
- Cython/Compiler/Tests/TestVisitor.py +61 -0
- Cython/Compiler/Tests/Utils.py +36 -0
- Cython/Compiler/Tests/__init__.py +1 -0
- Cython/Compiler/TreeFragment.py +278 -0
- Cython/Compiler/TreePath.py +290 -0
- Cython/Compiler/TypeInference.py +584 -0
- Cython/Compiler/TypeSlots.py +1181 -0
- Cython/Compiler/UFuncs.py +311 -0
- Cython/Compiler/UtilNodes.py +387 -0
- Cython/Compiler/UtilityCode.py +274 -0
- Cython/Compiler/Version.py +8 -0
- Cython/Compiler/Visitor.pxd +53 -0
- Cython/Compiler/Visitor.py +861 -0
- Cython/Compiler/__init__.py +1 -0
- Cython/Coverage.py +443 -0
- Cython/Debugger/Cygdb.py +179 -0
- Cython/Debugger/DebugWriter.py +82 -0
- Cython/Debugger/Tests/TestLibCython.py +275 -0
- Cython/Debugger/Tests/__init__.py +1 -0
- Cython/Debugger/Tests/cfuncs.c +8 -0
- Cython/Debugger/Tests/codefile +49 -0
- Cython/Debugger/Tests/test_libcython_in_gdb.py +578 -0
- Cython/Debugger/Tests/test_libpython_in_gdb.py +90 -0
- Cython/Debugger/__init__.py +1 -0
- Cython/Debugger/libcython.py +1549 -0
- Cython/Debugger/libpython.py +2821 -0
- Cython/Debugging.py +20 -0
- Cython/Distutils/__init__.py +2 -0
- Cython/Distutils/build_ext.py +137 -0
- Cython/Distutils/extension.py +96 -0
- Cython/Distutils/old_build_ext.py +351 -0
- Cython/Includes/cpython/__init__.pxd +173 -0
- Cython/Includes/cpython/array.pxd +174 -0
- Cython/Includes/cpython/bool.pxd +37 -0
- Cython/Includes/cpython/buffer.pxd +112 -0
- Cython/Includes/cpython/bytearray.pxd +33 -0
- Cython/Includes/cpython/bytes.pxd +200 -0
- Cython/Includes/cpython/cellobject.pxd +35 -0
- Cython/Includes/cpython/ceval.pxd +8 -0
- Cython/Includes/cpython/codecs.pxd +121 -0
- Cython/Includes/cpython/complex.pxd +55 -0
- Cython/Includes/cpython/contextvars.pxd +141 -0
- Cython/Includes/cpython/conversion.pxd +36 -0
- Cython/Includes/cpython/datetime.pxd +384 -0
- Cython/Includes/cpython/descr.pxd +26 -0
- Cython/Includes/cpython/dict.pxd +187 -0
- Cython/Includes/cpython/exc.pxd +263 -0
- Cython/Includes/cpython/fileobject.pxd +57 -0
- Cython/Includes/cpython/float.pxd +47 -0
- Cython/Includes/cpython/function.pxd +65 -0
- Cython/Includes/cpython/genobject.pxd +25 -0
- Cython/Includes/cpython/getargs.pxd +12 -0
- Cython/Includes/cpython/instance.pxd +25 -0
- Cython/Includes/cpython/iterator.pxd +36 -0
- Cython/Includes/cpython/iterobject.pxd +24 -0
- Cython/Includes/cpython/list.pxd +92 -0
- Cython/Includes/cpython/long.pxd +149 -0
- Cython/Includes/cpython/longintrepr.pxd +19 -0
- Cython/Includes/cpython/mapping.pxd +63 -0
- Cython/Includes/cpython/marshal.pxd +66 -0
- Cython/Includes/cpython/mem.pxd +120 -0
- Cython/Includes/cpython/memoryview.pxd +50 -0
- Cython/Includes/cpython/method.pxd +49 -0
- Cython/Includes/cpython/module.pxd +208 -0
- Cython/Includes/cpython/number.pxd +258 -0
- Cython/Includes/cpython/object.pxd +433 -0
- Cython/Includes/cpython/pycapsule.pxd +143 -0
- Cython/Includes/cpython/pylifecycle.pxd +68 -0
- Cython/Includes/cpython/pyport.pxd +8 -0
- Cython/Includes/cpython/pystate.pxd +95 -0
- Cython/Includes/cpython/pythread.pxd +53 -0
- Cython/Includes/cpython/ref.pxd +67 -0
- Cython/Includes/cpython/sequence.pxd +134 -0
- Cython/Includes/cpython/set.pxd +119 -0
- Cython/Includes/cpython/slice.pxd +70 -0
- Cython/Includes/cpython/time.pxd +129 -0
- Cython/Includes/cpython/tuple.pxd +72 -0
- Cython/Includes/cpython/type.pxd +53 -0
- Cython/Includes/cpython/unicode.pxd +639 -0
- Cython/Includes/cpython/version.pxd +32 -0
- Cython/Includes/cpython/weakref.pxd +42 -0
- Cython/Includes/libc/__init__.pxd +1 -0
- Cython/Includes/libc/complex.pxd +35 -0
- Cython/Includes/libc/errno.pxd +127 -0
- Cython/Includes/libc/float.pxd +43 -0
- Cython/Includes/libc/limits.pxd +28 -0
- Cython/Includes/libc/locale.pxd +46 -0
- Cython/Includes/libc/math.pxd +209 -0
- Cython/Includes/libc/setjmp.pxd +10 -0
- Cython/Includes/libc/signal.pxd +64 -0
- Cython/Includes/libc/stddef.pxd +9 -0
- Cython/Includes/libc/stdint.pxd +105 -0
- Cython/Includes/libc/stdio.pxd +80 -0
- Cython/Includes/libc/stdlib.pxd +72 -0
- Cython/Includes/libc/string.pxd +50 -0
- Cython/Includes/libc/time.pxd +47 -0
- Cython/Includes/libcpp/__init__.pxd +4 -0
- Cython/Includes/libcpp/algorithm.pxd +320 -0
- Cython/Includes/libcpp/any.pxd +16 -0
- Cython/Includes/libcpp/atomic.pxd +59 -0
- Cython/Includes/libcpp/bit.pxd +29 -0
- Cython/Includes/libcpp/cast.pxd +12 -0
- Cython/Includes/libcpp/cmath.pxd +518 -0
- Cython/Includes/libcpp/complex.pxd +106 -0
- Cython/Includes/libcpp/deque.pxd +165 -0
- Cython/Includes/libcpp/execution.pxd +15 -0
- Cython/Includes/libcpp/forward_list.pxd +63 -0
- Cython/Includes/libcpp/functional.pxd +26 -0
- Cython/Includes/libcpp/iterator.pxd +34 -0
- Cython/Includes/libcpp/limits.pxd +61 -0
- Cython/Includes/libcpp/list.pxd +117 -0
- Cython/Includes/libcpp/map.pxd +252 -0
- Cython/Includes/libcpp/memory.pxd +115 -0
- Cython/Includes/libcpp/numbers.pxd +15 -0
- Cython/Includes/libcpp/numeric.pxd +131 -0
- Cython/Includes/libcpp/optional.pxd +34 -0
- Cython/Includes/libcpp/pair.pxd +1 -0
- Cython/Includes/libcpp/queue.pxd +25 -0
- Cython/Includes/libcpp/random.pxd +166 -0
- Cython/Includes/libcpp/set.pxd +228 -0
- Cython/Includes/libcpp/stack.pxd +11 -0
- Cython/Includes/libcpp/string.pxd +333 -0
- Cython/Includes/libcpp/typeindex.pxd +15 -0
- Cython/Includes/libcpp/typeinfo.pxd +10 -0
- Cython/Includes/libcpp/unordered_map.pxd +193 -0
- Cython/Includes/libcpp/unordered_set.pxd +152 -0
- Cython/Includes/libcpp/utility.pxd +30 -0
- Cython/Includes/libcpp/vector.pxd +167 -0
- Cython/Includes/openmp.pxd +50 -0
- Cython/Includes/posix/__init__.pxd +1 -0
- Cython/Includes/posix/dlfcn.pxd +14 -0
- Cython/Includes/posix/fcntl.pxd +86 -0
- Cython/Includes/posix/ioctl.pxd +4 -0
- Cython/Includes/posix/mman.pxd +101 -0
- Cython/Includes/posix/resource.pxd +57 -0
- Cython/Includes/posix/select.pxd +21 -0
- Cython/Includes/posix/signal.pxd +73 -0
- Cython/Includes/posix/stat.pxd +98 -0
- Cython/Includes/posix/stdio.pxd +37 -0
- Cython/Includes/posix/stdlib.pxd +29 -0
- Cython/Includes/posix/strings.pxd +9 -0
- Cython/Includes/posix/time.pxd +71 -0
- Cython/Includes/posix/types.pxd +30 -0
- Cython/Includes/posix/uio.pxd +26 -0
- Cython/Includes/posix/unistd.pxd +271 -0
- Cython/Includes/posix/wait.pxd +38 -0
- Cython/Plex/Actions.pxd +24 -0
- Cython/Plex/Actions.py +119 -0
- Cython/Plex/DFA.pxd +14 -0
- Cython/Plex/DFA.py +164 -0
- Cython/Plex/Errors.py +48 -0
- Cython/Plex/Lexicons.py +178 -0
- Cython/Plex/Machines.pxd +36 -0
- Cython/Plex/Machines.py +238 -0
- Cython/Plex/Regexps.py +539 -0
- Cython/Plex/Scanners.pxd +47 -0
- Cython/Plex/Scanners.py +360 -0
- Cython/Plex/Transitions.pxd +14 -0
- Cython/Plex/Transitions.py +239 -0
- Cython/Plex/__init__.py +34 -0
- Cython/Runtime/__init__.py +1 -0
- Cython/Runtime/refnanny.pyx +261 -0
- Cython/Shadow.py +656 -0
- Cython/Shadow.pyi +521 -0
- Cython/StringIOTree.py +170 -0
- Cython/Tempita/__init__.py +4 -0
- Cython/Tempita/_looper.py +154 -0
- Cython/Tempita/_tempita.py +1091 -0
- Cython/TestUtils.py +417 -0
- Cython/Tests/TestCodeWriter.py +128 -0
- Cython/Tests/TestCythonUtils.py +202 -0
- Cython/Tests/TestJediTyper.py +223 -0
- Cython/Tests/TestShadow.py +114 -0
- Cython/Tests/TestStringIOTree.py +67 -0
- Cython/Tests/TestTestUtils.py +90 -0
- Cython/Tests/__init__.py +1 -0
- Cython/Tests/xmlrunner.py +390 -0
- Cython/Utility/AsyncGen.c +1263 -0
- Cython/Utility/Buffer.c +875 -0
- Cython/Utility/Builtins.c +660 -0
- Cython/Utility/CConvert.pyx +134 -0
- Cython/Utility/CMath.c +95 -0
- Cython/Utility/CommonStructures.c +139 -0
- Cython/Utility/Complex.c +378 -0
- Cython/Utility/Coroutine.c +2413 -0
- Cython/Utility/CpdefEnums.pyx +108 -0
- Cython/Utility/CppConvert.pyx +279 -0
- Cython/Utility/CppSupport.cpp +133 -0
- Cython/Utility/CythonFunction.c +1851 -0
- Cython/Utility/Dataclasses.c +185 -0
- Cython/Utility/Dataclasses.py +112 -0
- Cython/Utility/Embed.c +125 -0
- Cython/Utility/Exceptions.c +1017 -0
- Cython/Utility/ExtensionTypes.c +797 -0
- Cython/Utility/FunctionArguments.c +573 -0
- Cython/Utility/ImportExport.c +912 -0
- Cython/Utility/MemoryView.pyx +1478 -0
- Cython/Utility/MemoryView_C.c +992 -0
- Cython/Utility/ModuleSetupCode.c +2501 -0
- Cython/Utility/NumpyImportArray.c +46 -0
- Cython/Utility/ObjectHandling.c +3054 -0
- Cython/Utility/Optimize.c +1533 -0
- Cython/Utility/Overflow.c +404 -0
- Cython/Utility/Printing.c +86 -0
- Cython/Utility/Profile.c +660 -0
- Cython/Utility/StringTools.c +1206 -0
- Cython/Utility/TestCyUtilityLoader.pyx +8 -0
- Cython/Utility/TestCythonScope.pyx +75 -0
- Cython/Utility/TestUtilityLoader.c +12 -0
- Cython/Utility/TypeConversion.c +1329 -0
- Cython/Utility/UFuncs.pyx +50 -0
- Cython/Utility/UFuncs_C.c +89 -0
- Cython/Utility/__init__.py +28 -0
- Cython/Utility/arrayarray.h +143 -0
- Cython/Utils.py +687 -0
- Cython/__init__.py +10 -0
- Cython/__init__.pyi +7 -0
- Cython/py.typed +0 -0
- Cython-3.1.0a1.dist-info/COPYING.txt +19 -0
- Cython-3.1.0a1.dist-info/LICENSE.txt +176 -0
- Cython-3.1.0a1.dist-info/METADATA +67 -0
- Cython-3.1.0a1.dist-info/RECORD +301 -0
- Cython-3.1.0a1.dist-info/WHEEL +5 -0
- Cython-3.1.0a1.dist-info/entry_points.txt +4 -0
- Cython-3.1.0a1.dist-info/top_level.txt +3 -0
- cython.py +29 -0
- pyximport/__init__.py +4 -0
- pyximport/pyxbuild.py +160 -0
- pyximport/pyximport.py +482 -0
|
@@ -0,0 +1,573 @@
|
|
|
1
|
+
//////////////////// ArgTypeTest.proto ////////////////////
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
// Exact is 0 (False), 1 (True) or 2 (True and from annotation)
|
|
5
|
+
// The latter gives a small amount of extra error diagnostics
|
|
6
|
+
#define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact) \
|
|
7
|
+
((likely(__Pyx_IS_TYPE(obj, type) | (none_allowed && (obj == Py_None)))) ? 1 : \
|
|
8
|
+
__Pyx__ArgTypeTest(obj, type, name, exact))
|
|
9
|
+
|
|
10
|
+
static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact); /*proto*/
|
|
11
|
+
|
|
12
|
+
//////////////////// ArgTypeTest ////////////////////
|
|
13
|
+
|
|
14
|
+
static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact)
|
|
15
|
+
{
|
|
16
|
+
__Pyx_TypeName type_name;
|
|
17
|
+
__Pyx_TypeName obj_type_name;
|
|
18
|
+
PyObject *extra_info = EMPTY(unicode);
|
|
19
|
+
int from_annotation_subclass = 0;
|
|
20
|
+
if (unlikely(!type)) {
|
|
21
|
+
PyErr_SetString(PyExc_SystemError, "Missing type object");
|
|
22
|
+
return 0;
|
|
23
|
+
}
|
|
24
|
+
else if (!exact) {
|
|
25
|
+
if (likely(__Pyx_TypeCheck(obj, type))) return 1;
|
|
26
|
+
} else if (exact == 2) {
|
|
27
|
+
// type from annotation
|
|
28
|
+
if (__Pyx_TypeCheck(obj, type)) {
|
|
29
|
+
from_annotation_subclass = 1;
|
|
30
|
+
extra_info = PYUNICODE("Note that Cython is deliberately stricter than PEP-484 and rejects subclasses of builtin types. If you need to pass subclasses then set the 'annotation_typing' directive to False.");
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
type_name = __Pyx_PyType_GetName(type);
|
|
34
|
+
obj_type_name = __Pyx_PyType_GetName(Py_TYPE(obj));
|
|
35
|
+
PyErr_Format(PyExc_TypeError,
|
|
36
|
+
"Argument '%.200s' has incorrect type (expected " __Pyx_FMT_TYPENAME
|
|
37
|
+
", got " __Pyx_FMT_TYPENAME ")"
|
|
38
|
+
#if __PYX_LIMITED_VERSION_HEX < 0x030C0000
|
|
39
|
+
"%s%U"
|
|
40
|
+
#endif
|
|
41
|
+
, name, type_name, obj_type_name
|
|
42
|
+
#if __PYX_LIMITED_VERSION_HEX < 0x030C0000
|
|
43
|
+
, (from_annotation_subclass ? ". " : ""), extra_info
|
|
44
|
+
#endif
|
|
45
|
+
);
|
|
46
|
+
#if __PYX_LIMITED_VERSION_HEX >= 0x030C0000
|
|
47
|
+
// Set the extra_info as a note instead. In principle it'd be possible to do this
|
|
48
|
+
// from Python 3.11 up, but PyErr_GetRaisedException makes it much easier so do it
|
|
49
|
+
// from Python 3.12 instead.
|
|
50
|
+
if (exact == 2 && from_annotation_subclass) {
|
|
51
|
+
PyObject *res;
|
|
52
|
+
PyObject *vargs[2];
|
|
53
|
+
vargs[0] = PyErr_GetRaisedException();
|
|
54
|
+
vargs[1] = extra_info;
|
|
55
|
+
res = PyObject_VectorcallMethod(PYUNICODE("add_note"), vargs, 2, NULL);
|
|
56
|
+
Py_XDECREF(res);
|
|
57
|
+
PyErr_SetRaisedException(vargs[0]);
|
|
58
|
+
}
|
|
59
|
+
#endif
|
|
60
|
+
__Pyx_DECREF_TypeName(type_name);
|
|
61
|
+
__Pyx_DECREF_TypeName(obj_type_name);
|
|
62
|
+
return 0;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
//////////////////// RaiseArgTupleInvalid.proto ////////////////////
|
|
66
|
+
|
|
67
|
+
static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
|
|
68
|
+
Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/
|
|
69
|
+
|
|
70
|
+
//////////////////// RaiseArgTupleInvalid ////////////////////
|
|
71
|
+
|
|
72
|
+
// __Pyx_RaiseArgtupleInvalid raises the correct exception when too
|
|
73
|
+
// many or too few positional arguments were found. This handles
|
|
74
|
+
// Py_ssize_t formatting correctly.
|
|
75
|
+
|
|
76
|
+
static void __Pyx_RaiseArgtupleInvalid(
|
|
77
|
+
const char* func_name,
|
|
78
|
+
int exact,
|
|
79
|
+
Py_ssize_t num_min,
|
|
80
|
+
Py_ssize_t num_max,
|
|
81
|
+
Py_ssize_t num_found)
|
|
82
|
+
{
|
|
83
|
+
Py_ssize_t num_expected;
|
|
84
|
+
const char *more_or_less;
|
|
85
|
+
|
|
86
|
+
if (num_found < num_min) {
|
|
87
|
+
num_expected = num_min;
|
|
88
|
+
more_or_less = "at least";
|
|
89
|
+
} else {
|
|
90
|
+
num_expected = num_max;
|
|
91
|
+
more_or_less = "at most";
|
|
92
|
+
}
|
|
93
|
+
if (exact) {
|
|
94
|
+
more_or_less = "exactly";
|
|
95
|
+
}
|
|
96
|
+
PyErr_Format(PyExc_TypeError,
|
|
97
|
+
"%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
|
|
98
|
+
func_name, more_or_less, num_expected,
|
|
99
|
+
(num_expected == 1) ? "" : "s", num_found);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
//////////////////// RaiseKeywordRequired.proto ////////////////////
|
|
104
|
+
|
|
105
|
+
static void __Pyx_RaiseKeywordRequired(const char* func_name, PyObject* kw_name); /*proto*/
|
|
106
|
+
|
|
107
|
+
//////////////////// RaiseKeywordRequired ////////////////////
|
|
108
|
+
|
|
109
|
+
static void __Pyx_RaiseKeywordRequired(const char* func_name, PyObject* kw_name) {
|
|
110
|
+
PyErr_Format(PyExc_TypeError,
|
|
111
|
+
"%s() needs keyword-only argument %U", func_name, kw_name);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
//////////////////// RaiseDoubleKeywords.proto ////////////////////
|
|
116
|
+
|
|
117
|
+
static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); /*proto*/
|
|
118
|
+
|
|
119
|
+
//////////////////// RaiseDoubleKeywords ////////////////////
|
|
120
|
+
|
|
121
|
+
static void __Pyx_RaiseDoubleKeywordsError(
|
|
122
|
+
const char* func_name,
|
|
123
|
+
PyObject* kw_name)
|
|
124
|
+
{
|
|
125
|
+
PyErr_Format(PyExc_TypeError,
|
|
126
|
+
"%s() got multiple values for keyword argument '%U'", func_name, kw_name);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
//////////////////// RaiseMappingExpected.proto ////////////////////
|
|
131
|
+
|
|
132
|
+
static void __Pyx_RaiseMappingExpectedError(PyObject* arg); /*proto*/
|
|
133
|
+
|
|
134
|
+
//////////////////// RaiseMappingExpected ////////////////////
|
|
135
|
+
|
|
136
|
+
static void __Pyx_RaiseMappingExpectedError(PyObject* arg) {
|
|
137
|
+
__Pyx_TypeName arg_type_name = __Pyx_PyType_GetName(Py_TYPE(arg));
|
|
138
|
+
PyErr_Format(PyExc_TypeError,
|
|
139
|
+
"'" __Pyx_FMT_TYPENAME "' object is not a mapping", arg_type_name);
|
|
140
|
+
__Pyx_DECREF_TypeName(arg_type_name);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
//////////////////// KeywordStringCheck.proto ////////////////////
|
|
145
|
+
|
|
146
|
+
static int __Pyx_CheckKeywordStrings(PyObject *kw, const char* function_name, int kw_allowed); /*proto*/
|
|
147
|
+
|
|
148
|
+
//////////////////// KeywordStringCheck ////////////////////
|
|
149
|
+
|
|
150
|
+
// __Pyx_CheckKeywordStrings raises an error if non-string keywords
|
|
151
|
+
// were passed to a function, or if any keywords were passed to a
|
|
152
|
+
// function that does not accept them.
|
|
153
|
+
//
|
|
154
|
+
// The "kw" argument is either a dict (for METH_VARARGS) or a tuple
|
|
155
|
+
// (for METH_FASTCALL).
|
|
156
|
+
|
|
157
|
+
static int __Pyx_CheckKeywordStrings(
|
|
158
|
+
PyObject *kw,
|
|
159
|
+
const char* function_name,
|
|
160
|
+
int kw_allowed)
|
|
161
|
+
{
|
|
162
|
+
PyObject* key = 0;
|
|
163
|
+
Py_ssize_t pos = 0;
|
|
164
|
+
#if CYTHON_COMPILING_IN_PYPY
|
|
165
|
+
/* PyPy appears to check keywords at call time, not at unpacking time => not much to do here */
|
|
166
|
+
if (!kw_allowed && PyDict_Next(kw, &pos, &key, 0))
|
|
167
|
+
goto invalid_keyword;
|
|
168
|
+
return 1;
|
|
169
|
+
#else
|
|
170
|
+
if (CYTHON_METH_FASTCALL && likely(PyTuple_Check(kw))) {
|
|
171
|
+
Py_ssize_t kwsize;
|
|
172
|
+
#if CYTHON_ASSUME_SAFE_SIZE
|
|
173
|
+
kwsize = PyTuple_GET_SIZE(kw);
|
|
174
|
+
#else
|
|
175
|
+
kwsize = PyTuple_Size(kw);
|
|
176
|
+
if (kwsize < 0) return 0;
|
|
177
|
+
#endif
|
|
178
|
+
if (unlikely(kwsize == 0))
|
|
179
|
+
return 1;
|
|
180
|
+
if (!kw_allowed) {
|
|
181
|
+
#if CYTHON_ASSUME_SAFE_MACROS
|
|
182
|
+
key = PyTuple_GET_ITEM(kw, 0);
|
|
183
|
+
#else
|
|
184
|
+
key = PyTuple_GetItem(kw, pos);
|
|
185
|
+
if (!key) return 0;
|
|
186
|
+
#endif
|
|
187
|
+
goto invalid_keyword;
|
|
188
|
+
}
|
|
189
|
+
#if PY_VERSION_HEX < 0x03090000
|
|
190
|
+
// On CPython >= 3.9, the FASTCALL protocol guarantees that keyword
|
|
191
|
+
// names are strings (see https://bugs.python.org/issue37540)
|
|
192
|
+
for (pos = 0; pos < kwsize; pos++) {
|
|
193
|
+
#if CYTHON_ASSUME_SAFE_MACROS
|
|
194
|
+
key = PyTuple_GET_ITEM(kw, pos);
|
|
195
|
+
#else
|
|
196
|
+
key = PyTuple_GetItem(kw, pos);
|
|
197
|
+
if (!key) return 0;
|
|
198
|
+
#endif
|
|
199
|
+
if (unlikely(!PyUnicode_Check(key)))
|
|
200
|
+
goto invalid_keyword_type;
|
|
201
|
+
}
|
|
202
|
+
#endif
|
|
203
|
+
return 1;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
while (PyDict_Next(kw, &pos, &key, 0)) {
|
|
207
|
+
if (unlikely(!PyUnicode_Check(key)))
|
|
208
|
+
goto invalid_keyword_type;
|
|
209
|
+
}
|
|
210
|
+
if (!kw_allowed && unlikely(key))
|
|
211
|
+
goto invalid_keyword;
|
|
212
|
+
return 1;
|
|
213
|
+
invalid_keyword_type:
|
|
214
|
+
PyErr_Format(PyExc_TypeError,
|
|
215
|
+
"%.200s() keywords must be strings", function_name);
|
|
216
|
+
return 0;
|
|
217
|
+
#endif
|
|
218
|
+
invalid_keyword:
|
|
219
|
+
PyErr_Format(PyExc_TypeError,
|
|
220
|
+
"%s() got an unexpected keyword argument '%U'",
|
|
221
|
+
function_name, key);
|
|
222
|
+
return 0;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
//////////////////// ParseKeywords.proto ////////////////////
|
|
227
|
+
|
|
228
|
+
static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject *const *kwvalues,
|
|
229
|
+
PyObject **argnames[],
|
|
230
|
+
PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,
|
|
231
|
+
const char* function_name); /*proto*/
|
|
232
|
+
|
|
233
|
+
//////////////////// ParseKeywords ////////////////////
|
|
234
|
+
//@requires: RaiseDoubleKeywords
|
|
235
|
+
|
|
236
|
+
// __Pyx_ParseOptionalKeywords copies the optional/unknown keyword
|
|
237
|
+
// arguments from kwds into the dict kwds2. If kwds2 is NULL, unknown
|
|
238
|
+
// keywords will raise an invalid keyword error.
|
|
239
|
+
//
|
|
240
|
+
// When not using METH_FASTCALL, kwds is a dict and kwvalues is NULL.
|
|
241
|
+
// Otherwise, kwds is a tuple with keyword names and kwvalues is a C
|
|
242
|
+
// array with the corresponding values.
|
|
243
|
+
//
|
|
244
|
+
// Three kinds of errors are checked: 1) non-string keywords, 2)
|
|
245
|
+
// unexpected keywords and 3) overlap with positional arguments.
|
|
246
|
+
//
|
|
247
|
+
// If num_posargs is greater 0, it denotes the number of positional
|
|
248
|
+
// arguments that were passed and that must therefore not appear
|
|
249
|
+
// amongst the keywords as well.
|
|
250
|
+
//
|
|
251
|
+
// This method does not check for required keyword arguments.
|
|
252
|
+
|
|
253
|
+
static int __Pyx_ParseOptionalKeywords(
|
|
254
|
+
PyObject *kwds,
|
|
255
|
+
PyObject *const *kwvalues,
|
|
256
|
+
PyObject **argnames[],
|
|
257
|
+
PyObject *kwds2,
|
|
258
|
+
PyObject *values[],
|
|
259
|
+
Py_ssize_t num_pos_args,
|
|
260
|
+
const char* function_name)
|
|
261
|
+
{
|
|
262
|
+
PyObject *key = 0, *value = 0;
|
|
263
|
+
Py_ssize_t pos = 0;
|
|
264
|
+
PyObject*** name;
|
|
265
|
+
PyObject*** first_kw_arg = argnames + num_pos_args;
|
|
266
|
+
int kwds_is_tuple = CYTHON_METH_FASTCALL && likely(PyTuple_Check(kwds));
|
|
267
|
+
|
|
268
|
+
while (1) {
|
|
269
|
+
// clean up key and value when the loop is "continued"
|
|
270
|
+
Py_XDECREF(key); key = NULL;
|
|
271
|
+
Py_XDECREF(value); value = NULL;
|
|
272
|
+
|
|
273
|
+
if (kwds_is_tuple) {
|
|
274
|
+
Py_ssize_t size;
|
|
275
|
+
#if CYTHON_ASSUME_SAFE_SIZE
|
|
276
|
+
size = PyTuple_GET_SIZE(kwds);
|
|
277
|
+
#else
|
|
278
|
+
size = PyTuple_Size(kwds);
|
|
279
|
+
if (size < 0) goto bad;
|
|
280
|
+
#endif
|
|
281
|
+
if (pos >= size) break;
|
|
282
|
+
|
|
283
|
+
#if CYTHON_AVOID_BORROWED_REFS
|
|
284
|
+
// Get an owned reference to key.
|
|
285
|
+
key = __Pyx_PySequence_ITEM(kwds, pos);
|
|
286
|
+
if (!key) goto bad;
|
|
287
|
+
#elif CYTHON_ASSUME_SAFE_MACROS
|
|
288
|
+
key = PyTuple_GET_ITEM(kwds, pos);
|
|
289
|
+
#else
|
|
290
|
+
key = PyTuple_GetItem(kwds, pos);
|
|
291
|
+
if (!key) goto bad;
|
|
292
|
+
#endif
|
|
293
|
+
|
|
294
|
+
value = kwvalues[pos];
|
|
295
|
+
pos++;
|
|
296
|
+
}
|
|
297
|
+
else
|
|
298
|
+
{
|
|
299
|
+
if (!PyDict_Next(kwds, &pos, &key, &value)) break;
|
|
300
|
+
// It's unfortunately hard to avoid borrowed references (briefly) with PyDict_Next
|
|
301
|
+
#if CYTHON_AVOID_BORROWED_REFS
|
|
302
|
+
// Own the reference to match the behaviour above.
|
|
303
|
+
Py_INCREF(key);
|
|
304
|
+
#endif
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
name = first_kw_arg;
|
|
308
|
+
while (*name && (**name != key)) name++;
|
|
309
|
+
if (*name) {
|
|
310
|
+
values[name-argnames] = value;
|
|
311
|
+
#if CYTHON_AVOID_BORROWED_REFS
|
|
312
|
+
Py_INCREF(value); /* transfer ownership of value to values */
|
|
313
|
+
Py_DECREF(key);
|
|
314
|
+
#endif
|
|
315
|
+
key = NULL;
|
|
316
|
+
value = NULL;
|
|
317
|
+
continue;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
// Now make sure we own both references since we're doing non-trivial Python operations.
|
|
321
|
+
#if !CYTHON_AVOID_BORROWED_REFS
|
|
322
|
+
Py_INCREF(key);
|
|
323
|
+
#endif
|
|
324
|
+
Py_INCREF(value);
|
|
325
|
+
|
|
326
|
+
name = first_kw_arg;
|
|
327
|
+
if (likely(PyUnicode_Check(key))) {
|
|
328
|
+
while (*name) {
|
|
329
|
+
int cmp = (
|
|
330
|
+
#if CYTHON_ASSUME_SAFE_SIZE
|
|
331
|
+
(PyUnicode_GET_LENGTH(**name) != PyUnicode_GET_LENGTH(key)) ? 1 :
|
|
332
|
+
#endif
|
|
333
|
+
PyUnicode_Compare(**name, key)
|
|
334
|
+
);
|
|
335
|
+
if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
|
|
336
|
+
if (cmp == 0) {
|
|
337
|
+
values[name-argnames] = value;
|
|
338
|
+
#if CYTHON_AVOID_BORROWED_REFS
|
|
339
|
+
value = NULL; /* ownership transferred to values */
|
|
340
|
+
#endif
|
|
341
|
+
break;
|
|
342
|
+
}
|
|
343
|
+
name++;
|
|
344
|
+
}
|
|
345
|
+
if (*name) continue;
|
|
346
|
+
else {
|
|
347
|
+
// not found after positional args, check for duplicate
|
|
348
|
+
PyObject*** argname = argnames;
|
|
349
|
+
while (argname != first_kw_arg) {
|
|
350
|
+
int cmp = (**argname == key) ? 0 :
|
|
351
|
+
#if CYTHON_ASSUME_SAFE_SIZE
|
|
352
|
+
(PyUnicode_GET_LENGTH(**argname) != PyUnicode_GET_LENGTH(key)) ? 1 :
|
|
353
|
+
#endif
|
|
354
|
+
// need to convert argument name from bytes to unicode for comparison
|
|
355
|
+
PyUnicode_Compare(**argname, key);
|
|
356
|
+
if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
|
|
357
|
+
if (cmp == 0) goto arg_passed_twice;
|
|
358
|
+
argname++;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
} else
|
|
362
|
+
goto invalid_keyword_type;
|
|
363
|
+
|
|
364
|
+
if (kwds2) {
|
|
365
|
+
if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
|
|
366
|
+
} else {
|
|
367
|
+
goto invalid_keyword;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
Py_XDECREF(key);
|
|
371
|
+
Py_XDECREF(value);
|
|
372
|
+
return 0;
|
|
373
|
+
arg_passed_twice:
|
|
374
|
+
__Pyx_RaiseDoubleKeywordsError(function_name, key);
|
|
375
|
+
goto bad;
|
|
376
|
+
invalid_keyword_type:
|
|
377
|
+
PyErr_Format(PyExc_TypeError,
|
|
378
|
+
"%.200s() keywords must be strings", function_name);
|
|
379
|
+
goto bad;
|
|
380
|
+
invalid_keyword:
|
|
381
|
+
PyErr_Format(PyExc_TypeError,
|
|
382
|
+
"%s() got an unexpected keyword argument '%U'",
|
|
383
|
+
function_name, key);
|
|
384
|
+
bad:
|
|
385
|
+
Py_XDECREF(key);
|
|
386
|
+
Py_XDECREF(value);
|
|
387
|
+
return -1;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
//////////////////// MergeKeywords.proto ////////////////////
|
|
392
|
+
|
|
393
|
+
static int __Pyx_MergeKeywords(PyObject *kwdict, PyObject *source_mapping); /*proto*/
|
|
394
|
+
|
|
395
|
+
//////////////////// MergeKeywords ////////////////////
|
|
396
|
+
//@requires: RaiseDoubleKeywords
|
|
397
|
+
//@requires: Optimize.c::dict_iter
|
|
398
|
+
|
|
399
|
+
static int __Pyx_MergeKeywords(PyObject *kwdict, PyObject *source_mapping) {
|
|
400
|
+
PyObject *iter, *key = NULL, *value = NULL;
|
|
401
|
+
int source_is_dict, result;
|
|
402
|
+
Py_ssize_t orig_length, ppos = 0;
|
|
403
|
+
|
|
404
|
+
iter = __Pyx_dict_iterator(source_mapping, 0, PYIDENT("items"), &orig_length, &source_is_dict);
|
|
405
|
+
if (unlikely(!iter)) {
|
|
406
|
+
// slow fallback: try converting to dict, then iterate
|
|
407
|
+
PyObject *args;
|
|
408
|
+
if (unlikely(!PyErr_ExceptionMatches(PyExc_AttributeError))) goto bad;
|
|
409
|
+
PyErr_Clear();
|
|
410
|
+
args = PyTuple_Pack(1, source_mapping);
|
|
411
|
+
if (likely(args)) {
|
|
412
|
+
PyObject *fallback = PyObject_Call((PyObject*)&PyDict_Type, args, NULL);
|
|
413
|
+
Py_DECREF(args);
|
|
414
|
+
if (likely(fallback)) {
|
|
415
|
+
iter = __Pyx_dict_iterator(fallback, 1, PYIDENT("items"), &orig_length, &source_is_dict);
|
|
416
|
+
Py_DECREF(fallback);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
if (unlikely(!iter)) goto bad;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
while (1) {
|
|
423
|
+
result = __Pyx_dict_iter_next(iter, orig_length, &ppos, &key, &value, NULL, source_is_dict);
|
|
424
|
+
if (unlikely(result < 0)) goto bad;
|
|
425
|
+
if (!result) break;
|
|
426
|
+
|
|
427
|
+
if (unlikely(PyDict_Contains(kwdict, key))) {
|
|
428
|
+
__Pyx_RaiseDoubleKeywordsError("function", key);
|
|
429
|
+
result = -1;
|
|
430
|
+
} else {
|
|
431
|
+
result = PyDict_SetItem(kwdict, key, value);
|
|
432
|
+
}
|
|
433
|
+
Py_DECREF(key);
|
|
434
|
+
Py_DECREF(value);
|
|
435
|
+
if (unlikely(result < 0)) goto bad;
|
|
436
|
+
}
|
|
437
|
+
Py_XDECREF(iter);
|
|
438
|
+
return 0;
|
|
439
|
+
|
|
440
|
+
bad:
|
|
441
|
+
Py_XDECREF(iter);
|
|
442
|
+
return -1;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
|
|
446
|
+
/////////////// fastcall.proto ///////////////
|
|
447
|
+
|
|
448
|
+
// We define various functions and macros with two variants:
|
|
449
|
+
//..._FASTCALL and ..._VARARGS
|
|
450
|
+
|
|
451
|
+
// The first is used when METH_FASTCALL is enabled and the second is used
|
|
452
|
+
// otherwise. If the Python implementation does not support METH_FASTCALL
|
|
453
|
+
// (because it's an old version of CPython or it's not CPython at all),
|
|
454
|
+
// then the ..._FASTCALL macros simply alias ..._VARARGS
|
|
455
|
+
|
|
456
|
+
#if CYTHON_AVOID_BORROWED_REFS
|
|
457
|
+
// This is the only case where we request an owned reference.
|
|
458
|
+
#define __Pyx_Arg_VARARGS(args, i) PySequence_GetItem(args, i)
|
|
459
|
+
#elif CYTHON_ASSUME_SAFE_MACROS
|
|
460
|
+
#define __Pyx_Arg_VARARGS(args, i) PyTuple_GET_ITEM(args, i)
|
|
461
|
+
#else
|
|
462
|
+
#define __Pyx_Arg_VARARGS(args, i) PyTuple_GetItem(args, i)
|
|
463
|
+
#endif
|
|
464
|
+
#if CYTHON_AVOID_BORROWED_REFS
|
|
465
|
+
#define __Pyx_Arg_NewRef_VARARGS(arg) __Pyx_NewRef(arg)
|
|
466
|
+
#define __Pyx_Arg_XDECREF_VARARGS(arg) Py_XDECREF(arg)
|
|
467
|
+
#else
|
|
468
|
+
#define __Pyx_Arg_NewRef_VARARGS(arg) arg /* no-op */
|
|
469
|
+
#define __Pyx_Arg_XDECREF_VARARGS(arg) /* no-op - arg is borrowed */
|
|
470
|
+
#endif
|
|
471
|
+
#define __Pyx_NumKwargs_VARARGS(kwds) PyDict_Size(kwds)
|
|
472
|
+
#define __Pyx_KwValues_VARARGS(args, nargs) NULL
|
|
473
|
+
#define __Pyx_GetKwValue_VARARGS(kw, kwvalues, s) __Pyx_PyDict_GetItemStrWithError(kw, s)
|
|
474
|
+
#define __Pyx_KwargsAsDict_VARARGS(kw, kwvalues) PyDict_Copy(kw)
|
|
475
|
+
#if CYTHON_METH_FASTCALL
|
|
476
|
+
#define __Pyx_Arg_FASTCALL(args, i) args[i]
|
|
477
|
+
#define __Pyx_NumKwargs_FASTCALL(kwds) __Pyx_PyTuple_GET_SIZE(kwds)
|
|
478
|
+
#define __Pyx_KwValues_FASTCALL(args, nargs) ((args) + (nargs))
|
|
479
|
+
static CYTHON_INLINE PyObject * __Pyx_GetKwValue_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues, PyObject *s);
|
|
480
|
+
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030d0000
|
|
481
|
+
CYTHON_UNUSED static PyObject *__Pyx_KwargsAsDict_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues);/*proto*/
|
|
482
|
+
#else
|
|
483
|
+
#define __Pyx_KwargsAsDict_FASTCALL(kw, kwvalues) _PyStack_AsDict(kwvalues, kw)
|
|
484
|
+
#endif
|
|
485
|
+
#define __Pyx_Arg_NewRef_FASTCALL(arg) arg /* no-op, __Pyx_Arg_FASTCALL is direct and this needs
|
|
486
|
+
to have the same reference counting */
|
|
487
|
+
#define __Pyx_Arg_XDECREF_FASTCALL(arg) /* no-op - arg was returned from array */
|
|
488
|
+
#else
|
|
489
|
+
#define __Pyx_Arg_FASTCALL __Pyx_Arg_VARARGS
|
|
490
|
+
#define __Pyx_NumKwargs_FASTCALL __Pyx_NumKwargs_VARARGS
|
|
491
|
+
#define __Pyx_KwValues_FASTCALL __Pyx_KwValues_VARARGS
|
|
492
|
+
#define __Pyx_GetKwValue_FASTCALL __Pyx_GetKwValue_VARARGS
|
|
493
|
+
#define __Pyx_KwargsAsDict_FASTCALL __Pyx_KwargsAsDict_VARARGS
|
|
494
|
+
#define __Pyx_Arg_NewRef_FASTCALL(arg) __Pyx_Arg_NewRef_VARARGS(arg)
|
|
495
|
+
#define __Pyx_Arg_XDECREF_FASTCALL(arg) __Pyx_Arg_XDECREF_VARARGS(arg)
|
|
496
|
+
#endif
|
|
497
|
+
|
|
498
|
+
#if CYTHON_COMPILING_IN_CPYTHON && CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
|
|
499
|
+
#define __Pyx_ArgsSlice_VARARGS(args, start, stop) __Pyx_PyTuple_FromArray(&__Pyx_Arg_VARARGS(args, start), stop - start)
|
|
500
|
+
#else
|
|
501
|
+
#define __Pyx_ArgsSlice_VARARGS(args, start, stop) PyTuple_GetSlice(args, start, stop)
|
|
502
|
+
#endif
|
|
503
|
+
#if CYTHON_METH_FASTCALL || (CYTHON_COMPILING_IN_CPYTHON && CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
|
|
504
|
+
#define __Pyx_ArgsSlice_FASTCALL(args, start, stop) __Pyx_PyTuple_FromArray(&__Pyx_Arg_FASTCALL(args, start), stop - start)
|
|
505
|
+
#else
|
|
506
|
+
#define __Pyx_ArgsSlice_FASTCALL(args, start, stop) PyTuple_GetSlice(args, start, stop)
|
|
507
|
+
#endif
|
|
508
|
+
|
|
509
|
+
|
|
510
|
+
/////////////// fastcall ///////////////
|
|
511
|
+
//@requires: ObjectHandling.c::TupleAndListFromArray
|
|
512
|
+
//@requires: StringTools.c::UnicodeEquals
|
|
513
|
+
|
|
514
|
+
#if CYTHON_METH_FASTCALL
|
|
515
|
+
// kwnames: tuple with names of keyword arguments
|
|
516
|
+
// kwvalues: C array with values of keyword arguments
|
|
517
|
+
// s: str with the keyword name to look for
|
|
518
|
+
static CYTHON_INLINE PyObject * __Pyx_GetKwValue_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues, PyObject *s)
|
|
519
|
+
{
|
|
520
|
+
// Search the kwnames array for s and return the corresponding value.
|
|
521
|
+
// We do two loops: a first one to compare pointers (which will find a
|
|
522
|
+
// match if the name in kwnames is interned, given that s is interned
|
|
523
|
+
// by Cython). A second loop compares the actual strings.
|
|
524
|
+
Py_ssize_t i, n = __Pyx_PyTuple_GET_SIZE(kwnames);
|
|
525
|
+
#if !CYTHON_ASSUME_SAFE_SIZE
|
|
526
|
+
if (unlikely(n == -1)) return NULL;
|
|
527
|
+
#endif
|
|
528
|
+
for (i = 0; i < n; i++)
|
|
529
|
+
{
|
|
530
|
+
PyObject *namei = __Pyx_PyTuple_GET_ITEM(kwnames, i);
|
|
531
|
+
#if !CYTHON_ASSUME_SAFE_MACROS
|
|
532
|
+
if (unlikely(!namei)) return NULL;
|
|
533
|
+
#endif
|
|
534
|
+
if (s == namei) return kwvalues[i];
|
|
535
|
+
}
|
|
536
|
+
for (i = 0; i < n; i++)
|
|
537
|
+
{
|
|
538
|
+
PyObject *namei = __Pyx_PyTuple_GET_ITEM(kwnames, i);
|
|
539
|
+
#if !CYTHON_ASSUME_SAFE_MACROS
|
|
540
|
+
if (unlikely(!namei)) return NULL;
|
|
541
|
+
#endif
|
|
542
|
+
int eq = __Pyx_PyUnicode_Equals(s, namei, Py_EQ);
|
|
543
|
+
if (unlikely(eq != 0)) {
|
|
544
|
+
if (unlikely(eq < 0)) return NULL; /* error */
|
|
545
|
+
return kwvalues[i];
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
return NULL; /* not found (no exception set) */
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030d0000
|
|
552
|
+
CYTHON_UNUSED static PyObject *__Pyx_KwargsAsDict_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues) {
|
|
553
|
+
Py_ssize_t i, nkwargs = PyTuple_GET_SIZE(kwnames);
|
|
554
|
+
PyObject *dict;
|
|
555
|
+
|
|
556
|
+
dict = PyDict_New();
|
|
557
|
+
if (unlikely(!dict))
|
|
558
|
+
return NULL;
|
|
559
|
+
|
|
560
|
+
for (i=0; i<nkwargs; i++) {
|
|
561
|
+
PyObject *key = PyTuple_GET_ITEM(kwnames, i);
|
|
562
|
+
if (unlikely(PyDict_SetItem(dict, key, kwvalues[i]) < 0))
|
|
563
|
+
goto bad;
|
|
564
|
+
}
|
|
565
|
+
return dict;
|
|
566
|
+
|
|
567
|
+
bad:
|
|
568
|
+
Py_DECREF(dict);
|
|
569
|
+
return NULL;
|
|
570
|
+
}
|
|
571
|
+
#endif
|
|
572
|
+
|
|
573
|
+
#endif
|