Cython 3.3.0__cp315-cp315-win_amd64.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 (339) hide show
  1. Cython/Build/BuildExecutable.py +156 -0
  2. Cython/Build/Cache.py +199 -0
  3. Cython/Build/Cythonize.py +349 -0
  4. Cython/Build/Dependencies.py +1281 -0
  5. Cython/Build/Distutils.py +1 -0
  6. Cython/Build/Inline.py +467 -0
  7. Cython/Build/IpythonMagic.py +559 -0
  8. Cython/Build/SharedModule.py +165 -0
  9. Cython/Build/Tests/TestCyCache.py +195 -0
  10. Cython/Build/Tests/TestCythonizeArgsParser.py +480 -0
  11. Cython/Build/Tests/TestDependencies.py +133 -0
  12. Cython/Build/Tests/TestInline.py +177 -0
  13. Cython/Build/Tests/TestIpythonMagic.py +303 -0
  14. Cython/Build/Tests/TestRecythonize.py +212 -0
  15. Cython/Build/Tests/TestStripLiterals.py +155 -0
  16. Cython/Build/Tests/__init__.py +1 -0
  17. Cython/Build/__init__.py +11 -0
  18. Cython/CodeWriter.py +825 -0
  19. Cython/Compiler/AnalysedTreeTransforms.py +97 -0
  20. Cython/Compiler/Annotate.py +328 -0
  21. Cython/Compiler/AutoDocTransforms.py +320 -0
  22. Cython/Compiler/Buffer.py +679 -0
  23. Cython/Compiler/Builtin.py +1102 -0
  24. Cython/Compiler/CmdLine.py +373 -0
  25. Cython/Compiler/Code.cp315-win_amd64.pyd +0 -0
  26. Cython/Compiler/Code.pxd +154 -0
  27. Cython/Compiler/Code.py +3760 -0
  28. Cython/Compiler/CodeGeneration.py +33 -0
  29. Cython/Compiler/CythonScope.py +208 -0
  30. Cython/Compiler/Dataclass.py +890 -0
  31. Cython/Compiler/DebugFlags.py +24 -0
  32. Cython/Compiler/Errors.py +310 -0
  33. Cython/Compiler/ExprNodes.py +16273 -0
  34. Cython/Compiler/FlowControl.cp315-win_amd64.pyd +0 -0
  35. Cython/Compiler/FlowControl.pxd +112 -0
  36. Cython/Compiler/FlowControl.py +1573 -0
  37. Cython/Compiler/FusedNode.cp315-win_amd64.pyd +0 -0
  38. Cython/Compiler/FusedNode.py +978 -0
  39. Cython/Compiler/Future.py +16 -0
  40. Cython/Compiler/Interpreter.py +57 -0
  41. Cython/Compiler/Lexicon.py +422 -0
  42. Cython/Compiler/LineTable.cp315-win_amd64.pyd +0 -0
  43. Cython/Compiler/LineTable.py +114 -0
  44. Cython/Compiler/Main.py +856 -0
  45. Cython/Compiler/MatchCaseNodes.py +2200 -0
  46. Cython/Compiler/MemoryView.py +930 -0
  47. Cython/Compiler/ModuleNode.py +4548 -0
  48. Cython/Compiler/Naming.py +370 -0
  49. Cython/Compiler/Nodes.py +11304 -0
  50. Cython/Compiler/Optimize.py +5564 -0
  51. Cython/Compiler/Options.py +840 -0
  52. Cython/Compiler/ParseTreeTransforms.pxd +80 -0
  53. Cython/Compiler/ParseTreeTransforms.py +4808 -0
  54. Cython/Compiler/Parsing.cp315-win_amd64.pyd +0 -0
  55. Cython/Compiler/Parsing.pxd +9 -0
  56. Cython/Compiler/Parsing.py +4809 -0
  57. Cython/Compiler/Pipeline.py +439 -0
  58. Cython/Compiler/PyrexTypes.py +6588 -0
  59. Cython/Compiler/Pythran.py +232 -0
  60. Cython/Compiler/Scanning.cp315-win_amd64.pyd +0 -0
  61. Cython/Compiler/Scanning.pxd +70 -0
  62. Cython/Compiler/Scanning.py +720 -0
  63. Cython/Compiler/StringEncoding.cp315-win_amd64.pyd +0 -0
  64. Cython/Compiler/StringEncoding.py +354 -0
  65. Cython/Compiler/Symtab.py +3121 -0
  66. Cython/Compiler/Tests/TestBuffer.py +105 -0
  67. Cython/Compiler/Tests/TestBuiltin.py +196 -0
  68. Cython/Compiler/Tests/TestCmdLine.py +652 -0
  69. Cython/Compiler/Tests/TestCode.py +145 -0
  70. Cython/Compiler/Tests/TestFlowControl.py +65 -0
  71. Cython/Compiler/Tests/TestGrammar.py +202 -0
  72. Cython/Compiler/Tests/TestMemView.py +71 -0
  73. Cython/Compiler/Tests/TestParseTreeTransforms.py +285 -0
  74. Cython/Compiler/Tests/TestScanning.py +132 -0
  75. Cython/Compiler/Tests/TestSignatureMatching.py +73 -0
  76. Cython/Compiler/Tests/TestStringEncoding.py +20 -0
  77. Cython/Compiler/Tests/TestTreeFragment.py +63 -0
  78. Cython/Compiler/Tests/TestTreePath.py +103 -0
  79. Cython/Compiler/Tests/TestTypes.py +119 -0
  80. Cython/Compiler/Tests/TestUtilityLoad.py +112 -0
  81. Cython/Compiler/Tests/TestVisitor.py +119 -0
  82. Cython/Compiler/Tests/Utils.py +36 -0
  83. Cython/Compiler/Tests/__init__.py +1 -0
  84. Cython/Compiler/TreeFragment.py +279 -0
  85. Cython/Compiler/TreePath.py +303 -0
  86. Cython/Compiler/TypeInference.py +611 -0
  87. Cython/Compiler/TypeSlots.py +1329 -0
  88. Cython/Compiler/UFuncs.py +317 -0
  89. Cython/Compiler/UtilNodes.py +389 -0
  90. Cython/Compiler/UtilityCode.py +354 -0
  91. Cython/Compiler/Version.py +8 -0
  92. Cython/Compiler/Visitor.cp315-win_amd64.pyd +0 -0
  93. Cython/Compiler/Visitor.pxd +52 -0
  94. Cython/Compiler/Visitor.py +914 -0
  95. Cython/Compiler/__init__.py +1 -0
  96. Cython/Coverage.py +448 -0
  97. Cython/Debugger/Cygdb.py +214 -0
  98. Cython/Debugger/DebugWriter.py +82 -0
  99. Cython/Debugger/Tests/TestLibCython.py +280 -0
  100. Cython/Debugger/Tests/__init__.py +1 -0
  101. Cython/Debugger/Tests/cfuncs.c +8 -0
  102. Cython/Debugger/Tests/codefile +49 -0
  103. Cython/Debugger/Tests/test_libcython_in_gdb.py +580 -0
  104. Cython/Debugger/Tests/test_libpython_in_gdb.py +90 -0
  105. Cython/Debugger/__init__.py +1 -0
  106. Cython/Debugger/libcython.py +1548 -0
  107. Cython/Debugger/libpython.py +2821 -0
  108. Cython/Debugging.py +20 -0
  109. Cython/Distutils/__init__.py +2 -0
  110. Cython/Distutils/build_ext.py +143 -0
  111. Cython/Distutils/extension.py +96 -0
  112. Cython/Distutils/old_build_ext.py +351 -0
  113. Cython/Includes/cpython/__init__.pxd +173 -0
  114. Cython/Includes/cpython/array.pxd +152 -0
  115. Cython/Includes/cpython/bool.pxd +37 -0
  116. Cython/Includes/cpython/buffer.pxd +112 -0
  117. Cython/Includes/cpython/bytearray.pxd +33 -0
  118. Cython/Includes/cpython/bytes.pxd +200 -0
  119. Cython/Includes/cpython/cellobject.pxd +35 -0
  120. Cython/Includes/cpython/ceval.pxd +8 -0
  121. Cython/Includes/cpython/codecs.pxd +121 -0
  122. Cython/Includes/cpython/complex.pxd +60 -0
  123. Cython/Includes/cpython/contextvars.pxd +145 -0
  124. Cython/Includes/cpython/conversion.pxd +36 -0
  125. Cython/Includes/cpython/datetime.pxd +395 -0
  126. Cython/Includes/cpython/descr.pxd +26 -0
  127. Cython/Includes/cpython/dict.pxd +268 -0
  128. Cython/Includes/cpython/exc.pxd +263 -0
  129. Cython/Includes/cpython/fileobject.pxd +57 -0
  130. Cython/Includes/cpython/float.pxd +56 -0
  131. Cython/Includes/cpython/frozendict.pxd +37 -0
  132. Cython/Includes/cpython/function.pxd +65 -0
  133. Cython/Includes/cpython/genobject.pxd +25 -0
  134. Cython/Includes/cpython/getargs.pxd +12 -0
  135. Cython/Includes/cpython/instance.pxd +25 -0
  136. Cython/Includes/cpython/iterator.pxd +36 -0
  137. Cython/Includes/cpython/iterobject.pxd +24 -0
  138. Cython/Includes/cpython/list.pxd +144 -0
  139. Cython/Includes/cpython/long.pxd +180 -0
  140. Cython/Includes/cpython/longintrepr.pxd +14 -0
  141. Cython/Includes/cpython/mapping.pxd +63 -0
  142. Cython/Includes/cpython/marshal.pxd +66 -0
  143. Cython/Includes/cpython/mem.pxd +120 -0
  144. Cython/Includes/cpython/memoryview.pxd +50 -0
  145. Cython/Includes/cpython/method.pxd +49 -0
  146. Cython/Includes/cpython/module.pxd +208 -0
  147. Cython/Includes/cpython/number.pxd +258 -0
  148. Cython/Includes/cpython/object.pxd +430 -0
  149. Cython/Includes/cpython/pycapsule.pxd +143 -0
  150. Cython/Includes/cpython/pylifecycle.pxd +68 -0
  151. Cython/Includes/cpython/pyport.pxd +8 -0
  152. Cython/Includes/cpython/pystate.pxd +95 -0
  153. Cython/Includes/cpython/pythread.pxd +53 -0
  154. Cython/Includes/cpython/ref.pxd +141 -0
  155. Cython/Includes/cpython/sentinel.pxd +17 -0
  156. Cython/Includes/cpython/sequence.pxd +134 -0
  157. Cython/Includes/cpython/set.pxd +119 -0
  158. Cython/Includes/cpython/slice.pxd +70 -0
  159. Cython/Includes/cpython/time.pxd +129 -0
  160. Cython/Includes/cpython/tuple.pxd +72 -0
  161. Cython/Includes/cpython/type.pxd +146 -0
  162. Cython/Includes/cpython/unicode.pxd +639 -0
  163. Cython/Includes/cpython/version.pxd +32 -0
  164. Cython/Includes/cpython/weakref.pxd +78 -0
  165. Cython/Includes/libc/__init__.pxd +1 -0
  166. Cython/Includes/libc/complex.pxd +35 -0
  167. Cython/Includes/libc/errno.pxd +127 -0
  168. Cython/Includes/libc/float.pxd +43 -0
  169. Cython/Includes/libc/limits.pxd +28 -0
  170. Cython/Includes/libc/locale.pxd +46 -0
  171. Cython/Includes/libc/math.pxd +209 -0
  172. Cython/Includes/libc/setjmp.pxd +10 -0
  173. Cython/Includes/libc/signal.pxd +64 -0
  174. Cython/Includes/libc/stddef.pxd +9 -0
  175. Cython/Includes/libc/stdint.pxd +105 -0
  176. Cython/Includes/libc/stdio.pxd +80 -0
  177. Cython/Includes/libc/stdlib.pxd +72 -0
  178. Cython/Includes/libc/string.pxd +50 -0
  179. Cython/Includes/libc/threads.pxd +234 -0
  180. Cython/Includes/libc/time.pxd +52 -0
  181. Cython/Includes/libcpp/__init__.pxd +4 -0
  182. Cython/Includes/libcpp/algorithm.pxd +320 -0
  183. Cython/Includes/libcpp/any.pxd +16 -0
  184. Cython/Includes/libcpp/atomic.pxd +59 -0
  185. Cython/Includes/libcpp/barrier.pxd +22 -0
  186. Cython/Includes/libcpp/bit.pxd +29 -0
  187. Cython/Includes/libcpp/cast.pxd +12 -0
  188. Cython/Includes/libcpp/cmath.pxd +518 -0
  189. Cython/Includes/libcpp/complex.pxd +106 -0
  190. Cython/Includes/libcpp/condition_variable.pxd +322 -0
  191. Cython/Includes/libcpp/deque.pxd +165 -0
  192. Cython/Includes/libcpp/exception.pxd +216 -0
  193. Cython/Includes/libcpp/execution.pxd +15 -0
  194. Cython/Includes/libcpp/forward_list.pxd +63 -0
  195. Cython/Includes/libcpp/functional.pxd +26 -0
  196. Cython/Includes/libcpp/future.pxd +103 -0
  197. Cython/Includes/libcpp/iterator.pxd +34 -0
  198. Cython/Includes/libcpp/latch.pxd +17 -0
  199. Cython/Includes/libcpp/limits.pxd +61 -0
  200. Cython/Includes/libcpp/list.pxd +117 -0
  201. Cython/Includes/libcpp/map.pxd +252 -0
  202. Cython/Includes/libcpp/memory.pxd +115 -0
  203. Cython/Includes/libcpp/mutex.pxd +387 -0
  204. Cython/Includes/libcpp/numbers.pxd +15 -0
  205. Cython/Includes/libcpp/numeric.pxd +131 -0
  206. Cython/Includes/libcpp/optional.pxd +34 -0
  207. Cython/Includes/libcpp/pair.pxd +1 -0
  208. Cython/Includes/libcpp/queue.pxd +25 -0
  209. Cython/Includes/libcpp/random.pxd +166 -0
  210. Cython/Includes/libcpp/semaphore.pxd +43 -0
  211. Cython/Includes/libcpp/set.pxd +228 -0
  212. Cython/Includes/libcpp/shared_mutex.pxd +96 -0
  213. Cython/Includes/libcpp/span.pxd +87 -0
  214. Cython/Includes/libcpp/stack.pxd +11 -0
  215. Cython/Includes/libcpp/stop_token.pxd +117 -0
  216. Cython/Includes/libcpp/string.pxd +355 -0
  217. Cython/Includes/libcpp/string_view.pxd +183 -0
  218. Cython/Includes/libcpp/typeindex.pxd +15 -0
  219. Cython/Includes/libcpp/typeinfo.pxd +10 -0
  220. Cython/Includes/libcpp/unordered_map.pxd +193 -0
  221. Cython/Includes/libcpp/unordered_set.pxd +152 -0
  222. Cython/Includes/libcpp/utility.pxd +30 -0
  223. Cython/Includes/libcpp/vector.pxd +186 -0
  224. Cython/Includes/numpy/math.pxd +150 -0
  225. Cython/Includes/openmp.pxd +50 -0
  226. Cython/Includes/posix/__init__.pxd +1 -0
  227. Cython/Includes/posix/dlfcn.pxd +14 -0
  228. Cython/Includes/posix/fcntl.pxd +86 -0
  229. Cython/Includes/posix/ioctl.pxd +4 -0
  230. Cython/Includes/posix/mman.pxd +101 -0
  231. Cython/Includes/posix/resource.pxd +57 -0
  232. Cython/Includes/posix/select.pxd +21 -0
  233. Cython/Includes/posix/signal.pxd +73 -0
  234. Cython/Includes/posix/stat.pxd +98 -0
  235. Cython/Includes/posix/stdio.pxd +37 -0
  236. Cython/Includes/posix/stdlib.pxd +29 -0
  237. Cython/Includes/posix/strings.pxd +9 -0
  238. Cython/Includes/posix/time.pxd +71 -0
  239. Cython/Includes/posix/types.pxd +30 -0
  240. Cython/Includes/posix/uio.pxd +26 -0
  241. Cython/Includes/posix/unistd.pxd +271 -0
  242. Cython/Includes/posix/wait.pxd +38 -0
  243. Cython/LZSS.cp315-win_amd64.pyd +0 -0
  244. Cython/LZSS.py +184 -0
  245. Cython/Plex/Actions.cp315-win_amd64.pyd +0 -0
  246. Cython/Plex/Actions.pxd +24 -0
  247. Cython/Plex/Actions.py +119 -0
  248. Cython/Plex/DFA.cp315-win_amd64.pyd +0 -0
  249. Cython/Plex/DFA.pxd +14 -0
  250. Cython/Plex/DFA.py +164 -0
  251. Cython/Plex/Errors.py +48 -0
  252. Cython/Plex/Lexicons.py +178 -0
  253. Cython/Plex/Machines.cp315-win_amd64.pyd +0 -0
  254. Cython/Plex/Machines.pxd +36 -0
  255. Cython/Plex/Machines.py +238 -0
  256. Cython/Plex/Regexps.py +535 -0
  257. Cython/Plex/Scanners.cp315-win_amd64.pyd +0 -0
  258. Cython/Plex/Scanners.pxd +45 -0
  259. Cython/Plex/Scanners.py +328 -0
  260. Cython/Plex/Transitions.cp315-win_amd64.pyd +0 -0
  261. Cython/Plex/Transitions.pxd +14 -0
  262. Cython/Plex/Transitions.py +239 -0
  263. Cython/Plex/__init__.py +34 -0
  264. Cython/Runtime/__init__.py +1 -0
  265. Cython/Runtime/refnanny.cp315-win_amd64.pyd +0 -0
  266. Cython/Runtime/refnanny.pyx +237 -0
  267. Cython/Shadow.py +1174 -0
  268. Cython/StringIOTree.cp315-win_amd64.pyd +0 -0
  269. Cython/StringIOTree.py +169 -0
  270. Cython/Tempita/__init__.py +4 -0
  271. Cython/Tempita/_looper.py +154 -0
  272. Cython/Tempita/_tempita.cp315-win_amd64.pyd +0 -0
  273. Cython/Tempita/_tempita.py +1087 -0
  274. Cython/TestUtils.py +472 -0
  275. Cython/Tests/TestCodeWriter.py +128 -0
  276. Cython/Tests/TestCythonUtils.py +202 -0
  277. Cython/Tests/TestJediTyper.py +223 -0
  278. Cython/Tests/TestShadow.py +125 -0
  279. Cython/Tests/TestStringIOTree.py +68 -0
  280. Cython/Tests/TestTestUtils.py +89 -0
  281. Cython/Tests/__init__.py +1 -0
  282. Cython/Tests/xmlrunner.py +390 -0
  283. Cython/Utility/AsyncGen.c +1152 -0
  284. Cython/Utility/Buffer.c +866 -0
  285. Cython/Utility/BufferFormatFromTypeInfo.pxd +2 -0
  286. Cython/Utility/Builtins.c +1068 -0
  287. Cython/Utility/CConvert.pyx +153 -0
  288. Cython/Utility/CMath.c +104 -0
  289. Cython/Utility/CommonStructures.c +244 -0
  290. Cython/Utility/Complex.c +378 -0
  291. Cython/Utility/Coroutine.c +2344 -0
  292. Cython/Utility/CpdefEnums.pyx +119 -0
  293. Cython/Utility/CppConvert.pyx +282 -0
  294. Cython/Utility/CppSupport.cpp +151 -0
  295. Cython/Utility/CythonFunction.c +2185 -0
  296. Cython/Utility/Dataclasses.c +101 -0
  297. Cython/Utility/Embed.c +129 -0
  298. Cython/Utility/Exceptions.c +1331 -0
  299. Cython/Utility/Exceptions_Cy.pyx +109 -0
  300. Cython/Utility/ExtensionTypes.c +1199 -0
  301. Cython/Utility/FunctionArguments.c +1052 -0
  302. Cython/Utility/FusedFunction.pyx +44 -0
  303. Cython/Utility/ImportExport.c +972 -0
  304. Cython/Utility/MatchCase.c +981 -0
  305. Cython/Utility/MatchCase_Cy.pyx +12 -0
  306. Cython/Utility/MemoryView.pxd +108 -0
  307. Cython/Utility/MemoryView.pyx +1499 -0
  308. Cython/Utility/MemoryView_C.c +1056 -0
  309. Cython/Utility/ModuleSetupCode.c +3319 -0
  310. Cython/Utility/NumpyImportArray.c +46 -0
  311. Cython/Utility/ObjectHandling.c +3404 -0
  312. Cython/Utility/Optimize.c +2564 -0
  313. Cython/Utility/Overflow.c +378 -0
  314. Cython/Utility/Profile.c +736 -0
  315. Cython/Utility/StringTools.c +1534 -0
  316. Cython/Utility/Synchronization.c +438 -0
  317. Cython/Utility/TString.c +369 -0
  318. Cython/Utility/TestCyUtilityLoader.pyx +8 -0
  319. Cython/Utility/TestCythonScope.pyx +75 -0
  320. Cython/Utility/TestUtilityLoader.c +12 -0
  321. Cython/Utility/TypeConversion.c +1588 -0
  322. Cython/Utility/UFuncs.pyx +50 -0
  323. Cython/Utility/UFuncs_C.c +89 -0
  324. Cython/Utility/__init__.py +28 -0
  325. Cython/Utility/arrayarray.h +172 -0
  326. Cython/Utils.cp315-win_amd64.pyd +0 -0
  327. Cython/Utils.py +680 -0
  328. Cython/__init__.py +12 -0
  329. Cython/_shared.cp315-win_amd64.pyd +0 -0
  330. Cython/py.typed +0 -0
  331. cython-3.3.0.dist-info/METADATA +555 -0
  332. cython-3.3.0.dist-info/RECORD +339 -0
  333. cython-3.3.0.dist-info/WHEEL +5 -0
  334. cython-3.3.0.dist-info/entry_points.txt +4 -0
  335. cython-3.3.0.dist-info/top_level.txt +3 -0
  336. cython.py +29 -0
  337. pyximport/__init__.py +4 -0
  338. pyximport/pyxbuild.py +160 -0
  339. 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,268 @@
