Cython 3.1.0a1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (301) hide show
  1. Cython/Build/BuildExecutable.py +169 -0
  2. Cython/Build/Cache.py +199 -0
  3. Cython/Build/Cythonize.py +250 -0
  4. Cython/Build/Dependencies.py +1275 -0
  5. Cython/Build/Distutils.py +1 -0
  6. Cython/Build/Inline.py +342 -0
  7. Cython/Build/IpythonMagic.py +560 -0
  8. Cython/Build/Tests/TestCyCache.py +119 -0
  9. Cython/Build/Tests/TestCythonizeArgsParser.py +481 -0
  10. Cython/Build/Tests/TestDependencies.py +133 -0
  11. Cython/Build/Tests/TestInline.py +112 -0
  12. Cython/Build/Tests/TestIpythonMagic.py +287 -0
  13. Cython/Build/Tests/TestRecythonize.py +212 -0
  14. Cython/Build/Tests/TestStripLiterals.py +155 -0
  15. Cython/Build/Tests/__init__.py +1 -0
  16. Cython/Build/__init__.py +8 -0
  17. Cython/CodeWriter.py +811 -0
  18. Cython/Compiler/AnalysedTreeTransforms.py +97 -0
  19. Cython/Compiler/Annotate.py +326 -0
  20. Cython/Compiler/AutoDocTransforms.py +314 -0
  21. Cython/Compiler/Buffer.py +680 -0
  22. Cython/Compiler/Builtin.py +862 -0
  23. Cython/Compiler/CmdLine.py +243 -0
  24. Cython/Compiler/Code.pxd +145 -0
  25. Cython/Compiler/Code.py +3328 -0
  26. Cython/Compiler/CodeGeneration.py +33 -0
  27. Cython/Compiler/CythonScope.py +179 -0
  28. Cython/Compiler/Dataclass.py +868 -0
  29. Cython/Compiler/DebugFlags.py +21 -0
  30. Cython/Compiler/Errors.py +295 -0
  31. Cython/Compiler/ExprNodes.py +15051 -0
  32. Cython/Compiler/FlowControl.pxd +97 -0
  33. Cython/Compiler/FlowControl.py +1438 -0
  34. Cython/Compiler/FusedNode.py +998 -0
  35. Cython/Compiler/Future.py +16 -0
  36. Cython/Compiler/Interpreter.py +57 -0
  37. Cython/Compiler/Lexicon.py +340 -0
  38. Cython/Compiler/LineTable.py +114 -0
  39. Cython/Compiler/Main.py +779 -0
  40. Cython/Compiler/MatchCaseNodes.py +259 -0
  41. Cython/Compiler/MemoryView.py +860 -0
  42. Cython/Compiler/ModuleNode.py +4065 -0
  43. Cython/Compiler/Naming.py +369 -0
  44. Cython/Compiler/Nodes.py +10557 -0
  45. Cython/Compiler/Optimize.py +5269 -0
  46. Cython/Compiler/Options.py +828 -0
  47. Cython/Compiler/ParseTreeTransforms.pxd +78 -0
  48. Cython/Compiler/ParseTreeTransforms.py +4441 -0
  49. Cython/Compiler/Parsing.pxd +9 -0
  50. Cython/Compiler/Parsing.py +4797 -0
  51. Cython/Compiler/Pipeline.py +425 -0
  52. Cython/Compiler/PyrexTypes.py +5572 -0
  53. Cython/Compiler/Pythran.py +223 -0
  54. Cython/Compiler/Scanning.pxd +40 -0
  55. Cython/Compiler/Scanning.py +574 -0
  56. Cython/Compiler/StringEncoding.py +347 -0
  57. Cython/Compiler/Symtab.py +2998 -0
  58. Cython/Compiler/Tests/TestBuffer.py +105 -0
  59. Cython/Compiler/Tests/TestBuiltin.py +72 -0
  60. Cython/Compiler/Tests/TestCmdLine.py +573 -0
  61. Cython/Compiler/Tests/TestCode.py +86 -0
  62. Cython/Compiler/Tests/TestFlowControl.py +65 -0
  63. Cython/Compiler/Tests/TestGrammar.py +202 -0
  64. Cython/Compiler/Tests/TestMemView.py +71 -0
  65. Cython/Compiler/Tests/TestParseTreeTransforms.py +285 -0
  66. Cython/Compiler/Tests/TestScanning.py +134 -0
  67. Cython/Compiler/Tests/TestSignatureMatching.py +73 -0
  68. Cython/Compiler/Tests/TestStringEncoding.py +33 -0
  69. Cython/Compiler/Tests/TestTreeFragment.py +63 -0
  70. Cython/Compiler/Tests/TestTreePath.py +93 -0
  71. Cython/Compiler/Tests/TestTypes.py +75 -0
  72. Cython/Compiler/Tests/TestUtilityLoad.py +112 -0
  73. Cython/Compiler/Tests/TestVisitor.py +61 -0
  74. Cython/Compiler/Tests/Utils.py +36 -0
  75. Cython/Compiler/Tests/__init__.py +1 -0
  76. Cython/Compiler/TreeFragment.py +278 -0
  77. Cython/Compiler/TreePath.py +290 -0
  78. Cython/Compiler/TypeInference.py +584 -0
  79. Cython/Compiler/TypeSlots.py +1181 -0
  80. Cython/Compiler/UFuncs.py +311 -0
  81. Cython/Compiler/UtilNodes.py +387 -0
  82. Cython/Compiler/UtilityCode.py +274 -0
  83. Cython/Compiler/Version.py +8 -0
  84. Cython/Compiler/Visitor.pxd +53 -0
  85. Cython/Compiler/Visitor.py +861 -0
  86. Cython/Compiler/__init__.py +1 -0
  87. Cython/Coverage.py +443 -0
  88. Cython/Debugger/Cygdb.py +179 -0
  89. Cython/Debugger/DebugWriter.py +82 -0
  90. Cython/Debugger/Tests/TestLibCython.py +275 -0
  91. Cython/Debugger/Tests/__init__.py +1 -0
  92. Cython/Debugger/Tests/cfuncs.c +8 -0
  93. Cython/Debugger/Tests/codefile +49 -0
  94. Cython/Debugger/Tests/test_libcython_in_gdb.py +578 -0
  95. Cython/Debugger/Tests/test_libpython_in_gdb.py +90 -0
  96. Cython/Debugger/__init__.py +1 -0
  97. Cython/Debugger/libcython.py +1549 -0
  98. Cython/Debugger/libpython.py +2821 -0
  99. Cython/Debugging.py +20 -0
  100. Cython/Distutils/__init__.py +2 -0
  101. Cython/Distutils/build_ext.py +137 -0
  102. Cython/Distutils/extension.py +96 -0
  103. Cython/Distutils/old_build_ext.py +351 -0
  104. Cython/Includes/cpython/__init__.pxd +173 -0
  105. Cython/Includes/cpython/array.pxd +174 -0
  106. Cython/Includes/cpython/bool.pxd +37 -0
  107. Cython/Includes/cpython/buffer.pxd +112 -0
  108. Cython/Includes/cpython/bytearray.pxd +33 -0
  109. Cython/Includes/cpython/bytes.pxd +200 -0
  110. Cython/Includes/cpython/cellobject.pxd +35 -0
  111. Cython/Includes/cpython/ceval.pxd +8 -0
  112. Cython/Includes/cpython/codecs.pxd +121 -0
  113. Cython/Includes/cpython/complex.pxd +55 -0
  114. Cython/Includes/cpython/contextvars.pxd +141 -0
  115. Cython/Includes/cpython/conversion.pxd +36 -0
  116. Cython/Includes/cpython/datetime.pxd +384 -0
  117. Cython/Includes/cpython/descr.pxd +26 -0
  118. Cython/Includes/cpython/dict.pxd +187 -0
  119. Cython/Includes/cpython/exc.pxd +263 -0
  120. Cython/Includes/cpython/fileobject.pxd +57 -0
  121. Cython/Includes/cpython/float.pxd +47 -0
  122. Cython/Includes/cpython/function.pxd +65 -0
  123. Cython/Includes/cpython/genobject.pxd +25 -0
  124. Cython/Includes/cpython/getargs.pxd +12 -0
  125. Cython/Includes/cpython/instance.pxd +25 -0
  126. Cython/Includes/cpython/iterator.pxd +36 -0
  127. Cython/Includes/cpython/iterobject.pxd +24 -0
  128. Cython/Includes/cpython/list.pxd +92 -0
  129. Cython/Includes/cpython/long.pxd +149 -0
  130. Cython/Includes/cpython/longintrepr.pxd +19 -0
  131. Cython/Includes/cpython/mapping.pxd +63 -0
  132. Cython/Includes/cpython/marshal.pxd +66 -0
  133. Cython/Includes/cpython/mem.pxd +120 -0
  134. Cython/Includes/cpython/memoryview.pxd +50 -0
  135. Cython/Includes/cpython/method.pxd +49 -0
  136. Cython/Includes/cpython/module.pxd +208 -0
  137. Cython/Includes/cpython/number.pxd +258 -0
  138. Cython/Includes/cpython/object.pxd +433 -0
  139. Cython/Includes/cpython/pycapsule.pxd +143 -0
  140. Cython/Includes/cpython/pylifecycle.pxd +68 -0
  141. Cython/Includes/cpython/pyport.pxd +8 -0
  142. Cython/Includes/cpython/pystate.pxd +95 -0
  143. Cython/Includes/cpython/pythread.pxd +53 -0
  144. Cython/Includes/cpython/ref.pxd +67 -0
  145. Cython/Includes/cpython/sequence.pxd +134 -0
  146. Cython/Includes/cpython/set.pxd +119 -0
  147. Cython/Includes/cpython/slice.pxd +70 -0
  148. Cython/Includes/cpython/time.pxd +129 -0
  149. Cython/Includes/cpython/tuple.pxd +72 -0
  150. Cython/Includes/cpython/type.pxd +53 -0
  151. Cython/Includes/cpython/unicode.pxd +639 -0
  152. Cython/Includes/cpython/version.pxd +32 -0
  153. Cython/Includes/cpython/weakref.pxd +42 -0
  154. Cython/Includes/libc/__init__.pxd +1 -0
  155. Cython/Includes/libc/complex.pxd +35 -0
  156. Cython/Includes/libc/errno.pxd +127 -0
  157. Cython/Includes/libc/float.pxd +43 -0
  158. Cython/Includes/libc/limits.pxd +28 -0
  159. Cython/Includes/libc/locale.pxd +46 -0
  160. Cython/Includes/libc/math.pxd +209 -0
  161. Cython/Includes/libc/setjmp.pxd +10 -0
  162. Cython/Includes/libc/signal.pxd +64 -0
  163. Cython/Includes/libc/stddef.pxd +9 -0
  164. Cython/Includes/libc/stdint.pxd +105 -0
  165. Cython/Includes/libc/stdio.pxd +80 -0
  166. Cython/Includes/libc/stdlib.pxd +72 -0
  167. Cython/Includes/libc/string.pxd +50 -0
  168. Cython/Includes/libc/time.pxd +47 -0
  169. Cython/Includes/libcpp/__init__.pxd +4 -0
  170. Cython/Includes/libcpp/algorithm.pxd +320 -0
  171. Cython/Includes/libcpp/any.pxd +16 -0
  172. Cython/Includes/libcpp/atomic.pxd +59 -0
  173. Cython/Includes/libcpp/bit.pxd +29 -0
  174. Cython/Includes/libcpp/cast.pxd +12 -0
  175. Cython/Includes/libcpp/cmath.pxd +518 -0
  176. Cython/Includes/libcpp/complex.pxd +106 -0
  177. Cython/Includes/libcpp/deque.pxd +165 -0
  178. Cython/Includes/libcpp/execution.pxd +15 -0
  179. Cython/Includes/libcpp/forward_list.pxd +63 -0
  180. Cython/Includes/libcpp/functional.pxd +26 -0
  181. Cython/Includes/libcpp/iterator.pxd +34 -0
  182. Cython/Includes/libcpp/limits.pxd +61 -0
  183. Cython/Includes/libcpp/list.pxd +117 -0
  184. Cython/Includes/libcpp/map.pxd +252 -0
  185. Cython/Includes/libcpp/memory.pxd +115 -0
  186. Cython/Includes/libcpp/numbers.pxd +15 -0
  187. Cython/Includes/libcpp/numeric.pxd +131 -0
  188. Cython/Includes/libcpp/optional.pxd +34 -0
  189. Cython/Includes/libcpp/pair.pxd +1 -0
  190. Cython/Includes/libcpp/queue.pxd +25 -0
  191. Cython/Includes/libcpp/random.pxd +166 -0
  192. Cython/Includes/libcpp/set.pxd +228 -0
  193. Cython/Includes/libcpp/stack.pxd +11 -0
  194. Cython/Includes/libcpp/string.pxd +333 -0
  195. Cython/Includes/libcpp/typeindex.pxd +15 -0
  196. Cython/Includes/libcpp/typeinfo.pxd +10 -0
  197. Cython/Includes/libcpp/unordered_map.pxd +193 -0
  198. Cython/Includes/libcpp/unordered_set.pxd +152 -0
  199. Cython/Includes/libcpp/utility.pxd +30 -0
  200. Cython/Includes/libcpp/vector.pxd +167 -0
  201. Cython/Includes/openmp.pxd +50 -0
  202. Cython/Includes/posix/__init__.pxd +1 -0
  203. Cython/Includes/posix/dlfcn.pxd +14 -0
  204. Cython/Includes/posix/fcntl.pxd +86 -0
  205. Cython/Includes/posix/ioctl.pxd +4 -0
  206. Cython/Includes/posix/mman.pxd +101 -0
  207. Cython/Includes/posix/resource.pxd +57 -0
  208. Cython/Includes/posix/select.pxd +21 -0
  209. Cython/Includes/posix/signal.pxd +73 -0
  210. Cython/Includes/posix/stat.pxd +98 -0
  211. Cython/Includes/posix/stdio.pxd +37 -0
  212. Cython/Includes/posix/stdlib.pxd +29 -0
  213. Cython/Includes/posix/strings.pxd +9 -0
  214. Cython/Includes/posix/time.pxd +71 -0
  215. Cython/Includes/posix/types.pxd +30 -0
  216. Cython/Includes/posix/uio.pxd +26 -0
  217. Cython/Includes/posix/unistd.pxd +271 -0
  218. Cython/Includes/posix/wait.pxd +38 -0
  219. Cython/Plex/Actions.pxd +24 -0
  220. Cython/Plex/Actions.py +119 -0
  221. Cython/Plex/DFA.pxd +14 -0
  222. Cython/Plex/DFA.py +164 -0
  223. Cython/Plex/Errors.py +48 -0
  224. Cython/Plex/Lexicons.py +178 -0
  225. Cython/Plex/Machines.pxd +36 -0
  226. Cython/Plex/Machines.py +238 -0
  227. Cython/Plex/Regexps.py +539 -0
  228. Cython/Plex/Scanners.pxd +47 -0
  229. Cython/Plex/Scanners.py +360 -0
  230. Cython/Plex/Transitions.pxd +14 -0
  231. Cython/Plex/Transitions.py +239 -0
  232. Cython/Plex/__init__.py +34 -0
  233. Cython/Runtime/__init__.py +1 -0
  234. Cython/Runtime/refnanny.pyx +261 -0
  235. Cython/Shadow.py +656 -0
  236. Cython/Shadow.pyi +521 -0
  237. Cython/StringIOTree.py +170 -0
  238. Cython/Tempita/__init__.py +4 -0
  239. Cython/Tempita/_looper.py +154 -0
  240. Cython/Tempita/_tempita.py +1091 -0
  241. Cython/TestUtils.py +417 -0
  242. Cython/Tests/TestCodeWriter.py +128 -0
  243. Cython/Tests/TestCythonUtils.py +202 -0
  244. Cython/Tests/TestJediTyper.py +223 -0
  245. Cython/Tests/TestShadow.py +114 -0
  246. Cython/Tests/TestStringIOTree.py +67 -0
  247. Cython/Tests/TestTestUtils.py +90 -0
  248. Cython/Tests/__init__.py +1 -0
  249. Cython/Tests/xmlrunner.py +390 -0
  250. Cython/Utility/AsyncGen.c +1263 -0
  251. Cython/Utility/Buffer.c +875 -0
  252. Cython/Utility/Builtins.c +660 -0
  253. Cython/Utility/CConvert.pyx +134 -0
  254. Cython/Utility/CMath.c +95 -0
  255. Cython/Utility/CommonStructures.c +139 -0
  256. Cython/Utility/Complex.c +378 -0
  257. Cython/Utility/Coroutine.c +2413 -0
  258. Cython/Utility/CpdefEnums.pyx +108 -0
  259. Cython/Utility/CppConvert.pyx +279 -0
  260. Cython/Utility/CppSupport.cpp +133 -0
  261. Cython/Utility/CythonFunction.c +1851 -0
  262. Cython/Utility/Dataclasses.c +185 -0
  263. Cython/Utility/Dataclasses.py +112 -0
  264. Cython/Utility/Embed.c +125 -0
  265. Cython/Utility/Exceptions.c +1017 -0
  266. Cython/Utility/ExtensionTypes.c +797 -0
  267. Cython/Utility/FunctionArguments.c +573 -0
  268. Cython/Utility/ImportExport.c +912 -0
  269. Cython/Utility/MemoryView.pyx +1478 -0
  270. Cython/Utility/MemoryView_C.c +992 -0
  271. Cython/Utility/ModuleSetupCode.c +2501 -0
  272. Cython/Utility/NumpyImportArray.c +46 -0
  273. Cython/Utility/ObjectHandling.c +3054 -0
  274. Cython/Utility/Optimize.c +1533 -0
  275. Cython/Utility/Overflow.c +404 -0
  276. Cython/Utility/Printing.c +86 -0
  277. Cython/Utility/Profile.c +660 -0
  278. Cython/Utility/StringTools.c +1206 -0
  279. Cython/Utility/TestCyUtilityLoader.pyx +8 -0
  280. Cython/Utility/TestCythonScope.pyx +75 -0
  281. Cython/Utility/TestUtilityLoader.c +12 -0
  282. Cython/Utility/TypeConversion.c +1329 -0
  283. Cython/Utility/UFuncs.pyx +50 -0
  284. Cython/Utility/UFuncs_C.c +89 -0
  285. Cython/Utility/__init__.py +28 -0
  286. Cython/Utility/arrayarray.h +143 -0
  287. Cython/Utils.py +687 -0
  288. Cython/__init__.py +10 -0
  289. Cython/__init__.pyi +7 -0
  290. Cython/py.typed +0 -0
  291. Cython-3.1.0a1.dist-info/COPYING.txt +19 -0
  292. Cython-3.1.0a1.dist-info/LICENSE.txt +176 -0
  293. Cython-3.1.0a1.dist-info/METADATA +67 -0
  294. Cython-3.1.0a1.dist-info/RECORD +301 -0
  295. Cython-3.1.0a1.dist-info/WHEEL +5 -0
  296. Cython-3.1.0a1.dist-info/entry_points.txt +4 -0
  297. Cython-3.1.0a1.dist-info/top_level.txt +3 -0
  298. cython.py +29 -0
  299. pyximport/__init__.py +4 -0
  300. pyximport/pyxbuild.py +160 -0
  301. pyximport/pyximport.py +482 -0
