Cython 3.2.0__cp39-abi3-win32.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- Cython/Build/BuildExecutable.py +169 -0
- Cython/Build/Cache.py +199 -0
- Cython/Build/Cythonize.py +350 -0
- Cython/Build/Dependencies.py +1314 -0
- Cython/Build/Distutils.py +1 -0
- Cython/Build/Inline.py +463 -0
- Cython/Build/IpythonMagic.py +560 -0
- Cython/Build/SharedModule.py +94 -0
- Cython/Build/Tests/TestCyCache.py +194 -0
- Cython/Build/Tests/TestCythonizeArgsParser.py +481 -0
- Cython/Build/Tests/TestDependencies.py +133 -0
- Cython/Build/Tests/TestInline.py +177 -0
- Cython/Build/Tests/TestIpythonMagic.py +287 -0
- Cython/Build/Tests/TestRecythonize.py +212 -0
- Cython/Build/Tests/TestStripLiterals.py +155 -0
- Cython/Build/Tests/__init__.py +1 -0
- Cython/Build/__init__.py +11 -0
- Cython/CodeWriter.py +815 -0
- Cython/Compiler/AnalysedTreeTransforms.py +97 -0
- Cython/Compiler/Annotate.py +328 -0
- Cython/Compiler/AutoDocTransforms.py +320 -0
- Cython/Compiler/Buffer.py +680 -0
- Cython/Compiler/Builtin.py +984 -0
- Cython/Compiler/CmdLine.py +263 -0
- Cython/Compiler/Code.pxd +149 -0
- Cython/Compiler/Code.py +3746 -0
- Cython/Compiler/Code.pyd +0 -0
- Cython/Compiler/CodeGeneration.py +33 -0
- Cython/Compiler/CythonScope.py +191 -0
- Cython/Compiler/Dataclass.py +864 -0
- Cython/Compiler/DebugFlags.py +24 -0
- Cython/Compiler/Errors.py +297 -0
- Cython/Compiler/ExprNodes.py +15562 -0
- Cython/Compiler/FlowControl.pxd +97 -0
- Cython/Compiler/FlowControl.py +1451 -0
- Cython/Compiler/FlowControl.pyd +0 -0
- Cython/Compiler/FusedNode.py +971 -0
- Cython/Compiler/FusedNode.pyd +0 -0
- Cython/Compiler/Future.py +16 -0
- Cython/Compiler/Interpreter.py +57 -0
- Cython/Compiler/Lexicon.py +421 -0
- Cython/Compiler/LineTable.py +114 -0
- Cython/Compiler/LineTable.pyd +0 -0
- Cython/Compiler/Main.py +857 -0
- Cython/Compiler/MatchCaseNodes.py +259 -0
- Cython/Compiler/MemoryView.py +905 -0
- Cython/Compiler/ModuleNode.py +4235 -0
- Cython/Compiler/Naming.py +363 -0
- Cython/Compiler/Nodes.py +10831 -0
- Cython/Compiler/Optimize.py +5288 -0
- Cython/Compiler/Options.py +843 -0
- Cython/Compiler/ParseTreeTransforms.pxd +78 -0
- Cython/Compiler/ParseTreeTransforms.py +4638 -0
- Cython/Compiler/Parsing.pxd +9 -0
- Cython/Compiler/Parsing.py +4775 -0
- Cython/Compiler/Parsing.pyd +0 -0
- Cython/Compiler/Pipeline.py +439 -0
- Cython/Compiler/PyrexTypes.py +5870 -0
- Cython/Compiler/Pythran.py +232 -0
- Cython/Compiler/Scanning.pxd +48 -0
- Cython/Compiler/Scanning.py +701 -0
- Cython/Compiler/Scanning.pyd +0 -0
- Cython/Compiler/StringEncoding.py +298 -0
- Cython/Compiler/Symtab.py +3073 -0
- Cython/Compiler/Tests/TestBuffer.py +105 -0
- Cython/Compiler/Tests/TestBuiltin.py +72 -0
- Cython/Compiler/Tests/TestCmdLine.py +586 -0
- Cython/Compiler/Tests/TestCode.py +144 -0
- Cython/Compiler/Tests/TestFlowControl.py +65 -0
- Cython/Compiler/Tests/TestGrammar.py +202 -0
- Cython/Compiler/Tests/TestMemView.py +71 -0
- Cython/Compiler/Tests/TestParseTreeTransforms.py +285 -0
- Cython/Compiler/Tests/TestScanning.py +134 -0
- Cython/Compiler/Tests/TestSignatureMatching.py +73 -0
- Cython/Compiler/Tests/TestStringEncoding.py +21 -0
- Cython/Compiler/Tests/TestTreeFragment.py +63 -0
- Cython/Compiler/Tests/TestTreePath.py +103 -0
- Cython/Compiler/Tests/TestTypes.py +75 -0
- Cython/Compiler/Tests/TestUtilityLoad.py +112 -0
- Cython/Compiler/Tests/TestVisitor.py +61 -0
- Cython/Compiler/Tests/Utils.py +36 -0
- Cython/Compiler/Tests/__init__.py +1 -0
- Cython/Compiler/TreeFragment.py +278 -0
- Cython/Compiler/TreePath.py +303 -0
- Cython/Compiler/TypeInference.py +591 -0
- Cython/Compiler/TypeSlots.py +1174 -0
- Cython/Compiler/UFuncs.py +311 -0
- Cython/Compiler/UtilNodes.py +389 -0
- Cython/Compiler/UtilityCode.py +344 -0
- Cython/Compiler/Version.py +8 -0
- Cython/Compiler/Visitor.pxd +53 -0
- Cython/Compiler/Visitor.py +861 -0
- Cython/Compiler/Visitor.pyd +0 -0
- Cython/Compiler/__init__.py +1 -0
- Cython/Coverage.py +448 -0
- Cython/Debugger/Cygdb.py +177 -0
- Cython/Debugger/DebugWriter.py +82 -0
- Cython/Debugger/Tests/TestLibCython.py +275 -0
- Cython/Debugger/Tests/__init__.py +1 -0
- Cython/Debugger/Tests/cfuncs.c +8 -0
- Cython/Debugger/Tests/codefile +49 -0
- Cython/Debugger/Tests/test_libcython_in_gdb.py +578 -0
- Cython/Debugger/Tests/test_libpython_in_gdb.py +90 -0
- Cython/Debugger/__init__.py +1 -0
- Cython/Debugger/libcython.py +1548 -0
- Cython/Debugger/libpython.py +2821 -0
- Cython/Debugging.py +20 -0
- Cython/Distutils/__init__.py +2 -0
- Cython/Distutils/build_ext.py +139 -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 +178 -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 +187 -0
- Cython/Includes/cpython/exc.pxd +263 -0
- Cython/Includes/cpython/fileobject.pxd +57 -0
- Cython/Includes/cpython/float.pxd +47 -0
- Cython/Includes/cpython/function.pxd +65 -0
- Cython/Includes/cpython/genobject.pxd +25 -0
- Cython/Includes/cpython/getargs.pxd +12 -0
- Cython/Includes/cpython/instance.pxd +25 -0
- Cython/Includes/cpython/iterator.pxd +36 -0
- Cython/Includes/cpython/iterobject.pxd +24 -0
- Cython/Includes/cpython/list.pxd +92 -0
- Cython/Includes/cpython/long.pxd +149 -0
- Cython/Includes/cpython/longintrepr.pxd +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 +433 -0
- Cython/Includes/cpython/pycapsule.pxd +143 -0
- Cython/Includes/cpython/pylifecycle.pxd +68 -0
- Cython/Includes/cpython/pyport.pxd +8 -0
- Cython/Includes/cpython/pystate.pxd +95 -0
- Cython/Includes/cpython/pythread.pxd +53 -0
- Cython/Includes/cpython/ref.pxd +141 -0
- Cython/Includes/cpython/sequence.pxd +134 -0
- Cython/Includes/cpython/set.pxd +119 -0
- Cython/Includes/cpython/slice.pxd +70 -0
- Cython/Includes/cpython/time.pxd +129 -0
- Cython/Includes/cpython/tuple.pxd +72 -0
- Cython/Includes/cpython/type.pxd +53 -0
- Cython/Includes/cpython/unicode.pxd +639 -0
- Cython/Includes/cpython/version.pxd +32 -0
- Cython/Includes/cpython/weakref.pxd +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/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 +86 -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/Plex/Actions.pxd +24 -0
- Cython/Plex/Actions.py +119 -0
- Cython/Plex/Actions.pyd +0 -0
- Cython/Plex/DFA.pxd +14 -0
- Cython/Plex/DFA.py +164 -0
- Cython/Plex/DFA.pyd +0 -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/Machines.pyd +0 -0
- Cython/Plex/Regexps.py +535 -0
- Cython/Plex/Scanners.pxd +45 -0
- Cython/Plex/Scanners.py +328 -0
- Cython/Plex/Scanners.pyd +0 -0
- Cython/Plex/Transitions.pxd +14 -0
- Cython/Plex/Transitions.py +239 -0
- Cython/Plex/Transitions.pyd +0 -0
- Cython/Plex/__init__.py +34 -0
- Cython/Runtime/__init__.py +1 -0
- Cython/Runtime/refnanny.pyd +0 -0
- Cython/Runtime/refnanny.pyx +237 -0
- Cython/Shadow.py +690 -0
- Cython/Shadow.pyi +521 -0
- Cython/StringIOTree.py +170 -0
- Cython/StringIOTree.pyd +0 -0
- Cython/Tempita/__init__.py +4 -0
- Cython/Tempita/_looper.py +154 -0
- Cython/Tempita/_tempita.py +1091 -0
- Cython/Tempita/_tempita.pyd +0 -0
- Cython/TestUtils.py +422 -0
- Cython/Tests/TestCodeWriter.py +128 -0
- Cython/Tests/TestCythonUtils.py +202 -0
- Cython/Tests/TestJediTyper.py +223 -0
- Cython/Tests/TestShadow.py +114 -0
- Cython/Tests/TestStringIOTree.py +67 -0
- Cython/Tests/TestTestUtils.py +90 -0
- Cython/Tests/__init__.py +1 -0
- Cython/Tests/xmlrunner.py +390 -0
- Cython/Utility/AsyncGen.c +1031 -0
- Cython/Utility/Buffer.c +865 -0
- Cython/Utility/BufferFormatFromTypeInfo.pxd +2 -0
- Cython/Utility/Builtins.c +810 -0
- Cython/Utility/CConvert.pyx +134 -0
- Cython/Utility/CMath.c +104 -0
- Cython/Utility/CommonStructures.c +226 -0
- Cython/Utility/Complex.c +378 -0
- Cython/Utility/Coroutine.c +2300 -0
- Cython/Utility/CpdefEnums.pyx +103 -0
- Cython/Utility/CppConvert.pyx +282 -0
- Cython/Utility/CppSupport.cpp +151 -0
- Cython/Utility/CythonFunction.c +1832 -0
- Cython/Utility/Dataclasses.c +101 -0
- Cython/Utility/Embed.c +121 -0
- Cython/Utility/Exceptions.c +1016 -0
- Cython/Utility/ExtensionTypes.c +996 -0
- Cython/Utility/FunctionArguments.c +1043 -0
- Cython/Utility/FusedFunction.pyx +44 -0
- Cython/Utility/ImportExport.c +907 -0
- Cython/Utility/MemoryView.pxd +188 -0
- Cython/Utility/MemoryView.pyx +1482 -0
- Cython/Utility/MemoryView_C.c +927 -0
- Cython/Utility/ModuleSetupCode.c +3203 -0
- Cython/Utility/NumpyImportArray.c +46 -0
- Cython/Utility/ObjectHandling.c +3273 -0
- Cython/Utility/Optimize.c +1603 -0
- Cython/Utility/Overflow.c +384 -0
- Cython/Utility/Printing.c +86 -0
- Cython/Utility/Profile.c +732 -0
- Cython/Utility/StringTools.c +1379 -0
- Cython/Utility/Synchronization.c +399 -0
- Cython/Utility/TString.c +356 -0
- Cython/Utility/TestCyUtilityLoader.pyx +8 -0
- Cython/Utility/TestCythonScope.pyx +75 -0
- Cython/Utility/TestUtilityLoader.c +12 -0
- Cython/Utility/TypeConversion.c +1385 -0
- Cython/Utility/UFuncs.pyx +50 -0
- Cython/Utility/UFuncs_C.c +89 -0
- Cython/Utility/__init__.py +28 -0
- Cython/Utility/arrayarray.h +167 -0
- Cython/Utils.py +687 -0
- Cython/Utils.pyd +0 -0
- Cython/__init__.py +10 -0
- Cython/__init__.pyi +7 -0
- Cython/py.typed +0 -0
- cython-3.2.0.dist-info/METADATA +85 -0
- cython-3.2.0.dist-info/RECORD +333 -0
- cython-3.2.0.dist-info/WHEEL +5 -0
- cython-3.2.0.dist-info/entry_points.txt +4 -0
- cython-3.2.0.dist-info/top_level.txt +3 -0
- cython.py +29 -0
- pyximport/__init__.py +4 -0
- pyximport/pyxbuild.py +160 -0
- pyximport/pyximport.py +482 -0
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
from cpython.object cimport PyObject
|
|
2
|
+
from cpython.version cimport PY_VERSION_HEX
|
|
3
|
+
|
|
4
|
+
cdef extern from *:
|
|
5
|
+
"""
|
|
6
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
7
|
+
#ifdef _MSC_VER
|
|
8
|
+
#pragma message ("This module uses CPython specific internals of 'datetime.datetime', which are not available in the limited API.")
|
|
9
|
+
#else
|
|
10
|
+
#warning This module uses CPython specific internals of 'datetime.datetime', which are not available in the limited API.
|
|
11
|
+
#endif
|
|
12
|
+
#endif
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
cdef extern from "Python.h":
|
|
16
|
+
ctypedef struct PyTypeObject:
|
|
17
|
+
pass
|
|
18
|
+
|
|
19
|
+
cdef extern from "datetime.h":
|
|
20
|
+
"""
|
|
21
|
+
#define __Pyx_DateTime_DateTimeWithFold(year, month, day, hour, minute, second, microsecond, tz, fold) \
|
|
22
|
+
PyDateTimeAPI->DateTime_FromDateAndTimeAndFold(year, month, day, hour, minute, second, \
|
|
23
|
+
microsecond, tz, fold, PyDateTimeAPI->DateTimeType)
|
|
24
|
+
#define __Pyx_DateTime_TimeWithFold(hour, minute, second, microsecond, tz, fold) \
|
|
25
|
+
PyDateTimeAPI->Time_FromTimeAndFold(hour, minute, second, microsecond, tz, fold, PyDateTimeAPI->TimeType)
|
|
26
|
+
|
|
27
|
+
#define __Pyx_TimeZone_UTC PyDateTime_TimeZone_UTC
|
|
28
|
+
#define __Pyx_TimeZone_FromOffsetAndName(offset, name) PyTimeZone_FromOffsetAndName(offset, name)
|
|
29
|
+
|
|
30
|
+
/* Backport for Python < 3.10 */
|
|
31
|
+
#if PY_VERSION_HEX < 0x030a00a1
|
|
32
|
+
#ifndef PyDateTime_TIME_GET_TZINFO
|
|
33
|
+
#define PyDateTime_TIME_GET_TZINFO(o) \
|
|
34
|
+
((((PyDateTime_Time*)o)->hastzinfo) ? ((PyDateTime_Time*)o)->tzinfo : Py_None)
|
|
35
|
+
#endif
|
|
36
|
+
#ifndef PyDateTime_DATE_GET_TZINFO
|
|
37
|
+
#define PyDateTime_DATE_GET_TZINFO(o) \
|
|
38
|
+
((((PyDateTime_DateTime*)o)->hastzinfo) ? ((PyDateTime_DateTime*)o)->tzinfo : Py_None)
|
|
39
|
+
#endif
|
|
40
|
+
#endif
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
ctypedef extern class datetime.date[object PyDateTime_Date]:
|
|
44
|
+
@property
|
|
45
|
+
cdef inline int year(self) noexcept:
|
|
46
|
+
return PyDateTime_GET_YEAR(self)
|
|
47
|
+
|
|
48
|
+
@property
|
|
49
|
+
cdef inline int month(self) noexcept:
|
|
50
|
+
return PyDateTime_GET_MONTH(self)
|
|
51
|
+
|
|
52
|
+
@property
|
|
53
|
+
cdef inline int day(self) noexcept:
|
|
54
|
+
return PyDateTime_GET_DAY(self)
|
|
55
|
+
|
|
56
|
+
ctypedef extern class datetime.time[object PyDateTime_Time]:
|
|
57
|
+
@property
|
|
58
|
+
cdef inline int hour(self) noexcept:
|
|
59
|
+
return PyDateTime_TIME_GET_HOUR(self)
|
|
60
|
+
|
|
61
|
+
@property
|
|
62
|
+
cdef inline int minute(self) noexcept:
|
|
63
|
+
return PyDateTime_TIME_GET_MINUTE(self)
|
|
64
|
+
|
|
65
|
+
@property
|
|
66
|
+
cdef inline int second(self) noexcept:
|
|
67
|
+
return PyDateTime_TIME_GET_SECOND(self)
|
|
68
|
+
|
|
69
|
+
@property
|
|
70
|
+
cdef inline int microsecond(self) noexcept:
|
|
71
|
+
return PyDateTime_TIME_GET_MICROSECOND(self)
|
|
72
|
+
|
|
73
|
+
@property
|
|
74
|
+
cdef inline object tzinfo(self):
|
|
75
|
+
return <object>PyDateTime_TIME_GET_TZINFO(self)
|
|
76
|
+
|
|
77
|
+
@property
|
|
78
|
+
cdef inline int fold(self) noexcept:
|
|
79
|
+
# For Python < 3.6 this returns 0 no matter what
|
|
80
|
+
return PyDateTime_TIME_GET_FOLD(self)
|
|
81
|
+
|
|
82
|
+
ctypedef extern class datetime.datetime[object PyDateTime_DateTime]:
|
|
83
|
+
@property
|
|
84
|
+
cdef inline int year(self) noexcept:
|
|
85
|
+
return PyDateTime_GET_YEAR(self)
|
|
86
|
+
|
|
87
|
+
@property
|
|
88
|
+
cdef inline int month(self) noexcept:
|
|
89
|
+
return PyDateTime_GET_MONTH(self)
|
|
90
|
+
|
|
91
|
+
@property
|
|
92
|
+
cdef inline int day(self) noexcept:
|
|
93
|
+
return PyDateTime_GET_DAY(self)
|
|
94
|
+
|
|
95
|
+
@property
|
|
96
|
+
cdef inline int hour(self) noexcept:
|
|
97
|
+
return PyDateTime_DATE_GET_HOUR(self)
|
|
98
|
+
|
|
99
|
+
@property
|
|
100
|
+
cdef inline int minute(self) noexcept:
|
|
101
|
+
return PyDateTime_DATE_GET_MINUTE(self)
|
|
102
|
+
|
|
103
|
+
@property
|
|
104
|
+
cdef inline int second(self) noexcept:
|
|
105
|
+
return PyDateTime_DATE_GET_SECOND(self)
|
|
106
|
+
|
|
107
|
+
@property
|
|
108
|
+
cdef inline int microsecond(self) noexcept:
|
|
109
|
+
return PyDateTime_DATE_GET_MICROSECOND(self)
|
|
110
|
+
|
|
111
|
+
@property
|
|
112
|
+
cdef inline object tzinfo(self):
|
|
113
|
+
return <object>PyDateTime_DATE_GET_TZINFO(self)
|
|
114
|
+
|
|
115
|
+
@property
|
|
116
|
+
cdef inline int fold(self) noexcept:
|
|
117
|
+
# For Python < 3.6 this returns 0 no matter what
|
|
118
|
+
return PyDateTime_DATE_GET_FOLD(self)
|
|
119
|
+
|
|
120
|
+
ctypedef extern class datetime.timedelta[object PyDateTime_Delta]:
|
|
121
|
+
@property
|
|
122
|
+
cdef inline int day(self) noexcept:
|
|
123
|
+
return PyDateTime_DELTA_GET_DAYS(self)
|
|
124
|
+
|
|
125
|
+
@property
|
|
126
|
+
cdef inline int second(self) noexcept:
|
|
127
|
+
return PyDateTime_DELTA_GET_SECONDS(self)
|
|
128
|
+
|
|
129
|
+
@property
|
|
130
|
+
cdef inline int microsecond(self) noexcept:
|
|
131
|
+
return PyDateTime_DELTA_GET_MICROSECONDS(self)
|
|
132
|
+
|
|
133
|
+
ctypedef extern class datetime.tzinfo[object PyDateTime_TZInfo]:
|
|
134
|
+
pass
|
|
135
|
+
|
|
136
|
+
ctypedef struct PyDateTime_Date:
|
|
137
|
+
pass
|
|
138
|
+
|
|
139
|
+
ctypedef struct PyDateTime_Time:
|
|
140
|
+
unsigned char fold
|
|
141
|
+
char hastzinfo
|
|
142
|
+
PyObject *tzinfo
|
|
143
|
+
|
|
144
|
+
ctypedef struct PyDateTime_DateTime:
|
|
145
|
+
unsigned char fold
|
|
146
|
+
char hastzinfo
|
|
147
|
+
PyObject *tzinfo
|
|
148
|
+
|
|
149
|
+
ctypedef struct PyDateTime_Delta:
|
|
150
|
+
int days
|
|
151
|
+
int seconds
|
|
152
|
+
int microseconds
|
|
153
|
+
|
|
154
|
+
# Define structure for C API.
|
|
155
|
+
ctypedef struct PyDateTime_CAPI:
|
|
156
|
+
# type objects
|
|
157
|
+
PyTypeObject *DateType
|
|
158
|
+
PyTypeObject *DateTimeType
|
|
159
|
+
PyTypeObject *TimeType
|
|
160
|
+
PyTypeObject *DeltaType
|
|
161
|
+
PyTypeObject *TZInfoType
|
|
162
|
+
|
|
163
|
+
# constructors
|
|
164
|
+
date (*Date_FromDate)(int, int, int, PyTypeObject*)
|
|
165
|
+
datetime (*DateTime_FromDateAndTime)(int, int, int, int, int, int, int, object, PyTypeObject*)
|
|
166
|
+
time (*Time_FromTime)(int, int, int, int, object, PyTypeObject*)
|
|
167
|
+
timedelta (*Delta_FromDelta)(int, int, int, int, PyTypeObject*)
|
|
168
|
+
|
|
169
|
+
# constructors for the DB API
|
|
170
|
+
datetime (*DateTime_FromTimestamp)(PyObject*, object, PyObject*)
|
|
171
|
+
date (*Date_FromTimestamp)(PyObject*, object)
|
|
172
|
+
|
|
173
|
+
# We cannot use the following because they do not compile in older Python versions.
|
|
174
|
+
# Instead, we use datetime.h's macros here that we can backport in C.
|
|
175
|
+
|
|
176
|
+
# Python 3.7+ constructors
|
|
177
|
+
object (*TimeZone_FromTimeZone)(object offset, PyObject *name)
|
|
178
|
+
|
|
179
|
+
# Python 3.7+ singletons
|
|
180
|
+
PyObject *TimeZone_UTC
|
|
181
|
+
|
|
182
|
+
# Python 3.6+ PEP 495 constructors
|
|
183
|
+
datetime (*DateTime_FromDateAndTimeAndFold)(int, int, int, int, int, int, int, object, int, PyTypeObject*)
|
|
184
|
+
time (*Time_FromTimeAndFold)(int, int, int ,int, object, int, PyTypeObject*)
|
|
185
|
+
|
|
186
|
+
# Check type of the object.
|
|
187
|
+
bint PyDate_Check(object op)
|
|
188
|
+
bint PyDate_CheckExact(object op)
|
|
189
|
+
|
|
190
|
+
bint PyDateTime_Check(object op)
|
|
191
|
+
bint PyDateTime_CheckExact(object op)
|
|
192
|
+
|
|
193
|
+
bint PyTime_Check(object op)
|
|
194
|
+
bint PyTime_CheckExact(object op)
|
|
195
|
+
|
|
196
|
+
bint PyDelta_Check(object op)
|
|
197
|
+
bint PyDelta_CheckExact(object op)
|
|
198
|
+
|
|
199
|
+
bint PyTZInfo_Check(object op)
|
|
200
|
+
bint PyTZInfo_CheckExact(object op)
|
|
201
|
+
|
|
202
|
+
# Getters for date and datetime (C macros).
|
|
203
|
+
int PyDateTime_GET_YEAR(object o)
|
|
204
|
+
int PyDateTime_GET_MONTH(object o)
|
|
205
|
+
int PyDateTime_GET_DAY(object o)
|
|
206
|
+
|
|
207
|
+
# Getters for datetime (C macros).
|
|
208
|
+
int PyDateTime_DATE_GET_HOUR(object o)
|
|
209
|
+
int PyDateTime_DATE_GET_MINUTE(object o)
|
|
210
|
+
int PyDateTime_DATE_GET_SECOND(object o)
|
|
211
|
+
int PyDateTime_DATE_GET_MICROSECOND(object o)
|
|
212
|
+
int PyDateTime_DATE_GET_FOLD(object o)
|
|
213
|
+
PyObject* PyDateTime_DATE_GET_TZINFO(object o) # returns a borrowed reference
|
|
214
|
+
|
|
215
|
+
# Getters for time (C macros).
|
|
216
|
+
int PyDateTime_TIME_GET_HOUR(object o)
|
|
217
|
+
int PyDateTime_TIME_GET_MINUTE(object o)
|
|
218
|
+
int PyDateTime_TIME_GET_SECOND(object o)
|
|
219
|
+
int PyDateTime_TIME_GET_MICROSECOND(object o)
|
|
220
|
+
int PyDateTime_TIME_GET_FOLD(object o)
|
|
221
|
+
PyObject* PyDateTime_TIME_GET_TZINFO(object o) # returns a borrowed reference
|
|
222
|
+
|
|
223
|
+
# Getters for timedelta (C macros).
|
|
224
|
+
int PyDateTime_DELTA_GET_DAYS(object o)
|
|
225
|
+
int PyDateTime_DELTA_GET_SECONDS(object o)
|
|
226
|
+
int PyDateTime_DELTA_GET_MICROSECONDS(object o)
|
|
227
|
+
|
|
228
|
+
# Constructors
|
|
229
|
+
object PyTimeZone_FromOffset(object offset)
|
|
230
|
+
object PyTimeZone_FromOffsetAndName(object offset, object name)
|
|
231
|
+
|
|
232
|
+
# The above macros is Python 3.7+ so we use these instead
|
|
233
|
+
object __Pyx_TimeZone_FromOffsetAndName(object offset, PyObject* name)
|
|
234
|
+
|
|
235
|
+
# Constructors for the DB API
|
|
236
|
+
datetime PyDateTime_FromTimeStamp(object args)
|
|
237
|
+
date PyDate_FromTimeStamp(object args)
|
|
238
|
+
|
|
239
|
+
# PEP 495 constructors but patched above to allow passing tz
|
|
240
|
+
datetime __Pyx_DateTime_DateTimeWithFold(int, int, int, int, int, int, int, object, int)
|
|
241
|
+
datetime __Pyx_DateTime_TimeWithFold(int, int, int ,int, object, int)
|
|
242
|
+
|
|
243
|
+
# PyDateTime CAPI object.
|
|
244
|
+
PyDateTime_CAPI *PyDateTimeAPI
|
|
245
|
+
|
|
246
|
+
PyObject* PyDateTime_TimeZone_UTC
|
|
247
|
+
|
|
248
|
+
# PyDateTime_TimeZone_UTC is Python 3.7+ so instead we use the following macro
|
|
249
|
+
PyObject* __Pyx_TimeZone_UTC
|
|
250
|
+
|
|
251
|
+
void PyDateTime_IMPORT()
|
|
252
|
+
|
|
253
|
+
# Datetime C API initialization function.
|
|
254
|
+
# You have to call it before any usage of DateTime CAPI functions.
|
|
255
|
+
cdef inline void import_datetime() noexcept:
|
|
256
|
+
PyDateTime_IMPORT
|
|
257
|
+
|
|
258
|
+
# Create date object using DateTime CAPI factory function.
|
|
259
|
+
# Note, there are no range checks for any of the arguments.
|
|
260
|
+
cdef inline date date_new(int year, int month, int day):
|
|
261
|
+
return PyDateTimeAPI.Date_FromDate(year, month, day, PyDateTimeAPI.DateType)
|
|
262
|
+
|
|
263
|
+
# Create time object using DateTime CAPI factory function
|
|
264
|
+
# Note, there are no range checks for any of the arguments.
|
|
265
|
+
cdef inline time time_new(int hour, int minute, int second, int microsecond, object tz, int fold=0):
|
|
266
|
+
return __Pyx_DateTime_TimeWithFold(hour, minute, second, microsecond, tz, fold)
|
|
267
|
+
|
|
268
|
+
# Create datetime object using DateTime CAPI factory function.
|
|
269
|
+
# Note, there are no range checks for any of the arguments.
|
|
270
|
+
cdef inline datetime datetime_new(int year, int month, int day, int hour, int minute, int second, int microsecond, object tz, int fold=0):
|
|
271
|
+
return __Pyx_DateTime_DateTimeWithFold(year, month, day, hour, minute, second, microsecond, tz, fold)
|
|
272
|
+
|
|
273
|
+
# Create timedelta object using DateTime CAPI factory function.
|
|
274
|
+
# Note, there are no range checks for any of the arguments.
|
|
275
|
+
cdef inline timedelta timedelta_new(int days, int seconds, int useconds):
|
|
276
|
+
return PyDateTimeAPI.Delta_FromDelta(days, seconds, useconds, 1, PyDateTimeAPI.DeltaType)
|
|
277
|
+
|
|
278
|
+
# Create timedelta object using DateTime CAPI factory function.
|
|
279
|
+
cdef inline object timezone_new(object offset, object name=None):
|
|
280
|
+
return __Pyx_TimeZone_FromOffsetAndName(offset, <PyObject*>name if name is not None else NULL)
|
|
281
|
+
|
|
282
|
+
# Create datetime object using DB API constructor.
|
|
283
|
+
cdef inline datetime datetime_from_timestamp(timestamp, tz=None):
|
|
284
|
+
return PyDateTimeAPI.DateTime_FromTimestamp(
|
|
285
|
+
<PyObject*>PyDateTimeAPI.DateTimeType, (timestamp, tz) if tz is not None else (timestamp,), NULL)
|
|
286
|
+
|
|
287
|
+
# Create date object using DB API constructor.
|
|
288
|
+
cdef inline date date_from_timestamp(timestamp):
|
|
289
|
+
return PyDateTimeAPI.Date_FromTimestamp(<PyObject*>PyDateTimeAPI.DateType, (timestamp,))
|
|
290
|
+
|
|
291
|
+
# More recognizable getters for date/time/datetime/timedelta.
|
|
292
|
+
# There are no setters because datetime.h hasn't them.
|
|
293
|
+
# This is because of immutable nature of these objects by design.
|
|
294
|
+
# If you would change time/date/datetime/timedelta object you need to recreate.
|
|
295
|
+
|
|
296
|
+
# Get UTC singleton
|
|
297
|
+
cdef inline object get_utc():
|
|
298
|
+
return <object>__Pyx_TimeZone_UTC
|
|
299
|
+
|
|
300
|
+
# Get tzinfo of time
|
|
301
|
+
cdef inline object time_tzinfo(object o):
|
|
302
|
+
return <object>PyDateTime_TIME_GET_TZINFO(o)
|
|
303
|
+
|
|
304
|
+
# Get tzinfo of datetime
|
|
305
|
+
cdef inline object datetime_tzinfo(object o):
|
|
306
|
+
return <object>PyDateTime_DATE_GET_TZINFO(o)
|
|
307
|
+
|
|
308
|
+
# Get year of date
|
|
309
|
+
cdef inline int date_year(object o) noexcept:
|
|
310
|
+
return PyDateTime_GET_YEAR(o)
|
|
311
|
+
|
|
312
|
+
# Get month of date
|
|
313
|
+
cdef inline int date_month(object o) noexcept:
|
|
314
|
+
return PyDateTime_GET_MONTH(o)
|
|
315
|
+
|
|
316
|
+
# Get day of date
|
|
317
|
+
cdef inline int date_day(object o) noexcept:
|
|
318
|
+
return PyDateTime_GET_DAY(o)
|
|
319
|
+
|
|
320
|
+
# Get year of datetime
|
|
321
|
+
cdef inline int datetime_year(object o) noexcept:
|
|
322
|
+
return PyDateTime_GET_YEAR(o)
|
|
323
|
+
|
|
324
|
+
# Get month of datetime
|
|
325
|
+
cdef inline int datetime_month(object o) noexcept:
|
|
326
|
+
return PyDateTime_GET_MONTH(o)
|
|
327
|
+
|
|
328
|
+
# Get day of datetime
|
|
329
|
+
cdef inline int datetime_day(object o) noexcept:
|
|
330
|
+
return PyDateTime_GET_DAY(o)
|
|
331
|
+
|
|
332
|
+
# Get hour of time
|
|
333
|
+
cdef inline int time_hour(object o) noexcept:
|
|
334
|
+
return PyDateTime_TIME_GET_HOUR(o)
|
|
335
|
+
|
|
336
|
+
# Get minute of time
|
|
337
|
+
cdef inline int time_minute(object o) noexcept:
|
|
338
|
+
return PyDateTime_TIME_GET_MINUTE(o)
|
|
339
|
+
|
|
340
|
+
# Get second of time
|
|
341
|
+
cdef inline int time_second(object o) noexcept:
|
|
342
|
+
return PyDateTime_TIME_GET_SECOND(o)
|
|
343
|
+
|
|
344
|
+
# Get microsecond of time
|
|
345
|
+
cdef inline int time_microsecond(object o) noexcept:
|
|
346
|
+
return PyDateTime_TIME_GET_MICROSECOND(o)
|
|
347
|
+
|
|
348
|
+
# Get fold of time
|
|
349
|
+
cdef inline int time_fold(object o) noexcept:
|
|
350
|
+
# For Python < 3.6 this returns 0 no matter what
|
|
351
|
+
return PyDateTime_TIME_GET_FOLD(o)
|
|
352
|
+
|
|
353
|
+
# Get hour of datetime
|
|
354
|
+
cdef inline int datetime_hour(object o) noexcept:
|
|
355
|
+
return PyDateTime_DATE_GET_HOUR(o)
|
|
356
|
+
|
|
357
|
+
# Get minute of datetime
|
|
358
|
+
cdef inline int datetime_minute(object o) noexcept:
|
|
359
|
+
return PyDateTime_DATE_GET_MINUTE(o)
|
|
360
|
+
|
|
361
|
+
# Get second of datetime
|
|
362
|
+
cdef inline int datetime_second(object o) noexcept:
|
|
363
|
+
return PyDateTime_DATE_GET_SECOND(o)
|
|
364
|
+
|
|
365
|
+
# Get microsecond of datetime
|
|
366
|
+
cdef inline int datetime_microsecond(object o) noexcept:
|
|
367
|
+
return PyDateTime_DATE_GET_MICROSECOND(o)
|
|
368
|
+
|
|
369
|
+
# Get fold of datetime
|
|
370
|
+
cdef inline int datetime_fold(object o) noexcept:
|
|
371
|
+
# For Python < 3.6 this returns 0 no matter what
|
|
372
|
+
return PyDateTime_DATE_GET_FOLD(o)
|
|
373
|
+
|
|
374
|
+
# Get days of timedelta
|
|
375
|
+
cdef inline int timedelta_days(object o) noexcept:
|
|
376
|
+
return PyDateTime_DELTA_GET_DAYS(o)
|
|
377
|
+
|
|
378
|
+
# Get seconds of timedelta
|
|
379
|
+
cdef inline int timedelta_seconds(object o) noexcept:
|
|
380
|
+
return PyDateTime_DELTA_GET_SECONDS(o)
|
|
381
|
+
|
|
382
|
+
# Get microseconds of timedelta
|
|
383
|
+
cdef inline int timedelta_microseconds(object o) noexcept:
|
|
384
|
+
return PyDateTime_DELTA_GET_MICROSECONDS(o)
|
|
385
|
+
|
|
386
|
+
cdef inline double total_seconds(timedelta obj) noexcept:
|
|
387
|
+
# Mirrors the "timedelta.total_seconds()" method.
|
|
388
|
+
# Note that this implementation is not guaranteed to give *exactly* the same
|
|
389
|
+
# result as the original method, due to potential differences in floating point rounding.
|
|
390
|
+
cdef:
|
|
391
|
+
double days, seconds, micros
|
|
392
|
+
days = <double>PyDateTime_DELTA_GET_DAYS(obj)
|
|
393
|
+
seconds = <double>PyDateTime_DELTA_GET_SECONDS(obj)
|
|
394
|
+
micros = <double>PyDateTime_DELTA_GET_MICROSECONDS(obj)
|
|
395
|
+
return days * 24 * 3600 + seconds + micros / 1_000_000
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
from .object cimport PyObject, PyTypeObject
|
|
2
|
+
|
|
3
|
+
cdef extern from "Python.h":
|
|
4
|
+
ctypedef object (*wrapperfunc)(self, args, void* wrapped)
|
|
5
|
+
ctypedef object (*wrapperfunc_kwds)(self, args, void* wrapped, kwds)
|
|
6
|
+
|
|
7
|
+
struct wrapperbase:
|
|
8
|
+
char* name
|
|
9
|
+
int offset
|
|
10
|
+
void* function
|
|
11
|
+
wrapperfunc wrapper
|
|
12
|
+
char* doc
|
|
13
|
+
int flags
|
|
14
|
+
PyObject* name_strobj
|
|
15
|
+
|
|
16
|
+
int PyWrapperFlag_KEYWORDS
|
|
17
|
+
|
|
18
|
+
ctypedef class __builtin__.wrapper_descriptor [object PyWrapperDescrObject]:
|
|
19
|
+
cdef type d_type
|
|
20
|
+
cdef d_name
|
|
21
|
+
cdef wrapperbase* d_base
|
|
22
|
+
cdef void* d_wrapped
|
|
23
|
+
|
|
24
|
+
object PyDescr_NewWrapper(PyTypeObject* cls, wrapperbase* wrapper, void* wrapped)
|
|
25
|
+
|
|
26
|
+
int PyDescr_IsData(descr)
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
from .object cimport PyObject
|
|
2
|
+
from .pyport cimport uint64_t
|
|
3
|
+
|
|
4
|
+
cdef extern from *:
|
|
5
|
+
# On Python 2, PyDict_GetItemWithError is called _PyDict_GetItemWithError
|
|
6
|
+
"""
|
|
7
|
+
#if PY_MAJOR_VERSION <= 2
|
|
8
|
+
#define PyDict_GetItemWithError _PyDict_GetItemWithError
|
|
9
|
+
#endif
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
cdef extern from "Python.h":
|
|
13
|
+
############################################################################
|
|
14
|
+
# 7.4.1 Dictionary Objects
|
|
15
|
+
############################################################################
|
|
16
|
+
|
|
17
|
+
# PyDictObject
|
|
18
|
+
#
|
|
19
|
+
# This subtype of PyObject represents a Python dictionary object
|
|
20
|
+
# (i.e. the 'dict' type).
|
|
21
|
+
|
|
22
|
+
# PyTypeObject PyDict_Type
|
|
23
|
+
#
|
|
24
|
+
# This instance of PyTypeObject represents the Python dictionary
|
|
25
|
+
# type. This is exposed to Python programs as dict and
|
|
26
|
+
# types.DictType.
|
|
27
|
+
|
|
28
|
+
bint PyDict_Check(object p)
|
|
29
|
+
# Return true if p is a dict object or an instance of a subtype of
|
|
30
|
+
# the dict type.
|
|
31
|
+
|
|
32
|
+
bint PyDict_CheckExact(object p)
|
|
33
|
+
# Return true if p is a dict object, but not an instance of a
|
|
34
|
+
# subtype of the dict type.
|
|
35
|
+
|
|
36
|
+
dict PyDict_New()
|
|
37
|
+
# Return value: New reference.
|
|
38
|
+
# Return a new empty dictionary, or NULL on failure.
|
|
39
|
+
|
|
40
|
+
object PyDictProxy_New(object dict)
|
|
41
|
+
# Return value: New reference.
|
|
42
|
+
# Return a proxy object for a mapping which enforces read-only
|
|
43
|
+
# behavior. This is normally used to create a proxy to prevent
|
|
44
|
+
# modification of the dictionary for non-dynamic class types.
|
|
45
|
+
|
|
46
|
+
void PyDict_Clear(object p)
|
|
47
|
+
# Empty an existing dictionary of all key-value pairs.
|
|
48
|
+
|
|
49
|
+
int PyDict_Contains(object p, object key) except -1
|
|
50
|
+
# Determine if dictionary p contains key. If an item in p is
|
|
51
|
+
# matches key, return 1, otherwise return 0. On error, return
|
|
52
|
+
# -1. This is equivalent to the Python expression "key in p".
|
|
53
|
+
|
|
54
|
+
dict PyDict_Copy(object p)
|
|
55
|
+
# Return value: New reference.
|
|
56
|
+
# Return a new dictionary that contains the same key-value pairs as p.
|
|
57
|
+
|
|
58
|
+
int PyDict_SetItem(object p, object key, object val) except -1
|
|
59
|
+
# Insert value into the dictionary p with a key of key. key must
|
|
60
|
+
# be hashable; if it isn't, TypeError will be raised. Return 0 on
|
|
61
|
+
# success or -1 on failure.
|
|
62
|
+
|
|
63
|
+
int PyDict_SetItemString(object p, const char *key, object val) except -1
|
|
64
|
+
# Insert value into the dictionary p using key as a key. key
|
|
65
|
+
# should be a char*. The key object is created using
|
|
66
|
+
# PyString_FromString(key). Return 0 on success or -1 on failure.
|
|
67
|
+
|
|
68
|
+
int PyDict_DelItem(object p, object key) except -1
|
|
69
|
+
# Remove the entry in dictionary p with key key. key must be
|
|
70
|
+
# hashable; if it isn't, TypeError is raised. Return 0 on success
|
|
71
|
+
# or -1 on failure.
|
|
72
|
+
|
|
73
|
+
int PyDict_DelItemString(object p, const char *key) except -1
|
|
74
|
+
# Remove the entry in dictionary p which has a key specified by
|
|
75
|
+
# the string key. Return 0 on success or -1 on failure.
|
|
76
|
+
|
|
77
|
+
PyObject* PyDict_GetItem(object p, object key)
|
|
78
|
+
# Return value: Borrowed reference.
|
|
79
|
+
# Return the object from dictionary p which has a key key. Return
|
|
80
|
+
# NULL if the key key is not present, but without setting an
|
|
81
|
+
# exception.
|
|
82
|
+
|
|
83
|
+
PyObject* PyDict_GetItemWithError(object p, object key) except? NULL
|
|
84
|
+
# Return value: Borrowed reference.
|
|
85
|
+
# Variant of PyDict_GetItem() that does not suppress exceptions. Return
|
|
86
|
+
# NULL with an exception set if an exception occurred. Return NULL
|
|
87
|
+
# without an exception set if the key wasn’t present.
|
|
88
|
+
|
|
89
|
+
PyObject* PyDict_GetItemString(object p, const char *key)
|
|
90
|
+
# Return value: Borrowed reference.
|
|
91
|
+
# This is the same as PyDict_GetItem(), but key is specified as a
|
|
92
|
+
# char*, rather than a PyObject*.
|
|
93
|
+
|
|
94
|
+
PyObject* PyDict_SetDefault(object p, object key, object default) except NULL
|
|
95
|
+
# Return value: Borrowed reference.
|
|
96
|
+
# This is the same as the Python-level dict.setdefault(). If present, it
|
|
97
|
+
# returns the value corresponding to key from the dictionary p. If the key
|
|
98
|
+
# is not in the dict, it is inserted with value defaultobj and defaultobj
|
|
99
|
+
# is returned. This function evaluates the hash function of key only once,
|
|
100
|
+
# instead of evaluating it independently for the lookup and the insertion.
|
|
101
|
+
|
|
102
|
+
list PyDict_Items(object p)
|
|
103
|
+
# Return value: New reference.
|
|
104
|
+
# Return a PyListObject containing all the items from the
|
|
105
|
+
# dictionary, as in the dictionary method items() (see the Python
|
|
106
|
+
# Library Reference).
|
|
107
|
+
|
|
108
|
+
list PyDict_Keys(object p)
|
|
109
|
+
# Return value: New reference.
|
|
110
|
+
# Return a PyListObject containing all the keys from the
|
|
111
|
+
# dictionary, as in the dictionary method keys() (see the Python
|
|
112
|
+
# Library Reference).
|
|
113
|
+
|
|
114
|
+
list PyDict_Values(object p)
|
|
115
|
+
# Return value: New reference.
|
|
116
|
+
# Return a PyListObject containing all the values from the
|
|
117
|
+
# dictionary p, as in the dictionary method values() (see the
|
|
118
|
+
# Python Library Reference).
|
|
119
|
+
|
|
120
|
+
Py_ssize_t PyDict_Size(object p) except -1
|
|
121
|
+
# Return the number of items in the dictionary. This is equivalent
|
|
122
|
+
# to "len(p)" on a dictionary.
|
|
123
|
+
|
|
124
|
+
int PyDict_Next(object p, Py_ssize_t *ppos, PyObject* *pkey, PyObject* *pvalue)
|
|
125
|
+
# Iterate over all key-value pairs in the dictionary p. The int
|
|
126
|
+
# referred to by ppos must be initialized to 0 prior to the first
|
|
127
|
+
# call to this function to start the iteration; the function
|
|
128
|
+
# returns true for each pair in the dictionary, and false once all
|
|
129
|
+
# pairs have been reported. The parameters pkey and pvalue should
|
|
130
|
+
# either point to PyObject* variables that will be filled in with
|
|
131
|
+
# each key and value, respectively, or may be NULL. Any references
|
|
132
|
+
# returned through them are borrowed. ppos should not be altered
|
|
133
|
+
# during iteration. Its value represents offsets within the
|
|
134
|
+
# internal dictionary structure, and since the structure is
|
|
135
|
+
# sparse, the offsets are not consecutive.
|
|
136
|
+
# For example:
|
|
137
|
+
#
|
|
138
|
+
#object key, *value;
|
|
139
|
+
#int pos = 0;
|
|
140
|
+
#
|
|
141
|
+
#while (PyDict_Next(self->dict, &pos, &key, &value)) {
|
|
142
|
+
# /* do something interesting with the values... */
|
|
143
|
+
# ...
|
|
144
|
+
#}
|
|
145
|
+
# The dictionary p should not be mutated during iteration. It is
|
|
146
|
+
# safe (since Python 2.1) to modify the values of the keys as you
|
|
147
|
+
# iterate over the dictionary, but only so long as the set of keys
|
|
148
|
+
# does not change. For example:
|
|
149
|
+
# object key, *value;
|
|
150
|
+
# int pos = 0;
|
|
151
|
+
# while (PyDict_Next(self->dict, &pos, &key, &value)) {
|
|
152
|
+
# int i = PyInt_AS_LONG(value) + 1;
|
|
153
|
+
# object o = PyInt_FromLong(i);
|
|
154
|
+
# if (o == NULL)
|
|
155
|
+
# return -1;
|
|
156
|
+
# if (PyDict_SetItem(self->dict, key, o) < 0) {
|
|
157
|
+
# Py_DECREF(o);
|
|
158
|
+
# return -1;
|
|
159
|
+
# }
|
|
160
|
+
# Py_DECREF(o);
|
|
161
|
+
# }
|
|
162
|
+
|
|
163
|
+
int PyDict_Merge(object a, object b, int override) except -1
|
|
164
|
+
# Iterate over mapping object b adding key-value pairs to
|
|
165
|
+
# dictionary a. b may be a dictionary, or any object supporting
|
|
166
|
+
# PyMapping_Keys() and PyObject_GetItem(). If override is true,
|
|
167
|
+
# existing pairs in a will be replaced if a matching key is found
|
|
168
|
+
# in b, otherwise pairs will only be added if there is not a
|
|
169
|
+
# matching key in a. Return 0 on success or -1 if an exception was
|
|
170
|
+
# raised.
|
|
171
|
+
|
|
172
|
+
int PyDict_Update(object a, object b) except -1
|
|
173
|
+
# This is the same as PyDict_Merge(a, b, 1) in C, or a.update(b)
|
|
174
|
+
# in Python. Return 0 on success or -1 if an exception was raised.
|
|
175
|
+
|
|
176
|
+
int PyDict_MergeFromSeq2(object a, object seq2, int override) except -1
|
|
177
|
+
# Update or merge into dictionary a, from the key-value pairs in
|
|
178
|
+
# seq2. seq2 must be an iterable object producing iterable objects
|
|
179
|
+
# of length 2, viewed as key-value pairs. In case of duplicate
|
|
180
|
+
# keys, the last wins if override is true, else the first
|
|
181
|
+
# wins. Return 0 on success or -1 if an exception was
|
|
182
|
+
# raised. Equivalent Python (except for the return value):
|
|
183
|
+
#
|
|
184
|
+
#def PyDict_MergeFromSeq2(a, seq2, override):
|
|
185
|
+
# for key, value in seq2:
|
|
186
|
+
# if override or key not in a:
|
|
187
|
+
# a[key] = value
|