1
+ from .object cimport PyObject
2
+ from .pyport cimport uint64_t
3
+
4
+ cdef extern from *:
5
+ # Backport PyDict_GetItemStringRef and PyDict_SetDefaultRef
6
+ """
7
+ #if __PYX_LIMITED_VERSION_HEX < 0x030d0000
8
+ static CYTHON_INLINE int
9
+ __Pyx_CAPI_PyDict_GetItemStringRef(PyObject *mp, const char *key, PyObject **result)
10
+ {
11
+ int res;
12
+ PyObject *key_obj = PyUnicode_FromString(key);
13
+ if (key_obj == NULL) {
14
+ *result = NULL;
15
+ return -1;
16
+ }
17
+ res = __Pyx_PyDict_GetItemRef(mp, key_obj, result);
18
+ Py_DECREF(key_obj);
19
+ return res;
20
+ }
21
+ #else
22
+ #define __Pyx_CAPI_PyDict_GetItemStringRef PyDict_GetItemStringRef
23
+ #endif
24
+ #if PY_VERSION_HEX < 0x030d0000 || (CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030F0000)
25
+ static CYTHON_INLINE int
26
+ __Pyx_CAPI_PyDict_SetDefaultRef(PyObject *d, PyObject *key, PyObject *default_value,
27
+ PyObject **result)
28
+ {
29
+ PyObject *value;
30
+ if (__Pyx_PyDict_GetItemRef(d, key, &value) < 0) {
31
+ // get error
32
+ if (result) {
33
+ *result = NULL;
34
+ }
35
+ return -1;
36
+ }
37
+ if (value != NULL) {
38
+ // present
39
+ if (result) {
40
+ *result = value;
41
+ }
42
+ else {
43
+ Py_DECREF(value);
44
+ }
45
+ return 1;
46
+ }
47
+
48
+ // missing: set the item
49
+ if (PyDict_SetItem(d, key, default_value) < 0) {
50
+ // set error
51
+ if (result) {
52
+ *result = NULL;
53
+ }
54
+ return -1;
55
+ }
56
+ if (result) {
57
+ Py_INCREF(default_value);
58
+ *result = default_value;
59
+ }
60
+ return 0;
61
+ }
62
+ #else
63
+ #define __Pyx_CAPI_PyDict_SetDefaultRef PyDict_SetDefaultRef
64
+ #endif
65
+ """
66
+ int PyDict_GetItemRef "__Pyx_PyDict_GetItemRef" (object p, object key, PyObject* *result) except -1
67
+ # Return a new strong reference to the object from dictionary p
68
+ # which has a key key:
69
+ # - If the key is present, set *result to a new strong reference to
70
+ # the value and return 1.
71
+ # - If the key is missing, set *result to NULL and return 0.
72
+ # - On error, raise an exception and return -1.
73
+
74
+ int PyDict_GetItemStringRef "__Pyx_CAPI_PyDict_GetItemStringRef" (object p, const char *key, PyObject* *result) except -1
75
+ # Similar to PyDict_GetItemRef(), but key is specified as a const char*
76
+ # UTF-8 encoded bytes string, rather than a PyObject*.
77
+
78
+ int PyDict_SetDefaultRef "__Pyx_CAPI_PyDict_SetDefaultRef" (object p, object key, object default_value, PyObject* *result) except -1
79
+ # Inserts default_value into the dictionary p with a key of key if the
80
+ # key is not already present in the dictionary. If result is not NULL,
81
+ # then *result is set to a strong reference to either default_value,
82
+ # if the key was not present, or the existing value, if key was already
83
+ # present in the dictionary. Returns 1 if the key was present and
84
+ # default_value was not inserted, or 0 if the key was not present and
85
+ # default_value was inserted. On failure, returns -1, sets an exception,
86
+ # and sets *result to NULL.
87
+ # For clarity: if you have a strong reference to default_value before
88
+ # calling this function, then after it returns, you hold a strong
89
+ # reference to both default_value and *result (if it’s not NULL). These
90
+ # may refer to the same object: in that case you hold two separate
91
+ # references to it.
92
+
93
+ cdef extern from "Python.h":
94
+ ############################################################################
95
+ # 7.4.1 Dictionary Objects
96
+ ############################################################################
97
+
98
+ # PyDictObject
99
+ #
100
+ # This subtype of PyObject represents a Python dictionary object
101
+ # (i.e. the 'dict' type).
102
+
103
+ # PyTypeObject PyDict_Type
104
+ #
105
+ # This instance of PyTypeObject represents the Python dictionary
106
+ # type. This is exposed to Python programs as dict and
107
+ # types.DictType.
108
+
109
+ bint PyDict_Check(object p)
110
+ # Return true if p is a dict object or an instance of a subtype of
111
+ # the dict type.
112
+
113
+ bint PyDict_CheckExact(object p)
114
+ # Return true if p is a dict object, but not an instance of a
115
+ # subtype of the dict type.
116
+
117
+ dict PyDict_New()
118
+ # Return value: New reference.
119
+ # Return a new empty dictionary, or NULL on failure.
120
+
121
+ object PyDictProxy_New(object dict)
122
+ # Return value: New reference.
123
+ # Return a proxy object for a mapping which enforces read-only
124
+ # behavior. This is normally used to create a proxy to prevent
125
+ # modification of the dictionary for non-dynamic class types.
126
+
127
+ void PyDict_Clear(object p)
128
+ # Empty an existing dictionary of all key-value pairs.
129
+
130
+ int PyDict_Contains(object p, object key) except -1
131
+ # Determine if dictionary p contains key. If an item in p is
132
+ # matches key, return 1, otherwise return 0. On error, return
133
+ # -1. This is equivalent to the Python expression "key in p".
134
+
135
+ dict PyDict_Copy(object p)
136
+ # Return value: New reference.
137
+ # Return a new dictionary that contains the same key-value pairs as p.
138
+
139
+ int PyDict_SetItem(object p, object key, object val) except -1
140
+ # Insert value into the dictionary p with a key of key. key must
141
+ # be hashable; if it isn't, TypeError will be raised. Return 0 on
142
+ # success or -1 on failure.
143
+
144
+ int PyDict_SetItemString(object p, const char *key, object val) except -1
145
+ # Insert value into the dictionary p using key as a key. key
146
+ # should be a char*. The key object is created using
147
+ # PyString_FromString(key). Return 0 on success or -1 on failure.
148
+
149
+ int PyDict_DelItem(object p, object key) except -1
150
+ # Remove the entry in dictionary p with key key. key must be
151
+ # hashable; if it isn't, TypeError is raised. Return 0 on success
152
+ # or -1 on failure.
153
+
154
+ int PyDict_DelItemString(object p, const char *key) except -1
155
+ # Remove the entry in dictionary p which has a key specified by
156
+ # the string key. Return 0 on success or -1 on failure.
157
+
158
+ PyObject* PyDict_GetItem(object p, object key)
159
+ # Return value: Borrowed reference.
160
+ # Return the object from dictionary p which has a key key. Return
161
+ # NULL if the key key is not present, but without setting an
162
+ # exception.
163
+
164
+ PyObject* PyDict_GetItemWithError(object p, object key) except? NULL
165
+ # Return value: Borrowed reference.
166
+ # Variant of PyDict_GetItem() that does not suppress exceptions. Return
167
+ # NULL with an exception set if an exception occurred. Return NULL
168
+ # without an exception set if the key wasn’t present.
169
+
170
+ PyObject* PyDict_GetItemString(object p, const char *key)
171
+ # Return value: Borrowed reference.
172
+ # This is the same as PyDict_GetItem(), but key is specified as a
173
+ # char*, rather than a PyObject*.
174
+
175
+ PyObject* PyDict_SetDefault(object p, object key, object default) except NULL
176
+ # Return value: Borrowed reference.
177
+ # This is the same as the Python-level dict.setdefault(). If present, it
178
+ # returns the value corresponding to key from the dictionary p. If the key
179
+ # is not in the dict, it is inserted with value defaultobj and defaultobj
180
+ # is returned. This function evaluates the hash function of key only once,
181
+ # instead of evaluating it independently for the lookup and the insertion.
182
+
183
+ list PyDict_Items(object p)
184
+ # Return value: New reference.
185
+ # Return a PyListObject containing all the items from the
186
+ # dictionary, as in the dictionary method items() (see the Python
187
+ # Library Reference).
188
+
189
+ list PyDict_Keys(object p)
190
+ # Return value: New reference.
191
+ # Return a PyListObject containing all the keys from the
192
+ # dictionary, as in the dictionary method keys() (see the Python
193
+ # Library Reference).
194
+
195
+ list PyDict_Values(object p)
196
+ # Return value: New reference.
197
+ # Return a PyListObject containing all the values from the
198
+ # dictionary p, as in the dictionary method values() (see the
199
+ # Python Library Reference).
200
+
201
+ Py_ssize_t PyDict_Size(object p) except -1
202
+ # Return the number of items in the dictionary. This is equivalent
203
+ # to "len(p)" on a dictionary.
204
+
205
+ int PyDict_Next(object p, Py_ssize_t *ppos, PyObject* *pkey, PyObject* *pvalue)
206
+ # Iterate over all key-value pairs in the dictionary p. The int
207
+ # referred to by ppos must be initialized to 0 prior to the first
208
+ # call to this function to start the iteration; the function
209
+ # returns true for each pair in the dictionary, and false once all
210
+ # pairs have been reported. The parameters pkey and pvalue should
211
+ # either point to PyObject* variables that will be filled in with
212
+ # each key and value, respectively, or may be NULL. Any references
213
+ # returned through them are borrowed. ppos should not be altered
214
+ # during iteration. Its value represents offsets within the
215
+ # internal dictionary structure, and since the structure is
216
+ # sparse, the offsets are not consecutive.
217
+ # For example:
218
+ #
219
+ #object key, *value;
220
+ #int pos = 0;
221
+ #
222
+ #while (PyDict_Next(self->dict, &pos, &key, &value)) {
223
+ # /* do something interesting with the values... */
224
+ # ...
225
+ #}
226
+ # The dictionary p should not be mutated during iteration. It is
227
+ # safe (since Python 2.1) to modify the values of the keys as you
228
+ # iterate over the dictionary, but only so long as the set of keys
229
+ # does not change. For example:
230
+ # object key, *value;
231
+ # int pos = 0;
232
+ # while (PyDict_Next(self->dict, &pos, &key, &value)) {
233
+ # int i = PyInt_AS_LONG(value) + 1;
234
+ # object o = PyInt_FromLong(i);
235
+ # if (o == NULL)
236
+ # return -1;
237
+ # if (PyDict_SetItem(self->dict, key, o) < 0) {
238
+ # Py_DECREF(o);
239
+ # return -1;
240
+ # }
241
+ # Py_DECREF(o);
242
+ # }
243
+
244
+ int PyDict_Merge(object a, object b, int override) except -1
245
+ # Iterate over mapping object b adding key-value pairs to
246
+ # dictionary a. b may be a dictionary, or any object supporting
247
+ # PyMapping_Keys() and PyObject_GetItem(). If override is true,
248
+ # existing pairs in a will be replaced if a matching key is found
249
+ # in b, otherwise pairs will only be added if there is not a
250
+ # matching key in a. Return 0 on success or -1 if an exception was
251
+ # raised.
252
+
253
+ int PyDict_Update(object a, object b) except -1
254
+ # This is the same as PyDict_Merge(a, b, 1) in C, or a.update(b)
255
+ # in Python. Return 0 on success or -1 if an exception was raised.
256
+
257
+ int PyDict_MergeFromSeq2(object a, object seq2, int override) except -1
258
+ # Update or merge into dictionary a, from the key-value pairs in
259
+ # seq2. seq2 must be an iterable object producing iterable objects
260
+ # of length 2, viewed as key-value pairs. In case of duplicate
261
+ # keys, the last wins if override is true, else the first
262
+ # wins. Return 0 on success or -1 if an exception was
263
+ # raised. Equivalent Python (except for the return value):
264
+ #
265
+ #def PyDict_MergeFromSeq2(a, seq2, override):
266
+ # for key, value in seq2:
267
+ # if override or key not in a:
268
+ # a[key] = value