@@ -0,0 +1,384 @@
1
+ from cpython.object cimport PyObject
2
+ from cpython.version cimport PY_VERSION_HEX
3
+
4
+ cdef extern from "Python.h":
5
+ ctypedef struct PyTypeObject:
6
+ pass
7
+
8
+ cdef extern from "datetime.h":
9
+ """
10
+ #define __Pyx_DateTime_DateTimeWithFold(year, month, day, hour, minute, second, microsecond, tz, fold) \
11
+ PyDateTimeAPI->DateTime_FromDateAndTimeAndFold(year, month, day, hour, minute, second, \
12
+ microsecond, tz, fold, PyDateTimeAPI->DateTimeType)
13
+ #define __Pyx_DateTime_TimeWithFold(hour, minute, second, microsecond, tz, fold) \
14
+ PyDateTimeAPI->Time_FromTimeAndFold(hour, minute, second, microsecond, tz, fold, PyDateTimeAPI->TimeType)
15
+
16
+ #define __Pyx_TimeZone_UTC PyDateTime_TimeZone_UTC
17
+ #define __Pyx_TimeZone_FromOffsetAndName(offset, name) PyTimeZone_FromOffsetAndName(offset, name)
18
+
19
+ /* Backport for Python < 3.10 */
20
+ #if PY_VERSION_HEX < 0x030a00a1
21
+ #ifndef PyDateTime_TIME_GET_TZINFO
22
+ #define PyDateTime_TIME_GET_TZINFO(o) \
23
+ ((((PyDateTime_Time*)o)->hastzinfo) ? ((PyDateTime_Time*)o)->tzinfo : Py_None)
24
+ #endif
25
+ #ifndef PyDateTime_DATE_GET_TZINFO
26
+ #define PyDateTime_DATE_GET_TZINFO(o) \
27
+ ((((PyDateTime_DateTime*)o)->hastzinfo) ? ((PyDateTime_DateTime*)o)->tzinfo : Py_None)
28
+ #endif
29
+ #endif
30
+ """
31
+
32
+ ctypedef extern class datetime.date[object PyDateTime_Date]:
33
+ @property
34
+ cdef inline int year(self) noexcept:
35
+ return PyDateTime_GET_YEAR(self)
36
+
37
+ @property
38
+ cdef inline int month(self) noexcept:
39
+ return PyDateTime_GET_MONTH(self)
40
+
41
+ @property
42
+ cdef inline int day(self) noexcept:
43
+ return PyDateTime_GET_DAY(self)
44
+
45
+ ctypedef extern class datetime.time[object PyDateTime_Time]:
46
+ @property
47
+ cdef inline int hour(self) noexcept:
48
+ return PyDateTime_TIME_GET_HOUR(self)
49
+
50
+ @property
51
+ cdef inline int minute(self) noexcept:
52
+ return PyDateTime_TIME_GET_MINUTE(self)
53
+
54
+ @property
55
+ cdef inline int second(self) noexcept:
56
+ return PyDateTime_TIME_GET_SECOND(self)
57
+
58
+ @property
59
+ cdef inline int microsecond(self) noexcept:
60
+ return PyDateTime_TIME_GET_MICROSECOND(self)
61
+
62
+ @property
63
+ cdef inline object tzinfo(self):
64
+ return <object>PyDateTime_TIME_GET_TZINFO(self)
65
+
66
+ @property
67
+ cdef inline int fold(self) noexcept:
68
+ # For Python < 3.6 this returns 0 no matter what
69
+ return PyDateTime_TIME_GET_FOLD(self)
70
+
71
+ ctypedef extern class datetime.datetime[object PyDateTime_DateTime]:
72
+ @property
73
+ cdef inline int year(self) noexcept:
74
+ return PyDateTime_GET_YEAR(self)
75
+
76
+ @property
77
+ cdef inline int month(self) noexcept:
78
+ return PyDateTime_GET_MONTH(self)
79
+
80
+ @property
81
+ cdef inline int day(self) noexcept:
82
+ return PyDateTime_GET_DAY(self)
83
+
84
+ @property
85
+ cdef inline int hour(self) noexcept:
86
+ return PyDateTime_DATE_GET_HOUR(self)
87
+
88
+ @property
89
+ cdef inline int minute(self) noexcept:
90
+ return PyDateTime_DATE_GET_MINUTE(self)
91
+
92
+ @property
93
+ cdef inline int second(self) noexcept:
94
+ return PyDateTime_DATE_GET_SECOND(self)
95
+
96
+ @property
97
+ cdef inline int microsecond(self) noexcept:
98
+ return PyDateTime_DATE_GET_MICROSECOND(self)
99
+
100
+ @property
101
+ cdef inline object tzinfo(self):
102
+ return <object>PyDateTime_DATE_GET_TZINFO(self)
103
+
104
+ @property
105
+ cdef inline int fold(self) noexcept:
106
+ # For Python < 3.6 this returns 0 no matter what
107
+ return PyDateTime_DATE_GET_FOLD(self)
108
+
109
+ ctypedef extern class datetime.timedelta[object PyDateTime_Delta]:
110
+ @property
111
+ cdef inline int day(self) noexcept:
112
+ return PyDateTime_DELTA_GET_DAYS(self)
113
+
114
+ @property
115
+ cdef inline int second(self) noexcept:
116
+ return PyDateTime_DELTA_GET_SECONDS(self)
117
+
118
+ @property
119
+ cdef inline int microsecond(self) noexcept:
120
+ return PyDateTime_DELTA_GET_MICROSECONDS(self)
121
+
122
+ ctypedef extern class datetime.tzinfo[object PyDateTime_TZInfo]:
123
+ pass
124
+
125
+ ctypedef struct PyDateTime_Date:
126
+ pass
127
+
128
+ ctypedef struct PyDateTime_Time:
129
+ unsigned char fold
130
+ char hastzinfo
131
+ PyObject *tzinfo
132
+
133
+ ctypedef struct PyDateTime_DateTime:
134
+ unsigned char fold
135
+ char hastzinfo
136
+ PyObject *tzinfo
137
+
138
+ ctypedef struct PyDateTime_Delta:
139
+ int days
140
+ int seconds
141
+ int microseconds
142
+
143
+ # Define structure for C API.
144
+ ctypedef struct PyDateTime_CAPI:
145
+ # type objects
146
+ PyTypeObject *DateType
147
+ PyTypeObject *DateTimeType
148
+ PyTypeObject *TimeType
149
+ PyTypeObject *DeltaType
150
+ PyTypeObject *TZInfoType
151
+
152
+ # constructors
153
+ date (*Date_FromDate)(int, int, int, PyTypeObject*)
154
+ datetime (*DateTime_FromDateAndTime)(int, int, int, int, int, int, int, object, PyTypeObject*)
155
+ time (*Time_FromTime)(int, int, int, int, object, PyTypeObject*)
156
+ timedelta (*Delta_FromDelta)(int, int, int, int, PyTypeObject*)
157
+
158
+ # constructors for the DB API
159
+ datetime (*DateTime_FromTimestamp)(PyObject*, object, PyObject*)
160
+ date (*Date_FromTimestamp)(PyObject*, object)
161
+
162
+ # We cannot use the following because they do not compile in older Python versions.
163
+ # Instead, we use datetime.h's macros here that we can backport in C.
164
+
165
+ # Python 3.7+ constructors
166
+ object (*TimeZone_FromTimeZone)(object offset, PyObject *name)
167
+
168
+ # Python 3.7+ singletons
169
+ PyObject *TimeZone_UTC
170
+
171
+ # Python 3.6+ PEP 495 constructors
172
+ datetime (*DateTime_FromDateAndTimeAndFold)(int, int, int, int, int, int, int, object, int, PyTypeObject*)
173
+ time (*Time_FromTimeAndFold)(int, int, int ,int, object, int, PyTypeObject*)
174
+
175
+ # Check type of the object.
176
+ bint PyDate_Check(object op)
177
+ bint PyDate_CheckExact(object op)
178
+
179
+ bint PyDateTime_Check(object op)
180
+ bint PyDateTime_CheckExact(object op)
181
+
182
+ bint PyTime_Check(object op)
183
+ bint PyTime_CheckExact(object op)
184
+
185
+ bint PyDelta_Check(object op)
186
+ bint PyDelta_CheckExact(object op)
187
+
188
+ bint PyTZInfo_Check(object op)
189
+ bint PyTZInfo_CheckExact(object op)
190
+
191
+ # Getters for date and datetime (C macros).
192
+ int PyDateTime_GET_YEAR(object o)
193
+ int PyDateTime_GET_MONTH(object o)
194
+ int PyDateTime_GET_DAY(object o)
195
+
196
+ # Getters for datetime (C macros).
197
+ int PyDateTime_DATE_GET_HOUR(object o)
198
+ int PyDateTime_DATE_GET_MINUTE(object o)
199
+ int PyDateTime_DATE_GET_SECOND(object o)
200
+ int PyDateTime_DATE_GET_MICROSECOND(object o)
201
+ int PyDateTime_DATE_GET_FOLD(object o)
202
+ PyObject* PyDateTime_DATE_GET_TZINFO(object o) # returns a borrowed reference
203
+
204
+ # Getters for time (C macros).
205
+ int PyDateTime_TIME_GET_HOUR(object o)
206
+ int PyDateTime_TIME_GET_MINUTE(object o)
207
+ int PyDateTime_TIME_GET_SECOND(object o)
208
+ int PyDateTime_TIME_GET_MICROSECOND(object o)
209
+ int PyDateTime_TIME_GET_FOLD(object o)
210
+ PyObject* PyDateTime_TIME_GET_TZINFO(object o) # returns a borrowed reference
211
+
212
+ # Getters for timedelta (C macros).
213
+ int PyDateTime_DELTA_GET_DAYS(object o)
214
+ int PyDateTime_DELTA_GET_SECONDS(object o)
215
+ int PyDateTime_DELTA_GET_MICROSECONDS(object o)
216
+
217
+ # Constructors
218
+ object PyTimeZone_FromOffset(object offset)
219
+ object PyTimeZone_FromOffsetAndName(object offset, object name)
220
+
221
+ # The above macros is Python 3.7+ so we use these instead
222
+ object __Pyx_TimeZone_FromOffsetAndName(object offset, PyObject* name)
223
+
224
+ # Constructors for the DB API
225
+ datetime PyDateTime_FromTimeStamp(object args)
226
+ date PyDate_FromTimeStamp(object args)
227
+
228
+ # PEP 495 constructors but patched above to allow passing tz
229
+ datetime __Pyx_DateTime_DateTimeWithFold(int, int, int, int, int, int, int, object, int)
230
+ datetime __Pyx_DateTime_TimeWithFold(int, int, int ,int, object, int)
231
+
232
+ # PyDateTime CAPI object.
233
+ PyDateTime_CAPI *PyDateTimeAPI
234
+
235
+ PyObject* PyDateTime_TimeZone_UTC
236
+
237
+ # PyDateTime_TimeZone_UTC is Python 3.7+ so instead we use the following macro
238
+ PyObject* __Pyx_TimeZone_UTC
239
+
240
+ void PyDateTime_IMPORT()
241
+
242
+ # Datetime C API initialization function.
243
+ # You have to call it before any usage of DateTime CAPI functions.
244
+ cdef inline void import_datetime() noexcept:
245
+ PyDateTime_IMPORT
246
+
247
+ # Create date object using DateTime CAPI factory function.
248
+ # Note, there are no range checks for any of the arguments.
249
+ cdef inline date date_new(int year, int month, int day):
250
+ return PyDateTimeAPI.Date_FromDate(year, month, day, PyDateTimeAPI.DateType)
251
+
252
+ # Create time object using DateTime CAPI factory function
253
+ # Note, there are no range checks for any of the arguments.
254
+ cdef inline time time_new(int hour, int minute, int second, int microsecond, object tz, int fold=0):
255
+ return __Pyx_DateTime_TimeWithFold(hour, minute, second, microsecond, tz, fold)
256
+
257
+ # Create datetime object using DateTime CAPI factory function.
258
+ # Note, there are no range checks for any of the arguments.
259
+ cdef inline datetime datetime_new(int year, int month, int day, int hour, int minute, int second, int microsecond, object tz, int fold=0):
260
+ return __Pyx_DateTime_DateTimeWithFold(year, month, day, hour, minute, second, microsecond, tz, fold)
261
+
262
+ # Create timedelta object using DateTime CAPI factory function.
263
+ # Note, there are no range checks for any of the arguments.
264
+ cdef inline timedelta timedelta_new(int days, int seconds, int useconds):
265
+ return PyDateTimeAPI.Delta_FromDelta(days, seconds, useconds, 1, PyDateTimeAPI.DeltaType)
266
+
267
+ # Create timedelta object using DateTime CAPI factory function.
268
+ cdef inline object timezone_new(object offset, object name=None):
269
+ return __Pyx_TimeZone_FromOffsetAndName(offset, <PyObject*>name if name is not None else NULL)
270
+
271
+ # Create datetime object using DB API constructor.
272
+ cdef inline datetime datetime_from_timestamp(timestamp, tz=None):
273
+ return PyDateTimeAPI.DateTime_FromTimestamp(
274
+ <PyObject*>PyDateTimeAPI.DateTimeType, (timestamp, tz) if tz is not None else (timestamp,), NULL)
275
+
276
+ # Create date object using DB API constructor.
277
+ cdef inline date date_from_timestamp(timestamp):
278
+ return PyDateTimeAPI.Date_FromTimestamp(<PyObject*>PyDateTimeAPI.DateType, (timestamp,))
279
+
280
+ # More recognizable getters for date/time/datetime/timedelta.
281
+ # There are no setters because datetime.h hasn't them.
282
+ # This is because of immutable nature of these objects by design.
283
+ # If you would change time/date/datetime/timedelta object you need to recreate.
284
+
285
+ # Get UTC singleton
286
+ cdef inline object get_utc():
287
+ return <object>__Pyx_TimeZone_UTC
288
+
289
+ # Get tzinfo of time
290
+ cdef inline object time_tzinfo(object o):
291
+ return <object>PyDateTime_TIME_GET_TZINFO(o)
292
+
293
+ # Get tzinfo of datetime
294
+ cdef inline object datetime_tzinfo(object o):
295
+ return <object>PyDateTime_DATE_GET_TZINFO(o)
296
+
297
+ # Get year of date
298
+ cdef inline int date_year(object o) noexcept:
299
+ return PyDateTime_GET_YEAR(o)
300
+
301
+ # Get month of date
302
+ cdef inline int date_month(object o) noexcept:
303
+ return PyDateTime_GET_MONTH(o)
304
+
305
+ # Get day of date
306
+ cdef inline int date_day(object o) noexcept:
307
+ return PyDateTime_GET_DAY(o)
308
+
309
+ # Get year of datetime
310
+ cdef inline int datetime_year(object o) noexcept:
311
+ return PyDateTime_GET_YEAR(o)
312
+
313
+ # Get month of datetime
314
+ cdef inline int datetime_month(object o) noexcept:
315
+ return PyDateTime_GET_MONTH(o)
316
+
317
+ # Get day of datetime
318
+ cdef inline int datetime_day(object o) noexcept:
319
+ return PyDateTime_GET_DAY(o)
320
+
321
+ # Get hour of time
322
+ cdef inline int time_hour(object o) noexcept:
323
+ return PyDateTime_TIME_GET_HOUR(o)
324
+
325
+ # Get minute of time
326
+ cdef inline int time_minute(object o) noexcept:
327
+ return PyDateTime_TIME_GET_MINUTE(o)
328
+
329
+ # Get second of time
330
+ cdef inline int time_second(object o) noexcept:
331
+ return PyDateTime_TIME_GET_SECOND(o)
332
+
333
+ # Get microsecond of time
334
+ cdef inline int time_microsecond(object o) noexcept:
335
+ return PyDateTime_TIME_GET_MICROSECOND(o)
336
+
337
+ # Get fold of time
338
+ cdef inline int time_fold(object o) noexcept:
339
+ # For Python < 3.6 this returns 0 no matter what
340
+ return PyDateTime_TIME_GET_FOLD(o)
341
+
342
+ # Get hour of datetime
343
+ cdef inline int datetime_hour(object o) noexcept:
344
+ return PyDateTime_DATE_GET_HOUR(o)
345
+
346
+ # Get minute of datetime
347
+ cdef inline int datetime_minute(object o) noexcept:
348
+ return PyDateTime_DATE_GET_MINUTE(o)
349
+
350
+ # Get second of datetime
351
+ cdef inline int datetime_second(object o) noexcept:
352
+ return PyDateTime_DATE_GET_SECOND(o)
353
+
354
+ # Get microsecond of datetime
355
+ cdef inline int datetime_microsecond(object o) noexcept:
356
+ return PyDateTime_DATE_GET_MICROSECOND(o)
357
+
358
+ # Get fold of datetime
359
+ cdef inline int datetime_fold(object o) noexcept:
360
+ # For Python < 3.6 this returns 0 no matter what
361
+ return PyDateTime_DATE_GET_FOLD(o)
362
+
363
+ # Get days of timedelta
364
+ cdef inline int timedelta_days(object o) noexcept:
365
+ return (<PyDateTime_Delta*>o).days
366
+
367
+ # Get seconds of timedelta
368
+ cdef inline int timedelta_seconds(object o) noexcept:
369
+ return (<PyDateTime_Delta*>o).seconds
370
+
371
+ # Get microseconds of timedelta
372
+ cdef inline int timedelta_microseconds(object o) noexcept:
373
+ return (<PyDateTime_Delta*>o).microseconds
374
+
375
+ cdef inline double total_seconds(timedelta obj) noexcept:
376
+ # Mirrors the "timedelta.total_seconds()" method.
377
+ # Note that this implementation is not guaranteed to give *exactly* the same
378
+ # result as the original method, due to potential differences in floating point rounding.
379
+ cdef:
380
+ double days, seconds, micros
381
+ days = <double>PyDateTime_DELTA_GET_DAYS(obj)
382
+ seconds = <double>PyDateTime_DELTA_GET_SECONDS(obj)
383
+ micros = <double>PyDateTime_DELTA_GET_MICROSECONDS(obj)
384
+ 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