oxython 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- Cython/Build/BuildExecutable.py +156 -0
- Cython/Build/Cache.py +198 -0
- Cython/Build/Cythonize.py +349 -0
- Cython/Build/Dependencies.py +1320 -0
- Cython/Build/Distutils.py +1 -0
- Cython/Build/Inline.py +467 -0
- Cython/Build/IpythonMagic.py +559 -0
- Cython/Build/SharedModule.py +165 -0
- Cython/Build/Tests/TestCyCache.py +222 -0
- Cython/Build/Tests/TestCythonizeArgsParser.py +480 -0
- Cython/Build/Tests/TestDependencies.py +133 -0
- Cython/Build/Tests/TestInline.py +177 -0
- Cython/Build/Tests/TestIpythonMagic.py +303 -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 +11 -0
- Cython/CodeWriter.py +825 -0
- Cython/Compiler/AnalysedTreeTransforms.py +97 -0
- Cython/Compiler/Annotate.py +328 -0
- Cython/Compiler/AutoDocTransforms.py +320 -0
- Cython/Compiler/Buffer.py +679 -0
- Cython/Compiler/Builtin.py +1102 -0
- Cython/Compiler/CmdLine.py +373 -0
- Cython/Compiler/Code.pxd +154 -0
- Cython/Compiler/Code.py +3760 -0
- Cython/Compiler/CodeGeneration.py +33 -0
- Cython/Compiler/CythonScope.py +208 -0
- Cython/Compiler/Dataclass.py +890 -0
- Cython/Compiler/DebugFlags.py +24 -0
- Cython/Compiler/Errors.py +310 -0
- Cython/Compiler/ExprNodes.py +16319 -0
- Cython/Compiler/FlowControl.pxd +112 -0
- Cython/Compiler/FlowControl.py +1575 -0
- Cython/Compiler/FusedNode.py +978 -0
- Cython/Compiler/Future.py +16 -0
- Cython/Compiler/Interpreter.py +57 -0
- Cython/Compiler/Lexicon.py +442 -0
- Cython/Compiler/LineTable.py +114 -0
- Cython/Compiler/Main.py +879 -0
- Cython/Compiler/MatchCaseNodes.py +2200 -0
- Cython/Compiler/MemoryView.py +930 -0
- Cython/Compiler/ModuleNode.py +4558 -0
- Cython/Compiler/Naming.py +370 -0
- Cython/Compiler/Nodes.py +11334 -0
- Cython/Compiler/Optimize.py +5563 -0
- Cython/Compiler/Options.py +841 -0
- Cython/Compiler/ParseTreeTransforms.pxd +80 -0
- Cython/Compiler/ParseTreeTransforms.py +4808 -0
- Cython/Compiler/Parsing.pxd +9 -0
- Cython/Compiler/Parsing.py +5442 -0
- Cython/Compiler/Pipeline.py +439 -0
- Cython/Compiler/PyrexTypes.py +6588 -0
- Cython/Compiler/Pythran.py +232 -0
- Cython/Compiler/Scanning.pxd +74 -0
- Cython/Compiler/Scanning.py +771 -0
- Cython/Compiler/StringEncoding.py +354 -0
- Cython/Compiler/Symtab.py +3122 -0
- Cython/Compiler/Tests/TestBuffer.py +105 -0
- Cython/Compiler/Tests/TestBuiltin.py +196 -0
- Cython/Compiler/Tests/TestCmdLine.py +652 -0
- Cython/Compiler/Tests/TestCode.py +145 -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 +132 -0
- Cython/Compiler/Tests/TestSignatureMatching.py +73 -0
- Cython/Compiler/Tests/TestStringEncoding.py +20 -0
- Cython/Compiler/Tests/TestTreeFragment.py +63 -0
- Cython/Compiler/Tests/TestTreePath.py +103 -0
- Cython/Compiler/Tests/TestTypes.py +119 -0
- Cython/Compiler/Tests/TestUtilityLoad.py +112 -0
- Cython/Compiler/Tests/TestVisitor.py +119 -0
- Cython/Compiler/Tests/Utils.py +36 -0
- Cython/Compiler/Tests/__init__.py +1 -0
- Cython/Compiler/TreeFragment.py +279 -0
- Cython/Compiler/TreePath.py +303 -0
- Cython/Compiler/TypeInference.py +626 -0
- Cython/Compiler/TypeSlots.py +1330 -0
- Cython/Compiler/UFuncs.py +317 -0
- Cython/Compiler/UtilNodes.py +389 -0
- Cython/Compiler/UtilityCode.py +354 -0
- Cython/Compiler/Version.py +8 -0
- Cython/Compiler/Visitor.pxd +52 -0
- Cython/Compiler/Visitor.py +914 -0
- Cython/Compiler/__init__.py +1 -0
- Cython/Coverage.py +448 -0
- Cython/Debugger/Cygdb.py +214 -0
- Cython/Debugger/DebugWriter.py +82 -0
- Cython/Debugger/Tests/TestLibCython.py +280 -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 +580 -0
- Cython/Debugger/Tests/test_libpython_in_gdb.py +90 -0
- Cython/Debugger/__init__.py +1 -0
- Cython/Debugger/libcython.py +1548 -0
- Cython/Debugger/libpython.py +2821 -0
- Cython/Debugging.py +20 -0
- Cython/Distutils/__init__.py +2 -0
- Cython/Distutils/build_ext.py +143 -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 +159 -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 +60 -0
- Cython/Includes/cpython/contextvars.pxd +145 -0
- Cython/Includes/cpython/conversion.pxd +36 -0
- Cython/Includes/cpython/datetime.pxd +395 -0
- Cython/Includes/cpython/descr.pxd +26 -0
- Cython/Includes/cpython/dict.pxd +268 -0
- Cython/Includes/cpython/exc.pxd +263 -0
- Cython/Includes/cpython/fileobject.pxd +57 -0
- Cython/Includes/cpython/float.pxd +56 -0
- Cython/Includes/cpython/frozendict.pxd +37 -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 +144 -0
- Cython/Includes/cpython/long.pxd +180 -0
- Cython/Includes/cpython/longintrepr.pxd +14 -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 +430 -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 +141 -0
- Cython/Includes/cpython/sentinel.pxd +17 -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 +146 -0
- Cython/Includes/cpython/unicode.pxd +639 -0
- Cython/Includes/cpython/version.pxd +32 -0
- Cython/Includes/cpython/weakref.pxd +78 -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/stdbool.pxd +5 -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/threads.pxd +234 -0
- Cython/Includes/libc/time.pxd +52 -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/barrier.pxd +22 -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/condition_variable.pxd +322 -0
- Cython/Includes/libcpp/deque.pxd +165 -0
- Cython/Includes/libcpp/exception.pxd +216 -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/future.pxd +103 -0
- Cython/Includes/libcpp/iterator.pxd +34 -0
- Cython/Includes/libcpp/latch.pxd +17 -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/mutex.pxd +387 -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/semaphore.pxd +43 -0
- Cython/Includes/libcpp/set.pxd +228 -0
- Cython/Includes/libcpp/shared_mutex.pxd +96 -0
- Cython/Includes/libcpp/span.pxd +87 -0
- Cython/Includes/libcpp/stack.pxd +11 -0
- Cython/Includes/libcpp/stop_token.pxd +117 -0
- Cython/Includes/libcpp/string.pxd +355 -0
- Cython/Includes/libcpp/string_view.pxd +183 -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 +186 -0
- Cython/Includes/numpy/math.pxd +150 -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/LZSS.py +184 -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 +535 -0
- Cython/Plex/Scanners.pxd +45 -0
- Cython/Plex/Scanners.py +328 -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 +237 -0
- Cython/Shadow.py +1172 -0
- Cython/StringIOTree.py +169 -0
- Cython/Tempita/__init__.py +4 -0
- Cython/Tempita/_looper.py +154 -0
- Cython/Tempita/_tempita.py +1087 -0
- Cython/TestUtils.py +472 -0
- Cython/Tests/TestCodeWriter.py +128 -0
- Cython/Tests/TestCythonUtils.py +237 -0
- Cython/Tests/TestJediTyper.py +223 -0
- Cython/Tests/TestShadow.py +125 -0
- Cython/Tests/TestStringIOTree.py +68 -0
- Cython/Tests/TestTestUtils.py +89 -0
- Cython/Tests/__init__.py +1 -0
- Cython/Tests/xmlrunner.py +390 -0
- Cython/Utility/AsyncGen.c +1152 -0
- Cython/Utility/Buffer.c +866 -0
- Cython/Utility/BufferFormatFromTypeInfo.pxd +2 -0
- Cython/Utility/Builtins.c +1068 -0
- Cython/Utility/CConvert.pyx +153 -0
- Cython/Utility/CMath.c +104 -0
- Cython/Utility/CommonStructures.c +244 -0
- Cython/Utility/Complex.c +378 -0
- Cython/Utility/Coroutine.c +2344 -0
- Cython/Utility/CpdefEnums.pyx +119 -0
- Cython/Utility/CppConvert.pyx +284 -0
- Cython/Utility/CppSupport.cpp +151 -0
- Cython/Utility/CythonFunction.c +2143 -0
- Cython/Utility/Dataclasses.c +101 -0
- Cython/Utility/Embed.c +129 -0
- Cython/Utility/Exceptions.c +1331 -0
- Cython/Utility/Exceptions_Cy.pyx +109 -0
- Cython/Utility/ExtensionTypes.c +1199 -0
- Cython/Utility/FunctionArguments.c +1052 -0
- Cython/Utility/FusedFunction.pyx +44 -0
- Cython/Utility/ImportExport.c +972 -0
- Cython/Utility/MatchCase.c +985 -0
- Cython/Utility/MatchCase_Cy.pyx +12 -0
- Cython/Utility/MemoryView.pxd +108 -0
- Cython/Utility/MemoryView.pyx +1499 -0
- Cython/Utility/MemoryView_C.c +1056 -0
- Cython/Utility/ModuleSetupCode.c +3349 -0
- Cython/Utility/NumpyImportArray.c +46 -0
- Cython/Utility/ObjectHandling.c +3404 -0
- Cython/Utility/Optimize.c +2575 -0
- Cython/Utility/Overflow.c +378 -0
- Cython/Utility/Profile.c +736 -0
- Cython/Utility/StringTools.c +1534 -0
- Cython/Utility/Synchronization.c +438 -0
- Cython/Utility/TString.c +369 -0
- Cython/Utility/TestCyUtilityLoader.pyx +8 -0
- Cython/Utility/TestCythonScope.pyx +75 -0
- Cython/Utility/TestUtilityLoader.c +12 -0
- Cython/Utility/TypeConversion.c +1588 -0
- Cython/Utility/UFuncs.pyx +50 -0
- Cython/Utility/UFuncs_C.c +89 -0
- Cython/Utility/__init__.py +28 -0
- Cython/Utility/arrayarray.h +190 -0
- Cython/Utils.py +682 -0
- Cython/__init__.py +12 -0
- Cython/py.typed +0 -0
- cython.py +29 -0
- oxython-0.1.0.dist-info/METADATA +138 -0
- oxython-0.1.0.dist-info/RECORD +321 -0
- oxython-0.1.0.dist-info/WHEEL +5 -0
- oxython-0.1.0.dist-info/entry_points.txt +4 -0
- oxython-0.1.0.dist-info/top_level.txt +3 -0
- pyximport/__init__.py +4 -0
- pyximport/pyxbuild.py +160 -0
- pyximport/pyximport.py +482 -0
|
@@ -0,0 +1,3349 @@
|
|
|
1
|
+
/////////////// InitLimitedAPI ///////////////
|
|
2
|
+
|
|
3
|
+
#if defined(Py_LIMITED_API)
|
|
4
|
+
#if !defined(CYTHON_LIMITED_API)
|
|
5
|
+
// Use Py_LIMITED_API as the main control for Cython's limited API mode.
|
|
6
|
+
// However it's still possible to define CYTHON_LIMITED_API alone to
|
|
7
|
+
// force Cython to use Limited-API code without enforcing it in Python.
|
|
8
|
+
#define CYTHON_LIMITED_API 1
|
|
9
|
+
#endif
|
|
10
|
+
#elif defined(CYTHON_LIMITED_API)
|
|
11
|
+
#ifdef _MSC_VER
|
|
12
|
+
#pragma message ("Limited API usage is enabled with 'CYTHON_LIMITED_API' but 'Py_LIMITED_API' does not define a Python target version. Consider setting 'Py_LIMITED_API' instead.")
|
|
13
|
+
#else
|
|
14
|
+
#warning Limited API usage is enabled with 'CYTHON_LIMITED_API' but 'Py_LIMITED_API' does not define a Python target version. Consider setting 'Py_LIMITED_API' instead.
|
|
15
|
+
#endif
|
|
16
|
+
#endif
|
|
17
|
+
|
|
18
|
+
/////////////// CModulePreamble ///////////////
|
|
19
|
+
|
|
20
|
+
#include <stddef.h> /* For offsetof */
|
|
21
|
+
#ifndef offsetof
|
|
22
|
+
#define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
|
|
23
|
+
#endif
|
|
24
|
+
|
|
25
|
+
#if !defined(_WIN32) && !defined(WIN32) && !defined(MS_WINDOWS)
|
|
26
|
+
#ifndef __stdcall
|
|
27
|
+
#define __stdcall
|
|
28
|
+
#endif
|
|
29
|
+
#ifndef __cdecl
|
|
30
|
+
#define __cdecl
|
|
31
|
+
#endif
|
|
32
|
+
#ifndef __fastcall
|
|
33
|
+
#define __fastcall
|
|
34
|
+
#endif
|
|
35
|
+
#endif
|
|
36
|
+
|
|
37
|
+
#ifdef __has_builtin
|
|
38
|
+
#define __Pyx_has_cbuiltin(name) __has_builtin(name)
|
|
39
|
+
#else
|
|
40
|
+
#define __Pyx_has_cbuiltin(name) (0)
|
|
41
|
+
#endif
|
|
42
|
+
|
|
43
|
+
#ifndef DL_IMPORT
|
|
44
|
+
#define DL_IMPORT(t) t
|
|
45
|
+
#endif
|
|
46
|
+
#ifndef DL_EXPORT
|
|
47
|
+
#define DL_EXPORT(t) t
|
|
48
|
+
#endif
|
|
49
|
+
|
|
50
|
+
// For use in DL_IMPORT/DL_EXPORT macros.
|
|
51
|
+
#define __PYX_COMMA ,
|
|
52
|
+
|
|
53
|
+
#ifndef PY_LONG_LONG
|
|
54
|
+
#define PY_LONG_LONG LONG_LONG
|
|
55
|
+
#endif
|
|
56
|
+
|
|
57
|
+
#ifndef Py_HUGE_VAL
|
|
58
|
+
#define Py_HUGE_VAL HUGE_VAL
|
|
59
|
+
#endif
|
|
60
|
+
|
|
61
|
+
// For the limited API it often makes sense to use Py_LIMITED_API rather than PY_VERSION_HEX
|
|
62
|
+
// when doing version checks.
|
|
63
|
+
#define __PYX_LIMITED_VERSION_HEX PY_VERSION_HEX
|
|
64
|
+
|
|
65
|
+
#if defined(CYTHON_LIMITED_API)
|
|
66
|
+
#ifdef Py_LIMITED_API
|
|
67
|
+
#undef __PYX_LIMITED_VERSION_HEX
|
|
68
|
+
#define __PYX_LIMITED_VERSION_HEX Py_LIMITED_API
|
|
69
|
+
#if Py_LIMITED_API < 0x03090000
|
|
70
|
+
#error "Cython 3.3 requires the Python Limited API version to be 3.9 or greater."
|
|
71
|
+
#endif
|
|
72
|
+
#endif
|
|
73
|
+
#if defined(GRAALVM_PYTHON) || defined(PYPY_VERSION)
|
|
74
|
+
#ifdef _MSC_VER
|
|
75
|
+
#pragma message ("Py_LIMITED_API is defined on PyPy or GraalPy. This takes precedence over Cython's specialized \
|
|
76
|
+
code for PyPy and GraalPy and is unlikely to work.")
|
|
77
|
+
#else
|
|
78
|
+
#warning "Py_LIMITED_API is defined on PyPy or GraalPy. This takes precedence over Cython's specialized \
|
|
79
|
+
code for PyPy and GraalPy and is unlikely to work."
|
|
80
|
+
#endif
|
|
81
|
+
#endif
|
|
82
|
+
#define CYTHON_COMPILING_IN_PYPY 0
|
|
83
|
+
#define CYTHON_COMPILING_IN_CPYTHON 0
|
|
84
|
+
#define CYTHON_COMPILING_IN_LIMITED_API 1
|
|
85
|
+
#define CYTHON_COMPILING_IN_GRAAL 0
|
|
86
|
+
|
|
87
|
+
#define CYTHON_COMPILING_IN_CPYTHON_FREETHREADING 0
|
|
88
|
+
|
|
89
|
+
#undef CYTHON_USE_TYPE_SLOTS
|
|
90
|
+
#define CYTHON_USE_TYPE_SLOTS 0
|
|
91
|
+
#undef CYTHON_USE_TYPE_SPECS
|
|
92
|
+
#define CYTHON_USE_TYPE_SPECS 1
|
|
93
|
+
#undef CYTHON_USE_PYTYPE_LOOKUP
|
|
94
|
+
#define CYTHON_USE_PYTYPE_LOOKUP 0
|
|
95
|
+
#undef CYTHON_USE_PYLIST_INTERNALS
|
|
96
|
+
#define CYTHON_USE_PYLIST_INTERNALS 0
|
|
97
|
+
#undef CYTHON_USE_UNICODE_INTERNALS
|
|
98
|
+
#define CYTHON_USE_UNICODE_INTERNALS 0
|
|
99
|
+
#ifndef CYTHON_USE_UNICODE_WRITER
|
|
100
|
+
#define CYTHON_USE_UNICODE_WRITER 0
|
|
101
|
+
#endif
|
|
102
|
+
#undef CYTHON_USE_PYLONG_INTERNALS
|
|
103
|
+
#define CYTHON_USE_PYLONG_INTERNALS 0
|
|
104
|
+
#ifndef CYTHON_AVOID_BORROWED_REFS
|
|
105
|
+
#define CYTHON_AVOID_BORROWED_REFS 0
|
|
106
|
+
#endif
|
|
107
|
+
#ifndef CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS
|
|
108
|
+
#define CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS 0
|
|
109
|
+
#endif
|
|
110
|
+
#undef CYTHON_ASSUME_SAFE_MACROS
|
|
111
|
+
#define CYTHON_ASSUME_SAFE_MACROS 0
|
|
112
|
+
#undef CYTHON_ASSUME_SAFE_SIZE
|
|
113
|
+
#define CYTHON_ASSUME_SAFE_SIZE 0
|
|
114
|
+
#undef CYTHON_UNPACK_METHODS
|
|
115
|
+
#define CYTHON_UNPACK_METHODS 0
|
|
116
|
+
#undef CYTHON_FAST_THREAD_STATE
|
|
117
|
+
#define CYTHON_FAST_THREAD_STATE 0
|
|
118
|
+
#undef CYTHON_FAST_GIL
|
|
119
|
+
#define CYTHON_FAST_GIL 0
|
|
120
|
+
#undef CYTHON_VECTORCALL
|
|
121
|
+
#define CYTHON_VECTORCALL (__PYX_LIMITED_VERSION_HEX >= 0x030C0000)
|
|
122
|
+
#ifndef CYTHON_VECTORCALL_TPNEW
|
|
123
|
+
#define CYTHON_VECTORCALL_TPNEW (CYTHON_VECTORCALL && __PYX_LIMITED_VERSION_HEX >= 0x030E0000)
|
|
124
|
+
#endif
|
|
125
|
+
#ifndef CYTHON_PEP487_INIT_SUBCLASS
|
|
126
|
+
#define CYTHON_PEP487_INIT_SUBCLASS 1
|
|
127
|
+
#endif
|
|
128
|
+
#ifndef CYTHON_PEP489_MULTI_PHASE_INIT
|
|
129
|
+
#define CYTHON_PEP489_MULTI_PHASE_INIT 1
|
|
130
|
+
#endif
|
|
131
|
+
#ifndef CYTHON_USE_MODULE_STATE
|
|
132
|
+
#define CYTHON_USE_MODULE_STATE 0
|
|
133
|
+
#endif
|
|
134
|
+
#undef CYTHON_USE_SYS_MONITORING
|
|
135
|
+
#define CYTHON_USE_SYS_MONITORING 0
|
|
136
|
+
#ifndef CYTHON_USE_TP_FINALIZE
|
|
137
|
+
// PyObject_CallFinalizerFromDealloc is missing and not easily replaced
|
|
138
|
+
#define CYTHON_USE_TP_FINALIZE (__PYX_LIMITED_VERSION_HEX >= 0x030F0000 && PY_VERSION_HEX > 0x030F00A8)
|
|
139
|
+
#endif
|
|
140
|
+
#ifndef CYTHON_USE_AM_SEND
|
|
141
|
+
#define CYTHON_USE_AM_SEND (__PYX_LIMITED_VERSION_HEX >= 0x030A0000)
|
|
142
|
+
#endif
|
|
143
|
+
#undef CYTHON_USE_DICT_VERSIONS
|
|
144
|
+
#define CYTHON_USE_DICT_VERSIONS 0
|
|
145
|
+
#undef CYTHON_USE_EXC_INFO_STACK
|
|
146
|
+
#define CYTHON_USE_EXC_INFO_STACK 0
|
|
147
|
+
#ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
|
|
148
|
+
#define CYTHON_UPDATE_DESCRIPTOR_DOC 0
|
|
149
|
+
#endif
|
|
150
|
+
#ifndef CYTHON_USE_OWN_PREP_RERAISE_STAR
|
|
151
|
+
#define CYTHON_USE_OWN_PREP_RERAISE_STAR 1
|
|
152
|
+
#endif
|
|
153
|
+
#ifndef CYTHON_USE_FREELISTS
|
|
154
|
+
#define CYTHON_USE_FREELISTS 1
|
|
155
|
+
#endif
|
|
156
|
+
#undef CYTHON_IMMORTAL_CONSTANTS
|
|
157
|
+
#define CYTHON_IMMORTAL_CONSTANTS 0
|
|
158
|
+
// Opaque objects: generally we prefer not to use them for performance reasons.
|
|
159
|
+
#if __PYX_LIMITED_VERSION_HEX < 0x030E0000
|
|
160
|
+
// If users manually request them then they aren't usable before 3.14 because
|
|
161
|
+
// it isn't possible to specify relative offsets like vectorcall.
|
|
162
|
+
#undef CYTHON_OPAQUE_OBJECTS
|
|
163
|
+
#define CYTHON_OPAQUE_OBJECTS 0
|
|
164
|
+
#elif !defined(CYTHON_OPAQUE_OBJECTS)
|
|
165
|
+
#define CYTHON_OPAQUE_OBJECTS 0
|
|
166
|
+
#endif
|
|
167
|
+
|
|
168
|
+
#elif defined(GRAALVM_PYTHON)
|
|
169
|
+
/* For very preliminary testing purposes. Most variables are set the same as PyPy.
|
|
170
|
+
The existence of this section does not imply that anything works or is even tested */
|
|
171
|
+
// GRAALVM_PYTHON test comes before PyPy test because GraalPython unhelpfully defines PYPY_VERSION
|
|
172
|
+
#define CYTHON_COMPILING_IN_PYPY 0
|
|
173
|
+
#define CYTHON_COMPILING_IN_CPYTHON 0
|
|
174
|
+
#define CYTHON_COMPILING_IN_LIMITED_API 0
|
|
175
|
+
#define CYTHON_COMPILING_IN_GRAAL 1
|
|
176
|
+
|
|
177
|
+
#define CYTHON_COMPILING_IN_CPYTHON_FREETHREADING 0
|
|
178
|
+
|
|
179
|
+
#ifndef CYTHON_USE_TYPE_SLOTS
|
|
180
|
+
#define CYTHON_USE_TYPE_SLOTS 0
|
|
181
|
+
#endif
|
|
182
|
+
#undef CYTHON_USE_TYPE_SPECS
|
|
183
|
+
#define CYTHON_USE_TYPE_SPECS 0
|
|
184
|
+
#undef CYTHON_USE_PYTYPE_LOOKUP
|
|
185
|
+
#define CYTHON_USE_PYTYPE_LOOKUP 0
|
|
186
|
+
#undef CYTHON_USE_PYLIST_INTERNALS
|
|
187
|
+
#define CYTHON_USE_PYLIST_INTERNALS 0
|
|
188
|
+
#undef CYTHON_USE_UNICODE_INTERNALS
|
|
189
|
+
#define CYTHON_USE_UNICODE_INTERNALS 0
|
|
190
|
+
#undef CYTHON_USE_UNICODE_WRITER
|
|
191
|
+
#define CYTHON_USE_UNICODE_WRITER 0
|
|
192
|
+
#undef CYTHON_USE_PYLONG_INTERNALS
|
|
193
|
+
#define CYTHON_USE_PYLONG_INTERNALS 0
|
|
194
|
+
#undef CYTHON_AVOID_BORROWED_REFS
|
|
195
|
+
#define CYTHON_AVOID_BORROWED_REFS 1
|
|
196
|
+
#undef CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS
|
|
197
|
+
#define CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS 0
|
|
198
|
+
#undef CYTHON_ASSUME_SAFE_MACROS
|
|
199
|
+
#define CYTHON_ASSUME_SAFE_MACROS 0
|
|
200
|
+
#undef CYTHON_ASSUME_SAFE_SIZE
|
|
201
|
+
#define CYTHON_ASSUME_SAFE_SIZE 0
|
|
202
|
+
#undef CYTHON_UNPACK_METHODS
|
|
203
|
+
#define CYTHON_UNPACK_METHODS 0
|
|
204
|
+
#undef CYTHON_FAST_THREAD_STATE
|
|
205
|
+
#define CYTHON_FAST_THREAD_STATE 0
|
|
206
|
+
#undef CYTHON_FAST_GIL
|
|
207
|
+
#define CYTHON_FAST_GIL 0
|
|
208
|
+
#ifndef CYTHON_VECTORCALL
|
|
209
|
+
#define CYTHON_VECTORCALL 1
|
|
210
|
+
#endif
|
|
211
|
+
#if CYTHON_USE_TYPE_SPECS && PY_VERSION_HEX < 0x030E0000
|
|
212
|
+
// Py_tp_vectorcall slot unavailable
|
|
213
|
+
#undef CYTHON_VECTORCALL_TPNEW
|
|
214
|
+
#define CYTHON_VECTORCALL_TPNEW 0
|
|
215
|
+
#elif !defined(CYTHON_VECTORCALL_TPNEW)
|
|
216
|
+
#define CYTHON_VECTORCALL_TPNEW CYTHON_VECTORCALL
|
|
217
|
+
#endif
|
|
218
|
+
#ifndef CYTHON_PEP487_INIT_SUBCLASS
|
|
219
|
+
#define CYTHON_PEP487_INIT_SUBCLASS 1
|
|
220
|
+
#endif
|
|
221
|
+
#undef CYTHON_PEP489_MULTI_PHASE_INIT
|
|
222
|
+
#define CYTHON_PEP489_MULTI_PHASE_INIT 1
|
|
223
|
+
#undef CYTHON_USE_MODULE_STATE
|
|
224
|
+
#define CYTHON_USE_MODULE_STATE 0
|
|
225
|
+
#undef CYTHON_USE_SYS_MONITORING
|
|
226
|
+
#define CYTHON_USE_SYS_MONITORING 0
|
|
227
|
+
#undef CYTHON_USE_TP_FINALIZE
|
|
228
|
+
#define CYTHON_USE_TP_FINALIZE 0
|
|
229
|
+
#undef CYTHON_USE_AM_SEND
|
|
230
|
+
#define CYTHON_USE_AM_SEND 0
|
|
231
|
+
#undef CYTHON_USE_DICT_VERSIONS
|
|
232
|
+
#define CYTHON_USE_DICT_VERSIONS 0
|
|
233
|
+
#undef CYTHON_USE_EXC_INFO_STACK
|
|
234
|
+
#define CYTHON_USE_EXC_INFO_STACK 1
|
|
235
|
+
#ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
|
|
236
|
+
#define CYTHON_UPDATE_DESCRIPTOR_DOC 0
|
|
237
|
+
#endif
|
|
238
|
+
#ifndef CYTHON_USE_OWN_PREP_RERAISE_STAR
|
|
239
|
+
#define CYTHON_USE_OWN_PREP_RERAISE_STAR 1
|
|
240
|
+
#endif
|
|
241
|
+
#undef CYTHON_USE_FREELISTS
|
|
242
|
+
#define CYTHON_USE_FREELISTS 0
|
|
243
|
+
#undef CYTHON_IMMORTAL_CONSTANTS
|
|
244
|
+
#define CYTHON_IMMORTAL_CONSTANTS 0
|
|
245
|
+
#undef CYTHON_OPAQUE_OBJECTS
|
|
246
|
+
#define CYTHON_OPAQUE_OBJECTS 0
|
|
247
|
+
|
|
248
|
+
#elif defined(PYPY_VERSION)
|
|
249
|
+
#define CYTHON_COMPILING_IN_PYPY 1
|
|
250
|
+
#define CYTHON_COMPILING_IN_CPYTHON 0
|
|
251
|
+
#define CYTHON_COMPILING_IN_LIMITED_API 0
|
|
252
|
+
#define CYTHON_COMPILING_IN_GRAAL 0
|
|
253
|
+
|
|
254
|
+
#define CYTHON_COMPILING_IN_CPYTHON_FREETHREADING 0
|
|
255
|
+
|
|
256
|
+
#undef CYTHON_USE_TYPE_SLOTS
|
|
257
|
+
#define CYTHON_USE_TYPE_SLOTS 1
|
|
258
|
+
#ifndef CYTHON_USE_TYPE_SPECS
|
|
259
|
+
#define CYTHON_USE_TYPE_SPECS 1
|
|
260
|
+
#endif
|
|
261
|
+
#undef CYTHON_USE_PYTYPE_LOOKUP
|
|
262
|
+
#define CYTHON_USE_PYTYPE_LOOKUP 0
|
|
263
|
+
#undef CYTHON_USE_PYLIST_INTERNALS
|
|
264
|
+
#define CYTHON_USE_PYLIST_INTERNALS 0
|
|
265
|
+
#undef CYTHON_USE_UNICODE_INTERNALS
|
|
266
|
+
#define CYTHON_USE_UNICODE_INTERNALS 0
|
|
267
|
+
#undef CYTHON_USE_UNICODE_WRITER
|
|
268
|
+
#define CYTHON_USE_UNICODE_WRITER 0
|
|
269
|
+
#undef CYTHON_USE_PYLONG_INTERNALS
|
|
270
|
+
#define CYTHON_USE_PYLONG_INTERNALS 0
|
|
271
|
+
#undef CYTHON_AVOID_BORROWED_REFS
|
|
272
|
+
#define CYTHON_AVOID_BORROWED_REFS 1
|
|
273
|
+
#undef CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS
|
|
274
|
+
#define CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS 1
|
|
275
|
+
#undef CYTHON_ASSUME_SAFE_MACROS
|
|
276
|
+
#define CYTHON_ASSUME_SAFE_MACROS 0
|
|
277
|
+
#ifndef CYTHON_ASSUME_SAFE_SIZE
|
|
278
|
+
#define CYTHON_ASSUME_SAFE_SIZE 1
|
|
279
|
+
#endif
|
|
280
|
+
#undef CYTHON_UNPACK_METHODS
|
|
281
|
+
#define CYTHON_UNPACK_METHODS 0
|
|
282
|
+
#undef CYTHON_FAST_THREAD_STATE
|
|
283
|
+
#define CYTHON_FAST_THREAD_STATE 0
|
|
284
|
+
#undef CYTHON_FAST_GIL
|
|
285
|
+
#define CYTHON_FAST_GIL 0
|
|
286
|
+
#ifndef CYTHON_VECTORCALL
|
|
287
|
+
#define CYTHON_VECTORCALL 1
|
|
288
|
+
#endif
|
|
289
|
+
#if CYTHON_USE_TYPE_SPECS && PY_VERSION_HEX < 0x030E0000
|
|
290
|
+
// Py_tp_vectorcall slot unavailable
|
|
291
|
+
#undef CYTHON_VECTORCALL_TPNEW
|
|
292
|
+
#define CYTHON_VECTORCALL_TPNEW 0
|
|
293
|
+
#elif !defined(CYTHON_VECTORCALL_TPNEW)
|
|
294
|
+
// PyPy doesn't define the slot below 7.3.8.
|
|
295
|
+
#define CYTHON_VECTORCALL_TPNEW (PYPY_VERSION_NUM >= 0x07030800 && CYTHON_VECTORCALL)
|
|
296
|
+
#endif
|
|
297
|
+
#ifndef CYTHON_PEP487_INIT_SUBCLASS
|
|
298
|
+
#define CYTHON_PEP487_INIT_SUBCLASS 1
|
|
299
|
+
#endif
|
|
300
|
+
#ifndef CYTHON_PEP489_MULTI_PHASE_INIT
|
|
301
|
+
#define CYTHON_PEP489_MULTI_PHASE_INIT 1
|
|
302
|
+
#endif
|
|
303
|
+
#undef CYTHON_USE_MODULE_STATE
|
|
304
|
+
#define CYTHON_USE_MODULE_STATE 0
|
|
305
|
+
#undef CYTHON_USE_SYS_MONITORING
|
|
306
|
+
#define CYTHON_USE_SYS_MONITORING 0
|
|
307
|
+
#ifndef CYTHON_USE_TP_FINALIZE
|
|
308
|
+
#define CYTHON_USE_TP_FINALIZE (PYPY_VERSION_NUM >= 0x07030C00)
|
|
309
|
+
#endif
|
|
310
|
+
#undef CYTHON_USE_AM_SEND
|
|
311
|
+
#define CYTHON_USE_AM_SEND 0
|
|
312
|
+
#undef CYTHON_USE_DICT_VERSIONS
|
|
313
|
+
#define CYTHON_USE_DICT_VERSIONS 0
|
|
314
|
+
#undef CYTHON_USE_EXC_INFO_STACK
|
|
315
|
+
#define CYTHON_USE_EXC_INFO_STACK 0
|
|
316
|
+
#ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
|
|
317
|
+
#define CYTHON_UPDATE_DESCRIPTOR_DOC (PYPY_VERSION_NUM >= 0x07031100)
|
|
318
|
+
#endif
|
|
319
|
+
#ifndef CYTHON_USE_OWN_PREP_RERAISE_STAR
|
|
320
|
+
#define CYTHON_USE_OWN_PREP_RERAISE_STAR 1
|
|
321
|
+
#endif
|
|
322
|
+
#undef CYTHON_USE_FREELISTS
|
|
323
|
+
#define CYTHON_USE_FREELISTS 0
|
|
324
|
+
#undef CYTHON_IMMORTAL_CONSTANTS
|
|
325
|
+
#define CYTHON_IMMORTAL_CONSTANTS 0
|
|
326
|
+
#undef CYTHON_OPAQUE_OBJECTS
|
|
327
|
+
#define CYTHON_OPAQUE_OBJECTS 0
|
|
328
|
+
|
|
329
|
+
#else
|
|
330
|
+
#define CYTHON_COMPILING_IN_PYPY 0
|
|
331
|
+
#define CYTHON_COMPILING_IN_CPYTHON 1
|
|
332
|
+
#define CYTHON_COMPILING_IN_LIMITED_API 0
|
|
333
|
+
#define CYTHON_COMPILING_IN_GRAAL 0
|
|
334
|
+
|
|
335
|
+
#ifdef Py_GIL_DISABLED
|
|
336
|
+
#define CYTHON_COMPILING_IN_CPYTHON_FREETHREADING 1
|
|
337
|
+
#else
|
|
338
|
+
#define CYTHON_COMPILING_IN_CPYTHON_FREETHREADING 0
|
|
339
|
+
#endif
|
|
340
|
+
|
|
341
|
+
#if PY_VERSION_HEX < 0x030A0000
|
|
342
|
+
// Before Py3.10, PyObject_GetSlot() rejects static (non-heap) types.
|
|
343
|
+
#undef CYTHON_USE_TYPE_SLOTS
|
|
344
|
+
#define CYTHON_USE_TYPE_SLOTS 1
|
|
345
|
+
#elif !defined(CYTHON_USE_TYPE_SLOTS)
|
|
346
|
+
#define CYTHON_USE_TYPE_SLOTS 1
|
|
347
|
+
#endif
|
|
348
|
+
#ifndef CYTHON_USE_TYPE_SPECS
|
|
349
|
+
#define CYTHON_USE_TYPE_SPECS 0
|
|
350
|
+
#endif
|
|
351
|
+
#ifndef CYTHON_USE_PYTYPE_LOOKUP
|
|
352
|
+
#define CYTHON_USE_PYTYPE_LOOKUP 1
|
|
353
|
+
#endif
|
|
354
|
+
#ifndef CYTHON_USE_PYLONG_INTERNALS
|
|
355
|
+
#define CYTHON_USE_PYLONG_INTERNALS 1
|
|
356
|
+
#endif
|
|
357
|
+
#if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
|
|
358
|
+
#undef CYTHON_USE_PYLIST_INTERNALS
|
|
359
|
+
// Use thread-safe CPython C API calls to manipulate list contents
|
|
360
|
+
#define CYTHON_USE_PYLIST_INTERNALS 0
|
|
361
|
+
#elif !defined(CYTHON_USE_PYLIST_INTERNALS)
|
|
362
|
+
#define CYTHON_USE_PYLIST_INTERNALS 1
|
|
363
|
+
#endif
|
|
364
|
+
#ifndef CYTHON_USE_UNICODE_INTERNALS
|
|
365
|
+
#define CYTHON_USE_UNICODE_INTERNALS 1
|
|
366
|
+
#endif
|
|
367
|
+
#if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING || PY_VERSION_HEX >= 0x030B00A2
|
|
368
|
+
// Python 3.11a2 hid _PyLong_FormatAdvancedWriter and _PyFloat_FormatAdvancedWriter
|
|
369
|
+
// therefore disable unicode writer until a better alternative appears
|
|
370
|
+
#undef CYTHON_USE_UNICODE_WRITER
|
|
371
|
+
#define CYTHON_USE_UNICODE_WRITER 0
|
|
372
|
+
#elif !defined(CYTHON_USE_UNICODE_WRITER)
|
|
373
|
+
#define CYTHON_USE_UNICODE_WRITER 1
|
|
374
|
+
#endif
|
|
375
|
+
// CYTHON_AVOID_BORROWED_REFS - Avoid borrowed references and always request owned references directly instead.
|
|
376
|
+
#ifndef CYTHON_AVOID_BORROWED_REFS
|
|
377
|
+
#define CYTHON_AVOID_BORROWED_REFS 0
|
|
378
|
+
#endif
|
|
379
|
+
// CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS - Avoid borrowed references that are not thread-safe in the free-threaded build of CPython.
|
|
380
|
+
#if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
|
|
381
|
+
#undef CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS
|
|
382
|
+
#define CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS 1
|
|
383
|
+
#elif !defined(CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS)
|
|
384
|
+
#define CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS 0
|
|
385
|
+
#endif
|
|
386
|
+
// CYTHON_ASSUME_SAFE_MACROS - Assume that macro calls do not fail and do not raise exceptions.
|
|
387
|
+
#ifndef CYTHON_ASSUME_SAFE_MACROS
|
|
388
|
+
#define CYTHON_ASSUME_SAFE_MACROS 1
|
|
389
|
+
#endif
|
|
390
|
+
// CYTHON_ASSUME_SAFE_SIZE - Assume that Py*_GET_SIZE() calls do not fail and do not raise exceptions.
|
|
391
|
+
#ifndef CYTHON_ASSUME_SAFE_SIZE
|
|
392
|
+
#define CYTHON_ASSUME_SAFE_SIZE 1
|
|
393
|
+
#endif
|
|
394
|
+
#ifndef CYTHON_UNPACK_METHODS
|
|
395
|
+
#define CYTHON_UNPACK_METHODS 1
|
|
396
|
+
#endif
|
|
397
|
+
#ifndef CYTHON_FAST_THREAD_STATE
|
|
398
|
+
#define CYTHON_FAST_THREAD_STATE 1
|
|
399
|
+
#endif
|
|
400
|
+
#if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
|
|
401
|
+
#undef CYTHON_FAST_GIL
|
|
402
|
+
#define CYTHON_FAST_GIL 0
|
|
403
|
+
#elif !defined(CYTHON_FAST_GIL)
|
|
404
|
+
// FIXME: FastGIL can probably be supported also in CPython 3.12 but needs to be adapted.
|
|
405
|
+
// The gain is unclear, however, since the GIL handling itself became faster in recent CPython versions.
|
|
406
|
+
#define CYTHON_FAST_GIL (PY_VERSION_HEX < 0x030C00A6)
|
|
407
|
+
#endif
|
|
408
|
+
#ifndef CYTHON_VECTORCALL
|
|
409
|
+
#define CYTHON_VECTORCALL 1
|
|
410
|
+
#endif
|
|
411
|
+
#if CYTHON_USE_TYPE_SPECS && PY_VERSION_HEX < 0x030E0000
|
|
412
|
+
// Py_tp_vectorcall slot unavailable
|
|
413
|
+
#undef CYTHON_VECTORCALL_TPNEW
|
|
414
|
+
#define CYTHON_VECTORCALL_TPNEW 0
|
|
415
|
+
#elif !defined(CYTHON_VECTORCALL_TPNEW)
|
|
416
|
+
#define CYTHON_VECTORCALL_TPNEW CYTHON_VECTORCALL
|
|
417
|
+
#endif
|
|
418
|
+
#ifndef CYTHON_PEP487_INIT_SUBCLASS
|
|
419
|
+
#define CYTHON_PEP487_INIT_SUBCLASS 1
|
|
420
|
+
#endif
|
|
421
|
+
#ifndef CYTHON_PEP489_MULTI_PHASE_INIT
|
|
422
|
+
#define CYTHON_PEP489_MULTI_PHASE_INIT 1
|
|
423
|
+
#endif
|
|
424
|
+
// CYTHON_USE_MODULE_STATE - Use a module state/globals struct tied to the module object.
|
|
425
|
+
#ifndef CYTHON_USE_MODULE_STATE
|
|
426
|
+
// EXPERIMENTAL !!
|
|
427
|
+
#define CYTHON_USE_MODULE_STATE 0
|
|
428
|
+
#endif
|
|
429
|
+
#ifndef CYTHON_USE_SYS_MONITORING
|
|
430
|
+
#define CYTHON_USE_SYS_MONITORING (PY_VERSION_HEX >= 0x030d00B1)
|
|
431
|
+
#endif
|
|
432
|
+
#ifndef CYTHON_USE_TP_FINALIZE
|
|
433
|
+
#define CYTHON_USE_TP_FINALIZE 1
|
|
434
|
+
#endif
|
|
435
|
+
#ifndef CYTHON_USE_AM_SEND
|
|
436
|
+
#define CYTHON_USE_AM_SEND 1
|
|
437
|
+
#endif
|
|
438
|
+
#if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
|
|
439
|
+
#undef CYTHON_USE_DICT_VERSIONS
|
|
440
|
+
#define CYTHON_USE_DICT_VERSIONS 0
|
|
441
|
+
#elif !defined(CYTHON_USE_DICT_VERSIONS)
|
|
442
|
+
// Python 3.12a5 deprecated "ma_version_tag"
|
|
443
|
+
// and we use static variables with dict versions so it's incompatible with module state
|
|
444
|
+
#define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX < 0x030C00A5 && !CYTHON_USE_MODULE_STATE)
|
|
445
|
+
#endif
|
|
446
|
+
#ifndef CYTHON_USE_EXC_INFO_STACK
|
|
447
|
+
#define CYTHON_USE_EXC_INFO_STACK 1
|
|
448
|
+
#endif
|
|
449
|
+
#ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
|
|
450
|
+
#define CYTHON_UPDATE_DESCRIPTOR_DOC 1
|
|
451
|
+
#endif
|
|
452
|
+
#ifndef CYTHON_USE_OWN_PREP_RERAISE_STAR
|
|
453
|
+
// Allow this to be overridden mainly to aid debugging of our internal
|
|
454
|
+
// implementation
|
|
455
|
+
#define CYTHON_USE_OWN_PREP_RERAISE_STAR (PY_VERSION_HEX < 0x030C00B2)
|
|
456
|
+
#endif
|
|
457
|
+
#ifndef CYTHON_USE_FREELISTS
|
|
458
|
+
#define CYTHON_USE_FREELISTS (!CYTHON_COMPILING_IN_CPYTHON_FREETHREADING)
|
|
459
|
+
#endif
|
|
460
|
+
#if defined(CYTHON_IMMORTAL_CONSTANTS) && PY_VERSION_HEX < 0x030C0000
|
|
461
|
+
#undef CYTHON_IMMORTAL_CONSTANTS
|
|
462
|
+
#define CYTHON_IMMORTAL_CONSTANTS 0 // definitely won't work
|
|
463
|
+
#elif !defined(CYTHON_IMMORTAL_CONSTANTS)
|
|
464
|
+
// The assumption is that immortal constants mainly help reduce contention when accessed from many threads
|
|
465
|
+
// (hence freethreading only), and that with module state the module may be unloaded and reloaded (so they
|
|
466
|
+
// could be a memory leak). However the user can always override these assumptions.
|
|
467
|
+
#define CYTHON_IMMORTAL_CONSTANTS (PY_VERSION_HEX >= 0x030C0000 && !CYTHON_USE_MODULE_STATE && CYTHON_COMPILING_IN_CPYTHON_FREETHREADING)
|
|
468
|
+
#endif
|
|
469
|
+
#ifndef CYTHON_OPAQUE_OBJECTS
|
|
470
|
+
#define CYTHON_OPAQUE_OBJECTS 0
|
|
471
|
+
#endif
|
|
472
|
+
#endif
|
|
473
|
+
|
|
474
|
+
#if CYTHON_USE_PYLONG_INTERNALS
|
|
475
|
+
/* These short defines from the PyLong header can easily conflict with other code */
|
|
476
|
+
#undef SHIFT
|
|
477
|
+
#undef BASE
|
|
478
|
+
#undef MASK
|
|
479
|
+
/* Compile-time sanity check that these are indeed equal. Github issue #2670. */
|
|
480
|
+
#ifdef SIZEOF_VOID_P
|
|
481
|
+
enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) };
|
|
482
|
+
#endif
|
|
483
|
+
#endif
|
|
484
|
+
|
|
485
|
+
#ifndef __has_attribute
|
|
486
|
+
#define __has_attribute(x) 0
|
|
487
|
+
#endif
|
|
488
|
+
|
|
489
|
+
#ifndef __has_cpp_attribute
|
|
490
|
+
#define __has_cpp_attribute(x) 0
|
|
491
|
+
#endif
|
|
492
|
+
|
|
493
|
+
// restrict
|
|
494
|
+
#ifndef CYTHON_RESTRICT
|
|
495
|
+
#if defined(__GNUC__)
|
|
496
|
+
#define CYTHON_RESTRICT __restrict__
|
|
497
|
+
#elif defined(_MSC_VER) && _MSC_VER >= 1400
|
|
498
|
+
#define CYTHON_RESTRICT __restrict
|
|
499
|
+
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
|
|
500
|
+
#define CYTHON_RESTRICT restrict
|
|
501
|
+
#else
|
|
502
|
+
#define CYTHON_RESTRICT
|
|
503
|
+
#endif
|
|
504
|
+
#endif
|
|
505
|
+
|
|
506
|
+
// unused attribute
|
|
507
|
+
#ifndef CYTHON_UNUSED
|
|
508
|
+
#if defined(__cplusplus)
|
|
509
|
+
/* for clang __has_cpp_attribute(maybe_unused) is true even before C++17
|
|
510
|
+
* but leads to warnings with -pedantic, since it is a C++17 feature */
|
|
511
|
+
#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L)
|
|
512
|
+
#if __has_cpp_attribute(maybe_unused)
|
|
513
|
+
#define CYTHON_UNUSED [[maybe_unused]]
|
|
514
|
+
#endif
|
|
515
|
+
#endif
|
|
516
|
+
#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
|
|
517
|
+
#define CYTHON_UNUSED [[maybe_unused]]
|
|
518
|
+
#endif
|
|
519
|
+
#endif
|
|
520
|
+
#ifndef CYTHON_UNUSED
|
|
521
|
+
# if defined(__GNUC__)
|
|
522
|
+
# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
|
|
523
|
+
# define CYTHON_UNUSED __attribute__ ((__unused__))
|
|
524
|
+
# else
|
|
525
|
+
# define CYTHON_UNUSED
|
|
526
|
+
# endif
|
|
527
|
+
# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
|
|
528
|
+
# define CYTHON_UNUSED __attribute__ ((__unused__))
|
|
529
|
+
# else
|
|
530
|
+
# define CYTHON_UNUSED
|
|
531
|
+
# endif
|
|
532
|
+
#endif
|
|
533
|
+
|
|
534
|
+
#ifndef CYTHON_UNUSED_VAR
|
|
535
|
+
# if defined(__cplusplus)
|
|
536
|
+
template<class T> void CYTHON_UNUSED_VAR( const T& ) { }
|
|
537
|
+
# else
|
|
538
|
+
# define CYTHON_UNUSED_VAR(x) (void)(x)
|
|
539
|
+
# endif
|
|
540
|
+
#endif
|
|
541
|
+
|
|
542
|
+
#ifndef CYTHON_MAYBE_UNUSED_VAR
|
|
543
|
+
#define CYTHON_MAYBE_UNUSED_VAR(x) CYTHON_UNUSED_VAR(x)
|
|
544
|
+
#endif
|
|
545
|
+
|
|
546
|
+
#ifndef CYTHON_NCP_UNUSED
|
|
547
|
+
# if CYTHON_COMPILING_IN_CPYTHON && !CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
|
|
548
|
+
# define CYTHON_NCP_UNUSED
|
|
549
|
+
# else
|
|
550
|
+
# define CYTHON_NCP_UNUSED CYTHON_UNUSED
|
|
551
|
+
# endif
|
|
552
|
+
#endif
|
|
553
|
+
|
|
554
|
+
#ifndef CYTHON_USE_CPP_STD_MOVE
|
|
555
|
+
// msvc doesn't set __cplusplus to a useful value
|
|
556
|
+
#if defined(__cplusplus) && ( \
|
|
557
|
+
__cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1600))
|
|
558
|
+
#define CYTHON_USE_CPP_STD_MOVE 1
|
|
559
|
+
#else
|
|
560
|
+
#define CYTHON_USE_CPP_STD_MOVE 0
|
|
561
|
+
#endif
|
|
562
|
+
#endif
|
|
563
|
+
|
|
564
|
+
#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
|
|
565
|
+
|
|
566
|
+
#include <stdint.h>
|
|
567
|
+
typedef uintptr_t __pyx_uintptr_t;
|
|
568
|
+
|
|
569
|
+
#ifndef CYTHON_FALLTHROUGH
|
|
570
|
+
#if defined(__cplusplus)
|
|
571
|
+
/* for clang __has_cpp_attribute(fallthrough) is true even before C++17
|
|
572
|
+
* but leads to warnings with -pedantic, since it is a C++17 feature */
|
|
573
|
+
#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L)
|
|
574
|
+
#if __has_cpp_attribute(fallthrough)
|
|
575
|
+
#define CYTHON_FALLTHROUGH [[fallthrough]]
|
|
576
|
+
#endif
|
|
577
|
+
#endif
|
|
578
|
+
|
|
579
|
+
#ifndef CYTHON_FALLTHROUGH
|
|
580
|
+
#if __has_cpp_attribute(clang::fallthrough)
|
|
581
|
+
#define CYTHON_FALLTHROUGH [[clang::fallthrough]]
|
|
582
|
+
#elif __has_cpp_attribute(gnu::fallthrough)
|
|
583
|
+
#define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
|
|
584
|
+
#endif
|
|
585
|
+
#endif
|
|
586
|
+
#endif
|
|
587
|
+
|
|
588
|
+
#ifndef CYTHON_FALLTHROUGH
|
|
589
|
+
#if __has_attribute(fallthrough)
|
|
590
|
+
#define CYTHON_FALLTHROUGH __attribute__((fallthrough))
|
|
591
|
+
#else
|
|
592
|
+
#define CYTHON_FALLTHROUGH
|
|
593
|
+
#endif
|
|
594
|
+
#endif
|
|
595
|
+
|
|
596
|
+
#if defined(__clang__) && defined(__apple_build_version__)
|
|
597
|
+
#if __apple_build_version__ < 7000000 /* Xcode < 7.0 */
|
|
598
|
+
#undef CYTHON_FALLTHROUGH
|
|
599
|
+
#define CYTHON_FALLTHROUGH
|
|
600
|
+
#endif
|
|
601
|
+
#endif
|
|
602
|
+
#endif
|
|
603
|
+
|
|
604
|
+
#ifdef Py_UNREACHABLE
|
|
605
|
+
#define __Pyx_UNREACHABLE() Py_UNREACHABLE()
|
|
606
|
+
#elif __Pyx_has_cbuiltin(__builtin_unreachable)
|
|
607
|
+
#define __Pyx_UNREACHABLE() __builtin_unreachable()
|
|
608
|
+
#elif defined(__clang__) || defined(__INTEL_COMPILER) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)))
|
|
609
|
+
#define __Pyx_UNREACHABLE() __builtin_unreachable()
|
|
610
|
+
#elif defined(_MSC_VER)
|
|
611
|
+
#define __Pyx_UNREACHABLE() __assume(0)
|
|
612
|
+
#else
|
|
613
|
+
#define __Pyx_UNREACHABLE() Py_FatalError("Unreachable C code path reached")
|
|
614
|
+
#endif
|
|
615
|
+
|
|
616
|
+
#ifndef Py_UNREACHABLE
|
|
617
|
+
#define Py_UNREACHABLE() __Pyx_UNREACHABLE()
|
|
618
|
+
#endif
|
|
619
|
+
|
|
620
|
+
#ifdef __cplusplus
|
|
621
|
+
template <typename T>
|
|
622
|
+
struct __PYX_IS_UNSIGNED_IMPL {static const bool value = T(0) < T(-1);};
|
|
623
|
+
#define __PYX_IS_UNSIGNED(type) (__PYX_IS_UNSIGNED_IMPL<type>::value)
|
|
624
|
+
#else
|
|
625
|
+
#define __PYX_IS_UNSIGNED(type) (((type)-1) > 0)
|
|
626
|
+
#endif
|
|
627
|
+
|
|
628
|
+
#if CYTHON_COMPILING_IN_PYPY == 1
|
|
629
|
+
#define __PYX_NEED_TP_PRINT_SLOT (PY_VERSION_HEX < 0x030A0000)
|
|
630
|
+
#else
|
|
631
|
+
#define __PYX_NEED_TP_PRINT_SLOT 0
|
|
632
|
+
#endif
|
|
633
|
+
// reinterpret
|
|
634
|
+
|
|
635
|
+
// TODO: refactor existing code to use those macros
|
|
636
|
+
#define __PYX_REINTERPRET_FUNCION(func_pointer, other_pointer) ((func_pointer)(void(*)(void))(other_pointer))
|
|
637
|
+
// #define __PYX_REINTERPRET_POINTER(pointer_type, pointer) ((pointer_type)(void *)(pointer))
|
|
638
|
+
// #define __PYX_RUNTIME_REINTERPRET(type, var) (*(type *)(&var))
|
|
639
|
+
|
|
640
|
+
#if __PYX_LIMITED_VERSION_HEX < 0x030C0000
|
|
641
|
+
#define __Pyx_PyErr_FetchException(petype, peval, petb) PyErr_Fetch(petype, peval, petb)
|
|
642
|
+
#define __Pyx_PyErr_RestoreException(etype, eval, etb) PyErr_Restore(etype, eval, etb)
|
|
643
|
+
#else
|
|
644
|
+
#define __Pyx_PyErr_FetchException(petype, peval, petb) *(petype)=NULL; *(peval)=PyErr_GetRaisedException(); *(petb)=NULL
|
|
645
|
+
#define __Pyx_PyErr_RestoreException(etype, eval, etb) PyErr_SetRaisedException(eval)
|
|
646
|
+
#endif
|
|
647
|
+
|
|
648
|
+
|
|
649
|
+
/////////////// CInitCode ///////////////
|
|
650
|
+
|
|
651
|
+
// inline attribute
|
|
652
|
+
#ifndef CYTHON_INLINE
|
|
653
|
+
#if defined(__clang__)
|
|
654
|
+
#define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
|
|
655
|
+
#elif defined(__GNUC__)
|
|
656
|
+
#define CYTHON_INLINE __inline__
|
|
657
|
+
#elif defined(_MSC_VER)
|
|
658
|
+
#define CYTHON_INLINE __inline
|
|
659
|
+
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
|
|
660
|
+
#define CYTHON_INLINE inline
|
|
661
|
+
#else
|
|
662
|
+
#define CYTHON_INLINE
|
|
663
|
+
#endif
|
|
664
|
+
#endif
|
|
665
|
+
|
|
666
|
+
|
|
667
|
+
/////////////// CppInitCode ///////////////
|
|
668
|
+
|
|
669
|
+
#ifndef __cplusplus
|
|
670
|
+
#error "Cython files generated with the C++ option must be compiled with a C++ compiler."
|
|
671
|
+
#endif
|
|
672
|
+
|
|
673
|
+
// inline attribute
|
|
674
|
+
#ifndef CYTHON_INLINE
|
|
675
|
+
#if defined(__clang__)
|
|
676
|
+
#define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
|
|
677
|
+
#else
|
|
678
|
+
#define CYTHON_INLINE inline
|
|
679
|
+
#endif
|
|
680
|
+
#endif
|
|
681
|
+
|
|
682
|
+
// Work around clang bug https://stackoverflow.com/questions/21847816/c-invoke-nested-template-class-destructor
|
|
683
|
+
// (even without the clang bug, the need not to know the typename is generally a benefit)
|
|
684
|
+
template<typename T>
|
|
685
|
+
void __Pyx_call_destructor(T& x) {
|
|
686
|
+
x.~T();
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
// Used for temporary variables of "reference" type.
|
|
690
|
+
template<typename T>
|
|
691
|
+
class __Pyx_FakeReference {
|
|
692
|
+
public:
|
|
693
|
+
__Pyx_FakeReference() : ptr(NULL) { }
|
|
694
|
+
// __Pyx_FakeReference(T& ref) : ptr(&ref) { }
|
|
695
|
+
// Const version needed as Cython doesn't know about const overloads (e.g. for stl containers).
|
|
696
|
+
__Pyx_FakeReference(const T& ref) : ptr(const_cast<T*>(&ref)) { }
|
|
697
|
+
T *operator->() { return ptr; }
|
|
698
|
+
T *operator&() { return ptr; }
|
|
699
|
+
operator T&() { return *ptr; }
|
|
700
|
+
// TODO(robertwb): Delegate all operators (or auto-generate unwrapping code where needed).
|
|
701
|
+
template<typename U> bool operator ==(const U& other) const { return *ptr == other; }
|
|
702
|
+
template<typename U> bool operator !=(const U& other) const { return *ptr != other; }
|
|
703
|
+
template<typename U> bool operator==(const __Pyx_FakeReference<U>& other) const { return *ptr == *other.ptr; }
|
|
704
|
+
template<typename U> bool operator!=(const __Pyx_FakeReference<U>& other) const { return *ptr != *other.ptr; }
|
|
705
|
+
private:
|
|
706
|
+
T *ptr;
|
|
707
|
+
};
|
|
708
|
+
|
|
709
|
+
|
|
710
|
+
/////////////// PythonCompatibility ///////////////
|
|
711
|
+
//@substitute: naming
|
|
712
|
+
|
|
713
|
+
#define __PYX_BUILD_PY_SSIZE_T "n"
|
|
714
|
+
#define CYTHON_FORMAT_SSIZE_T "z"
|
|
715
|
+
|
|
716
|
+
// TODO: remove this block
|
|
717
|
+
#define __Pyx_BUILTIN_MODULE_NAME "builtins"
|
|
718
|
+
#define __Pyx_DefaultClassType PyType_Type
|
|
719
|
+
|
|
720
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
721
|
+
// Cython uses these constants but they are not available in the limited API.
|
|
722
|
+
// Therefore define them as static variables and look them up at module init.
|
|
723
|
+
#ifndef CO_OPTIMIZED
|
|
724
|
+
static int CO_OPTIMIZED;
|
|
725
|
+
#endif
|
|
726
|
+
#ifndef CO_NEWLOCALS
|
|
727
|
+
static int CO_NEWLOCALS;
|
|
728
|
+
#endif
|
|
729
|
+
#ifndef CO_VARARGS
|
|
730
|
+
static int CO_VARARGS;
|
|
731
|
+
#endif
|
|
732
|
+
#ifndef CO_VARKEYWORDS
|
|
733
|
+
static int CO_VARKEYWORDS;
|
|
734
|
+
#endif
|
|
735
|
+
#ifndef CO_ASYNC_GENERATOR
|
|
736
|
+
static int CO_ASYNC_GENERATOR;
|
|
737
|
+
#endif
|
|
738
|
+
#ifndef CO_GENERATOR
|
|
739
|
+
static int CO_GENERATOR;
|
|
740
|
+
#endif
|
|
741
|
+
#ifndef CO_COROUTINE
|
|
742
|
+
static int CO_COROUTINE;
|
|
743
|
+
#endif
|
|
744
|
+
#else
|
|
745
|
+
#ifndef CO_COROUTINE
|
|
746
|
+
#define CO_COROUTINE 0x80
|
|
747
|
+
#endif
|
|
748
|
+
#ifndef CO_ASYNC_GENERATOR
|
|
749
|
+
#define CO_ASYNC_GENERATOR 0x200
|
|
750
|
+
#endif
|
|
751
|
+
#endif
|
|
752
|
+
static int __Pyx_init_co_variables(void); /* proto */
|
|
753
|
+
|
|
754
|
+
#if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_Is)
|
|
755
|
+
#define __Pyx_Py_Is(x, y) Py_Is(x, y)
|
|
756
|
+
#else
|
|
757
|
+
#define __Pyx_Py_Is(x, y) ((x) == (y))
|
|
758
|
+
#endif
|
|
759
|
+
#if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_IsNone)
|
|
760
|
+
#define __Pyx_Py_IsNone(ob) Py_IsNone(ob)
|
|
761
|
+
#else
|
|
762
|
+
#define __Pyx_Py_IsNone(ob) __Pyx_Py_Is((ob), Py_None)
|
|
763
|
+
#endif
|
|
764
|
+
#if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_IsTrue)
|
|
765
|
+
#define __Pyx_Py_IsTrue(ob) Py_IsTrue(ob)
|
|
766
|
+
#else
|
|
767
|
+
#define __Pyx_Py_IsTrue(ob) __Pyx_Py_Is((ob), Py_True)
|
|
768
|
+
#endif
|
|
769
|
+
#if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_IsFalse)
|
|
770
|
+
#define __Pyx_Py_IsFalse(ob) Py_IsFalse(ob)
|
|
771
|
+
#else
|
|
772
|
+
#define __Pyx_Py_IsFalse(ob) __Pyx_Py_Is((ob), Py_False)
|
|
773
|
+
#endif
|
|
774
|
+
#define __Pyx_NoneAsNull(obj) (__Pyx_Py_IsNone(obj) ? NULL : (obj))
|
|
775
|
+
|
|
776
|
+
#if CYTHON_COMPILING_IN_PYPY
|
|
777
|
+
#define __Pyx_PyObject_GC_IsFinalized(o) _PyGC_FINALIZED(o)
|
|
778
|
+
#else
|
|
779
|
+
#define __Pyx_PyObject_GC_IsFinalized(o) PyObject_GC_IsFinalized(o)
|
|
780
|
+
#endif
|
|
781
|
+
|
|
782
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
783
|
+
// These can be deduced at runtime and are enough of an optimization that
|
|
784
|
+
// it's worth doing (while still respecting the decision not to add them to
|
|
785
|
+
// the Limited API).
|
|
786
|
+
static unsigned long __Pyx_Runtime_TPFLAGS_SEQUENCE;
|
|
787
|
+
static unsigned long __Pyx_Runtime_TPFLAGS_MAPPING;
|
|
788
|
+
#else
|
|
789
|
+
#define __Pyx_Runtime_TPFLAGS_SEQUENCE Py_TPFLAGS_SEQUENCE
|
|
790
|
+
#define __Pyx_Runtime_TPFLAGS_MAPPING Py_TPFLAGS_MAPPING
|
|
791
|
+
#endif
|
|
792
|
+
|
|
793
|
+
static int __Pyx_init_tpflags_variables(void); /* proto */
|
|
794
|
+
|
|
795
|
+
#ifndef Py_TPFLAGS_HAVE_FINALIZE
|
|
796
|
+
#define Py_TPFLAGS_HAVE_FINALIZE 0
|
|
797
|
+
#endif
|
|
798
|
+
#ifndef Py_TPFLAGS_SEQUENCE
|
|
799
|
+
#define Py_TPFLAGS_SEQUENCE (CYTHON_COMPILING_IN_LIMITED_API ? 0 : 1 << 5)
|
|
800
|
+
#endif
|
|
801
|
+
#ifndef Py_TPFLAGS_MAPPING
|
|
802
|
+
#define Py_TPFLAGS_MAPPING (CYTHON_COMPILING_IN_LIMITED_API ? 0 : 1 << 6)
|
|
803
|
+
#endif
|
|
804
|
+
#ifndef Py_TPFLAGS_IMMUTABLETYPE
|
|
805
|
+
#define Py_TPFLAGS_IMMUTABLETYPE (1UL << 8)
|
|
806
|
+
#endif
|
|
807
|
+
#ifndef Py_TPFLAGS_DISALLOW_INSTANTIATION
|
|
808
|
+
#define Py_TPFLAGS_DISALLOW_INSTANTIATION (1UL << 7)
|
|
809
|
+
#endif
|
|
810
|
+
|
|
811
|
+
#ifndef METH_STACKLESS
|
|
812
|
+
// Now unused. Already defined for Stackless Python (all versions) and C-Python >= 3.7.
|
|
813
|
+
// Value if defined: Stackless Python < 3.6: 0x80 else 0x100.
|
|
814
|
+
#define METH_STACKLESS 0
|
|
815
|
+
#endif
|
|
816
|
+
#if !defined(METH_FASTCALL) || CYTHON_COMPILING_IN_PYPY
|
|
817
|
+
// new in CPython 3.6, but changed in 3.7 - see
|
|
818
|
+
// positional-only parameters:
|
|
819
|
+
// https://bugs.python.org/issue29464
|
|
820
|
+
// const args:
|
|
821
|
+
// https://bugs.python.org/issue32240
|
|
822
|
+
// PyPy doesn't have the const args.
|
|
823
|
+
#ifndef METH_FASTCALL
|
|
824
|
+
#define METH_FASTCALL 0x80
|
|
825
|
+
#endif
|
|
826
|
+
typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
|
|
827
|
+
// new in CPython 3.7, used to be old signature of _PyCFunctionFast() in 3.6
|
|
828
|
+
typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
|
|
829
|
+
Py_ssize_t nargs, PyObject *kwnames);
|
|
830
|
+
#else
|
|
831
|
+
#if PY_VERSION_HEX >= 0x030d00A4
|
|
832
|
+
# define __Pyx_PyCFunctionFast PyCFunctionFast
|
|
833
|
+
# define __Pyx_PyCFunctionFastWithKeywords PyCFunctionFastWithKeywords
|
|
834
|
+
#else
|
|
835
|
+
# define __Pyx_PyCFunctionFast _PyCFunctionFast
|
|
836
|
+
# define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
|
|
837
|
+
#endif
|
|
838
|
+
#endif
|
|
839
|
+
|
|
840
|
+
#if CYTHON_VECTORCALL
|
|
841
|
+
#define __Pyx_METH_FASTCALL METH_FASTCALL
|
|
842
|
+
#define __Pyx_PyCFunction_FastCall __Pyx_PyCFunctionFast
|
|
843
|
+
#define __Pyx_PyCFunction_FastCallWithKeywords __Pyx_PyCFunctionFastWithKeywords
|
|
844
|
+
#else
|
|
845
|
+
#define __Pyx_METH_FASTCALL METH_VARARGS
|
|
846
|
+
#define __Pyx_PyCFunction_FastCall PyCFunction
|
|
847
|
+
#define __Pyx_PyCFunction_FastCallWithKeywords PyCFunctionWithKeywords
|
|
848
|
+
#endif
|
|
849
|
+
|
|
850
|
+
#if CYTHON_VECTORCALL
|
|
851
|
+
#define __pyx_vectorcallfunc vectorcallfunc
|
|
852
|
+
#define __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET PY_VECTORCALL_ARGUMENTS_OFFSET
|
|
853
|
+
#define __Pyx_PyVectorcall_NARGS(n) PyVectorcall_NARGS((size_t)(n))
|
|
854
|
+
#else
|
|
855
|
+
#define __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET 0
|
|
856
|
+
#define __Pyx_PyVectorcall_NARGS(n) ((Py_ssize_t)(n))
|
|
857
|
+
#endif
|
|
858
|
+
|
|
859
|
+
// These PyCFunction related macros get redefined in CythonFunction.c.
|
|
860
|
+
// We need our own copies because the inline functions in CPython have a type-check assert
|
|
861
|
+
// that breaks with a CyFunction in debug mode.
|
|
862
|
+
#define __Pyx_PyCFunction_CheckExact(func) PyCFunction_CheckExact(func)
|
|
863
|
+
#define __Pyx_CyOrPyCFunction_Check(func) PyCFunction_Check(func)
|
|
864
|
+
|
|
865
|
+
#if CYTHON_COMPILING_IN_CPYTHON
|
|
866
|
+
#define __Pyx_CyOrPyCFunction_GET_FUNCTION(func) (((PyCFunctionObject*)(func))->m_ml->ml_meth)
|
|
867
|
+
#elif !CYTHON_COMPILING_IN_LIMITED_API
|
|
868
|
+
// It's probably easier for non-CPythons to support PyCFunction_GET_FUNCTION() than the object struct layout.
|
|
869
|
+
#define __Pyx_CyOrPyCFunction_GET_FUNCTION(func) PyCFunction_GET_FUNCTION(func)
|
|
870
|
+
// Unused in CYTHON_COMPILING_IN_LIMITED_API.
|
|
871
|
+
#endif
|
|
872
|
+
#if CYTHON_COMPILING_IN_CPYTHON
|
|
873
|
+
#define __Pyx_CyOrPyCFunction_GET_FLAGS(func) (((PyCFunctionObject*)(func))->m_ml->ml_flags)
|
|
874
|
+
static CYTHON_INLINE PyObject* __Pyx_CyOrPyCFunction_GET_SELF(PyObject *func) {
|
|
875
|
+
return (__Pyx_CyOrPyCFunction_GET_FLAGS(func) & METH_STATIC) ? NULL : ((PyCFunctionObject*)func)->m_self;
|
|
876
|
+
}
|
|
877
|
+
// Only used if CYTHON_COMPILING_IN_CPYTHON.
|
|
878
|
+
#endif
|
|
879
|
+
static CYTHON_INLINE int __Pyx__IsSameCFunction(PyObject *func, void (*cfunc)(void)) {
|
|
880
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
881
|
+
return PyCFunction_Check(func) && PyCFunction_GetFunction(func) == (PyCFunction) cfunc;
|
|
882
|
+
#else
|
|
883
|
+
return PyCFunction_Check(func) && PyCFunction_GET_FUNCTION(func) == (PyCFunction) cfunc;
|
|
884
|
+
#endif
|
|
885
|
+
}
|
|
886
|
+
#define __Pyx_IsSameCFunction(func, cfunc) __Pyx__IsSameCFunction(func, cfunc)
|
|
887
|
+
|
|
888
|
+
// PEP-573: PyCFunction holds reference to defining class (PyCMethodObject)
|
|
889
|
+
#if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
|
|
890
|
+
#define __Pyx_PyType_FromModuleAndSpec(m, s, b) ((void)m, PyType_FromSpecWithBases(s, b))
|
|
891
|
+
#else
|
|
892
|
+
#define __Pyx_PyType_FromModuleAndSpec(m, s, b) PyType_FromModuleAndSpec(m, s, b)
|
|
893
|
+
#endif
|
|
894
|
+
#if CYTHON_COMPILING_IN_PYPY
|
|
895
|
+
// PyPy's internal definition misses the const
|
|
896
|
+
typedef PyObject *(*__Pyx_PyCMethod)(PyObject *, PyTypeObject *, PyObject *const *, size_t, PyObject *);
|
|
897
|
+
#else
|
|
898
|
+
#define __Pyx_PyCMethod PyCMethod
|
|
899
|
+
#endif
|
|
900
|
+
#ifndef METH_METHOD
|
|
901
|
+
#define METH_METHOD 0x200
|
|
902
|
+
#endif
|
|
903
|
+
|
|
904
|
+
#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x030C0000 && !defined(PyObject_Malloc)
|
|
905
|
+
#define PyObject_Malloc(s) PyMem_Malloc(s)
|
|
906
|
+
#define PyObject_Free(p) PyMem_Free(p)
|
|
907
|
+
#define PyObject_Realloc(p) PyMem_Realloc(p)
|
|
908
|
+
#endif
|
|
909
|
+
|
|
910
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
911
|
+
// __Pyx_PyCode_HasFreeVars isn't easily emulated in the limited API (but isn't really necessary)
|
|
912
|
+
#define __Pyx_PyFrame_SetLineNumber(frame, lineno)
|
|
913
|
+
#elif CYTHON_COMPILING_IN_GRAAL && defined(GRAALPY_VERSION_NUM) && GRAALPY_VERSION_NUM > 0x19000000
|
|
914
|
+
#define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
|
|
915
|
+
#define __Pyx_PyFrame_SetLineNumber(frame, lineno) GraalPyFrame_SetLineNumber((frame), (lineno))
|
|
916
|
+
#elif CYTHON_COMPILING_IN_GRAAL
|
|
917
|
+
// Remove when GraalPy 24 goes EOL
|
|
918
|
+
#define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
|
|
919
|
+
#define __Pyx_PyFrame_SetLineNumber(frame, lineno) _PyFrame_SetLineNumber((frame), (lineno))
|
|
920
|
+
#else
|
|
921
|
+
#define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
|
|
922
|
+
#define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
|
|
923
|
+
#endif
|
|
924
|
+
|
|
925
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
926
|
+
#define __Pyx_PyThreadState_Current PyThreadState_Get()
|
|
927
|
+
#elif !CYTHON_FAST_THREAD_STATE
|
|
928
|
+
#define __Pyx_PyThreadState_Current PyThreadState_GET()
|
|
929
|
+
#elif PY_VERSION_HEX >= 0x030d00A1
|
|
930
|
+
#define __Pyx_PyThreadState_Current PyThreadState_GetUnchecked()
|
|
931
|
+
#else
|
|
932
|
+
#define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
|
|
933
|
+
#endif
|
|
934
|
+
|
|
935
|
+
// For our shared types, they are only ever opaque in the Limited API.
|
|
936
|
+
// While there may be a reason to let users override their own types,
|
|
937
|
+
// there's no benefit to changing our internal types except in the Limited API.
|
|
938
|
+
#if CYTHON_OPAQUE_OBJECTS && CYTHON_COMPILING_IN_LIMITED_API
|
|
939
|
+
#define __PYX_SHARED_SIZEOF(T) -((int)sizeof(T))
|
|
940
|
+
#define __PYX_SHARED_RELATIVE_OFFSET Py_RELATIVE_OFFSET
|
|
941
|
+
#define CYTHON_OPAQUE_SHARED_TYPES 1
|
|
942
|
+
#else
|
|
943
|
+
#define __PYX_SHARED_SIZEOF(T) sizeof(T)
|
|
944
|
+
#define __PYX_SHARED_RELATIVE_OFFSET 0
|
|
945
|
+
#define CYTHON_OPAQUE_SHARED_TYPES 0
|
|
946
|
+
#endif
|
|
947
|
+
|
|
948
|
+
#if CYTHON_USE_MODULE_STATE
|
|
949
|
+
static CYTHON_INLINE void *__Pyx__PyModule_GetState(PyObject *op)
|
|
950
|
+
{
|
|
951
|
+
void *result;
|
|
952
|
+
|
|
953
|
+
result = PyModule_GetState(op);
|
|
954
|
+
if (!result)
|
|
955
|
+
Py_FatalError("Couldn't find the module state");
|
|
956
|
+
return result;
|
|
957
|
+
}
|
|
958
|
+
// Define a macro with a cast because the modulestate type isn't known yet and
|
|
959
|
+
// is a typedef struct so impossible to forward declare
|
|
960
|
+
#define __Pyx_PyModule_GetState(o) ($modulestatetype_cname *)__Pyx__PyModule_GetState(o)
|
|
961
|
+
#else
|
|
962
|
+
#define __Pyx_PyModule_GetState(op) ((void)op,$modulestateglobal_cname)
|
|
963
|
+
#endif
|
|
964
|
+
|
|
965
|
+
// The "Try" variants may return NULL on static types with the Limited API on earlier versions
|
|
966
|
+
// so should be used for optimization rather than where a result is required.
|
|
967
|
+
#define __Pyx_PyObject_GetSlot(obj, name, func_ctype) __Pyx_PyType_GetSlot(Py_TYPE((PyObject *) obj), name, func_ctype)
|
|
968
|
+
#define __Pyx_PyObject_TryGetSlot(obj, name, func_ctype) __Pyx_PyType_TryGetSlot(Py_TYPE(obj), name, func_ctype)
|
|
969
|
+
#define __Pyx_PyObject_GetSubSlot(obj, sub, name, func_ctype) __Pyx_PyType_GetSubSlot(Py_TYPE(obj), sub, name, func_ctype)
|
|
970
|
+
#define __Pyx_PyObject_TryGetSubSlot(obj, sub, name, func_ctype) __Pyx_PyType_TryGetSubSlot(Py_TYPE(obj), sub, name, func_ctype)
|
|
971
|
+
#if CYTHON_USE_TYPE_SLOTS
|
|
972
|
+
#define __Pyx_PyType_GetSlot(type, name, func_ctype) ((type)->name)
|
|
973
|
+
#define __Pyx_PyType_TryGetSlot(type, name, func_ctype) __Pyx_PyType_GetSlot(type, name, func_ctype)
|
|
974
|
+
#define __Pyx_PyType_GetSubSlot(type, sub, name, func_ctype) (((type)->sub) ? ((type)->sub->name) : NULL)
|
|
975
|
+
#define __Pyx_PyType_TryGetSubSlot(type, sub, name, func_ctype) __Pyx_PyType_GetSubSlot(type, sub, name, func_ctype)
|
|
976
|
+
#else
|
|
977
|
+
#define __Pyx_PyType_GetSlot(type, name, func_ctype) ((func_ctype) PyType_GetSlot((type), Py_##name))
|
|
978
|
+
#define __Pyx_PyType_TryGetSlot(type, name, func_ctype) \
|
|
979
|
+
((__PYX_LIMITED_VERSION_HEX >= 0x030A0000 || \
|
|
980
|
+
(PyType_GetFlags(type) & Py_TPFLAGS_HEAPTYPE) || __Pyx_get_runtime_version() >= 0x030A0000) ? \
|
|
981
|
+
__Pyx_PyType_GetSlot(type, name, func_ctype) : NULL)
|
|
982
|
+
#define __Pyx_PyType_GetSubSlot(obj, sub, name, func_ctype) __Pyx_PyType_GetSlot(obj, name, func_ctype)
|
|
983
|
+
#define __Pyx_PyType_TryGetSubSlot(obj, sub, name, func_ctype) __Pyx_PyType_TryGetSlot(obj, name, func_ctype)
|
|
984
|
+
#endif
|
|
985
|
+
|
|
986
|
+
#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
|
|
987
|
+
#define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
|
|
988
|
+
#else
|
|
989
|
+
#define __Pyx_PyDict_NewPresized(n) PyDict_New()
|
|
990
|
+
#endif
|
|
991
|
+
|
|
992
|
+
#define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
|
|
993
|
+
#define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
|
|
994
|
+
|
|
995
|
+
#if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_UNICODE_INTERNALS
|
|
996
|
+
// _PyDict_GetItem_KnownHash() existed from CPython 3.5 to 3.12, but it was
|
|
997
|
+
// dropping exceptions in 3.5. Since 3.6, exceptions are kept.
|
|
998
|
+
#define __Pyx_PyDict_GetItemStrWithError(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
|
|
999
|
+
static CYTHON_INLINE PyObject * __Pyx_PyDict_GetItemStr(PyObject *dict, PyObject *name) {
|
|
1000
|
+
PyObject *res = __Pyx_PyDict_GetItemStrWithError(dict, name);
|
|
1001
|
+
if (res == NULL && PyErr_Occurred()) {
|
|
1002
|
+
// Like PyDict_GetItem, this is a bit indiscriminate about catching *all* errors.
|
|
1003
|
+
// Recent versions of Python format any unraised exception so do that too here.
|
|
1004
|
+
PyErr_WriteUnraisable(NULL);
|
|
1005
|
+
}
|
|
1006
|
+
return res;
|
|
1007
|
+
}
|
|
1008
|
+
#elif !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07020000
|
|
1009
|
+
#define __Pyx_PyDict_GetItemStrWithError PyDict_GetItemWithError
|
|
1010
|
+
#define __Pyx_PyDict_GetItemStr PyDict_GetItem
|
|
1011
|
+
#else
|
|
1012
|
+
static CYTHON_INLINE PyObject * __Pyx_PyDict_GetItemStrWithError(PyObject *dict, PyObject *name) {
|
|
1013
|
+
// This is tricky - we should return a borrowed reference but not swallow non-KeyError exceptions. 8-|
|
|
1014
|
+
// But: this function is only used in Py2 and older PyPys,
|
|
1015
|
+
// and currently only for argument parsing and other non-correctness-critical lookups
|
|
1016
|
+
// and we know that 'name' is an interned 'str' with pre-calculated hash value (only comparisons can fail),
|
|
1017
|
+
// thus, performance matters more than correctness here, especially in the "not found" case.
|
|
1018
|
+
#if CYTHON_COMPILING_IN_PYPY
|
|
1019
|
+
// So we ignore any exceptions in old PyPys ...
|
|
1020
|
+
return PyDict_GetItem(dict, name);
|
|
1021
|
+
#else
|
|
1022
|
+
// and hack together a stripped-down and modified PyDict_GetItem() in CPython 2.
|
|
1023
|
+
PyDictEntry *ep;
|
|
1024
|
+
PyDictObject *mp = (PyDictObject*) dict;
|
|
1025
|
+
long hash = ((PyStringObject *) name)->ob_shash;
|
|
1026
|
+
assert(hash != -1); /* hash values of interned strings are always initialised */
|
|
1027
|
+
ep = (mp->ma_lookup)(mp, name, hash);
|
|
1028
|
+
if (ep == NULL) {
|
|
1029
|
+
// error occurred
|
|
1030
|
+
return NULL;
|
|
1031
|
+
}
|
|
1032
|
+
// found or not found
|
|
1033
|
+
return ep->me_value;
|
|
1034
|
+
#endif
|
|
1035
|
+
}
|
|
1036
|
+
#define __Pyx_PyDict_GetItemStr PyDict_GetItem
|
|
1037
|
+
#endif
|
|
1038
|
+
|
|
1039
|
+
/* Type slots */
|
|
1040
|
+
|
|
1041
|
+
#if CYTHON_USE_TYPE_SLOTS
|
|
1042
|
+
#define __Pyx_PyType_GetFlags(tp) (((PyTypeObject *)tp)->tp_flags)
|
|
1043
|
+
#define __Pyx_PyType_HasFeature(type, feature) ((__Pyx_PyType_GetFlags(type) & (feature)) != 0)
|
|
1044
|
+
#else
|
|
1045
|
+
#define __Pyx_PyType_GetFlags(tp) (PyType_GetFlags((PyTypeObject *)tp))
|
|
1046
|
+
#define __Pyx_PyType_HasFeature(type, feature) PyType_HasFeature(type, feature)
|
|
1047
|
+
#endif
|
|
1048
|
+
|
|
1049
|
+
// There is no replacement for "Py_TYPE(obj)->iternext" in the C-API.
|
|
1050
|
+
// PyIter_Next() discards the StopIteration, unlike Python's "next()".
|
|
1051
|
+
#define __Pyx_PyObject_GetIterNextFunc(iterator) __Pyx_PyObject_GetSlot(iterator, tp_iternext, iternextfunc)
|
|
1052
|
+
|
|
1053
|
+
#if CYTHON_USE_TYPE_SPECS
|
|
1054
|
+
// In Py3.8+, instances of heap types need to decref their type on deallocation.
|
|
1055
|
+
// https://bugs.python.org/issue35810
|
|
1056
|
+
#define __Pyx_PyHeapTypeObject_GC_Del(obj) { \
|
|
1057
|
+
PyTypeObject *type = Py_TYPE((PyObject*)obj); \
|
|
1058
|
+
assert(__Pyx_PyType_HasFeature(type, Py_TPFLAGS_HEAPTYPE)); \
|
|
1059
|
+
PyObject_GC_Del(obj); \
|
|
1060
|
+
Py_DECREF(type); \
|
|
1061
|
+
}
|
|
1062
|
+
#else
|
|
1063
|
+
#define __Pyx_PyHeapTypeObject_GC_Del(obj) PyObject_GC_Del(obj)
|
|
1064
|
+
#endif
|
|
1065
|
+
|
|
1066
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
1067
|
+
#define __Pyx_PyUnicode_READY(op) (0)
|
|
1068
|
+
#define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_ReadChar(u, i)
|
|
1069
|
+
#define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((void)u, 1114111U)
|
|
1070
|
+
#define __Pyx_PyUnicode_KIND(u) ((void)u, (0))
|
|
1071
|
+
#define __Pyx_PyUnicode_KIND_04(u) __Pyx_PyUnicode_KIND(u)
|
|
1072
|
+
// __Pyx_PyUnicode_DATA() and __Pyx_PyUnicode_READ() must go together, e.g. for iteration.
|
|
1073
|
+
#define __Pyx_PyUnicode_DATA(u) ((void*)u)
|
|
1074
|
+
#define __Pyx_PyUnicode_READ(k, d, i) ((void)k, PyUnicode_ReadChar((PyObject*)(d), i))
|
|
1075
|
+
//#define __Pyx_PyUnicode_WRITE(k, d, i, ch) /* not available */
|
|
1076
|
+
#define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GetLength(u))
|
|
1077
|
+
#else
|
|
1078
|
+
#if PY_VERSION_HEX >= 0x030C0000
|
|
1079
|
+
// Py3.12 / PEP-623 removed wstr type unicode strings and all of the PyUnicode_READY() machinery.
|
|
1080
|
+
#define __Pyx_PyUnicode_READY(op) (0)
|
|
1081
|
+
#else
|
|
1082
|
+
#define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ? \
|
|
1083
|
+
0 : _PyUnicode_Ready((PyObject *)(op)))
|
|
1084
|
+
#endif
|
|
1085
|
+
|
|
1086
|
+
#define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
|
|
1087
|
+
#define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
|
|
1088
|
+
#define __Pyx_PyUnicode_KIND(u) ((int)PyUnicode_KIND(u))
|
|
1089
|
+
#define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
|
|
1090
|
+
#define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
|
|
1091
|
+
#define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, (Py_UCS4) ch)
|
|
1092
|
+
#if PY_VERSION_HEX >= 0x030C0000
|
|
1093
|
+
#define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_LENGTH(u))
|
|
1094
|
+
#else
|
|
1095
|
+
#if CYTHON_COMPILING_IN_CPYTHON
|
|
1096
|
+
// Avoid calling deprecated C-API functions in Py3.9+ that PEP-623 schedules for removal in Py3.12.
|
|
1097
|
+
// https://www.python.org/dev/peps/pep-0623/
|
|
1098
|
+
#define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : ((PyCompactUnicodeObject *)(u))->wstr_length))
|
|
1099
|
+
#else
|
|
1100
|
+
#define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
|
|
1101
|
+
#endif
|
|
1102
|
+
#endif
|
|
1103
|
+
|
|
1104
|
+
static CYTHON_INLINE int __Pyx_PyUnicode_KIND_04(PyObject *o) {
|
|
1105
|
+
// Returns 0 for ASCII strings and KIND (1, 2, 4) otherwise.
|
|
1106
|
+
return __Pyx_PyUnicode_KIND(o) - (int) !!PyUnicode_IS_ASCII(o);
|
|
1107
|
+
}
|
|
1108
|
+
#endif
|
|
1109
|
+
|
|
1110
|
+
#if CYTHON_COMPILING_IN_PYPY
|
|
1111
|
+
#define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
|
|
1112
|
+
#define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
|
|
1113
|
+
#else
|
|
1114
|
+
#define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
|
|
1115
|
+
#define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ? \
|
|
1116
|
+
PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
|
|
1117
|
+
#endif
|
|
1118
|
+
|
|
1119
|
+
#if CYTHON_COMPILING_IN_PYPY
|
|
1120
|
+
#if !defined(PyUnicode_DecodeUnicodeEscape)
|
|
1121
|
+
#define PyUnicode_DecodeUnicodeEscape(s, size, errors) PyUnicode_Decode(s, size, "unicode_escape", errors)
|
|
1122
|
+
#endif
|
|
1123
|
+
#if PY_VERSION_HEX < 0x030C0000 && !defined(PyUnicode_Contains)
|
|
1124
|
+
#define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
|
|
1125
|
+
#endif
|
|
1126
|
+
#if !defined(PyByteArray_Check)
|
|
1127
|
+
#define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
|
|
1128
|
+
#endif
|
|
1129
|
+
#if PY_VERSION_HEX < 0x030C0000 && !defined(PyObject_Format)
|
|
1130
|
+
#define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
|
|
1131
|
+
#endif
|
|
1132
|
+
#endif
|
|
1133
|
+
|
|
1134
|
+
// ("..." % x) must call PyNumber_Remainder() if x is a string subclass that implements "__rmod__()".
|
|
1135
|
+
#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
|
|
1136
|
+
|
|
1137
|
+
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
|
|
1138
|
+
#define __Pyx_PySequence_ListKeepNew(obj) \
|
|
1139
|
+
(likely(PyList_CheckExact(obj) && PyUnstable_Object_IsUniquelyReferenced(obj)) ? __Pyx_NewRef(obj) : PySequence_List(obj))
|
|
1140
|
+
#elif CYTHON_COMPILING_IN_CPYTHON
|
|
1141
|
+
#define __Pyx_PySequence_ListKeepNew(obj) \
|
|
1142
|
+
(likely(PyList_CheckExact(obj) && Py_REFCNT(obj) == 1) ? __Pyx_NewRef(obj) : PySequence_List(obj))
|
|
1143
|
+
#else
|
|
1144
|
+
#define __Pyx_PySequence_ListKeepNew(obj) PySequence_List(obj)
|
|
1145
|
+
#endif
|
|
1146
|
+
|
|
1147
|
+
#ifndef PySet_CheckExact
|
|
1148
|
+
#define PySet_CheckExact(obj) Py_IS_TYPE(obj, &PySet_Type)
|
|
1149
|
+
#endif
|
|
1150
|
+
|
|
1151
|
+
enum __Pyx_ReferenceSharing {
|
|
1152
|
+
__Pyx_ReferenceSharing_DefinitelyUnique, // We created it so we know it's unshared - no need to check
|
|
1153
|
+
__Pyx_ReferenceSharing_OwnStrongReference,
|
|
1154
|
+
__Pyx_ReferenceSharing_FunctionArgument,
|
|
1155
|
+
__Pyx_ReferenceSharing_SharedReference, // Never trust it to be unshared because it's a global or similar
|
|
1156
|
+
};
|
|
1157
|
+
|
|
1158
|
+
#if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING && PY_VERSION_HEX >= 0x030E0000
|
|
1159
|
+
#define __Pyx_IS_UNIQUELY_REFERENCED(o, sharing) \
|
|
1160
|
+
(sharing == __Pyx_ReferenceSharing_DefinitelyUnique ? 1 : \
|
|
1161
|
+
(sharing == __Pyx_ReferenceSharing_FunctionArgument ? PyUnstable_Object_IsUniqueReferencedTemporary(o) : \
|
|
1162
|
+
(sharing == __Pyx_ReferenceSharing_OwnStrongReference ? PyUnstable_Object_IsUniquelyReferenced(o) : 0)))
|
|
1163
|
+
#elif (CYTHON_COMPILING_IN_CPYTHON && !CYTHON_COMPILING_IN_CPYTHON_FREETHREADING) || CYTHON_COMPILING_IN_LIMITED_API
|
|
1164
|
+
#define __Pyx_IS_UNIQUELY_REFERENCED(o, sharing) (((void)sharing), Py_REFCNT(o) == 1)
|
|
1165
|
+
#else
|
|
1166
|
+
// On other platforms we don't trust the refcount so don't optimize based on it
|
|
1167
|
+
#define __Pyx_IS_UNIQUELY_REFERENCED(o, sharing) (((void)o), ((void)sharing), 0)
|
|
1168
|
+
#endif
|
|
1169
|
+
|
|
1170
|
+
|
|
1171
|
+
// __Pyx_PyList_GetItemRef(): return safely owned reference, bounds checking, no wraparound
|
|
1172
|
+
#if __PYX_LIMITED_VERSION_HEX >= 0x030d0000
|
|
1173
|
+
#define __Pyx_PyList_GetItemRef(o, i) PyList_GetItemRef(o, i)
|
|
1174
|
+
#elif CYTHON_AVOID_BORROWED_REFS || CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS
|
|
1175
|
+
#if CYTHON_COMPILING_IN_LIMITED_API || !CYTHON_ASSUME_SAFE_MACROS
|
|
1176
|
+
#define __Pyx_PyList_GetItemRef(o, i) (likely((i) >= 0) ? PySequence_GetItem(o, i) : (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
|
|
1177
|
+
#else
|
|
1178
|
+
#define __Pyx_PyList_GetItemRef(o, i) PySequence_ITEM(o, i)
|
|
1179
|
+
#endif
|
|
1180
|
+
#elif CYTHON_COMPILING_IN_LIMITED_API || !(CYTHON_ASSUME_SAFE_MACROS && CYTHON_ASSUME_SAFE_SIZE)
|
|
1181
|
+
#define __Pyx_PyList_GetItemRef(o, i) __Pyx_XNewRef(PyList_GetItem(o, i))
|
|
1182
|
+
#else
|
|
1183
|
+
#define __Pyx_PyList_GetItemRef(o, i) (likely(__Pyx_is_valid_index(i, PyList_GET_SIZE(o))) ? \
|
|
1184
|
+
__Pyx_NewRef(PyList_GET_ITEM(o, i)) : (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
|
|
1185
|
+
#endif
|
|
1186
|
+
|
|
1187
|
+
// __Pyx_PyList_GET_ITEM_REF(): return safely owned reference, no bounds checking (if avoidable), no wraparound
|
|
1188
|
+
#if CYTHON_AVOID_BORROWED_REFS || CYTHON_COMPILING_IN_LIMITED_API
|
|
1189
|
+
#define __Pyx_PyList_GET_ITEM_REF(o, i, unsafe_shared) ((void)(unsafe_shared), \
|
|
1190
|
+
__Pyx_PyList_GetItemRef(o, i))
|
|
1191
|
+
#elif CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS
|
|
1192
|
+
#if CYTHON_ASSUME_SAFE_MACROS
|
|
1193
|
+
#define __Pyx_PyList_GET_ITEM_REF(o, i, unsafe_shared) ( \
|
|
1194
|
+
__Pyx_IS_UNIQUELY_REFERENCED(o, unsafe_shared) ? \
|
|
1195
|
+
__Pyx_NewRef(PyList_GET_ITEM(o, i)) : __Pyx_PyList_GetItemRef(o, i))
|
|
1196
|
+
#else
|
|
1197
|
+
#define __Pyx_PyList_GET_ITEM_REF(o, i, unsafe_shared) ( \
|
|
1198
|
+
__Pyx_IS_UNIQUELY_REFERENCED(o, unsafe_shared) ? \
|
|
1199
|
+
__Pyx_XNewRef(PyList_GetItem(o, i)) : __Pyx_PyList_GetItemRef(o, i))
|
|
1200
|
+
#endif
|
|
1201
|
+
#elif CYTHON_ASSUME_SAFE_MACROS
|
|
1202
|
+
#define __Pyx_PyList_GET_ITEM_REF(o, i, unsafe_shared) ((void)(unsafe_shared), \
|
|
1203
|
+
__Pyx_NewRef(PyList_GET_ITEM(o, i)))
|
|
1204
|
+
#else
|
|
1205
|
+
#define __Pyx_PyList_GET_ITEM_REF(o, i, unsafe_shared) ((void)(unsafe_shared), \
|
|
1206
|
+
__Pyx_XNewRef(PyList_GetItem(o, i)))
|
|
1207
|
+
#endif
|
|
1208
|
+
|
|
1209
|
+
#if __PYX_LIMITED_VERSION_HEX >= 0x030d0000
|
|
1210
|
+
#define __Pyx_PyDict_GetItemRef(dict, key, result) PyDict_GetItemRef(dict, key, result)
|
|
1211
|
+
#elif CYTHON_AVOID_BORROWED_REFS || CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS
|
|
1212
|
+
static CYTHON_INLINE int __Pyx_PyDict_GetItemRef(PyObject *dict, PyObject *key, PyObject **result) {
|
|
1213
|
+
*result = PyObject_GetItem(dict, key);
|
|
1214
|
+
if (*result == NULL) {
|
|
1215
|
+
if (PyErr_ExceptionMatches(PyExc_KeyError)) {
|
|
1216
|
+
PyErr_Clear();
|
|
1217
|
+
return 0;
|
|
1218
|
+
}
|
|
1219
|
+
return -1;
|
|
1220
|
+
}
|
|
1221
|
+
return 1;
|
|
1222
|
+
}
|
|
1223
|
+
#else
|
|
1224
|
+
static CYTHON_INLINE int __Pyx_PyDict_GetItemRef(PyObject *dict, PyObject *key, PyObject **result) {
|
|
1225
|
+
*result = PyDict_GetItemWithError(dict, key);
|
|
1226
|
+
if (*result == NULL) {
|
|
1227
|
+
return PyErr_Occurred() ? -1 : 0;
|
|
1228
|
+
}
|
|
1229
|
+
Py_INCREF(*result);
|
|
1230
|
+
return 1;
|
|
1231
|
+
}
|
|
1232
|
+
#endif
|
|
1233
|
+
|
|
1234
|
+
// No-op macro for calling Py_VISIT() on known constants that can never participate in reference cycles.
|
|
1235
|
+
// Users can define "CYTHON_DEBUG_VISIT_CONST=1" to help in debugging reference issues.
|
|
1236
|
+
#if defined(CYTHON_DEBUG_VISIT_CONST) && CYTHON_DEBUG_VISIT_CONST
|
|
1237
|
+
#define __Pyx_VISIT_CONST(obj) Py_VISIT(obj)
|
|
1238
|
+
#else
|
|
1239
|
+
#define __Pyx_VISIT_CONST(obj)
|
|
1240
|
+
#endif
|
|
1241
|
+
|
|
1242
|
+
#if CYTHON_ASSUME_SAFE_MACROS
|
|
1243
|
+
#define __Pyx_PySequence_ITEM(o, i) PySequence_ITEM(o, i)
|
|
1244
|
+
#define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq)
|
|
1245
|
+
#define __Pyx_PyTuple_SET_ITEM(o, i, v) (PyTuple_SET_ITEM(o, i, v), (0))
|
|
1246
|
+
#define __Pyx_PyTuple_GET_ITEM(o, i) PyTuple_GET_ITEM(o, i)
|
|
1247
|
+
#define __Pyx_PyList_SET_ITEM(o, i, v) (PyList_SET_ITEM(o, i, v), (0))
|
|
1248
|
+
#define __Pyx_PyList_GET_ITEM(o, i) PyList_GET_ITEM(o, i)
|
|
1249
|
+
#else
|
|
1250
|
+
// NOTE: implements wrap-around
|
|
1251
|
+
#define __Pyx_PySequence_ITEM(o, i) PySequence_GetItem(o, i)
|
|
1252
|
+
// NOTE: might fail with exception => check for -1
|
|
1253
|
+
#define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq)
|
|
1254
|
+
// NOTE: this doesn't leak a reference to whatever is at o[i]
|
|
1255
|
+
#define __Pyx_PyTuple_SET_ITEM(o, i, v) PyTuple_SetItem(o, i, v)
|
|
1256
|
+
#define __Pyx_PyTuple_GET_ITEM(o, i) PyTuple_GetItem(o, i)
|
|
1257
|
+
#define __Pyx_PyList_SET_ITEM(o, i, v) PyList_SetItem(o, i, v)
|
|
1258
|
+
#define __Pyx_PyList_GET_ITEM(o, i) PyList_GetItem(o, i)
|
|
1259
|
+
#endif
|
|
1260
|
+
|
|
1261
|
+
#if CYTHON_ASSUME_SAFE_SIZE
|
|
1262
|
+
#define __Pyx_PyTuple_GET_SIZE(o) PyTuple_GET_SIZE(o)
|
|
1263
|
+
#define __Pyx_PyList_GET_SIZE(o) PyList_GET_SIZE(o)
|
|
1264
|
+
#define __Pyx_PySet_GET_SIZE(o) PySet_GET_SIZE(o)
|
|
1265
|
+
#define __Pyx_PyDict_GET_SIZE(o) PyDict_GET_SIZE(o)
|
|
1266
|
+
#define __Pyx_PyBytes_GET_SIZE(o) PyBytes_GET_SIZE(o)
|
|
1267
|
+
#define __Pyx_PyByteArray_GET_SIZE(o) PyByteArray_GET_SIZE(o)
|
|
1268
|
+
#define __Pyx_PyUnicode_GET_LENGTH(o) PyUnicode_GET_LENGTH(o)
|
|
1269
|
+
#else
|
|
1270
|
+
// These all need exception checks for -1.
|
|
1271
|
+
#define __Pyx_PyTuple_GET_SIZE(o) PyTuple_Size(o)
|
|
1272
|
+
#define __Pyx_PyList_GET_SIZE(o) PyList_Size(o)
|
|
1273
|
+
#define __Pyx_PySet_GET_SIZE(o) PySet_Size(o)
|
|
1274
|
+
#define __Pyx_PyDict_GET_SIZE(o) PyDict_Size(o)
|
|
1275
|
+
#define __Pyx_PyBytes_GET_SIZE(o) PyBytes_Size(o)
|
|
1276
|
+
#define __Pyx_PyByteArray_GET_SIZE(o) PyByteArray_Size(o)
|
|
1277
|
+
#define __Pyx_PyUnicode_GET_LENGTH(o) PyUnicode_GetLength(o)
|
|
1278
|
+
#endif
|
|
1279
|
+
|
|
1280
|
+
#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x030C0000 && !defined(PyUnicode_InternFromString)
|
|
1281
|
+
#define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
|
|
1282
|
+
#endif
|
|
1283
|
+
|
|
1284
|
+
#define __Pyx_PyLong_FromHash_t PyLong_FromSsize_t
|
|
1285
|
+
#define __Pyx_PyLong_AsHash_t __Pyx_PyIndex_AsSsize_t
|
|
1286
|
+
|
|
1287
|
+
|
|
1288
|
+
// backport of PyAsyncMethods from Py3.10 to older Py3.x versions
|
|
1289
|
+
#if __PYX_LIMITED_VERSION_HEX >= 0x030A0000
|
|
1290
|
+
#define __Pyx_PySendResult PySendResult
|
|
1291
|
+
#else
|
|
1292
|
+
typedef enum {
|
|
1293
|
+
PYGEN_RETURN = 0,
|
|
1294
|
+
PYGEN_ERROR = -1,
|
|
1295
|
+
PYGEN_NEXT = 1,
|
|
1296
|
+
} __Pyx_PySendResult;
|
|
1297
|
+
#endif
|
|
1298
|
+
|
|
1299
|
+
#if CYTHON_COMPILING_IN_LIMITED_API || PY_VERSION_HEX < 0x030A00A3
|
|
1300
|
+
typedef __Pyx_PySendResult (*__Pyx_pyiter_sendfunc)(PyObject *iter, PyObject *value, PyObject **result);
|
|
1301
|
+
#else
|
|
1302
|
+
#define __Pyx_pyiter_sendfunc sendfunc
|
|
1303
|
+
#endif
|
|
1304
|
+
|
|
1305
|
+
// "Py_am_send" requires Py3.10 when using type specs (which utility code types do).
|
|
1306
|
+
#if !CYTHON_USE_AM_SEND
|
|
1307
|
+
#define __PYX_HAS_PY_AM_SEND 0
|
|
1308
|
+
#elif __PYX_LIMITED_VERSION_HEX >= 0x030A0000
|
|
1309
|
+
#define __PYX_HAS_PY_AM_SEND 1
|
|
1310
|
+
#else
|
|
1311
|
+
#define __PYX_HAS_PY_AM_SEND 2 // our own backported implementation
|
|
1312
|
+
#endif
|
|
1313
|
+
|
|
1314
|
+
#if __PYX_HAS_PY_AM_SEND < 2
|
|
1315
|
+
#define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
|
|
1316
|
+
#else
|
|
1317
|
+
// PyAsyncMethods in Py<3.10 lacks "am_send"
|
|
1318
|
+
typedef struct {
|
|
1319
|
+
unaryfunc am_await;
|
|
1320
|
+
unaryfunc am_aiter;
|
|
1321
|
+
unaryfunc am_anext;
|
|
1322
|
+
__Pyx_pyiter_sendfunc am_send;
|
|
1323
|
+
} __Pyx_PyAsyncMethodsStruct;
|
|
1324
|
+
|
|
1325
|
+
#define __Pyx_SlotTpAsAsync(s) ((PyAsyncMethods*)(s))
|
|
1326
|
+
#endif
|
|
1327
|
+
|
|
1328
|
+
// Use a flag in Py < 3.10 to mark coroutines that have the "am_send" field.
|
|
1329
|
+
#if CYTHON_USE_AM_SEND && PY_VERSION_HEX < 0x030A00F0
|
|
1330
|
+
#define __Pyx_TPFLAGS_HAVE_AM_SEND (1UL << 21)
|
|
1331
|
+
#else
|
|
1332
|
+
#define __Pyx_TPFLAGS_HAVE_AM_SEND (0)
|
|
1333
|
+
#endif
|
|
1334
|
+
|
|
1335
|
+
#if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030A0000
|
|
1336
|
+
// PyMem_Calloc *is* in the Stable ABI in all the Limited API versions we care about.
|
|
1337
|
+
// However, it is omitted from the Python headers which means that C incorrectly
|
|
1338
|
+
// assumes it returns an int (and generates dubious code on based on that assumption).
|
|
1339
|
+
// Therefore, copy the prototype.
|
|
1340
|
+
#ifdef __cplusplus
|
|
1341
|
+
extern "C"
|
|
1342
|
+
#endif
|
|
1343
|
+
PyAPI_FUNC(void *) PyMem_Calloc(size_t nelem, size_t elsize); /* proto */
|
|
1344
|
+
#endif
|
|
1345
|
+
|
|
1346
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
1347
|
+
// returns 1 for success and 0 for failure to enable it to be chained in an &&
|
|
1348
|
+
static int __Pyx_init_co_variable(PyObject *inspect, const char* name, int *write_to) {
|
|
1349
|
+
int value;
|
|
1350
|
+
PyObject *py_value = PyObject_GetAttrString(inspect, name);
|
|
1351
|
+
if (!py_value) return 0;
|
|
1352
|
+
// There's a small chance of overflow here, but it'd only happen if inspect was set up wrongly.
|
|
1353
|
+
value = (int) PyLong_AsLong(py_value);
|
|
1354
|
+
Py_DECREF(py_value);
|
|
1355
|
+
*write_to = value;
|
|
1356
|
+
return value != -1 || !PyErr_Occurred();
|
|
1357
|
+
}
|
|
1358
|
+
|
|
1359
|
+
// Returns 0 on success and -1 on failure for normal error handling
|
|
1360
|
+
static int __Pyx_init_co_variables(void) {
|
|
1361
|
+
PyObject *inspect;
|
|
1362
|
+
int result;
|
|
1363
|
+
inspect = PyImport_ImportModule("inspect");
|
|
1364
|
+
|
|
1365
|
+
result =
|
|
1366
|
+
#if !defined(CO_OPTIMIZED)
|
|
1367
|
+
__Pyx_init_co_variable(inspect, "CO_OPTIMIZED", &CO_OPTIMIZED) &&
|
|
1368
|
+
#endif
|
|
1369
|
+
#if !defined(CO_NEWLOCALS)
|
|
1370
|
+
__Pyx_init_co_variable(inspect, "CO_NEWLOCALS", &CO_NEWLOCALS) &&
|
|
1371
|
+
#endif
|
|
1372
|
+
#if !defined(CO_VARARGS)
|
|
1373
|
+
__Pyx_init_co_variable(inspect, "CO_VARARGS", &CO_VARARGS) &&
|
|
1374
|
+
#endif
|
|
1375
|
+
#if !defined(CO_VARKEYWORDS)
|
|
1376
|
+
__Pyx_init_co_variable(inspect, "CO_VARKEYWORDS", &CO_VARKEYWORDS) &&
|
|
1377
|
+
#endif
|
|
1378
|
+
#if !defined(CO_ASYNC_GENERATOR)
|
|
1379
|
+
__Pyx_init_co_variable(inspect, "CO_ASYNC_GENERATOR", &CO_ASYNC_GENERATOR) &&
|
|
1380
|
+
#endif
|
|
1381
|
+
#if !defined(CO_GENERATOR)
|
|
1382
|
+
__Pyx_init_co_variable(inspect, "CO_GENERATOR", &CO_GENERATOR) &&
|
|
1383
|
+
#endif
|
|
1384
|
+
#if !defined(CO_COROUTINE)
|
|
1385
|
+
__Pyx_init_co_variable(inspect, "CO_COROUTINE", &CO_COROUTINE) &&
|
|
1386
|
+
#endif
|
|
1387
|
+
1;
|
|
1388
|
+
|
|
1389
|
+
Py_DECREF(inspect);
|
|
1390
|
+
return result ? 0 : -1;
|
|
1391
|
+
}
|
|
1392
|
+
|
|
1393
|
+
static int __Pyx_init_tpflags_bitcount(unsigned long flag) {
|
|
1394
|
+
int count = 0;
|
|
1395
|
+
while (flag) {
|
|
1396
|
+
count += (int) (flag & 1);
|
|
1397
|
+
flag >>= 1;
|
|
1398
|
+
}
|
|
1399
|
+
return count;
|
|
1400
|
+
}
|
|
1401
|
+
|
|
1402
|
+
// It's quite possible that the flags aren't reliably available at runtime.
|
|
1403
|
+
// Therefore most errors are ignored and we just leave the values as 0.
|
|
1404
|
+
static int __Pyx_init_tpflags_variables(void) {
|
|
1405
|
+
if (__Pyx_Runtime_TPFLAGS_SEQUENCE != 0 && __Pyx_Runtime_TPFLAGS_MAPPING != 0) {
|
|
1406
|
+
// Already set (possibly in another subinterpreter). Note that there's a
|
|
1407
|
+
// harmless race here because the variables aren't atomic.
|
|
1408
|
+
return 0;
|
|
1409
|
+
}
|
|
1410
|
+
|
|
1411
|
+
PyObject *collections_abc = PyImport_ImportModule("collections.abc");
|
|
1412
|
+
if (!collections_abc) return -1;
|
|
1413
|
+
|
|
1414
|
+
int result = 0;
|
|
1415
|
+
PyObject *sequence = NULL, *mapping = NULL;
|
|
1416
|
+
#if __PYX_LIMITED_VERSION_HEX >= 0x030D0000
|
|
1417
|
+
if (PyObject_GetOptionalAttrString(collections_abc, "Sequence", &sequence) != 1) goto fail;
|
|
1418
|
+
if (PyObject_GetOptionalAttrString(collections_abc, "Mapping", &mapping) != 1) goto fail;
|
|
1419
|
+
#else
|
|
1420
|
+
sequence = PyObject_GetAttrString(collections_abc, "Sequence");
|
|
1421
|
+
if (!sequence) goto fail_attr_lookup;
|
|
1422
|
+
mapping = PyObject_GetAttrString(collections_abc, "Mapping");
|
|
1423
|
+
if (!mapping) goto fail_attr_lookup;
|
|
1424
|
+
#endif
|
|
1425
|
+
|
|
1426
|
+
// The assumption is that the the type flags for sequence and mapping
|
|
1427
|
+
// should be identical except for a single bit on each class.
|
|
1428
|
+
// If that isn't true then fail silently.
|
|
1429
|
+
|
|
1430
|
+
if (!PyType_Check(sequence) || !PyType_Check(mapping)) goto fail;
|
|
1431
|
+
{
|
|
1432
|
+
unsigned long sequence_flags = PyType_GetFlags((PyTypeObject*)sequence);
|
|
1433
|
+
unsigned long mapping_flags = PyType_GetFlags((PyTypeObject*)mapping);
|
|
1434
|
+
unsigned long mutual_flags = sequence_flags & mapping_flags;
|
|
1435
|
+
sequence_flags = sequence_flags ^ mutual_flags;
|
|
1436
|
+
mapping_flags = mapping_flags ^ mutual_flags;
|
|
1437
|
+
|
|
1438
|
+
if (__Pyx_Runtime_TPFLAGS_SEQUENCE == 0 && __Pyx_init_tpflags_bitcount(sequence_flags) == 1) {
|
|
1439
|
+
__Pyx_Runtime_TPFLAGS_SEQUENCE = sequence_flags;
|
|
1440
|
+
}
|
|
1441
|
+
if (__Pyx_Runtime_TPFLAGS_MAPPING == 0 && __Pyx_init_tpflags_bitcount(mapping_flags) == 1) {
|
|
1442
|
+
__Pyx_Runtime_TPFLAGS_MAPPING = mapping_flags;
|
|
1443
|
+
}
|
|
1444
|
+
}
|
|
1445
|
+
|
|
1446
|
+
cleanup:
|
|
1447
|
+
Py_XDECREF(mapping);
|
|
1448
|
+
Py_XDECREF(sequence);
|
|
1449
|
+
Py_DECREF(collections_abc);
|
|
1450
|
+
|
|
1451
|
+
return result;
|
|
1452
|
+
#if __PYX_LIMITED_VERSION_HEX < 0x030D0000
|
|
1453
|
+
fail_attr_lookup:
|
|
1454
|
+
if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
|
|
1455
|
+
PyErr_Clear();
|
|
1456
|
+
}
|
|
1457
|
+
#endif
|
|
1458
|
+
fail:
|
|
1459
|
+
result = PyErr_Occurred() ? -1 : 0;
|
|
1460
|
+
goto cleanup;
|
|
1461
|
+
}
|
|
1462
|
+
#else
|
|
1463
|
+
static int __Pyx_init_co_variables(void) {
|
|
1464
|
+
return 0; // It's a limited API-only feature
|
|
1465
|
+
}
|
|
1466
|
+
|
|
1467
|
+
static int __Pyx_init_tpflags_variables(void) {
|
|
1468
|
+
return 0; // It's a limited API-only feature
|
|
1469
|
+
}
|
|
1470
|
+
#endif
|
|
1471
|
+
|
|
1472
|
+
/////////////// CythonABIVersion.proto ///////////////
|
|
1473
|
+
//@proto_block: module_declarations
|
|
1474
|
+
// This needs to go after the utility code 'proto' section but before user code and utility impl.
|
|
1475
|
+
|
|
1476
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
1477
|
+
// The limited API makes some significant changes to data structures, so we don't
|
|
1478
|
+
// want to share the implementations compiled with and without the limited API.
|
|
1479
|
+
#if CYTHON_VECTORCALL
|
|
1480
|
+
#define __PYX_VECTORCALL_ABI_SUFFIX "vectorcall"
|
|
1481
|
+
#else
|
|
1482
|
+
#define __PYX_VECTORCALL_ABI_SUFFIX
|
|
1483
|
+
#endif
|
|
1484
|
+
|
|
1485
|
+
#if __PYX_LIMITED_VERSION_HEX >= 0x03100000
|
|
1486
|
+
#define __PYX_LIMITED_ABI_V_SUFFIX "16"
|
|
1487
|
+
#elif __PYX_LIMITED_VERSION_HEX >= 0x030F0000
|
|
1488
|
+
#define __PYX_LIMITED_ABI_V_SUFFIX "15"
|
|
1489
|
+
#elif __PYX_LIMITED_VERSION_HEX >= 0x030E0000
|
|
1490
|
+
#define __PYX_LIMITED_ABI_V_SUFFIX "14"
|
|
1491
|
+
#elif __PYX_LIMITED_VERSION_HEX >= 0x030d0000
|
|
1492
|
+
#define __PYX_LIMITED_ABI_V_SUFFIX "13"
|
|
1493
|
+
#elif __PYX_LIMITED_VERSION_HEX >= 0x030C0000
|
|
1494
|
+
#define __PYX_LIMITED_ABI_V_SUFFIX "12"
|
|
1495
|
+
#elif __PYX_LIMITED_VERSION_HEX >= 0x030B0000
|
|
1496
|
+
#define __PYX_LIMITED_ABI_V_SUFFIX "11"
|
|
1497
|
+
#elif __PYX_LIMITED_VERSION_HEX >= 0x030A0000
|
|
1498
|
+
#define __PYX_LIMITED_ABI_V_SUFFIX "10"
|
|
1499
|
+
#elif __PYX_LIMITED_VERSION_HEX >= 0x03090000
|
|
1500
|
+
#define __PYX_LIMITED_ABI_V_SUFFIX "9"
|
|
1501
|
+
#else
|
|
1502
|
+
// 8 and below are unsupported anyway
|
|
1503
|
+
#define __PYX_LIMITED_ABI_V_SUFFIX "8"
|
|
1504
|
+
#endif
|
|
1505
|
+
|
|
1506
|
+
#define __PYX_LIMITED_ABI_SUFFIX "limited" __PYX_LIMITED_ABI_V_SUFFIX "_" __PYX_VECTORCALL_ABI_SUFFIX __PYX_AM_SEND_ABI_SUFFIX
|
|
1507
|
+
#else
|
|
1508
|
+
#define __PYX_LIMITED_ABI_SUFFIX
|
|
1509
|
+
#endif
|
|
1510
|
+
|
|
1511
|
+
#if __PYX_HAS_PY_AM_SEND == 1
|
|
1512
|
+
#define __PYX_AM_SEND_ABI_SUFFIX
|
|
1513
|
+
#elif __PYX_HAS_PY_AM_SEND == 2
|
|
1514
|
+
#define __PYX_AM_SEND_ABI_SUFFIX "amsendbackport"
|
|
1515
|
+
#else
|
|
1516
|
+
#define __PYX_AM_SEND_ABI_SUFFIX "noamsend"
|
|
1517
|
+
#endif
|
|
1518
|
+
|
|
1519
|
+
#ifndef __PYX_MONITORING_ABI_SUFFIX
|
|
1520
|
+
#define __PYX_MONITORING_ABI_SUFFIX
|
|
1521
|
+
#endif
|
|
1522
|
+
|
|
1523
|
+
#if CYTHON_USE_TP_FINALIZE
|
|
1524
|
+
#define __PYX_TP_FINALIZE_ABI_SUFFIX
|
|
1525
|
+
#else
|
|
1526
|
+
// affects destruction of async generator/coroutines
|
|
1527
|
+
#define __PYX_TP_FINALIZE_ABI_SUFFIX "nofinalize"
|
|
1528
|
+
#endif
|
|
1529
|
+
|
|
1530
|
+
#if CYTHON_USE_FREELISTS || !defined(__Pyx_AsyncGen_USED)
|
|
1531
|
+
#define __PYX_FREELISTS_ABI_SUFFIX
|
|
1532
|
+
#else
|
|
1533
|
+
// affects allocation/deallocation of async generator objects.
|
|
1534
|
+
#define __PYX_FREELISTS_ABI_SUFFIX "nofreelists"
|
|
1535
|
+
#endif
|
|
1536
|
+
|
|
1537
|
+
// Outside the Limited API we don't use opaque objects for shared types (even if we may use them elsewhere)
|
|
1538
|
+
#if CYTHON_OPAQUE_OBJECTS && CYTHON_COMPILING_IN_LIMITED_API
|
|
1539
|
+
#define __PYX_OPAQUE_OBJECTS_ABI_SUFFIX "opaque"
|
|
1540
|
+
#else
|
|
1541
|
+
#define __PYX_OPAQUE_OBJECTS_ABI_SUFFIX
|
|
1542
|
+
#endif
|
|
1543
|
+
|
|
1544
|
+
#define CYTHON_ABI __PYX_ABI_VERSION __PYX_LIMITED_ABI_SUFFIX __PYX_MONITORING_ABI_SUFFIX __PYX_TP_FINALIZE_ABI_SUFFIX __PYX_FREELISTS_ABI_SUFFIX __PYX_AM_SEND_ABI_SUFFIX __PYX_OPAQUE_OBJECTS_ABI_SUFFIX
|
|
1545
|
+
|
|
1546
|
+
#define __PYX_ABI_MODULE_NAME "_cython_" CYTHON_ABI
|
|
1547
|
+
#define __PYX_TYPE_MODULE_PREFIX __PYX_ABI_MODULE_NAME "."
|
|
1548
|
+
|
|
1549
|
+
/////////////// PythonCompatibility.init ///////////////
|
|
1550
|
+
|
|
1551
|
+
if (likely(__Pyx_init_co_variables() == 0 && __Pyx_init_tpflags_variables() == 0)); else
|
|
1552
|
+
|
|
1553
|
+
|
|
1554
|
+
/////////////// IncludeStructmemberH.proto ///////////////
|
|
1555
|
+
//@proto_block: utility_code_proto_before_types
|
|
1556
|
+
|
|
1557
|
+
#include <structmember.h>
|
|
1558
|
+
|
|
1559
|
+
|
|
1560
|
+
/////////////// SmallCodeConfig ///////////////
|
|
1561
|
+
|
|
1562
|
+
#ifndef CYTHON_SMALL_CODE
|
|
1563
|
+
#if defined(__clang__)
|
|
1564
|
+
#define CYTHON_SMALL_CODE
|
|
1565
|
+
#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
|
|
1566
|
+
#define CYTHON_SMALL_CODE __attribute__((cold))
|
|
1567
|
+
#else
|
|
1568
|
+
#define CYTHON_SMALL_CODE
|
|
1569
|
+
#endif
|
|
1570
|
+
#endif
|
|
1571
|
+
|
|
1572
|
+
|
|
1573
|
+
/////////////// PyModInitFuncType ///////////////
|
|
1574
|
+
|
|
1575
|
+
#ifndef CYTHON_NO_PYINIT_EXPORT
|
|
1576
|
+
#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
|
|
1577
|
+
#else
|
|
1578
|
+
// define this to PyObject * manually because PyMODINIT_FUNC adds __declspec(dllexport) to it's definition.
|
|
1579
|
+
#ifdef __cplusplus
|
|
1580
|
+
#define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
|
|
1581
|
+
#else
|
|
1582
|
+
#define __Pyx_PyMODINIT_FUNC PyObject *
|
|
1583
|
+
#endif
|
|
1584
|
+
#endif
|
|
1585
|
+
|
|
1586
|
+
|
|
1587
|
+
/////////////// FastTypeChecks.proto ///////////////
|
|
1588
|
+
|
|
1589
|
+
#if CYTHON_COMPILING_IN_CPYTHON
|
|
1590
|
+
#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
|
|
1591
|
+
#define __Pyx_TypeCheck2(obj, type1, type2) __Pyx_IsAnySubtype2(Py_TYPE(obj), (PyTypeObject *)type1, (PyTypeObject *)type2)
|
|
1592
|
+
static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);/*proto*/
|
|
1593
|
+
static CYTHON_INLINE int __Pyx_IsAnySubtype2(PyTypeObject *cls, PyTypeObject *a, PyTypeObject *b);/*proto*/
|
|
1594
|
+
#define __Pyx_PyAnySet_Check(obj) __Pyx_TypeCheck2(obj, &PySet_Type, &PyFrozenSet_Type)
|
|
1595
|
+
#else
|
|
1596
|
+
#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
|
|
1597
|
+
#define __Pyx_TypeCheck2(obj, type1, type2) (PyObject_TypeCheck(obj, (PyTypeObject *)type1) || PyObject_TypeCheck(obj, (PyTypeObject *)type2))
|
|
1598
|
+
#define __Pyx_PyAnySet_Check(obj) PyAnySet_Check(obj)
|
|
1599
|
+
#endif
|
|
1600
|
+
|
|
1601
|
+
|
|
1602
|
+
/////////////// FastTypeChecks ///////////////
|
|
1603
|
+
|
|
1604
|
+
#if CYTHON_COMPILING_IN_CPYTHON
|
|
1605
|
+
static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
|
|
1606
|
+
while (a) {
|
|
1607
|
+
a = __Pyx_PyType_GetSlot(a, tp_base, PyTypeObject*);
|
|
1608
|
+
if (a == b)
|
|
1609
|
+
return 1;
|
|
1610
|
+
}
|
|
1611
|
+
return b == &PyBaseObject_Type;
|
|
1612
|
+
}
|
|
1613
|
+
|
|
1614
|
+
static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
|
|
1615
|
+
PyObject *mro;
|
|
1616
|
+
if (a == b) return 1;
|
|
1617
|
+
mro = a->tp_mro;
|
|
1618
|
+
if (likely(mro)) {
|
|
1619
|
+
Py_ssize_t i, n;
|
|
1620
|
+
n = PyTuple_GET_SIZE(mro);
|
|
1621
|
+
for (i = 0; i < n; i++) {
|
|
1622
|
+
if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
|
|
1623
|
+
return 1;
|
|
1624
|
+
}
|
|
1625
|
+
return 0;
|
|
1626
|
+
}
|
|
1627
|
+
// should only get here for incompletely initialised types, i.e. never under normal usage patterns
|
|
1628
|
+
return __Pyx_InBases(a, b);
|
|
1629
|
+
}
|
|
1630
|
+
|
|
1631
|
+
static CYTHON_INLINE int __Pyx_IsAnySubtype2(PyTypeObject *cls, PyTypeObject *a, PyTypeObject *b) {
|
|
1632
|
+
PyObject *mro;
|
|
1633
|
+
if (cls == a || cls == b) return 1;
|
|
1634
|
+
mro = cls->tp_mro;
|
|
1635
|
+
if (likely(mro)) {
|
|
1636
|
+
Py_ssize_t i, n;
|
|
1637
|
+
n = PyTuple_GET_SIZE(mro);
|
|
1638
|
+
for (i = 0; i < n; i++) {
|
|
1639
|
+
PyObject *base = PyTuple_GET_ITEM(mro, i);
|
|
1640
|
+
if (base == (PyObject *)a || base == (PyObject *)b)
|
|
1641
|
+
return 1;
|
|
1642
|
+
}
|
|
1643
|
+
return 0;
|
|
1644
|
+
}
|
|
1645
|
+
// should only get here for incompletely initialised types, i.e. never under normal usage patterns
|
|
1646
|
+
return __Pyx_InBases(cls, a) || __Pyx_InBases(cls, b);
|
|
1647
|
+
}
|
|
1648
|
+
#endif
|
|
1649
|
+
|
|
1650
|
+
|
|
1651
|
+
/////////////// MathInitCode ///////////////
|
|
1652
|
+
|
|
1653
|
+
#if defined(_WIN32) || defined(WIN32) || defined(MS_WINDOWS)
|
|
1654
|
+
#ifndef _USE_MATH_DEFINES
|
|
1655
|
+
#define _USE_MATH_DEFINES
|
|
1656
|
+
#endif
|
|
1657
|
+
#endif
|
|
1658
|
+
#include <math.h>
|
|
1659
|
+
|
|
1660
|
+
#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
|
|
1661
|
+
#define __Pyx_truncl trunc
|
|
1662
|
+
#else
|
|
1663
|
+
#define __Pyx_truncl truncl
|
|
1664
|
+
#endif
|
|
1665
|
+
|
|
1666
|
+
#if defined(__cplusplus)
|
|
1667
|
+
// <cmath> in NetBSD undefines the declaration in <math.h>.
|
|
1668
|
+
// See https://github.com/cython/cython/issues/7915
|
|
1669
|
+
#include <cmath>
|
|
1670
|
+
#define __Pyx_isfinite(x) std::isfinite(x)
|
|
1671
|
+
#else
|
|
1672
|
+
#define __Pyx_isfinite(x) isfinite(x)
|
|
1673
|
+
#endif
|
|
1674
|
+
|
|
1675
|
+
|
|
1676
|
+
/////////////// ForceInitThreads.proto ///////////////
|
|
1677
|
+
//@proto_block: utility_code_proto_before_types
|
|
1678
|
+
|
|
1679
|
+
#ifndef __PYX_FORCE_INIT_THREADS
|
|
1680
|
+
#define __PYX_FORCE_INIT_THREADS 0
|
|
1681
|
+
#endif
|
|
1682
|
+
|
|
1683
|
+
|
|
1684
|
+
/////////////// ModuleCreationPEP489 ///////////////
|
|
1685
|
+
//@substitute: naming
|
|
1686
|
+
|
|
1687
|
+
#if CYTHON_COMPILING_IN_LIMITED_API && (__PYX_LIMITED_VERSION_HEX < 0x030A0000 && \
|
|
1688
|
+
(defined(_WIN32) || defined(WIN32) || defined(MS_WINDOWS)))
|
|
1689
|
+
static PY_INT64_T __Pyx_GetCurrentInterpreterId(void) {
|
|
1690
|
+
{
|
|
1691
|
+
PyObject *module = PyImport_ImportModule("_interpreters"); // 3.13+ I think
|
|
1692
|
+
if (!module) {
|
|
1693
|
+
if (!PyErr_ExceptionMatches(PyExc_Exception)) {
|
|
1694
|
+
goto bad; // BaseException
|
|
1695
|
+
}
|
|
1696
|
+
PyErr_Clear(); // just try the 3.8-3.12 version
|
|
1697
|
+
module = PyImport_ImportModule("_xxsubinterpreters");
|
|
1698
|
+
if (!module) goto bad;
|
|
1699
|
+
}
|
|
1700
|
+
PyObject *current = PyObject_CallMethod(module, "get_current", NULL);
|
|
1701
|
+
Py_DECREF(module);
|
|
1702
|
+
if (!current) goto bad;
|
|
1703
|
+
if (PyTuple_Check(current)) {
|
|
1704
|
+
// I think 3.13+ returns a tuple of (ID, whence),
|
|
1705
|
+
// but it's obviously a private module so the API changes a bit.
|
|
1706
|
+
PyObject *new_current = PySequence_GetItem(current, 0);
|
|
1707
|
+
Py_DECREF(current);
|
|
1708
|
+
current = new_current;
|
|
1709
|
+
if (!new_current) goto bad;
|
|
1710
|
+
}
|
|
1711
|
+
long long as_c_int = PyLong_AsLongLong(current);
|
|
1712
|
+
Py_DECREF(current);
|
|
1713
|
+
return as_c_int;
|
|
1714
|
+
}
|
|
1715
|
+
bad:
|
|
1716
|
+
PySys_WriteStderr("__Pyx_GetCurrentInterpreterId failed. Try setting the C define CYTHON_PEP489_MULTI_PHASE_INIT=0\n");
|
|
1717
|
+
return -1;
|
|
1718
|
+
}
|
|
1719
|
+
#endif
|
|
1720
|
+
|
|
1721
|
+
//#if CYTHON_PEP489_MULTI_PHASE_INIT
|
|
1722
|
+
#if !CYTHON_USE_MODULE_STATE
|
|
1723
|
+
static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
|
|
1724
|
+
static PY_INT64_T main_interpreter_id = -1;
|
|
1725
|
+
#if CYTHON_COMPILING_IN_GRAAL && defined(GRAALPY_VERSION_NUM) && GRAALPY_VERSION_NUM > 0x19000000
|
|
1726
|
+
PY_INT64_T current_id = GraalPyInterpreterState_GetIDFromThreadState(PyThreadState_Get());
|
|
1727
|
+
#elif CYTHON_COMPILING_IN_GRAAL
|
|
1728
|
+
PY_INT64_T current_id = PyInterpreterState_GetIDFromThreadState(PyThreadState_Get());
|
|
1729
|
+
#elif CYTHON_COMPILING_IN_LIMITED_API && (__PYX_LIMITED_VERSION_HEX < 0x030A0000 && \
|
|
1730
|
+
(defined(_WIN32) || defined(WIN32) || defined(MS_WINDOWS)))
|
|
1731
|
+
// Although PyInterpreterState_Get is part of the Stable ABI from Python 3.9,
|
|
1732
|
+
// it was somehow omitted from the Windows dll in that version.
|
|
1733
|
+
PY_INT64_T current_id = __Pyx_GetCurrentInterpreterId();
|
|
1734
|
+
#elif CYTHON_COMPILING_IN_LIMITED_API
|
|
1735
|
+
PY_INT64_T current_id = PyInterpreterState_GetID(PyInterpreterState_Get());
|
|
1736
|
+
#else
|
|
1737
|
+
PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
|
|
1738
|
+
#endif
|
|
1739
|
+
if (unlikely(current_id == -1)) {
|
|
1740
|
+
return -1;
|
|
1741
|
+
}
|
|
1742
|
+
if (main_interpreter_id == -1) {
|
|
1743
|
+
main_interpreter_id = current_id;
|
|
1744
|
+
return 0;
|
|
1745
|
+
} else if (unlikely(main_interpreter_id != current_id)) {
|
|
1746
|
+
PyErr_SetString(
|
|
1747
|
+
PyExc_ImportError,
|
|
1748
|
+
"Interpreter change detected - this module can only be loaded into one interpreter per process.");
|
|
1749
|
+
return -1;
|
|
1750
|
+
}
|
|
1751
|
+
return 0;
|
|
1752
|
+
}
|
|
1753
|
+
#endif
|
|
1754
|
+
|
|
1755
|
+
static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none)
|
|
1756
|
+
{
|
|
1757
|
+
PyObject *value = PyObject_GetAttrString(spec, from_name);
|
|
1758
|
+
int result = 0;
|
|
1759
|
+
if (likely(value)) {
|
|
1760
|
+
if (allow_none || value != Py_None) {
|
|
1761
|
+
result = PyDict_SetItemString(moddict, to_name, value);
|
|
1762
|
+
}
|
|
1763
|
+
Py_DECREF(value);
|
|
1764
|
+
} else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
|
|
1765
|
+
PyErr_Clear();
|
|
1766
|
+
} else {
|
|
1767
|
+
result = -1;
|
|
1768
|
+
}
|
|
1769
|
+
return result;
|
|
1770
|
+
}
|
|
1771
|
+
|
|
1772
|
+
static CYTHON_SMALL_CODE PyObject* ${pymodule_create_func_cname}(PyObject *spec, PyModuleDef *def) {
|
|
1773
|
+
PyObject *module = NULL, *moddict, *modname;
|
|
1774
|
+
CYTHON_UNUSED_VAR(def);
|
|
1775
|
+
|
|
1776
|
+
#if !CYTHON_USE_MODULE_STATE
|
|
1777
|
+
// For now, we only have exactly one module instance.
|
|
1778
|
+
if (__Pyx_check_single_interpreter())
|
|
1779
|
+
return NULL;
|
|
1780
|
+
#endif
|
|
1781
|
+
if (${module_cname})
|
|
1782
|
+
return __Pyx_NewRef(${module_cname});
|
|
1783
|
+
|
|
1784
|
+
modname = PyObject_GetAttrString(spec, "name");
|
|
1785
|
+
if (unlikely(!modname)) goto bad;
|
|
1786
|
+
|
|
1787
|
+
module = PyModule_NewObject(modname);
|
|
1788
|
+
Py_DECREF(modname);
|
|
1789
|
+
if (unlikely(!module)) goto bad;
|
|
1790
|
+
|
|
1791
|
+
moddict = PyModule_GetDict(module);
|
|
1792
|
+
if (unlikely(!moddict)) goto bad;
|
|
1793
|
+
// moddict is a borrowed reference
|
|
1794
|
+
|
|
1795
|
+
if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
|
|
1796
|
+
if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
|
|
1797
|
+
if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
|
|
1798
|
+
if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
|
|
1799
|
+
|
|
1800
|
+
return module;
|
|
1801
|
+
bad:
|
|
1802
|
+
Py_XDECREF(module);
|
|
1803
|
+
return NULL;
|
|
1804
|
+
}
|
|
1805
|
+
//#endif
|
|
1806
|
+
|
|
1807
|
+
|
|
1808
|
+
/////////////// CodeObjectCache.proto ///////////////
|
|
1809
|
+
//@requires: Synchronization.c::Atomics
|
|
1810
|
+
|
|
1811
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
1812
|
+
typedef PyObject __Pyx_CachedCodeObjectType;
|
|
1813
|
+
#else
|
|
1814
|
+
typedef PyCodeObject __Pyx_CachedCodeObjectType;
|
|
1815
|
+
#endif
|
|
1816
|
+
|
|
1817
|
+
typedef struct {
|
|
1818
|
+
__Pyx_CachedCodeObjectType* code_object;
|
|
1819
|
+
int code_line;
|
|
1820
|
+
} __Pyx_CodeObjectCacheEntry;
|
|
1821
|
+
|
|
1822
|
+
struct __Pyx_CodeObjectCache {
|
|
1823
|
+
int count;
|
|
1824
|
+
int max_count;
|
|
1825
|
+
__Pyx_CodeObjectCacheEntry* entries;
|
|
1826
|
+
#if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
|
|
1827
|
+
// 0 for none, +ve for readers, -ve for writers.
|
|
1828
|
+
//
|
|
1829
|
+
__pyx_atomic_int_type accessor_count;
|
|
1830
|
+
#endif
|
|
1831
|
+
};
|
|
1832
|
+
|
|
1833
|
+
static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
|
|
1834
|
+
|
|
1835
|
+
static __Pyx_CachedCodeObjectType *__pyx_find_code_object(int code_line);
|
|
1836
|
+
static void __pyx_insert_code_object(int code_line, __Pyx_CachedCodeObjectType* code_object);
|
|
1837
|
+
|
|
1838
|
+
/////////////// CodeObjectCache.module_state_decls ////////////////
|
|
1839
|
+
|
|
1840
|
+
struct __Pyx_CodeObjectCache __pyx_code_cache;
|
|
1841
|
+
|
|
1842
|
+
/////////////// CodeObjectCache ///////////////
|
|
1843
|
+
// Note that errors are simply ignored in the code below.
|
|
1844
|
+
// This is just a cache, if a lookup or insertion fails - so what?
|
|
1845
|
+
|
|
1846
|
+
static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
|
|
1847
|
+
int start = 0, mid = 0, end = count - 1;
|
|
1848
|
+
if (end >= 0 && code_line > entries[end].code_line) {
|
|
1849
|
+
return count;
|
|
1850
|
+
}
|
|
1851
|
+
while (start < end) {
|
|
1852
|
+
mid = start + (end - start) / 2;
|
|
1853
|
+
if (code_line < entries[mid].code_line) {
|
|
1854
|
+
end = mid;
|
|
1855
|
+
} else if (code_line > entries[mid].code_line) {
|
|
1856
|
+
start = mid + 1;
|
|
1857
|
+
} else {
|
|
1858
|
+
return mid;
|
|
1859
|
+
}
|
|
1860
|
+
}
|
|
1861
|
+
if (code_line <= entries[mid].code_line) {
|
|
1862
|
+
return mid;
|
|
1863
|
+
} else {
|
|
1864
|
+
return mid + 1;
|
|
1865
|
+
}
|
|
1866
|
+
}
|
|
1867
|
+
|
|
1868
|
+
static __Pyx_CachedCodeObjectType *__pyx__find_code_object(struct __Pyx_CodeObjectCache *code_cache, int code_line) {
|
|
1869
|
+
__Pyx_CachedCodeObjectType* code_object;
|
|
1870
|
+
int pos;
|
|
1871
|
+
if (unlikely(!code_line) || unlikely(!code_cache->entries)) {
|
|
1872
|
+
return NULL;
|
|
1873
|
+
}
|
|
1874
|
+
pos = __pyx_bisect_code_objects(code_cache->entries, code_cache->count, code_line);
|
|
1875
|
+
if (unlikely(pos >= code_cache->count) || unlikely(code_cache->entries[pos].code_line != code_line)) {
|
|
1876
|
+
return NULL;
|
|
1877
|
+
}
|
|
1878
|
+
code_object = code_cache->entries[pos].code_object;
|
|
1879
|
+
Py_INCREF(code_object);
|
|
1880
|
+
return code_object;
|
|
1881
|
+
}
|
|
1882
|
+
|
|
1883
|
+
static __Pyx_CachedCodeObjectType *__pyx_find_code_object(int code_line) {
|
|
1884
|
+
#if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING && !CYTHON_ATOMICS
|
|
1885
|
+
(void)&__pyx__find_code_object;
|
|
1886
|
+
return NULL; // Most implementation should have atomics. But otherwise, don't make it thread-safe, just miss.
|
|
1887
|
+
#else
|
|
1888
|
+
struct __Pyx_CodeObjectCache *code_cache = &CGLOBAL(__pyx_code_cache);
|
|
1889
|
+
#if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
|
|
1890
|
+
__pyx_nonatomic_int_type old_count = __pyx_atomic_incr_acq_rel(&code_cache->accessor_count);
|
|
1891
|
+
if (old_count < 0) {
|
|
1892
|
+
// It's being written so currently unreadable.
|
|
1893
|
+
__pyx_atomic_decr_acq_rel(&code_cache->accessor_count);
|
|
1894
|
+
return NULL;
|
|
1895
|
+
}
|
|
1896
|
+
#endif
|
|
1897
|
+
__Pyx_CachedCodeObjectType *result = __pyx__find_code_object(code_cache, code_line);
|
|
1898
|
+
#if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
|
|
1899
|
+
__pyx_atomic_decr_acq_rel(&code_cache->accessor_count);
|
|
1900
|
+
#endif
|
|
1901
|
+
return result;
|
|
1902
|
+
#endif
|
|
1903
|
+
}
|
|
1904
|
+
|
|
1905
|
+
|
|
1906
|
+
static void __pyx__insert_code_object(struct __Pyx_CodeObjectCache *code_cache, int code_line, __Pyx_CachedCodeObjectType* code_object)
|
|
1907
|
+
{
|
|
1908
|
+
int pos, i;
|
|
1909
|
+
__Pyx_CodeObjectCacheEntry* entries = code_cache->entries;
|
|
1910
|
+
if (unlikely(!code_line)) {
|
|
1911
|
+
return;
|
|
1912
|
+
}
|
|
1913
|
+
if (unlikely(!entries)) {
|
|
1914
|
+
entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
|
|
1915
|
+
if (likely(entries)) {
|
|
1916
|
+
code_cache->entries = entries;
|
|
1917
|
+
code_cache->max_count = 64;
|
|
1918
|
+
code_cache->count = 1;
|
|
1919
|
+
entries[0].code_line = code_line;
|
|
1920
|
+
entries[0].code_object = code_object;
|
|
1921
|
+
Py_INCREF(code_object);
|
|
1922
|
+
}
|
|
1923
|
+
return;
|
|
1924
|
+
}
|
|
1925
|
+
pos = __pyx_bisect_code_objects(code_cache->entries, code_cache->count, code_line);
|
|
1926
|
+
if ((pos < code_cache->count) && unlikely(code_cache->entries[pos].code_line == code_line)) {
|
|
1927
|
+
__Pyx_CachedCodeObjectType* tmp = entries[pos].code_object;
|
|
1928
|
+
entries[pos].code_object = code_object;
|
|
1929
|
+
Py_INCREF(code_object);
|
|
1930
|
+
Py_DECREF(tmp);
|
|
1931
|
+
return;
|
|
1932
|
+
}
|
|
1933
|
+
if (code_cache->count == code_cache->max_count) {
|
|
1934
|
+
int new_max = code_cache->max_count + 64;
|
|
1935
|
+
entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
|
|
1936
|
+
code_cache->entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry));
|
|
1937
|
+
if (unlikely(!entries)) {
|
|
1938
|
+
return;
|
|
1939
|
+
}
|
|
1940
|
+
code_cache->entries = entries;
|
|
1941
|
+
code_cache->max_count = new_max;
|
|
1942
|
+
}
|
|
1943
|
+
for (i=code_cache->count; i>pos; i--) {
|
|
1944
|
+
entries[i] = entries[i-1];
|
|
1945
|
+
}
|
|
1946
|
+
entries[pos].code_line = code_line;
|
|
1947
|
+
entries[pos].code_object = code_object;
|
|
1948
|
+
code_cache->count++;
|
|
1949
|
+
Py_INCREF(code_object);
|
|
1950
|
+
}
|
|
1951
|
+
|
|
1952
|
+
static void __pyx_insert_code_object(int code_line, __Pyx_CachedCodeObjectType* code_object) {
|
|
1953
|
+
#if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING && !CYTHON_ATOMICS
|
|
1954
|
+
(void)&__pyx__insert_code_object;
|
|
1955
|
+
return; // Most implementation should have atomics. But otherwise, don't make it thread-safe, just fail.
|
|
1956
|
+
#else
|
|
1957
|
+
struct __Pyx_CodeObjectCache *code_cache = &CGLOBAL(__pyx_code_cache);
|
|
1958
|
+
#if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
|
|
1959
|
+
__pyx_nonatomic_int_type expected = 0;
|
|
1960
|
+
if (!__pyx_atomic_int_cmp_exchange(&code_cache->accessor_count, &expected, INT_MIN)) {
|
|
1961
|
+
// it's being written or read, Either way we can't do anything
|
|
1962
|
+
return;
|
|
1963
|
+
}
|
|
1964
|
+
#endif
|
|
1965
|
+
__pyx__insert_code_object(code_cache, code_line, code_object);
|
|
1966
|
+
#if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
|
|
1967
|
+
__pyx_atomic_sub(&code_cache->accessor_count, INT_MIN);
|
|
1968
|
+
#endif
|
|
1969
|
+
#endif
|
|
1970
|
+
}
|
|
1971
|
+
|
|
1972
|
+
/////////////// CodeObjectCache.cleanup ///////////////
|
|
1973
|
+
|
|
1974
|
+
{
|
|
1975
|
+
struct __Pyx_CodeObjectCache *code_cache = &CGLOBAL(__pyx_code_cache);
|
|
1976
|
+
if (code_cache->entries) {
|
|
1977
|
+
__Pyx_CodeObjectCacheEntry* entries = code_cache->entries;
|
|
1978
|
+
int i, count = code_cache->count;
|
|
1979
|
+
code_cache->count = 0;
|
|
1980
|
+
code_cache->max_count = 0;
|
|
1981
|
+
code_cache->entries = NULL;
|
|
1982
|
+
for (i=0; i<count; i++) {
|
|
1983
|
+
Py_DECREF(entries[i].code_object);
|
|
1984
|
+
}
|
|
1985
|
+
PyMem_Free(entries);
|
|
1986
|
+
}
|
|
1987
|
+
}
|
|
1988
|
+
|
|
1989
|
+
/////////////// GetRuntimeVersion.proto ///////////////
|
|
1990
|
+
|
|
1991
|
+
#if __PYX_LIMITED_VERSION_HEX < 0x030b0000
|
|
1992
|
+
static unsigned long __Pyx_cached_runtime_version = 0;
|
|
1993
|
+
|
|
1994
|
+
static void __Pyx_init_runtime_version(void);
|
|
1995
|
+
#else
|
|
1996
|
+
#define __Pyx_init_runtime_version()
|
|
1997
|
+
#endif
|
|
1998
|
+
|
|
1999
|
+
// Does not require the GIL to be held
|
|
2000
|
+
static unsigned long __Pyx_get_runtime_version(void);
|
|
2001
|
+
|
|
2002
|
+
/////////////// GetRuntimeVersion ///////////////
|
|
2003
|
+
|
|
2004
|
+
#if __PYX_LIMITED_VERSION_HEX < 0x030b0000
|
|
2005
|
+
void __Pyx_init_runtime_version(void) {
|
|
2006
|
+
if (__Pyx_cached_runtime_version == 0) {
|
|
2007
|
+
const char* rt_version = Py_GetVersion();
|
|
2008
|
+
unsigned long version = 0;
|
|
2009
|
+
unsigned long factor = 0x01000000UL;
|
|
2010
|
+
unsigned int digit = 0;
|
|
2011
|
+
int i = 0;
|
|
2012
|
+
while (factor) {
|
|
2013
|
+
while ('0' <= rt_version[i] && rt_version[i] <= '9') {
|
|
2014
|
+
digit = digit * 10 + (unsigned int) (rt_version[i] - '0');
|
|
2015
|
+
++i;
|
|
2016
|
+
}
|
|
2017
|
+
version += factor * digit;
|
|
2018
|
+
if (rt_version[i] != '.')
|
|
2019
|
+
break;
|
|
2020
|
+
digit = 0;
|
|
2021
|
+
factor >>= 8;
|
|
2022
|
+
++i;
|
|
2023
|
+
}
|
|
2024
|
+
__Pyx_cached_runtime_version = version;
|
|
2025
|
+
}
|
|
2026
|
+
}
|
|
2027
|
+
#endif
|
|
2028
|
+
|
|
2029
|
+
static unsigned long __Pyx_get_runtime_version(void) {
|
|
2030
|
+
// We will probably never need the alpha/beta status, so avoid the complexity to parse it.
|
|
2031
|
+
#if __PYX_LIMITED_VERSION_HEX >= 0x030b0000
|
|
2032
|
+
return Py_Version & ~0xFFUL;
|
|
2033
|
+
#else
|
|
2034
|
+
return __Pyx_cached_runtime_version;
|
|
2035
|
+
#endif
|
|
2036
|
+
}
|
|
2037
|
+
|
|
2038
|
+
/////////////// CheckBinaryVersion.proto ///////////////
|
|
2039
|
+
|
|
2040
|
+
static int __Pyx_check_binary_version(unsigned long ct_version, unsigned long rt_version, int allow_newer);
|
|
2041
|
+
|
|
2042
|
+
/////////////// CheckBinaryVersion ///////////////
|
|
2043
|
+
|
|
2044
|
+
static int __Pyx_check_binary_version(unsigned long ct_version, unsigned long rt_version, int allow_newer) {
|
|
2045
|
+
// runtime version is: -1 => older, 0 => equal, 1 => newer
|
|
2046
|
+
const unsigned long MAJOR_MINOR = 0xFFFF0000UL;
|
|
2047
|
+
if ((rt_version & MAJOR_MINOR) == (ct_version & MAJOR_MINOR))
|
|
2048
|
+
return 0;
|
|
2049
|
+
if (likely(allow_newer && (rt_version & MAJOR_MINOR) > (ct_version & MAJOR_MINOR)))
|
|
2050
|
+
return 1;
|
|
2051
|
+
|
|
2052
|
+
{
|
|
2053
|
+
char message[200];
|
|
2054
|
+
PyOS_snprintf(message, sizeof(message),
|
|
2055
|
+
"compile time Python version %d.%d "
|
|
2056
|
+
"of module '%.100s' "
|
|
2057
|
+
"%s "
|
|
2058
|
+
"runtime version %d.%d",
|
|
2059
|
+
(int) (ct_version >> 24), (int) ((ct_version >> 16) & 0xFF),
|
|
2060
|
+
__Pyx_MODULE_NAME,
|
|
2061
|
+
(allow_newer) ? "was newer than" : "does not match",
|
|
2062
|
+
(int) (rt_version >> 24), (int) ((rt_version >> 16) & 0xFF)
|
|
2063
|
+
);
|
|
2064
|
+
// returns 0 or -1
|
|
2065
|
+
return PyErr_WarnEx(NULL, message, 1);
|
|
2066
|
+
}
|
|
2067
|
+
}
|
|
2068
|
+
|
|
2069
|
+
/////////////// IsLittleEndian.proto ///////////////
|
|
2070
|
+
|
|
2071
|
+
static CYTHON_INLINE int __Pyx_Is_Little_Endian(void);
|
|
2072
|
+
|
|
2073
|
+
/////////////// IsLittleEndian ///////////////
|
|
2074
|
+
|
|
2075
|
+
static CYTHON_INLINE int __Pyx_Is_Little_Endian(void)
|
|
2076
|
+
{
|
|
2077
|
+
union {
|
|
2078
|
+
uint32_t u32;
|
|
2079
|
+
uint8_t u8[4];
|
|
2080
|
+
} S;
|
|
2081
|
+
S.u32 = 0x01020304;
|
|
2082
|
+
return S.u8[0] == 4;
|
|
2083
|
+
}
|
|
2084
|
+
|
|
2085
|
+
/////////////// Refnanny.proto ///////////////
|
|
2086
|
+
|
|
2087
|
+
#ifndef CYTHON_REFNANNY
|
|
2088
|
+
#define CYTHON_REFNANNY 0
|
|
2089
|
+
#endif
|
|
2090
|
+
|
|
2091
|
+
#if CYTHON_REFNANNY
|
|
2092
|
+
typedef struct {
|
|
2093
|
+
void (*INCREF)(void*, PyObject*, Py_ssize_t);
|
|
2094
|
+
void (*DECREF)(void*, PyObject*, Py_ssize_t);
|
|
2095
|
+
void (*GOTREF)(void*, PyObject*, Py_ssize_t);
|
|
2096
|
+
void (*GIVEREF)(void*, PyObject*, Py_ssize_t);
|
|
2097
|
+
void* (*SetupContext)(const char*, Py_ssize_t, const char*);
|
|
2098
|
+
void (*FinishContext)(void**);
|
|
2099
|
+
} __Pyx_RefNannyAPIStruct;
|
|
2100
|
+
static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
|
|
2101
|
+
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); /*proto*/
|
|
2102
|
+
#define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
|
|
2103
|
+
#define __Pyx_RefNannySetupContext(name, acquire_gil) \
|
|
2104
|
+
if (acquire_gil) { \
|
|
2105
|
+
PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); \
|
|
2106
|
+
__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), (__LINE__), (__FILE__)); \
|
|
2107
|
+
PyGILState_Release(__pyx_gilstate_save); \
|
|
2108
|
+
} else { \
|
|
2109
|
+
__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), (__LINE__), (__FILE__)); \
|
|
2110
|
+
}
|
|
2111
|
+
#define __Pyx_RefNannyFinishContextNogil() { \
|
|
2112
|
+
PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); \
|
|
2113
|
+
__Pyx_RefNannyFinishContext(); \
|
|
2114
|
+
PyGILState_Release(__pyx_gilstate_save); \
|
|
2115
|
+
}
|
|
2116
|
+
#define __Pyx_RefNannyFinishContextNogil() { \
|
|
2117
|
+
PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); \
|
|
2118
|
+
__Pyx_RefNannyFinishContext(); \
|
|
2119
|
+
PyGILState_Release(__pyx_gilstate_save); \
|
|
2120
|
+
}
|
|
2121
|
+
#define __Pyx_RefNannyFinishContext() \
|
|
2122
|
+
__Pyx_RefNanny->FinishContext(&__pyx_refnanny)
|
|
2123
|
+
#define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), (__LINE__))
|
|
2124
|
+
#define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), (__LINE__))
|
|
2125
|
+
#define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), (__LINE__))
|
|
2126
|
+
#define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), (__LINE__))
|
|
2127
|
+
#define __Pyx_XINCREF(r) do { if((r) == NULL); else {__Pyx_INCREF(r); }} while(0)
|
|
2128
|
+
#define __Pyx_XDECREF(r) do { if((r) == NULL); else {__Pyx_DECREF(r); }} while(0)
|
|
2129
|
+
#define __Pyx_XGOTREF(r) do { if((r) == NULL); else {__Pyx_GOTREF(r); }} while(0)
|
|
2130
|
+
#define __Pyx_XGIVEREF(r) do { if((r) == NULL); else {__Pyx_GIVEREF(r);}} while(0)
|
|
2131
|
+
#else
|
|
2132
|
+
#define __Pyx_RefNannyDeclarations
|
|
2133
|
+
#define __Pyx_RefNannySetupContext(name, acquire_gil)
|
|
2134
|
+
#define __Pyx_RefNannyFinishContextNogil()
|
|
2135
|
+
#define __Pyx_RefNannyFinishContext()
|
|
2136
|
+
#define __Pyx_INCREF(r) Py_INCREF(r)
|
|
2137
|
+
#define __Pyx_DECREF(r) Py_DECREF(r)
|
|
2138
|
+
#define __Pyx_GOTREF(r)
|
|
2139
|
+
#define __Pyx_GIVEREF(r)
|
|
2140
|
+
#define __Pyx_XINCREF(r) Py_XINCREF(r)
|
|
2141
|
+
#define __Pyx_XDECREF(r) Py_XDECREF(r)
|
|
2142
|
+
#define __Pyx_XGOTREF(r)
|
|
2143
|
+
#define __Pyx_XGIVEREF(r)
|
|
2144
|
+
#endif /* CYTHON_REFNANNY */
|
|
2145
|
+
|
|
2146
|
+
#define __Pyx_Py_XDECREF_SET(r, v) do { \
|
|
2147
|
+
PyObject *tmp = (PyObject *) r; \
|
|
2148
|
+
r = v; Py_XDECREF(tmp); \
|
|
2149
|
+
} while (0)
|
|
2150
|
+
#define __Pyx_XDECREF_SET(r, v) do { \
|
|
2151
|
+
PyObject *tmp = (PyObject *) r; \
|
|
2152
|
+
r = v; __Pyx_XDECREF(tmp); \
|
|
2153
|
+
} while (0)
|
|
2154
|
+
#define __Pyx_DECREF_SET(r, v) do { \
|
|
2155
|
+
PyObject *tmp = (PyObject *) r; \
|
|
2156
|
+
r = v; __Pyx_DECREF(tmp); \
|
|
2157
|
+
} while (0)
|
|
2158
|
+
|
|
2159
|
+
#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
|
|
2160
|
+
#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
|
|
2161
|
+
|
|
2162
|
+
/////////////// Refnanny ///////////////
|
|
2163
|
+
|
|
2164
|
+
#if CYTHON_REFNANNY
|
|
2165
|
+
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
|
|
2166
|
+
PyObject *m = NULL, *p = NULL;
|
|
2167
|
+
void *r = NULL;
|
|
2168
|
+
m = PyImport_ImportModule(modname);
|
|
2169
|
+
if (!m) goto end;
|
|
2170
|
+
p = PyObject_GetAttrString(m, "RefNannyAPI");
|
|
2171
|
+
if (!p) goto end;
|
|
2172
|
+
r = PyLong_AsVoidPtr(p);
|
|
2173
|
+
end:
|
|
2174
|
+
Py_XDECREF(p);
|
|
2175
|
+
Py_XDECREF(m);
|
|
2176
|
+
return (__Pyx_RefNannyAPIStruct *)r;
|
|
2177
|
+
}
|
|
2178
|
+
#endif /* CYTHON_REFNANNY */
|
|
2179
|
+
|
|
2180
|
+
|
|
2181
|
+
/////////////// ImportRefnannyAPI ///////////////
|
|
2182
|
+
|
|
2183
|
+
#if CYTHON_REFNANNY
|
|
2184
|
+
__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
|
|
2185
|
+
if (!__Pyx_RefNanny) {
|
|
2186
|
+
if (PyErr_ExceptionMatches(PyExc_Exception)) {
|
|
2187
|
+
PyErr_Clear();
|
|
2188
|
+
__Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
|
|
2189
|
+
}
|
|
2190
|
+
if (!__Pyx_RefNanny)
|
|
2191
|
+
Py_FatalError("failed to import 'refnanny' module");
|
|
2192
|
+
}
|
|
2193
|
+
#endif
|
|
2194
|
+
|
|
2195
|
+
|
|
2196
|
+
/////////////// RegisterModuleCleanup.proto ///////////////
|
|
2197
|
+
//@substitute: naming
|
|
2198
|
+
|
|
2199
|
+
static void ${cleanup_cname}(PyObject *self); /*proto*/
|
|
2200
|
+
|
|
2201
|
+
#if CYTHON_COMPILING_IN_PYPY
|
|
2202
|
+
static int __Pyx_RegisterCleanup(void); /*proto*/
|
|
2203
|
+
#else
|
|
2204
|
+
#define __Pyx_RegisterCleanup() (0)
|
|
2205
|
+
#endif
|
|
2206
|
+
|
|
2207
|
+
/////////////// RegisterModuleCleanup ///////////////
|
|
2208
|
+
//@substitute: naming
|
|
2209
|
+
//@requires: Exceptions.c::IgnoreException
|
|
2210
|
+
|
|
2211
|
+
#if CYTHON_COMPILING_IN_PYPY
|
|
2212
|
+
static PyObject* ${cleanup_cname}_atexit(PyObject *module, PyObject *unused) {
|
|
2213
|
+
CYTHON_UNUSED_VAR(unused);
|
|
2214
|
+
${cleanup_cname}(module);
|
|
2215
|
+
Py_INCREF(Py_None); return Py_None;
|
|
2216
|
+
}
|
|
2217
|
+
|
|
2218
|
+
static int __Pyx_RegisterCleanup(void) {
|
|
2219
|
+
// Don't use Py_AtExit because that has a 32-call limit and is called
|
|
2220
|
+
// after python finalization.
|
|
2221
|
+
// Also, we try to prepend the cleanup function to "atexit._exithandlers"
|
|
2222
|
+
// in Py2 because CPython runs them last-to-first. Being run last allows
|
|
2223
|
+
// user exit code to run before us that may depend on the globals
|
|
2224
|
+
// and cached objects that we are about to clean up.
|
|
2225
|
+
|
|
2226
|
+
static PyMethodDef cleanup_def = {
|
|
2227
|
+
"__cleanup", (PyCFunction)${cleanup_cname}_atexit, METH_NOARGS, 0};
|
|
2228
|
+
|
|
2229
|
+
PyObject *cleanup_func = 0;
|
|
2230
|
+
PyObject *atexit = 0;
|
|
2231
|
+
PyObject *reg = 0;
|
|
2232
|
+
PyObject *args = 0;
|
|
2233
|
+
PyObject *res = 0;
|
|
2234
|
+
int ret = -1;
|
|
2235
|
+
|
|
2236
|
+
cleanup_func = PyCFunction_New(&cleanup_def, 0);
|
|
2237
|
+
if (!cleanup_func)
|
|
2238
|
+
goto bad;
|
|
2239
|
+
|
|
2240
|
+
atexit = PyImport_ImportModule("atexit");
|
|
2241
|
+
if (!atexit)
|
|
2242
|
+
goto bad;
|
|
2243
|
+
reg = PyObject_GetAttrString(atexit, "_exithandlers");
|
|
2244
|
+
if (reg && PyList_Check(reg)) {
|
|
2245
|
+
PyObject *a, *kw;
|
|
2246
|
+
a = PyTuple_New(0);
|
|
2247
|
+
if (!a)
|
|
2248
|
+
goto bad;
|
|
2249
|
+
kw = PyDict_New();
|
|
2250
|
+
if (!kw) {
|
|
2251
|
+
Py_DECREF(a);
|
|
2252
|
+
goto bad;
|
|
2253
|
+
}
|
|
2254
|
+
args = PyTuple_Pack(3, cleanup_func, a, kw);
|
|
2255
|
+
Py_DECREF(a);
|
|
2256
|
+
Py_DECREF(kw);
|
|
2257
|
+
if (!args)
|
|
2258
|
+
goto bad;
|
|
2259
|
+
ret = PyList_Insert(reg, 0, args);
|
|
2260
|
+
} else {
|
|
2261
|
+
if (!reg) {
|
|
2262
|
+
if (!__Pyx_IgnoreException(PyExc_AttributeError)) {
|
|
2263
|
+
goto bad;
|
|
2264
|
+
}
|
|
2265
|
+
} else {
|
|
2266
|
+
Py_DECREF(reg);
|
|
2267
|
+
}
|
|
2268
|
+
reg = PyObject_GetAttrString(atexit, "register");
|
|
2269
|
+
if (!reg)
|
|
2270
|
+
goto bad;
|
|
2271
|
+
args = PyTuple_Pack(1, cleanup_func);
|
|
2272
|
+
if (!args)
|
|
2273
|
+
goto bad;
|
|
2274
|
+
res = PyObject_CallObject(reg, args);
|
|
2275
|
+
if (!res)
|
|
2276
|
+
goto bad;
|
|
2277
|
+
ret = 0;
|
|
2278
|
+
}
|
|
2279
|
+
bad:
|
|
2280
|
+
Py_XDECREF(cleanup_func);
|
|
2281
|
+
Py_XDECREF(atexit);
|
|
2282
|
+
Py_XDECREF(reg);
|
|
2283
|
+
Py_XDECREF(args);
|
|
2284
|
+
Py_XDECREF(res);
|
|
2285
|
+
return ret;
|
|
2286
|
+
}
|
|
2287
|
+
#endif
|
|
2288
|
+
|
|
2289
|
+
/////////////// FastGil.init ///////////////
|
|
2290
|
+
__Pyx_FastGilFuncInit();
|
|
2291
|
+
|
|
2292
|
+
/////////////// NoFastGil.proto ///////////////
|
|
2293
|
+
//@proto_block: utility_code_proto_before_types
|
|
2294
|
+
|
|
2295
|
+
#define __Pyx_PyGILState_Ensure PyGILState_Ensure
|
|
2296
|
+
#define __Pyx_PyGILState_Release PyGILState_Release
|
|
2297
|
+
#define __Pyx_FastGIL_Remember()
|
|
2298
|
+
#define __Pyx_FastGIL_Forget()
|
|
2299
|
+
#define __Pyx_FastGilFuncInit()
|
|
2300
|
+
|
|
2301
|
+
/////////////// FastGil.proto ///////////////
|
|
2302
|
+
//@proto_block: utility_code_proto_before_types
|
|
2303
|
+
|
|
2304
|
+
#if CYTHON_FAST_GIL
|
|
2305
|
+
|
|
2306
|
+
struct __Pyx_FastGilVtab {
|
|
2307
|
+
PyGILState_STATE (*Fast_PyGILState_Ensure)(void);
|
|
2308
|
+
void (*Fast_PyGILState_Release)(PyGILState_STATE oldstate);
|
|
2309
|
+
void (*FastGIL_Remember)(void);
|
|
2310
|
+
void (*FastGIL_Forget)(void);
|
|
2311
|
+
};
|
|
2312
|
+
|
|
2313
|
+
static void __Pyx_FastGIL_Noop(void) {}
|
|
2314
|
+
static struct __Pyx_FastGilVtab __Pyx_FastGilFuncs = {
|
|
2315
|
+
PyGILState_Ensure,
|
|
2316
|
+
PyGILState_Release,
|
|
2317
|
+
__Pyx_FastGIL_Noop,
|
|
2318
|
+
__Pyx_FastGIL_Noop
|
|
2319
|
+
};
|
|
2320
|
+
|
|
2321
|
+
static void __Pyx_FastGilFuncInit(void);
|
|
2322
|
+
|
|
2323
|
+
#define __Pyx_PyGILState_Ensure __Pyx_FastGilFuncs.Fast_PyGILState_Ensure
|
|
2324
|
+
#define __Pyx_PyGILState_Release __Pyx_FastGilFuncs.Fast_PyGILState_Release
|
|
2325
|
+
#define __Pyx_FastGIL_Remember __Pyx_FastGilFuncs.FastGIL_Remember
|
|
2326
|
+
#define __Pyx_FastGIL_Forget __Pyx_FastGilFuncs.FastGIL_Forget
|
|
2327
|
+
|
|
2328
|
+
#ifndef CYTHON_THREAD_LOCAL
|
|
2329
|
+
#if defined(__cplusplus) && __cplusplus >= 201103L
|
|
2330
|
+
#define CYTHON_THREAD_LOCAL thread_local
|
|
2331
|
+
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112
|
|
2332
|
+
#define CYTHON_THREAD_LOCAL _Thread_local
|
|
2333
|
+
#elif defined(__GNUC__)
|
|
2334
|
+
#define CYTHON_THREAD_LOCAL __thread
|
|
2335
|
+
#elif defined(_MSC_VER)
|
|
2336
|
+
#define CYTHON_THREAD_LOCAL __declspec(thread)
|
|
2337
|
+
#endif
|
|
2338
|
+
#endif
|
|
2339
|
+
|
|
2340
|
+
#else
|
|
2341
|
+
#define __Pyx_PyGILState_Ensure PyGILState_Ensure
|
|
2342
|
+
#define __Pyx_PyGILState_Release PyGILState_Release
|
|
2343
|
+
#define __Pyx_FastGIL_Remember()
|
|
2344
|
+
#define __Pyx_FastGIL_Forget()
|
|
2345
|
+
#define __Pyx_FastGilFuncInit()
|
|
2346
|
+
#endif
|
|
2347
|
+
|
|
2348
|
+
/////////////// FastGil ///////////////
|
|
2349
|
+
//@requires: AddModuleRef
|
|
2350
|
+
//@requires: Exceptions.c::IgnoreException
|
|
2351
|
+
// The implementations of PyGILState_Ensure/Release calls PyThread_get_key_value
|
|
2352
|
+
// several times which is turns out to be quite slow (slower in fact than
|
|
2353
|
+
// acquiring the GIL itself). Simply storing it in a thread local for the
|
|
2354
|
+
// common case is much faster.
|
|
2355
|
+
// To make optimal use of this thread local, we attempt to share it between
|
|
2356
|
+
// modules.
|
|
2357
|
+
|
|
2358
|
+
#if CYTHON_FAST_GIL
|
|
2359
|
+
|
|
2360
|
+
#define __Pyx_FastGIL_ABI_module __PYX_ABI_MODULE_NAME
|
|
2361
|
+
#define __Pyx_FastGIL_PyCapsuleName "FastGilFuncs"
|
|
2362
|
+
#define __Pyx_FastGIL_PyCapsule \
|
|
2363
|
+
__Pyx_FastGIL_ABI_module "." __Pyx_FastGIL_PyCapsuleName
|
|
2364
|
+
|
|
2365
|
+
#ifdef CYTHON_THREAD_LOCAL
|
|
2366
|
+
|
|
2367
|
+
#include "pythread.h"
|
|
2368
|
+
#include "pystate.h"
|
|
2369
|
+
|
|
2370
|
+
static CYTHON_THREAD_LOCAL PyThreadState *__Pyx_FastGil_tcur = NULL;
|
|
2371
|
+
static CYTHON_THREAD_LOCAL int __Pyx_FastGil_tcur_depth = 0;
|
|
2372
|
+
static int __Pyx_FastGil_autoTLSkey = -1;
|
|
2373
|
+
|
|
2374
|
+
static CYTHON_INLINE void __Pyx_FastGIL_Remember0(void) {
|
|
2375
|
+
++__Pyx_FastGil_tcur_depth;
|
|
2376
|
+
}
|
|
2377
|
+
|
|
2378
|
+
static CYTHON_INLINE void __Pyx_FastGIL_Forget0(void) {
|
|
2379
|
+
if (--__Pyx_FastGil_tcur_depth == 0) {
|
|
2380
|
+
__Pyx_FastGil_tcur = NULL;
|
|
2381
|
+
}
|
|
2382
|
+
}
|
|
2383
|
+
|
|
2384
|
+
static CYTHON_INLINE PyThreadState *__Pyx_FastGil_get_tcur(void) {
|
|
2385
|
+
PyThreadState *tcur = __Pyx_FastGil_tcur;
|
|
2386
|
+
if (tcur == NULL) {
|
|
2387
|
+
tcur = __Pyx_FastGil_tcur = (PyThreadState*)PyThread_get_key_value(__Pyx_FastGil_autoTLSkey);
|
|
2388
|
+
}
|
|
2389
|
+
return tcur;
|
|
2390
|
+
}
|
|
2391
|
+
|
|
2392
|
+
static PyGILState_STATE __Pyx_FastGil_PyGILState_Ensure(void) {
|
|
2393
|
+
int current;
|
|
2394
|
+
PyThreadState *tcur;
|
|
2395
|
+
__Pyx_FastGIL_Remember0();
|
|
2396
|
+
tcur = __Pyx_FastGil_get_tcur();
|
|
2397
|
+
if (tcur == NULL) {
|
|
2398
|
+
// Uninitialized, need to initialize now.
|
|
2399
|
+
return PyGILState_Ensure();
|
|
2400
|
+
}
|
|
2401
|
+
current = tcur == __Pyx_PyThreadState_Current;
|
|
2402
|
+
if (current == 0) {
|
|
2403
|
+
PyEval_RestoreThread(tcur);
|
|
2404
|
+
}
|
|
2405
|
+
++tcur->gilstate_counter;
|
|
2406
|
+
return current ? PyGILState_LOCKED : PyGILState_UNLOCKED;
|
|
2407
|
+
}
|
|
2408
|
+
|
|
2409
|
+
static void __Pyx_FastGil_PyGILState_Release(PyGILState_STATE oldstate) {
|
|
2410
|
+
PyThreadState *tcur = __Pyx_FastGil_get_tcur();
|
|
2411
|
+
__Pyx_FastGIL_Forget0();
|
|
2412
|
+
if (tcur->gilstate_counter == 1) {
|
|
2413
|
+
// This is the last lock, do all the cleanup as well.
|
|
2414
|
+
PyGILState_Release(oldstate);
|
|
2415
|
+
} else {
|
|
2416
|
+
--tcur->gilstate_counter;
|
|
2417
|
+
if (oldstate == PyGILState_UNLOCKED) {
|
|
2418
|
+
PyEval_SaveThread();
|
|
2419
|
+
}
|
|
2420
|
+
}
|
|
2421
|
+
}
|
|
2422
|
+
|
|
2423
|
+
static void __Pyx_FastGilFuncInit0(void) {
|
|
2424
|
+
/* Try to detect autoTLSkey. */
|
|
2425
|
+
int key;
|
|
2426
|
+
void* this_thread_state = (void*) PyGILState_GetThisThreadState();
|
|
2427
|
+
for (key = 0; key < 100; key++) {
|
|
2428
|
+
if (PyThread_get_key_value(key) == this_thread_state) {
|
|
2429
|
+
__Pyx_FastGil_autoTLSkey = key;
|
|
2430
|
+
break;
|
|
2431
|
+
}
|
|
2432
|
+
}
|
|
2433
|
+
if (__Pyx_FastGil_autoTLSkey != -1) {
|
|
2434
|
+
PyObject* capsule = NULL;
|
|
2435
|
+
PyObject* abi_module = NULL;
|
|
2436
|
+
__Pyx_PyGILState_Ensure = __Pyx_FastGil_PyGILState_Ensure;
|
|
2437
|
+
__Pyx_PyGILState_Release = __Pyx_FastGil_PyGILState_Release;
|
|
2438
|
+
__Pyx_FastGIL_Remember = __Pyx_FastGIL_Remember0;
|
|
2439
|
+
__Pyx_FastGIL_Forget = __Pyx_FastGIL_Forget0;
|
|
2440
|
+
capsule = PyCapsule_New(&__Pyx_FastGilFuncs, __Pyx_FastGIL_PyCapsule, NULL);
|
|
2441
|
+
if (capsule) {
|
|
2442
|
+
abi_module = __Pyx_PyImport_AddModuleRef(__Pyx_FastGIL_ABI_module);
|
|
2443
|
+
if (abi_module) {
|
|
2444
|
+
PyObject_SetAttrString(abi_module, __Pyx_FastGIL_PyCapsuleName, capsule);
|
|
2445
|
+
Py_DECREF(abi_module);
|
|
2446
|
+
}
|
|
2447
|
+
}
|
|
2448
|
+
Py_XDECREF(capsule);
|
|
2449
|
+
}
|
|
2450
|
+
}
|
|
2451
|
+
|
|
2452
|
+
#else
|
|
2453
|
+
|
|
2454
|
+
static void __Pyx_FastGilFuncInit0(void) {
|
|
2455
|
+
}
|
|
2456
|
+
|
|
2457
|
+
#endif
|
|
2458
|
+
|
|
2459
|
+
static void __Pyx_FastGilFuncInit(void) {
|
|
2460
|
+
struct __Pyx_FastGilVtab* shared = (struct __Pyx_FastGilVtab*)PyCapsule_Import(__Pyx_FastGIL_PyCapsule, 1);
|
|
2461
|
+
if (shared) {
|
|
2462
|
+
__Pyx_FastGilFuncs = *shared;
|
|
2463
|
+
} else if (__Pyx_IgnoreException(PyExc_Exception)) {
|
|
2464
|
+
return __Pyx_FastGilFuncInit0();
|
|
2465
|
+
}
|
|
2466
|
+
}
|
|
2467
|
+
|
|
2468
|
+
#endif
|
|
2469
|
+
|
|
2470
|
+
///////////////////// PretendToInitialize.proto ////////////////////////
|
|
2471
|
+
|
|
2472
|
+
#ifdef __cplusplus
|
|
2473
|
+
// In C++ a variable must actually be initialized to make returning
|
|
2474
|
+
// it defined behaviour, and there doesn't seem to be a viable compiler trick to
|
|
2475
|
+
// avoid that.
|
|
2476
|
+
#if __cplusplus > 201103L
|
|
2477
|
+
#include <type_traits>
|
|
2478
|
+
#endif
|
|
2479
|
+
|
|
2480
|
+
template <typename T>
|
|
2481
|
+
static void __Pyx_pretend_to_initialize(T* ptr) {
|
|
2482
|
+
// In C++11 we have enough introspection to work out which types it's actually
|
|
2483
|
+
// necessary to apply this to (non-trivial types will have been initialized by
|
|
2484
|
+
// the definition). Below C++11 just initialize everything.
|
|
2485
|
+
#if __cplusplus > 201103L
|
|
2486
|
+
if ((std::is_trivially_default_constructible<T>::value))
|
|
2487
|
+
#endif
|
|
2488
|
+
*ptr = T();
|
|
2489
|
+
(void)ptr;
|
|
2490
|
+
}
|
|
2491
|
+
#else
|
|
2492
|
+
// For C, taking an address of a variable is enough to make returning it
|
|
2493
|
+
// defined behaviour.
|
|
2494
|
+
static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
|
|
2495
|
+
#endif
|
|
2496
|
+
|
|
2497
|
+
///////////////////// UtilityCodePragmas /////////////////////////
|
|
2498
|
+
|
|
2499
|
+
#ifdef _MSC_VER
|
|
2500
|
+
#pragma warning( push )
|
|
2501
|
+
/* Warning 4127: conditional expression is constant
|
|
2502
|
+
* Cython uses constant conditional expressions to allow in inline functions to be optimized at
|
|
2503
|
+
* compile-time, so this warning is not useful
|
|
2504
|
+
*/
|
|
2505
|
+
#pragma warning( disable : 4127 )
|
|
2506
|
+
#endif
|
|
2507
|
+
|
|
2508
|
+
///////////////////// UtilityCodePragmasEnd //////////////////////
|
|
2509
|
+
|
|
2510
|
+
#ifdef _MSC_VER
|
|
2511
|
+
#pragma warning( pop ) /* undo whatever Cython has done to warnings */
|
|
2512
|
+
#endif
|
|
2513
|
+
|
|
2514
|
+
|
|
2515
|
+
//////////////////// NewCodeObj.proto ////////////////////////
|
|
2516
|
+
//@proto_block: init_codeobjects
|
|
2517
|
+
|
|
2518
|
+
static PyObject* __Pyx_PyCode_New(
|
|
2519
|
+
//int argcount,
|
|
2520
|
+
//int num_posonly_args,
|
|
2521
|
+
//int num_kwonly_args,
|
|
2522
|
+
//int nlocals,
|
|
2523
|
+
// int s,
|
|
2524
|
+
//int flags,
|
|
2525
|
+
//int first_line,
|
|
2526
|
+
const __Pyx_PyCode_New_function_description descr,
|
|
2527
|
+
// PyObject *code,
|
|
2528
|
+
// PyObject *consts,
|
|
2529
|
+
// PyObject* n,
|
|
2530
|
+
// PyObject *varnames_tuple,
|
|
2531
|
+
PyObject * const *varnames,
|
|
2532
|
+
// PyObject *freevars,
|
|
2533
|
+
// PyObject *cellvars,
|
|
2534
|
+
PyObject *filename,
|
|
2535
|
+
PyObject *funcname,
|
|
2536
|
+
PyObject *line_table,
|
|
2537
|
+
PyObject *tuple_dedup_map
|
|
2538
|
+
);/*proto*/
|
|
2539
|
+
|
|
2540
|
+
//////////////////// NewCodeObj ////////////////////////
|
|
2541
|
+
|
|
2542
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
2543
|
+
// Note that the limited API doesn't know about PyCodeObject, so the type of this
|
|
2544
|
+
// is PyObject (unlike for the main API)
|
|
2545
|
+
static PyObject* __Pyx__PyCode_New(int a, int p, int k, int l, int s, int f,
|
|
2546
|
+
PyObject *code, PyObject *c, PyObject* n, PyObject *v,
|
|
2547
|
+
PyObject *fv, PyObject *cell, PyObject* fn,
|
|
2548
|
+
PyObject *name, int fline, PyObject *lnos) {
|
|
2549
|
+
// Backup option for generating a code object.
|
|
2550
|
+
// PyCode_NewEmpty isn't in the limited API. Therefore the two options are
|
|
2551
|
+
// 1. Python call of the code type with a long list of positional args.
|
|
2552
|
+
// 2. Generate a code object by compiling some trivial code, and customize.
|
|
2553
|
+
// We use the first option here.
|
|
2554
|
+
PyObject *exception_table = NULL;
|
|
2555
|
+
PyObject *types_module=NULL, *code_type=NULL, *result=NULL;
|
|
2556
|
+
#if __PYX_LIMITED_VERSION_HEX < 0x030b0000
|
|
2557
|
+
PyObject *version_info; /* borrowed */
|
|
2558
|
+
PyObject *py_minor_version = NULL;
|
|
2559
|
+
#endif
|
|
2560
|
+
long minor_version = 0;
|
|
2561
|
+
|
|
2562
|
+
#if __PYX_LIMITED_VERSION_HEX >= 0x030b0000
|
|
2563
|
+
minor_version = 11;
|
|
2564
|
+
// we don't yet need to distinguish between versions > 11
|
|
2565
|
+
// Note that from 3.13, when we do, we can use Py_Version
|
|
2566
|
+
#else
|
|
2567
|
+
if (!(version_info = PySys_GetObject("version_info"))) goto end;
|
|
2568
|
+
if (!(py_minor_version = PySequence_GetItem(version_info, 1))) goto end;
|
|
2569
|
+
minor_version = PyLong_AsLong(py_minor_version);
|
|
2570
|
+
Py_DECREF(py_minor_version);
|
|
2571
|
+
if (minor_version == -1 && PyErr_Occurred()) goto end;
|
|
2572
|
+
#endif
|
|
2573
|
+
|
|
2574
|
+
if (!(types_module = PyImport_ImportModule("types"))) goto end;
|
|
2575
|
+
if (!(code_type = PyObject_GetAttrString(types_module, "CodeType"))) goto end;
|
|
2576
|
+
|
|
2577
|
+
if (minor_version <= 10) {
|
|
2578
|
+
// [3.8], 3.9, 3.10
|
|
2579
|
+
// code(argcount, posonlyargcount, kwonlyargcount, nlocals, stacksize,
|
|
2580
|
+
// flags, codestring, constants, names, varnames, filename, name,
|
|
2581
|
+
// firstlineno, lnotab[, freevars[, cellvars]])
|
|
2582
|
+
// 3.10 switches lnotab for linetable, but is otherwise the same
|
|
2583
|
+
result = PyObject_CallFunction(code_type, "iiiiiiOOOOOOiOOO", a,p, k, l, s, f, code,
|
|
2584
|
+
c, n, v, fn, name, fline, lnos, fv, cell);
|
|
2585
|
+
} else {
|
|
2586
|
+
// 3.11, 3.12
|
|
2587
|
+
// code(argcount, posonlyargcount, kwonlyargcount, nlocals, stacksize,
|
|
2588
|
+
// flags, codestring, constants, names, varnames, filename, name,
|
|
2589
|
+
// qualname, firstlineno, linetable, exceptiontable, freevars=(), cellvars=(), /)
|
|
2590
|
+
// We use name and qualname for simplicity
|
|
2591
|
+
if (!(exception_table = PyBytes_FromStringAndSize(NULL, 0))) goto end;
|
|
2592
|
+
result = PyObject_CallFunction(code_type, "iiiiiiOOOOOOOiOOOO", a,p, k, l, s, f, code,
|
|
2593
|
+
c, n, v, fn, name, name, fline, lnos, exception_table, fv, cell);
|
|
2594
|
+
}
|
|
2595
|
+
|
|
2596
|
+
end:
|
|
2597
|
+
Py_XDECREF(code_type);
|
|
2598
|
+
Py_XDECREF(exception_table);
|
|
2599
|
+
Py_XDECREF(types_module);
|
|
2600
|
+
|
|
2601
|
+
if (!result) {
|
|
2602
|
+
// We use private API to create code objects and so it could fail in future.
|
|
2603
|
+
// In this case it's probably best if they keep working with a warning:
|
|
2604
|
+
// they're mostly just introspection decoration.
|
|
2605
|
+
PyObject *exc_type, *exc_value, *exc_tb;
|
|
2606
|
+
PyErr_Fetch(&exc_type, &exc_value, &exc_tb);
|
|
2607
|
+
if (PyErr_WarnFormat(
|
|
2608
|
+
PyExc_RuntimeWarning, 1,
|
|
2609
|
+
"Code object creation failed in Cython module: %S\nTry recompiling with a more recent version of Cython.",
|
|
2610
|
+
exc_value ? exc_value : exc_type) == 0) {
|
|
2611
|
+
result = Py_None;
|
|
2612
|
+
Py_INCREF(result);
|
|
2613
|
+
}
|
|
2614
|
+
Py_DECREF(exc_type);
|
|
2615
|
+
Py_XDECREF(exc_value);
|
|
2616
|
+
Py_XDECREF(exc_tb);
|
|
2617
|
+
}
|
|
2618
|
+
|
|
2619
|
+
return result;
|
|
2620
|
+
}
|
|
2621
|
+
|
|
2622
|
+
#elif PY_VERSION_HEX >= 0x030B0000
|
|
2623
|
+
static PyCodeObject* __Pyx__PyCode_New(int a, int p, int k, int l, int s, int f,
|
|
2624
|
+
PyObject *code, PyObject *c, PyObject* n, PyObject *v,
|
|
2625
|
+
PyObject *fv, PyObject *cell, PyObject* fn,
|
|
2626
|
+
PyObject *name, int fline, PyObject *lnos) {
|
|
2627
|
+
// As earlier versions, but
|
|
2628
|
+
// 1. pass an empty bytes string as exception_table
|
|
2629
|
+
// 2. pass name as qualname (TODO this might implementing properly in future)
|
|
2630
|
+
PyCodeObject *result;
|
|
2631
|
+
result =
|
|
2632
|
+
#if PY_VERSION_HEX >= 0x030C0000
|
|
2633
|
+
PyUnstable_Code_NewWithPosOnlyArgs
|
|
2634
|
+
#else
|
|
2635
|
+
PyCode_NewWithPosOnlyArgs
|
|
2636
|
+
#endif
|
|
2637
|
+
(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, name, fline, lnos, EMPTY(bytes));
|
|
2638
|
+
|
|
2639
|
+
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030c00A1
|
|
2640
|
+
if (likely(result))
|
|
2641
|
+
result->_co_firsttraceable = 0;
|
|
2642
|
+
#endif
|
|
2643
|
+
return result;
|
|
2644
|
+
}
|
|
2645
|
+
#elif !CYTHON_COMPILING_IN_PYPY
|
|
2646
|
+
#define __Pyx__PyCode_New(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \
|
|
2647
|
+
PyCode_NewWithPosOnlyArgs(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
|
|
2648
|
+
#else
|
|
2649
|
+
#define __Pyx__PyCode_New(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \
|
|
2650
|
+
PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
|
|
2651
|
+
#endif
|
|
2652
|
+
|
|
2653
|
+
// This is a specialised helper function for creating Cython's function code objects.
|
|
2654
|
+
// It only receives the arguments that differ between the Cython functions of the module.
|
|
2655
|
+
// This minimises the calling code in the module init function.
|
|
2656
|
+
static PyObject* __Pyx_PyCode_New(
|
|
2657
|
+
//int argcount,
|
|
2658
|
+
//int num_posonly_args,
|
|
2659
|
+
//int num_kwonly_args,
|
|
2660
|
+
//int nlocals,
|
|
2661
|
+
// int s,
|
|
2662
|
+
//int flags,
|
|
2663
|
+
//int first_line,
|
|
2664
|
+
const __Pyx_PyCode_New_function_description descr,
|
|
2665
|
+
// PyObject *code,
|
|
2666
|
+
// PyObject *consts,
|
|
2667
|
+
// PyObject* n,
|
|
2668
|
+
// PyObject *varnames_tuple,
|
|
2669
|
+
PyObject * const *varnames,
|
|
2670
|
+
// PyObject *freevars,
|
|
2671
|
+
// PyObject *cellvars,
|
|
2672
|
+
PyObject *filename,
|
|
2673
|
+
PyObject *funcname,
|
|
2674
|
+
// line table replaced lnotab in Py3.11 (PEP-626)
|
|
2675
|
+
PyObject *line_table,
|
|
2676
|
+
PyObject *tuple_dedup_map
|
|
2677
|
+
) {
|
|
2678
|
+
|
|
2679
|
+
PyObject *code_obj = NULL, *varnames_tuple_dedup = NULL, *code_bytes = NULL;
|
|
2680
|
+
Py_ssize_t var_count = (Py_ssize_t) descr.nlocals;
|
|
2681
|
+
|
|
2682
|
+
PyObject *varnames_tuple = PyTuple_New(var_count);
|
|
2683
|
+
if (unlikely(!varnames_tuple)) return NULL;
|
|
2684
|
+
for (Py_ssize_t i=0; i < var_count; i++) {
|
|
2685
|
+
Py_INCREF(varnames[i]);
|
|
2686
|
+
if (__Pyx_PyTuple_SET_ITEM(varnames_tuple, i, varnames[i]) != (0)) goto done;
|
|
2687
|
+
}
|
|
2688
|
+
|
|
2689
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
2690
|
+
varnames_tuple_dedup = PyDict_GetItem(tuple_dedup_map, varnames_tuple);
|
|
2691
|
+
if (!varnames_tuple_dedup) {
|
|
2692
|
+
if (unlikely(PyDict_SetItem(tuple_dedup_map, varnames_tuple, varnames_tuple) < 0)) goto done;
|
|
2693
|
+
varnames_tuple_dedup = varnames_tuple;
|
|
2694
|
+
}
|
|
2695
|
+
#else
|
|
2696
|
+
varnames_tuple_dedup = PyDict_SetDefault(tuple_dedup_map, varnames_tuple, varnames_tuple);
|
|
2697
|
+
if (unlikely(!varnames_tuple_dedup)) goto done;
|
|
2698
|
+
#endif
|
|
2699
|
+
|
|
2700
|
+
#if CYTHON_AVOID_BORROWED_REFS
|
|
2701
|
+
Py_INCREF(varnames_tuple_dedup);
|
|
2702
|
+
#endif
|
|
2703
|
+
|
|
2704
|
+
if (__PYX_LIMITED_VERSION_HEX >= (0x030b0000) && line_table != NULL && !CYTHON_COMPILING_IN_GRAAL) {
|
|
2705
|
+
// Allocate a "byte code" array (oversized) to match the addresses in the line table.
|
|
2706
|
+
// Length and alignment must be a multiple of sizeof(_Py_CODEUNIT), which is CPython specific but currently 2.
|
|
2707
|
+
// CPython makes a copy of the code array internally, so make sure it's somewhat short (but not too short).
|
|
2708
|
+
Py_ssize_t line_table_length = __Pyx_PyBytes_GET_SIZE(line_table);
|
|
2709
|
+
#if !CYTHON_ASSUME_SAFE_SIZE
|
|
2710
|
+
if (unlikely(line_table_length == -1)) goto done;
|
|
2711
|
+
#endif
|
|
2712
|
+
Py_ssize_t code_len = (line_table_length * 2 + 4) & ~3LL;
|
|
2713
|
+
code_bytes = PyBytes_FromStringAndSize(NULL, code_len);
|
|
2714
|
+
if (unlikely(!code_bytes)) goto done;
|
|
2715
|
+
char* c_code_bytes = PyBytes_AsString(code_bytes);
|
|
2716
|
+
if (unlikely(!c_code_bytes)) goto done;
|
|
2717
|
+
// We initialise the code array to '\0' even though a NOP would be more accurate,
|
|
2718
|
+
// but NOP changes its byte code ID across Python versions/implementations.
|
|
2719
|
+
memset(c_code_bytes, 0, (size_t) code_len);
|
|
2720
|
+
}
|
|
2721
|
+
|
|
2722
|
+
code_obj = (PyObject*) __Pyx__PyCode_New(
|
|
2723
|
+
(int) descr.argcount,
|
|
2724
|
+
(int) descr.num_posonly_args,
|
|
2725
|
+
(int) descr.num_kwonly_args,
|
|
2726
|
+
(int) descr.nlocals,
|
|
2727
|
+
0,
|
|
2728
|
+
(int) descr.flags,
|
|
2729
|
+
code_bytes ? code_bytes : EMPTY(bytes),
|
|
2730
|
+
EMPTY(tuple),
|
|
2731
|
+
EMPTY(tuple),
|
|
2732
|
+
varnames_tuple_dedup,
|
|
2733
|
+
EMPTY(tuple),
|
|
2734
|
+
EMPTY(tuple),
|
|
2735
|
+
filename,
|
|
2736
|
+
funcname,
|
|
2737
|
+
(int) descr.first_line,
|
|
2738
|
+
(__PYX_LIMITED_VERSION_HEX >= (0x030b0000) && line_table) ? line_table : EMPTY(bytes)
|
|
2739
|
+
);
|
|
2740
|
+
|
|
2741
|
+
done:
|
|
2742
|
+
Py_XDECREF(code_bytes);
|
|
2743
|
+
#if CYTHON_AVOID_BORROWED_REFS
|
|
2744
|
+
Py_XDECREF(varnames_tuple_dedup);
|
|
2745
|
+
#endif
|
|
2746
|
+
Py_DECREF(varnames_tuple);
|
|
2747
|
+
return code_obj;
|
|
2748
|
+
}
|
|
2749
|
+
|
|
2750
|
+
|
|
2751
|
+
////////////////////////// MultiPhaseInitModuleState.proto /////////////
|
|
2752
|
+
|
|
2753
|
+
#if CYTHON_PEP489_MULTI_PHASE_INIT && CYTHON_USE_MODULE_STATE
|
|
2754
|
+
#include <stdlib.h>
|
|
2755
|
+
|
|
2756
|
+
// This defines an ad-hoc, single module version of PyState_FindModule that
|
|
2757
|
+
// works for multi-phase init modules. It's intended to be the last option
|
|
2758
|
+
// when all the other official ways of getting the module are unavailable.
|
|
2759
|
+
static PyObject *__Pyx_State_FindModule(void*); /* proto */
|
|
2760
|
+
static int __Pyx_State_AddModule(PyObject* module, void*); /* proto */
|
|
2761
|
+
static int __Pyx_State_RemoveModule(void*); /* proto */
|
|
2762
|
+
|
|
2763
|
+
#elif CYTHON_USE_MODULE_STATE
|
|
2764
|
+
#define __Pyx_State_FindModule PyState_FindModule
|
|
2765
|
+
#define __Pyx_State_AddModule PyState_AddModule
|
|
2766
|
+
#define __Pyx_State_RemoveModule PyState_RemoveModule
|
|
2767
|
+
#endif
|
|
2768
|
+
|
|
2769
|
+
////////////////////////// MultiPhaseInitModuleState /////////////
|
|
2770
|
+
//@requires: Synchronization.c::Atomics
|
|
2771
|
+
|
|
2772
|
+
|
|
2773
|
+
// Code to maintain a mapping between (sub)interpreters and the module instance that they imported.
|
|
2774
|
+
// This is used to find the correct module state for the current interpreter.
|
|
2775
|
+
|
|
2776
|
+
#if CYTHON_PEP489_MULTI_PHASE_INIT && CYTHON_USE_MODULE_STATE
|
|
2777
|
+
|
|
2778
|
+
#ifndef CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
|
|
2779
|
+
// If you're using multiple interpreters but a single GIL then
|
|
2780
|
+
// this can be undefined for a bit of speed.
|
|
2781
|
+
// Isolated subinterpreters were added in 3.12, and nogil in 3.13, so before that
|
|
2782
|
+
// we can safely assume that we're protected by the GIL.
|
|
2783
|
+
// TODO - turn this off as appropriate when the user is able to set
|
|
2784
|
+
// Py_MOD_PER_INTERPRETER_GIL_SUPPORTED explicitly.
|
|
2785
|
+
#if (CYTHON_COMPILING_IN_LIMITED_API || PY_VERSION_HEX >= 0x030C0000)
|
|
2786
|
+
#define CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE 1
|
|
2787
|
+
#else
|
|
2788
|
+
#define CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE 0
|
|
2789
|
+
#endif
|
|
2790
|
+
#endif
|
|
2791
|
+
|
|
2792
|
+
#if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE && !CYTHON_ATOMICS
|
|
2793
|
+
#error "Module state with PEP489 requires atomics. Currently that's one of\
|
|
2794
|
+
C11, C++11, gcc atomic intrinsics or MSVC atomic intrinsics"
|
|
2795
|
+
#endif
|
|
2796
|
+
|
|
2797
|
+
// We also need a lock. In order of preference:
|
|
2798
|
+
// - PyMutex
|
|
2799
|
+
// - a language standard library
|
|
2800
|
+
// - pthreads
|
|
2801
|
+
// - msvc
|
|
2802
|
+
// - PyThread_lock isn't acceptable since we can't initialize it in a thread safe way
|
|
2803
|
+
#if !CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
|
|
2804
|
+
|
|
2805
|
+
#define __Pyx_ModuleStateLookup_Lock()
|
|
2806
|
+
#define __Pyx_ModuleStateLookup_Unlock()
|
|
2807
|
+
|
|
2808
|
+
#elif !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d0000
|
|
2809
|
+
|
|
2810
|
+
static PyMutex __Pyx_ModuleStateLookup_mutex = {0};
|
|
2811
|
+
#define __Pyx_ModuleStateLookup_Lock() PyMutex_Lock(&__Pyx_ModuleStateLookup_mutex)
|
|
2812
|
+
#define __Pyx_ModuleStateLookup_Unlock() PyMutex_Unlock(&__Pyx_ModuleStateLookup_mutex)
|
|
2813
|
+
|
|
2814
|
+
#elif defined(__cplusplus) && __cplusplus >= 201103L
|
|
2815
|
+
|
|
2816
|
+
#include <mutex>
|
|
2817
|
+
static std::mutex __Pyx_ModuleStateLookup_mutex;
|
|
2818
|
+
#define __Pyx_ModuleStateLookup_Lock() __Pyx_ModuleStateLookup_mutex.lock()
|
|
2819
|
+
#define __Pyx_ModuleStateLookup_Unlock() __Pyx_ModuleStateLookup_mutex.unlock()
|
|
2820
|
+
|
|
2821
|
+
#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ > 201112L) && !defined(__STDC_NO_THREADS__)
|
|
2822
|
+
#include <threads.h>
|
|
2823
|
+
static mtx_t __Pyx_ModuleStateLookup_mutex;
|
|
2824
|
+
static once_flag __Pyx_ModuleStateLookup_mutex_once_flag = ONCE_FLAG_INIT;
|
|
2825
|
+
static void __Pyx_ModuleStateLookup_initialize_mutex(void) {
|
|
2826
|
+
mtx_init(&__Pyx_ModuleStateLookup_mutex, mtx_plain);
|
|
2827
|
+
}
|
|
2828
|
+
#define __Pyx_ModuleStateLookup_Lock() \
|
|
2829
|
+
call_once(&__Pyx_ModuleStateLookup_mutex_once_flag, __Pyx_ModuleStateLookup_initialize_mutex); \
|
|
2830
|
+
mtx_lock(&__Pyx_ModuleStateLookup_mutex)
|
|
2831
|
+
#define __Pyx_ModuleStateLookup_Unlock() mtx_unlock(&__Pyx_ModuleStateLookup_mutex)
|
|
2832
|
+
|
|
2833
|
+
// HAVE_PTHREAD_H comes from pyconfig.h
|
|
2834
|
+
#elif defined(HAVE_PTHREAD_H)
|
|
2835
|
+
|
|
2836
|
+
#include <pthread.h>
|
|
2837
|
+
static pthread_mutex_t __Pyx_ModuleStateLookup_mutex = PTHREAD_MUTEX_INITIALIZER;
|
|
2838
|
+
#define __Pyx_ModuleStateLookup_Lock() pthread_mutex_lock(&__Pyx_ModuleStateLookup_mutex)
|
|
2839
|
+
#define __Pyx_ModuleStateLookup_Unlock() pthread_mutex_unlock(&__Pyx_ModuleStateLookup_mutex)
|
|
2840
|
+
|
|
2841
|
+
#elif defined(_WIN32)
|
|
2842
|
+
|
|
2843
|
+
#include <Windows.h> // synchapi.h on its own doesn't work
|
|
2844
|
+
|
|
2845
|
+
// Using a slim-read-write lock (instead of a mutex/critical section)
|
|
2846
|
+
// because it can be statically initialized.
|
|
2847
|
+
static SRWLOCK __Pyx_ModuleStateLookup_mutex = SRWLOCK_INIT;
|
|
2848
|
+
#define __Pyx_ModuleStateLookup_Lock() AcquireSRWLockExclusive(&__Pyx_ModuleStateLookup_mutex)
|
|
2849
|
+
#define __Pyx_ModuleStateLookup_Unlock() ReleaseSRWLockExclusive(&__Pyx_ModuleStateLookup_mutex)
|
|
2850
|
+
|
|
2851
|
+
#else
|
|
2852
|
+
#error "No suitable lock available for CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE.\
|
|
2853
|
+
Requires C standard >= C11, or C++ standard >= C++11,\
|
|
2854
|
+
or pthreads, or the Windows 32 API, or Python >= 3.13."
|
|
2855
|
+
#endif
|
|
2856
|
+
|
|
2857
|
+
|
|
2858
|
+
typedef struct {
|
|
2859
|
+
int64_t id;
|
|
2860
|
+
PyObject *module;
|
|
2861
|
+
} __Pyx_InterpreterIdAndModule;
|
|
2862
|
+
|
|
2863
|
+
typedef struct {
|
|
2864
|
+
char interpreter_id_as_index;
|
|
2865
|
+
Py_ssize_t count;
|
|
2866
|
+
Py_ssize_t allocated;
|
|
2867
|
+
__Pyx_InterpreterIdAndModule table[1];
|
|
2868
|
+
} __Pyx_ModuleStateLookupData;
|
|
2869
|
+
|
|
2870
|
+
#define __PYX_MODULE_STATE_LOOKUP_SMALL_SIZE 32
|
|
2871
|
+
// "interpreter_id_as_index" above means "the maximum interpreter ID ever seen is smaller than
|
|
2872
|
+
// __PYX_MODULE_STATE_LOOKUP_SMALL_SIZE and thus they're stored in an array
|
|
2873
|
+
// where the index corresponds to interpreter ID, and __Pyx_ModuleStateLookup_count
|
|
2874
|
+
// is the size of the array.
|
|
2875
|
+
|
|
2876
|
+
#if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
|
|
2877
|
+
static __pyx_atomic_int_type __Pyx_ModuleStateLookup_read_counter = 0;
|
|
2878
|
+
#endif
|
|
2879
|
+
|
|
2880
|
+
// A sorted list of (sub)interpreter IDs and the module that was imported into that interpreter.
|
|
2881
|
+
// For now look this up via binary search.
|
|
2882
|
+
#if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
|
|
2883
|
+
static __pyx_atomic_ptr_type __Pyx_ModuleStateLookup_data = 0;
|
|
2884
|
+
#else
|
|
2885
|
+
static __Pyx_ModuleStateLookupData* __Pyx_ModuleStateLookup_data = NULL;
|
|
2886
|
+
#endif
|
|
2887
|
+
|
|
2888
|
+
|
|
2889
|
+
static __Pyx_InterpreterIdAndModule* __Pyx_State_FindModuleStateLookupTableLowerBound(
|
|
2890
|
+
__Pyx_InterpreterIdAndModule* table,
|
|
2891
|
+
Py_ssize_t count,
|
|
2892
|
+
int64_t interpreterId) {
|
|
2893
|
+
__Pyx_InterpreterIdAndModule* begin = table;
|
|
2894
|
+
__Pyx_InterpreterIdAndModule* end = begin + count;
|
|
2895
|
+
|
|
2896
|
+
// fairly likely - e.g. single interpreter
|
|
2897
|
+
if (begin->id == interpreterId) {
|
|
2898
|
+
return begin;
|
|
2899
|
+
}
|
|
2900
|
+
|
|
2901
|
+
while ((end - begin) > __PYX_MODULE_STATE_LOOKUP_SMALL_SIZE) {
|
|
2902
|
+
__Pyx_InterpreterIdAndModule* halfway = begin + (end - begin)/2;
|
|
2903
|
+
if (halfway->id == interpreterId) {
|
|
2904
|
+
return halfway;
|
|
2905
|
+
}
|
|
2906
|
+
if (halfway->id < interpreterId) {
|
|
2907
|
+
begin = halfway;
|
|
2908
|
+
} else {
|
|
2909
|
+
end = halfway;
|
|
2910
|
+
}
|
|
2911
|
+
}
|
|
2912
|
+
|
|
2913
|
+
// Assume that for small ranges, it's quicker to do a linear search
|
|
2914
|
+
for (; begin < end; ++begin) {
|
|
2915
|
+
if (begin->id >= interpreterId) return begin;
|
|
2916
|
+
}
|
|
2917
|
+
return begin;
|
|
2918
|
+
}
|
|
2919
|
+
|
|
2920
|
+
static PyObject *__Pyx_State_FindModule(CYTHON_UNUSED void* dummy) {
|
|
2921
|
+
int64_t interpreter_id = PyInterpreterState_GetID(PyInterpreterState_Get());
|
|
2922
|
+
if (interpreter_id == -1) return NULL;
|
|
2923
|
+
|
|
2924
|
+
#if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
|
|
2925
|
+
__Pyx_ModuleStateLookupData* data = (__Pyx_ModuleStateLookupData*)__pyx_atomic_pointer_load_relaxed(&__Pyx_ModuleStateLookup_data);
|
|
2926
|
+
{
|
|
2927
|
+
// Thread sanitizer says that this is OK relaxed, but I think it needs to be acquire-release
|
|
2928
|
+
__pyx_atomic_incr_acq_rel(&__Pyx_ModuleStateLookup_read_counter);
|
|
2929
|
+
// data == NULL can either mean we're writing, or it's uninitialized.
|
|
2930
|
+
// Uninitialized only happens infrequently on the first few calls, so it's fine
|
|
2931
|
+
// to be on the slow path.
|
|
2932
|
+
if (likely(data)) {
|
|
2933
|
+
__Pyx_ModuleStateLookupData* new_data = (__Pyx_ModuleStateLookupData*)__pyx_atomic_pointer_load_acquire(&__Pyx_ModuleStateLookup_data);
|
|
2934
|
+
if (likely(data == new_data)) {
|
|
2935
|
+
// Nothing has written the data between incrementing the read counter and loading the pointer.
|
|
2936
|
+
goto read_finished;
|
|
2937
|
+
}
|
|
2938
|
+
}
|
|
2939
|
+
// In principle DW believes this could be "relaxed", but it's on the unlikely slow path anyway
|
|
2940
|
+
// so let's not add more macros.
|
|
2941
|
+
// Undo our addition to the read counter.
|
|
2942
|
+
__pyx_atomic_decr_acq_rel(&__Pyx_ModuleStateLookup_read_counter);
|
|
2943
|
+
// Wait for the write to finish and try again
|
|
2944
|
+
__Pyx_ModuleStateLookup_Lock();
|
|
2945
|
+
__pyx_atomic_incr_relaxed(&__Pyx_ModuleStateLookup_read_counter);
|
|
2946
|
+
data = (__Pyx_ModuleStateLookupData*)__pyx_atomic_pointer_load_relaxed(&__Pyx_ModuleStateLookup_data);
|
|
2947
|
+
__Pyx_ModuleStateLookup_Unlock();
|
|
2948
|
+
}
|
|
2949
|
+
read_finished:;
|
|
2950
|
+
|
|
2951
|
+
#else
|
|
2952
|
+
__Pyx_ModuleStateLookupData* data = __Pyx_ModuleStateLookup_data;
|
|
2953
|
+
#endif
|
|
2954
|
+
|
|
2955
|
+
__Pyx_InterpreterIdAndModule* found = NULL;
|
|
2956
|
+
|
|
2957
|
+
// There's one "already imported" check that'll hit this
|
|
2958
|
+
if (unlikely(!data)) goto end;
|
|
2959
|
+
|
|
2960
|
+
if (data->interpreter_id_as_index) {
|
|
2961
|
+
if (interpreter_id < data->count) {
|
|
2962
|
+
found = data->table+interpreter_id;
|
|
2963
|
+
}
|
|
2964
|
+
} else {
|
|
2965
|
+
found = __Pyx_State_FindModuleStateLookupTableLowerBound(
|
|
2966
|
+
data->table, data->count, interpreter_id);
|
|
2967
|
+
}
|
|
2968
|
+
|
|
2969
|
+
end:
|
|
2970
|
+
{
|
|
2971
|
+
PyObject *result=NULL;
|
|
2972
|
+
|
|
2973
|
+
if (found && found->id == interpreter_id) {
|
|
2974
|
+
result = found->module;
|
|
2975
|
+
}
|
|
2976
|
+
#if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
|
|
2977
|
+
__pyx_atomic_decr_acq_rel(&__Pyx_ModuleStateLookup_read_counter);
|
|
2978
|
+
#endif
|
|
2979
|
+
return result;
|
|
2980
|
+
}
|
|
2981
|
+
}
|
|
2982
|
+
|
|
2983
|
+
#if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
|
|
2984
|
+
static void __Pyx_ModuleStateLookup_wait_until_no_readers(void) {
|
|
2985
|
+
// Wait for any readers still working on the old data. Spin-lock is
|
|
2986
|
+
// fine because readers should be much faster than memory allocation.
|
|
2987
|
+
while (__pyx_atomic_load(&__Pyx_ModuleStateLookup_read_counter) != 0);
|
|
2988
|
+
}
|
|
2989
|
+
#else
|
|
2990
|
+
#define __Pyx_ModuleStateLookup_wait_until_no_readers()
|
|
2991
|
+
#endif
|
|
2992
|
+
|
|
2993
|
+
static int __Pyx_State_AddModuleInterpIdAsIndex(__Pyx_ModuleStateLookupData **old_data, PyObject* module, int64_t interpreter_id) {
|
|
2994
|
+
Py_ssize_t to_allocate = (*old_data)->allocated;
|
|
2995
|
+
while (to_allocate <= interpreter_id) {
|
|
2996
|
+
if (to_allocate == 0) to_allocate = 1;
|
|
2997
|
+
else to_allocate *= 2;
|
|
2998
|
+
}
|
|
2999
|
+
__Pyx_ModuleStateLookupData *new_data = *old_data;
|
|
3000
|
+
if (to_allocate != (*old_data)->allocated) {
|
|
3001
|
+
new_data = (__Pyx_ModuleStateLookupData *)realloc(
|
|
3002
|
+
*old_data,
|
|
3003
|
+
sizeof(__Pyx_ModuleStateLookupData)+(to_allocate-1)*sizeof(__Pyx_InterpreterIdAndModule));
|
|
3004
|
+
if (!new_data) {
|
|
3005
|
+
PyErr_NoMemory();
|
|
3006
|
+
return -1;
|
|
3007
|
+
}
|
|
3008
|
+
for (Py_ssize_t i = new_data->allocated; i < to_allocate; ++i) {
|
|
3009
|
+
new_data->table[i].id = i;
|
|
3010
|
+
new_data->table[i].module = NULL;
|
|
3011
|
+
}
|
|
3012
|
+
new_data->allocated = to_allocate;
|
|
3013
|
+
}
|
|
3014
|
+
new_data->table[interpreter_id].module = module;
|
|
3015
|
+
if (new_data->count < interpreter_id+1) {
|
|
3016
|
+
new_data->count = interpreter_id+1;
|
|
3017
|
+
}
|
|
3018
|
+
*old_data = new_data;
|
|
3019
|
+
return 0;
|
|
3020
|
+
}
|
|
3021
|
+
|
|
3022
|
+
static void __Pyx_State_ConvertFromInterpIdAsIndex(__Pyx_ModuleStateLookupData *data) {
|
|
3023
|
+
__Pyx_InterpreterIdAndModule *read = data->table;
|
|
3024
|
+
__Pyx_InterpreterIdAndModule *write = data->table;
|
|
3025
|
+
__Pyx_InterpreterIdAndModule *end = read + data->count;
|
|
3026
|
+
|
|
3027
|
+
for (; read<end; ++read) {
|
|
3028
|
+
if (read->module) {
|
|
3029
|
+
write->id = read->id;
|
|
3030
|
+
write->module = read->module;
|
|
3031
|
+
++write;
|
|
3032
|
+
}
|
|
3033
|
+
// Otherwise empty; don't copy
|
|
3034
|
+
}
|
|
3035
|
+
data->count = write - data->table;
|
|
3036
|
+
for (; write<end; ++write) {
|
|
3037
|
+
// clear rest of array
|
|
3038
|
+
write->id = 0;
|
|
3039
|
+
write->module = NULL;
|
|
3040
|
+
}
|
|
3041
|
+
data->interpreter_id_as_index = 0;
|
|
3042
|
+
}
|
|
3043
|
+
|
|
3044
|
+
static int __Pyx_State_AddModule(PyObject* module, CYTHON_UNUSED void* dummy) {
|
|
3045
|
+
int64_t interpreter_id = PyInterpreterState_GetID(PyInterpreterState_Get());
|
|
3046
|
+
if (interpreter_id == -1) return -1;
|
|
3047
|
+
|
|
3048
|
+
int result = 0;
|
|
3049
|
+
|
|
3050
|
+
__Pyx_ModuleStateLookup_Lock();
|
|
3051
|
+
|
|
3052
|
+
// Adding modules is the slow path so I've not thought about memory ordering much and
|
|
3053
|
+
// just made it strict.
|
|
3054
|
+
#if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
|
|
3055
|
+
// we're working and maybe modifying it, swap for 0
|
|
3056
|
+
__Pyx_ModuleStateLookupData *old_data = (__Pyx_ModuleStateLookupData *)
|
|
3057
|
+
__pyx_atomic_pointer_exchange(&__Pyx_ModuleStateLookup_data, 0);
|
|
3058
|
+
#else
|
|
3059
|
+
__Pyx_ModuleStateLookupData *old_data = __Pyx_ModuleStateLookup_data;
|
|
3060
|
+
#endif
|
|
3061
|
+
__Pyx_ModuleStateLookupData *new_data = old_data;
|
|
3062
|
+
|
|
3063
|
+
if (!new_data) {
|
|
3064
|
+
// If we don't yet have anything, initialize
|
|
3065
|
+
new_data = (__Pyx_ModuleStateLookupData *)calloc(1, sizeof(__Pyx_ModuleStateLookupData));
|
|
3066
|
+
if (!new_data) {
|
|
3067
|
+
result = -1;
|
|
3068
|
+
PyErr_NoMemory();
|
|
3069
|
+
goto end;
|
|
3070
|
+
}
|
|
3071
|
+
new_data->allocated = 1;
|
|
3072
|
+
new_data->interpreter_id_as_index = 1;
|
|
3073
|
+
}
|
|
3074
|
+
|
|
3075
|
+
// Pretty much everything from here modifies the data, and so requires us to wait
|
|
3076
|
+
// until all existing readers have finished in order to be thread-safe.
|
|
3077
|
+
__Pyx_ModuleStateLookup_wait_until_no_readers();
|
|
3078
|
+
if (new_data->interpreter_id_as_index) {
|
|
3079
|
+
if (interpreter_id < __PYX_MODULE_STATE_LOOKUP_SMALL_SIZE) {
|
|
3080
|
+
result = __Pyx_State_AddModuleInterpIdAsIndex(&new_data, module, interpreter_id);
|
|
3081
|
+
goto end;
|
|
3082
|
+
}
|
|
3083
|
+
// otherwise we have to convert then proceed with a normal insertion
|
|
3084
|
+
__Pyx_State_ConvertFromInterpIdAsIndex(new_data);
|
|
3085
|
+
}
|
|
3086
|
+
{
|
|
3087
|
+
Py_ssize_t insert_at = 0;
|
|
3088
|
+
{
|
|
3089
|
+
__Pyx_InterpreterIdAndModule* lower_bound = __Pyx_State_FindModuleStateLookupTableLowerBound(
|
|
3090
|
+
new_data->table, new_data->count, interpreter_id);
|
|
3091
|
+
|
|
3092
|
+
assert(lower_bound);
|
|
3093
|
+
|
|
3094
|
+
insert_at = lower_bound - new_data->table;
|
|
3095
|
+
|
|
3096
|
+
if (unlikely(insert_at < new_data->count && lower_bound->id == interpreter_id)) {
|
|
3097
|
+
lower_bound->module = module;
|
|
3098
|
+
goto end; // already in table, nothing more to do
|
|
3099
|
+
}
|
|
3100
|
+
|
|
3101
|
+
}
|
|
3102
|
+
|
|
3103
|
+
if (new_data->count+1 >= new_data->allocated) {
|
|
3104
|
+
// Use C realloc. PyMem_RawMalloc is added to the limited API fairly late (3.13)
|
|
3105
|
+
// and we want allocation independent of the interpreter which I think excludes PyMem_Malloc.
|
|
3106
|
+
Py_ssize_t to_allocate = (new_data->count+1)*2;
|
|
3107
|
+
new_data =
|
|
3108
|
+
(__Pyx_ModuleStateLookupData*)realloc(
|
|
3109
|
+
new_data,
|
|
3110
|
+
sizeof(__Pyx_ModuleStateLookupData) +
|
|
3111
|
+
(to_allocate-1)*sizeof(__Pyx_InterpreterIdAndModule));
|
|
3112
|
+
if (!new_data) {
|
|
3113
|
+
result = -1;
|
|
3114
|
+
new_data = old_data;
|
|
3115
|
+
PyErr_NoMemory();
|
|
3116
|
+
goto end;
|
|
3117
|
+
}
|
|
3118
|
+
new_data->allocated = to_allocate;
|
|
3119
|
+
}
|
|
3120
|
+
|
|
3121
|
+
++new_data->count;
|
|
3122
|
+
|
|
3123
|
+
int64_t last_id = interpreter_id;
|
|
3124
|
+
PyObject *last_module = module;
|
|
3125
|
+
for (Py_ssize_t i=insert_at; i<new_data->count; ++i) {
|
|
3126
|
+
int64_t current_id = new_data->table[i].id;
|
|
3127
|
+
new_data->table[i].id = last_id;
|
|
3128
|
+
last_id = current_id;
|
|
3129
|
+
PyObject *current_module = new_data->table[i].module;
|
|
3130
|
+
new_data->table[i].module = last_module;
|
|
3131
|
+
last_module = current_module;
|
|
3132
|
+
}
|
|
3133
|
+
}
|
|
3134
|
+
|
|
3135
|
+
end:
|
|
3136
|
+
#if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
|
|
3137
|
+
__pyx_atomic_pointer_exchange(&__Pyx_ModuleStateLookup_data, new_data);
|
|
3138
|
+
#else
|
|
3139
|
+
__Pyx_ModuleStateLookup_data = new_data;
|
|
3140
|
+
#endif
|
|
3141
|
+
|
|
3142
|
+
__Pyx_ModuleStateLookup_Unlock();
|
|
3143
|
+
return result;
|
|
3144
|
+
}
|
|
3145
|
+
|
|
3146
|
+
static int __Pyx_State_RemoveModule(CYTHON_UNUSED void* dummy) {
|
|
3147
|
+
int64_t interpreter_id = PyInterpreterState_GetID(PyInterpreterState_Get());
|
|
3148
|
+
if (interpreter_id == -1) return -1;
|
|
3149
|
+
|
|
3150
|
+
__Pyx_ModuleStateLookup_Lock();
|
|
3151
|
+
|
|
3152
|
+
#if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
|
|
3153
|
+
__Pyx_ModuleStateLookupData *data = (__Pyx_ModuleStateLookupData *)
|
|
3154
|
+
__pyx_atomic_pointer_exchange(&__Pyx_ModuleStateLookup_data, 0);
|
|
3155
|
+
#else
|
|
3156
|
+
__Pyx_ModuleStateLookupData *data = __Pyx_ModuleStateLookup_data;
|
|
3157
|
+
#endif
|
|
3158
|
+
|
|
3159
|
+
if (data->interpreter_id_as_index) {
|
|
3160
|
+
if (interpreter_id < data->count) {
|
|
3161
|
+
data->table[interpreter_id].module = NULL;
|
|
3162
|
+
}
|
|
3163
|
+
goto done;
|
|
3164
|
+
}
|
|
3165
|
+
{
|
|
3166
|
+
__Pyx_ModuleStateLookup_wait_until_no_readers();
|
|
3167
|
+
|
|
3168
|
+
__Pyx_InterpreterIdAndModule* lower_bound = __Pyx_State_FindModuleStateLookupTableLowerBound(
|
|
3169
|
+
data->table, data->count, interpreter_id);
|
|
3170
|
+
|
|
3171
|
+
// TODO Errors here?
|
|
3172
|
+
if (!lower_bound) goto done;
|
|
3173
|
+
if (lower_bound->id != interpreter_id) goto done;
|
|
3174
|
+
|
|
3175
|
+
__Pyx_InterpreterIdAndModule *end = data->table+data->count;
|
|
3176
|
+
for (;lower_bound<end-1; ++lower_bound) {
|
|
3177
|
+
lower_bound->id = (lower_bound+1)->id;
|
|
3178
|
+
lower_bound->module = (lower_bound+1)->module;
|
|
3179
|
+
}
|
|
3180
|
+
}
|
|
3181
|
+
--data->count;
|
|
3182
|
+
if (data->count == 0) {
|
|
3183
|
+
free(data);
|
|
3184
|
+
data = NULL;
|
|
3185
|
+
}
|
|
3186
|
+
// For now, never shrink the allocated table.
|
|
3187
|
+
done:
|
|
3188
|
+
#if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
|
|
3189
|
+
__pyx_atomic_pointer_exchange(&__Pyx_ModuleStateLookup_data, data);
|
|
3190
|
+
#else
|
|
3191
|
+
__Pyx_ModuleStateLookup_data = data;
|
|
3192
|
+
#endif
|
|
3193
|
+
__Pyx_ModuleStateLookup_Unlock();
|
|
3194
|
+
return 0;
|
|
3195
|
+
}
|
|
3196
|
+
|
|
3197
|
+
#endif
|
|
3198
|
+
|
|
3199
|
+
////////////////////// IncludeStdlibH.proto //////////////////////
|
|
3200
|
+
|
|
3201
|
+
#include <stdlib.h>
|
|
3202
|
+
|
|
3203
|
+
////////////////////// ReleaseUnknownGil.proto ///////////////////
|
|
3204
|
+
|
|
3205
|
+
#if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030d0000
|
|
3206
|
+
typedef struct {
|
|
3207
|
+
PyThreadState* ts;
|
|
3208
|
+
PyGILState_STATE gil_state;
|
|
3209
|
+
} __Pyx_UnknownThreadState;
|
|
3210
|
+
#else
|
|
3211
|
+
#define __Pyx_UnknownThreadState PyThreadState*
|
|
3212
|
+
#endif
|
|
3213
|
+
|
|
3214
|
+
static __Pyx_UnknownThreadState __Pyx_SaveUnknownThread(void); /* proto */
|
|
3215
|
+
static void __Pyx_RestoreUnknownThread(__Pyx_UnknownThreadState state); /* proto */
|
|
3216
|
+
|
|
3217
|
+
// Note - may return false negatives for some versions of the Limited API
|
|
3218
|
+
static CYTHON_INLINE int __Pyx_UnknownThreadStateDefinitelyHadGil(__Pyx_UnknownThreadState state); /* proto */
|
|
3219
|
+
// Note - may return false positives for some versions of the Limited API
|
|
3220
|
+
static CYTHON_INLINE int __Pyx_UnknownThreadStateMayHaveHadGil(__Pyx_UnknownThreadState state); /* proto */
|
|
3221
|
+
|
|
3222
|
+
////////////////////// ReleaseUnknownGil ///////////////////
|
|
3223
|
+
|
|
3224
|
+
static __Pyx_UnknownThreadState __Pyx_SaveUnknownThread(void) {
|
|
3225
|
+
#if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030d0000
|
|
3226
|
+
if (__Pyx_get_runtime_version() >= 0x030d0000) {
|
|
3227
|
+
// On Python 3.13+ we can just swap the thread state for NULL, and that's fine,
|
|
3228
|
+
// whether we have the GIL or not.
|
|
3229
|
+
PyThreadState *ts = PyThreadState_Swap(NULL);
|
|
3230
|
+
__Pyx_UnknownThreadState out = { ts, PyGILState_UNLOCKED /* arbitrary value */ };
|
|
3231
|
+
return out;
|
|
3232
|
+
} else {
|
|
3233
|
+
// On Python <3.13 there's no way of telling if we have the GIL in the Limited API.
|
|
3234
|
+
// Therefore, the only safe thing to do is to acquire it then release it.
|
|
3235
|
+
PyGILState_STATE gil_state = PyGILState_Ensure();
|
|
3236
|
+
PyThreadState *ts = PyEval_SaveThread();
|
|
3237
|
+
__Pyx_UnknownThreadState out = { ts, gil_state };
|
|
3238
|
+
return out;
|
|
3239
|
+
}
|
|
3240
|
+
#elif __PYX_LIMITED_VERSION_HEX >= 0x030d0000
|
|
3241
|
+
return PyThreadState_Swap(NULL);
|
|
3242
|
+
#else
|
|
3243
|
+
#if CYTHON_COMPILING_IN_PYPY || PY_VERSION_HEX < 0x030C0000
|
|
3244
|
+
if (PyGILState_Check())
|
|
3245
|
+
#else
|
|
3246
|
+
if (_PyThreadState_UncheckedGet()) // UncheckedGet is a reliable check for the GIL from 3.12 upwards
|
|
3247
|
+
#endif
|
|
3248
|
+
{
|
|
3249
|
+
return PyEval_SaveThread();
|
|
3250
|
+
}
|
|
3251
|
+
return NULL; // Nothing to release - we don't have the GIL
|
|
3252
|
+
#endif
|
|
3253
|
+
}
|
|
3254
|
+
|
|
3255
|
+
static void __Pyx_RestoreUnknownThread(__Pyx_UnknownThreadState state) {
|
|
3256
|
+
#if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030d0000
|
|
3257
|
+
if (!state.ts) return;
|
|
3258
|
+
PyEval_RestoreThread(state.ts);
|
|
3259
|
+
if (__Pyx_get_runtime_version() < 0x030d0000) {
|
|
3260
|
+
PyGILState_Release(state.gil_state);
|
|
3261
|
+
}
|
|
3262
|
+
#else
|
|
3263
|
+
if (state) {
|
|
3264
|
+
PyEval_RestoreThread(state);
|
|
3265
|
+
}
|
|
3266
|
+
#endif
|
|
3267
|
+
}
|
|
3268
|
+
|
|
3269
|
+
static CYTHON_INLINE int __Pyx_UnknownThreadStateDefinitelyHadGil(__Pyx_UnknownThreadState state) {
|
|
3270
|
+
#if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030d0000
|
|
3271
|
+
// For older Limited API versions we can't tell if we had the GIL
|
|
3272
|
+
return ((state.ts != NULL) && (__Pyx_get_runtime_version() >= 0x030d0000));
|
|
3273
|
+
#else
|
|
3274
|
+
return state != NULL;
|
|
3275
|
+
#endif
|
|
3276
|
+
}
|
|
3277
|
+
|
|
3278
|
+
static CYTHON_INLINE int __Pyx_UnknownThreadStateMayHaveHadGil(__Pyx_UnknownThreadState state) {
|
|
3279
|
+
#if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030d0000
|
|
3280
|
+
return state.ts != NULL;
|
|
3281
|
+
#else
|
|
3282
|
+
return state != NULL;
|
|
3283
|
+
#endif
|
|
3284
|
+
}
|
|
3285
|
+
|
|
3286
|
+
///////////////////// AddModuleRef.proto ///////////////////////
|
|
3287
|
+
|
|
3288
|
+
#if ((CYTHON_COMPILING_IN_CPYTHON_FREETHREADING && PY_VERSION_HEX < 0x030F00a3) || \
|
|
3289
|
+
__PYX_LIMITED_VERSION_HEX < 0x030d0000)
|
|
3290
|
+
// https://github.com/python/cpython/issues/137422 - PyImport_AddModule(Ref) isn't thread safe!
|
|
3291
|
+
static PyObject *__Pyx_PyImport_AddModuleRef(const char *name); /* proto */
|
|
3292
|
+
#else
|
|
3293
|
+
#define __Pyx_PyImport_AddModuleRef(name) PyImport_AddModuleRef(name)
|
|
3294
|
+
#endif
|
|
3295
|
+
|
|
3296
|
+
///////////////////// AddModuleRef ////////////////////////////
|
|
3297
|
+
|
|
3298
|
+
#if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING && PY_VERSION_HEX < 0x030F00a3
|
|
3299
|
+
// https://github.com/python/cpython/issues/137422 - PyImport_AddModule(Ref) isn't thread safe!
|
|
3300
|
+
// TODO - if this gets used for anything other than implementing AddModuleRef then add a
|
|
3301
|
+
// runtime version check for fixed versions.
|
|
3302
|
+
static PyObject *__Pyx_PyImport_AddModuleObjectRef(PyObject *name) {
|
|
3303
|
+
// We're going to assume nobody is swapping the module dict out from under us
|
|
3304
|
+
// (even though they're allowed to) because we really can't write code that's
|
|
3305
|
+
// safe against that.
|
|
3306
|
+
PyObject *module_dict = PyImport_GetModuleDict();
|
|
3307
|
+
PyObject *m;
|
|
3308
|
+
if (PyMapping_GetOptionalItem(module_dict, name, &m) < 0) {
|
|
3309
|
+
return NULL;
|
|
3310
|
+
}
|
|
3311
|
+
if (m != NULL && PyModule_Check(m)) {
|
|
3312
|
+
return m;
|
|
3313
|
+
}
|
|
3314
|
+
Py_XDECREF(m);
|
|
3315
|
+
m = PyModule_NewObject(name);
|
|
3316
|
+
if (m == NULL)
|
|
3317
|
+
return NULL;
|
|
3318
|
+
if (PyDict_CheckExact(module_dict)) {
|
|
3319
|
+
PyObject *new_m;
|
|
3320
|
+
(void)PyDict_SetDefaultRef(module_dict, name, m, &new_m);
|
|
3321
|
+
Py_DECREF(m);
|
|
3322
|
+
return new_m;
|
|
3323
|
+
} else {
|
|
3324
|
+
// For non-dict sys-modules I don't think it's possible to reliably make thread-safe.
|
|
3325
|
+
if (PyObject_SetItem(module_dict, name, m) != 0) {
|
|
3326
|
+
Py_DECREF(m);
|
|
3327
|
+
return NULL;
|
|
3328
|
+
}
|
|
3329
|
+
return m;
|
|
3330
|
+
}
|
|
3331
|
+
}
|
|
3332
|
+
static PyObject *__Pyx_PyImport_AddModuleRef(const char *name) {
|
|
3333
|
+
if ((PY_VERSION_HEX >= 0x030E0000) && Py_Version >= 0x030E0100) {
|
|
3334
|
+
// Fixed here... their implementation is probably better
|
|
3335
|
+
return PyImport_AddModuleRef(name);
|
|
3336
|
+
}
|
|
3337
|
+
PyObject *py_name = PyUnicode_FromString(name);
|
|
3338
|
+
if (!py_name) return NULL;
|
|
3339
|
+
PyObject *module = __Pyx_PyImport_AddModuleObjectRef(py_name);
|
|
3340
|
+
Py_DECREF(py_name);
|
|
3341
|
+
return module;
|
|
3342
|
+
}
|
|
3343
|
+
#elif __PYX_LIMITED_VERSION_HEX < 0x030d0000
|
|
3344
|
+
static PyObject *__Pyx_PyImport_AddModuleRef(const char *name) {
|
|
3345
|
+
PyObject *module = PyImport_AddModule(name);
|
|
3346
|
+
Py_XINCREF(module);
|
|
3347
|
+
return module;
|
|
3348
|
+
}
|
|
3349
|
+
#endif
|