oxython 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (321) hide show
  1. Cython/Build/BuildExecutable.py +156 -0
  2. Cython/Build/Cache.py +198 -0
  3. Cython/Build/Cythonize.py +349 -0
  4. Cython/Build/Dependencies.py +1320 -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 +222 -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.pxd +154 -0
  26. Cython/Compiler/Code.py +3760 -0
  27. Cython/Compiler/CodeGeneration.py +33 -0
  28. Cython/Compiler/CythonScope.py +208 -0
  29. Cython/Compiler/Dataclass.py +890 -0
  30. Cython/Compiler/DebugFlags.py +24 -0
  31. Cython/Compiler/Errors.py +310 -0
  32. Cython/Compiler/ExprNodes.py +16319 -0
  33. Cython/Compiler/FlowControl.pxd +112 -0
  34. Cython/Compiler/FlowControl.py +1575 -0
  35. Cython/Compiler/FusedNode.py +978 -0
  36. Cython/Compiler/Future.py +16 -0
  37. Cython/Compiler/Interpreter.py +57 -0
  38. Cython/Compiler/Lexicon.py +442 -0
  39. Cython/Compiler/LineTable.py +114 -0
  40. Cython/Compiler/Main.py +879 -0
  41. Cython/Compiler/MatchCaseNodes.py +2200 -0
  42. Cython/Compiler/MemoryView.py +930 -0
  43. Cython/Compiler/ModuleNode.py +4558 -0
  44. Cython/Compiler/Naming.py +370 -0
  45. Cython/Compiler/Nodes.py +11334 -0
  46. Cython/Compiler/Optimize.py +5563 -0
  47. Cython/Compiler/Options.py +841 -0
  48. Cython/Compiler/ParseTreeTransforms.pxd +80 -0
  49. Cython/Compiler/ParseTreeTransforms.py +4808 -0
  50. Cython/Compiler/Parsing.pxd +9 -0
  51. Cython/Compiler/Parsing.py +5442 -0
  52. Cython/Compiler/Pipeline.py +439 -0
  53. Cython/Compiler/PyrexTypes.py +6588 -0
  54. Cython/Compiler/Pythran.py +232 -0
  55. Cython/Compiler/Scanning.pxd +74 -0
  56. Cython/Compiler/Scanning.py +771 -0
  57. Cython/Compiler/StringEncoding.py +354 -0
  58. Cython/Compiler/Symtab.py +3122 -0
  59. Cython/Compiler/Tests/TestBuffer.py +105 -0
  60. Cython/Compiler/Tests/TestBuiltin.py +196 -0
  61. Cython/Compiler/Tests/TestCmdLine.py +652 -0
  62. Cython/Compiler/Tests/TestCode.py +145 -0
  63. Cython/Compiler/Tests/TestFlowControl.py +65 -0
  64. Cython/Compiler/Tests/TestGrammar.py +202 -0
  65. Cython/Compiler/Tests/TestMemView.py +71 -0
  66. Cython/Compiler/Tests/TestParseTreeTransforms.py +285 -0
  67. Cython/Compiler/Tests/TestScanning.py +132 -0
  68. Cython/Compiler/Tests/TestSignatureMatching.py +73 -0
  69. Cython/Compiler/Tests/TestStringEncoding.py +20 -0
  70. Cython/Compiler/Tests/TestTreeFragment.py +63 -0
  71. Cython/Compiler/Tests/TestTreePath.py +103 -0
  72. Cython/Compiler/Tests/TestTypes.py +119 -0
  73. Cython/Compiler/Tests/TestUtilityLoad.py +112 -0
  74. Cython/Compiler/Tests/TestVisitor.py +119 -0
  75. Cython/Compiler/Tests/Utils.py +36 -0
  76. Cython/Compiler/Tests/__init__.py +1 -0
  77. Cython/Compiler/TreeFragment.py +279 -0
  78. Cython/Compiler/TreePath.py +303 -0
  79. Cython/Compiler/TypeInference.py +626 -0
  80. Cython/Compiler/TypeSlots.py +1330 -0
  81. Cython/Compiler/UFuncs.py +317 -0
  82. Cython/Compiler/UtilNodes.py +389 -0
  83. Cython/Compiler/UtilityCode.py +354 -0
  84. Cython/Compiler/Version.py +8 -0
  85. Cython/Compiler/Visitor.pxd +52 -0
  86. Cython/Compiler/Visitor.py +914 -0
  87. Cython/Compiler/__init__.py +1 -0
  88. Cython/Coverage.py +448 -0
  89. Cython/Debugger/Cygdb.py +214 -0
  90. Cython/Debugger/DebugWriter.py +82 -0
  91. Cython/Debugger/Tests/TestLibCython.py +280 -0
  92. Cython/Debugger/Tests/__init__.py +1 -0
  93. Cython/Debugger/Tests/cfuncs.c +8 -0
  94. Cython/Debugger/Tests/codefile +49 -0
  95. Cython/Debugger/Tests/test_libcython_in_gdb.py +580 -0
  96. Cython/Debugger/Tests/test_libpython_in_gdb.py +90 -0
  97. Cython/Debugger/__init__.py +1 -0
  98. Cython/Debugger/libcython.py +1548 -0
  99. Cython/Debugger/libpython.py +2821 -0
  100. Cython/Debugging.py +20 -0
  101. Cython/Distutils/__init__.py +2 -0
  102. Cython/Distutils/build_ext.py +143 -0
  103. Cython/Distutils/extension.py +96 -0
  104. Cython/Distutils/old_build_ext.py +351 -0
  105. Cython/Includes/cpython/__init__.pxd +173 -0
  106. Cython/Includes/cpython/array.pxd +159 -0
  107. Cython/Includes/cpython/bool.pxd +37 -0
  108. Cython/Includes/cpython/buffer.pxd +112 -0
  109. Cython/Includes/cpython/bytearray.pxd +33 -0
  110. Cython/Includes/cpython/bytes.pxd +200 -0
  111. Cython/Includes/cpython/cellobject.pxd +35 -0
  112. Cython/Includes/cpython/ceval.pxd +8 -0
  113. Cython/Includes/cpython/codecs.pxd +121 -0
  114. Cython/Includes/cpython/complex.pxd +60 -0
  115. Cython/Includes/cpython/contextvars.pxd +145 -0
  116. Cython/Includes/cpython/conversion.pxd +36 -0
  117. Cython/Includes/cpython/datetime.pxd +395 -0
  118. Cython/Includes/cpython/descr.pxd +26 -0
  119. Cython/Includes/cpython/dict.pxd +268 -0
  120. Cython/Includes/cpython/exc.pxd +263 -0
  121. Cython/Includes/cpython/fileobject.pxd +57 -0
  122. Cython/Includes/cpython/float.pxd +56 -0
  123. Cython/Includes/cpython/frozendict.pxd +37 -0
  124. Cython/Includes/cpython/function.pxd +65 -0
  125. Cython/Includes/cpython/genobject.pxd +25 -0
  126. Cython/Includes/cpython/getargs.pxd +12 -0
  127. Cython/Includes/cpython/instance.pxd +25 -0
  128. Cython/Includes/cpython/iterator.pxd +36 -0
  129. Cython/Includes/cpython/iterobject.pxd +24 -0
  130. Cython/Includes/cpython/list.pxd +144 -0
  131. Cython/Includes/cpython/long.pxd +180 -0
  132. Cython/Includes/cpython/longintrepr.pxd +14 -0
  133. Cython/Includes/cpython/mapping.pxd +63 -0
  134. Cython/Includes/cpython/marshal.pxd +66 -0
  135. Cython/Includes/cpython/mem.pxd +120 -0
  136. Cython/Includes/cpython/memoryview.pxd +50 -0
  137. Cython/Includes/cpython/method.pxd +49 -0
  138. Cython/Includes/cpython/module.pxd +208 -0
  139. Cython/Includes/cpython/number.pxd +258 -0
  140. Cython/Includes/cpython/object.pxd +430 -0
  141. Cython/Includes/cpython/pycapsule.pxd +143 -0
  142. Cython/Includes/cpython/pylifecycle.pxd +68 -0
  143. Cython/Includes/cpython/pyport.pxd +8 -0
  144. Cython/Includes/cpython/pystate.pxd +95 -0
  145. Cython/Includes/cpython/pythread.pxd +53 -0
  146. Cython/Includes/cpython/ref.pxd +141 -0
  147. Cython/Includes/cpython/sentinel.pxd +17 -0
  148. Cython/Includes/cpython/sequence.pxd +134 -0
  149. Cython/Includes/cpython/set.pxd +119 -0
  150. Cython/Includes/cpython/slice.pxd +70 -0
  151. Cython/Includes/cpython/time.pxd +129 -0
  152. Cython/Includes/cpython/tuple.pxd +72 -0
  153. Cython/Includes/cpython/type.pxd +146 -0
  154. Cython/Includes/cpython/unicode.pxd +639 -0
  155. Cython/Includes/cpython/version.pxd +32 -0
  156. Cython/Includes/cpython/weakref.pxd +78 -0
  157. Cython/Includes/libc/__init__.pxd +1 -0
  158. Cython/Includes/libc/complex.pxd +35 -0
  159. Cython/Includes/libc/errno.pxd +127 -0
  160. Cython/Includes/libc/float.pxd +43 -0
  161. Cython/Includes/libc/limits.pxd +28 -0
  162. Cython/Includes/libc/locale.pxd +46 -0
  163. Cython/Includes/libc/math.pxd +209 -0
  164. Cython/Includes/libc/setjmp.pxd +10 -0
  165. Cython/Includes/libc/signal.pxd +64 -0
  166. Cython/Includes/libc/stdbool.pxd +5 -0
  167. Cython/Includes/libc/stddef.pxd +9 -0
  168. Cython/Includes/libc/stdint.pxd +105 -0
  169. Cython/Includes/libc/stdio.pxd +80 -0
  170. Cython/Includes/libc/stdlib.pxd +72 -0
  171. Cython/Includes/libc/string.pxd +50 -0
  172. Cython/Includes/libc/threads.pxd +234 -0
  173. Cython/Includes/libc/time.pxd +52 -0
  174. Cython/Includes/libcpp/__init__.pxd +4 -0
  175. Cython/Includes/libcpp/algorithm.pxd +320 -0
  176. Cython/Includes/libcpp/any.pxd +16 -0
  177. Cython/Includes/libcpp/atomic.pxd +59 -0
  178. Cython/Includes/libcpp/barrier.pxd +22 -0
  179. Cython/Includes/libcpp/bit.pxd +29 -0
  180. Cython/Includes/libcpp/cast.pxd +12 -0
  181. Cython/Includes/libcpp/cmath.pxd +518 -0
  182. Cython/Includes/libcpp/complex.pxd +106 -0
  183. Cython/Includes/libcpp/condition_variable.pxd +322 -0
  184. Cython/Includes/libcpp/deque.pxd +165 -0
  185. Cython/Includes/libcpp/exception.pxd +216 -0
  186. Cython/Includes/libcpp/execution.pxd +15 -0
  187. Cython/Includes/libcpp/forward_list.pxd +63 -0
  188. Cython/Includes/libcpp/functional.pxd +26 -0
  189. Cython/Includes/libcpp/future.pxd +103 -0
  190. Cython/Includes/libcpp/iterator.pxd +34 -0
  191. Cython/Includes/libcpp/latch.pxd +17 -0
  192. Cython/Includes/libcpp/limits.pxd +61 -0
  193. Cython/Includes/libcpp/list.pxd +117 -0
  194. Cython/Includes/libcpp/map.pxd +252 -0
  195. Cython/Includes/libcpp/memory.pxd +115 -0
  196. Cython/Includes/libcpp/mutex.pxd +387 -0
  197. Cython/Includes/libcpp/numbers.pxd +15 -0
  198. Cython/Includes/libcpp/numeric.pxd +131 -0
  199. Cython/Includes/libcpp/optional.pxd +34 -0
  200. Cython/Includes/libcpp/pair.pxd +1 -0
  201. Cython/Includes/libcpp/queue.pxd +25 -0
  202. Cython/Includes/libcpp/random.pxd +166 -0
  203. Cython/Includes/libcpp/semaphore.pxd +43 -0
  204. Cython/Includes/libcpp/set.pxd +228 -0
  205. Cython/Includes/libcpp/shared_mutex.pxd +96 -0
  206. Cython/Includes/libcpp/span.pxd +87 -0
  207. Cython/Includes/libcpp/stack.pxd +11 -0
  208. Cython/Includes/libcpp/stop_token.pxd +117 -0
  209. Cython/Includes/libcpp/string.pxd +355 -0
  210. Cython/Includes/libcpp/string_view.pxd +183 -0
  211. Cython/Includes/libcpp/typeindex.pxd +15 -0
  212. Cython/Includes/libcpp/typeinfo.pxd +10 -0
  213. Cython/Includes/libcpp/unordered_map.pxd +193 -0
  214. Cython/Includes/libcpp/unordered_set.pxd +152 -0
  215. Cython/Includes/libcpp/utility.pxd +30 -0
  216. Cython/Includes/libcpp/vector.pxd +186 -0
  217. Cython/Includes/numpy/math.pxd +150 -0
  218. Cython/Includes/openmp.pxd +50 -0
  219. Cython/Includes/posix/__init__.pxd +1 -0
  220. Cython/Includes/posix/dlfcn.pxd +14 -0
  221. Cython/Includes/posix/fcntl.pxd +86 -0
  222. Cython/Includes/posix/ioctl.pxd +4 -0
  223. Cython/Includes/posix/mman.pxd +101 -0
  224. Cython/Includes/posix/resource.pxd +57 -0
  225. Cython/Includes/posix/select.pxd +21 -0
  226. Cython/Includes/posix/signal.pxd +73 -0
  227. Cython/Includes/posix/stat.pxd +98 -0
  228. Cython/Includes/posix/stdio.pxd +37 -0
  229. Cython/Includes/posix/stdlib.pxd +29 -0
  230. Cython/Includes/posix/strings.pxd +9 -0
  231. Cython/Includes/posix/time.pxd +71 -0
  232. Cython/Includes/posix/types.pxd +30 -0
  233. Cython/Includes/posix/uio.pxd +26 -0
  234. Cython/Includes/posix/unistd.pxd +271 -0
  235. Cython/Includes/posix/wait.pxd +38 -0
  236. Cython/LZSS.py +184 -0
  237. Cython/Plex/Actions.pxd +24 -0
  238. Cython/Plex/Actions.py +119 -0
  239. Cython/Plex/DFA.pxd +14 -0
  240. Cython/Plex/DFA.py +164 -0
  241. Cython/Plex/Errors.py +48 -0
  242. Cython/Plex/Lexicons.py +178 -0
  243. Cython/Plex/Machines.pxd +36 -0
  244. Cython/Plex/Machines.py +238 -0
  245. Cython/Plex/Regexps.py +535 -0
  246. Cython/Plex/Scanners.pxd +45 -0
  247. Cython/Plex/Scanners.py +328 -0
  248. Cython/Plex/Transitions.pxd +14 -0
  249. Cython/Plex/Transitions.py +239 -0
  250. Cython/Plex/__init__.py +34 -0
  251. Cython/Runtime/__init__.py +1 -0
  252. Cython/Runtime/refnanny.pyx +237 -0
  253. Cython/Shadow.py +1172 -0
  254. Cython/StringIOTree.py +169 -0
  255. Cython/Tempita/__init__.py +4 -0
  256. Cython/Tempita/_looper.py +154 -0
  257. Cython/Tempita/_tempita.py +1087 -0
  258. Cython/TestUtils.py +472 -0
  259. Cython/Tests/TestCodeWriter.py +128 -0
  260. Cython/Tests/TestCythonUtils.py +237 -0
  261. Cython/Tests/TestJediTyper.py +223 -0
  262. Cython/Tests/TestShadow.py +125 -0
  263. Cython/Tests/TestStringIOTree.py +68 -0
  264. Cython/Tests/TestTestUtils.py +89 -0
  265. Cython/Tests/__init__.py +1 -0
  266. Cython/Tests/xmlrunner.py +390 -0
  267. Cython/Utility/AsyncGen.c +1152 -0
  268. Cython/Utility/Buffer.c +866 -0
  269. Cython/Utility/BufferFormatFromTypeInfo.pxd +2 -0
  270. Cython/Utility/Builtins.c +1068 -0
  271. Cython/Utility/CConvert.pyx +153 -0
  272. Cython/Utility/CMath.c +104 -0
  273. Cython/Utility/CommonStructures.c +244 -0
  274. Cython/Utility/Complex.c +378 -0
  275. Cython/Utility/Coroutine.c +2344 -0
  276. Cython/Utility/CpdefEnums.pyx +119 -0
  277. Cython/Utility/CppConvert.pyx +284 -0
  278. Cython/Utility/CppSupport.cpp +151 -0
  279. Cython/Utility/CythonFunction.c +2143 -0
  280. Cython/Utility/Dataclasses.c +101 -0
  281. Cython/Utility/Embed.c +129 -0
  282. Cython/Utility/Exceptions.c +1331 -0
  283. Cython/Utility/Exceptions_Cy.pyx +109 -0
  284. Cython/Utility/ExtensionTypes.c +1199 -0
  285. Cython/Utility/FunctionArguments.c +1052 -0
  286. Cython/Utility/FusedFunction.pyx +44 -0
  287. Cython/Utility/ImportExport.c +972 -0
  288. Cython/Utility/MatchCase.c +985 -0
  289. Cython/Utility/MatchCase_Cy.pyx +12 -0
  290. Cython/Utility/MemoryView.pxd +108 -0
  291. Cython/Utility/MemoryView.pyx +1499 -0
  292. Cython/Utility/MemoryView_C.c +1056 -0
  293. Cython/Utility/ModuleSetupCode.c +3349 -0
  294. Cython/Utility/NumpyImportArray.c +46 -0
  295. Cython/Utility/ObjectHandling.c +3404 -0
  296. Cython/Utility/Optimize.c +2575 -0
  297. Cython/Utility/Overflow.c +378 -0
  298. Cython/Utility/Profile.c +736 -0
  299. Cython/Utility/StringTools.c +1534 -0
  300. Cython/Utility/Synchronization.c +438 -0
  301. Cython/Utility/TString.c +369 -0
  302. Cython/Utility/TestCyUtilityLoader.pyx +8 -0
  303. Cython/Utility/TestCythonScope.pyx +75 -0
  304. Cython/Utility/TestUtilityLoader.c +12 -0
  305. Cython/Utility/TypeConversion.c +1588 -0
  306. Cython/Utility/UFuncs.pyx +50 -0
  307. Cython/Utility/UFuncs_C.c +89 -0
  308. Cython/Utility/__init__.py +28 -0
  309. Cython/Utility/arrayarray.h +190 -0
  310. Cython/Utils.py +682 -0
  311. Cython/__init__.py +12 -0
  312. Cython/py.typed +0 -0
  313. cython.py +29 -0
  314. oxython-0.1.0.dist-info/METADATA +138 -0
  315. oxython-0.1.0.dist-info/RECORD +321 -0
  316. oxython-0.1.0.dist-info/WHEEL +5 -0
  317. oxython-0.1.0.dist-info/entry_points.txt +4 -0
  318. oxython-0.1.0.dist-info/top_level.txt +3 -0
  319. pyximport/__init__.py +4 -0
  320. pyximport/pyxbuild.py +160 -0
  321. pyximport/pyximport.py +482 -0
@@ -0,0 +1,1534 @@
1
+
2
+ //////////////////// IncludeStringH.proto ////////////////////
3
+
4
+ #include <string.h>
5
+
6
+ //////////////////// IncludeCppStringH.proto ////////////////////
7
+
8
+ #include <string>
9
+
10
+ //////////////////// IncludeCppStringViewH.proto ////////////////////
11
+
12
+ #include <string_view>
13
+
14
+
15
+ //////////////////// ssize_pyunicode_strlen.proto ////////////////////
16
+
17
+ static CYTHON_INLINE Py_ssize_t __Pyx_Py_UNICODE_ssize_strlen(const Py_UNICODE *u);/*proto*/
18
+
19
+ //////////////////// ssize_pyunicode_strlen ////////////////////
20
+ //@requires: pyunicode_strlen
21
+
22
+ static CYTHON_INLINE Py_ssize_t __Pyx_Py_UNICODE_ssize_strlen(const Py_UNICODE *u) {
23
+ size_t len = __Pyx_Py_UNICODE_strlen(u);
24
+ if (unlikely(len > PY_SSIZE_T_MAX)) {
25
+ PyErr_SetString(PyExc_OverflowError, "Py_UNICODE string is too long");
26
+ return -1;
27
+ }
28
+ return (Py_ssize_t) len;
29
+ }
30
+
31
+ //////////////////// pyunicode_strlen.proto ///////////////
32
+
33
+ // There used to be a Py_UNICODE_strlen() in CPython 3.x, but it is deprecated since Py3.3.
34
+ static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u); /* proto */
35
+
36
+ //////////////////// pyunicode_strlen /////////////////////
37
+
38
+ // Note: will not work in the limited API since Py_UNICODE is not available there.
39
+ // May stop working at some point after Python 3.13 (deprecated)
40
+ static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u)
41
+ {
42
+ const Py_UNICODE *u_end = u;
43
+ while (*u_end++) ;
44
+ return (size_t)(u_end - u - 1);
45
+ }
46
+
47
+ //////////////////// pyunicode_from_unicode.proto //////////////////////
48
+ //@requires: pyunicode_strlen
49
+
50
+ #define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
51
+ #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
52
+
53
+
54
+ //////////////////// DecompressString.proto ////////////////////
55
+ // TODO: Move to the shared module if we can import that before initialising the strings.
56
+
57
+ static PyObject *__Pyx_DecompressString(const char *s, Py_ssize_t length, int algo); /*proto*/
58
+
59
+ //////////////////// DecompressString ////////////////////
60
+ //@requires: TypeConversion.c::GCCDiagnostics
61
+
62
+ CYTHON_UNUSED
63
+ static CYTHON_SMALL_CODE PyObject *__Pyx_DecompressString(const char *s, Py_ssize_t length, int algo) {
64
+ #ifdef __Pyx_DecompressString_UNUSED
65
+ CYTHON_UNUSED_VAR(s);
66
+ CYTHON_UNUSED_VAR(length);
67
+ CYTHON_UNUSED_VAR(algo);
68
+ return NULL;
69
+ #else
70
+ PyObject *module = NULL, *decompress, *compressed_bytes, *decompressed;
71
+
72
+ const char* module_name = algo == 3 ? "compression.zstd" : algo == 2 ? "bz2" : "zlib";
73
+
74
+ PyObject *methodname = PyUnicode_FromString("decompress");
75
+ if (unlikely(!methodname)) return NULL;
76
+
77
+ #if __PYX_LIMITED_VERSION_HEX >= 0x030e0000
78
+ if (algo == 3) {
79
+ PyObject *fromlist = Py_BuildValue("[O]", methodname);
80
+ if (unlikely(!fromlist)) goto bad;
81
+ module = PyImport_ImportModuleLevel("compression.zstd", NULL, NULL, fromlist, 0);
82
+ Py_DECREF(fromlist);
83
+ } else
84
+ #endif
85
+ module = PyImport_ImportModule(module_name);
86
+
87
+ if (unlikely(!module)) goto import_failed;
88
+
89
+ decompress = PyObject_GetAttr(module, methodname);
90
+ // Let's keep the module alive during the Python function call, just in case.
91
+ if (unlikely(!decompress)) goto import_failed;
92
+
93
+ {
94
+ // 's' is 'const' for storage reasons but PyMemoryView_FromMemory() requires a non-const pointer.
95
+ // We create a read-only buffer, so casting away the 'const' is ok here.
96
+ #ifdef __cplusplus
97
+ char *memview_bytes = const_cast<char*>(s);
98
+ #else
99
+ #if defined(__clang__)
100
+ #pragma clang diagnostic push
101
+ #pragma clang diagnostic ignored "-Wcast-qual"
102
+ #elif !defined(__INTEL_COMPILER) && defined(__GNUC__)
103
+ #pragma GCC diagnostic push
104
+ #pragma GCC diagnostic ignored "-Wcast-qual"
105
+ #endif
106
+ char *memview_bytes = (char*) s;
107
+ #if defined(__clang__)
108
+ #pragma clang diagnostic pop
109
+ #elif !defined(__INTEL_COMPILER) && defined(__GNUC__)
110
+ #pragma GCC diagnostic pop
111
+ #endif
112
+ #endif
113
+
114
+ #if CYTHON_COMPILING_IN_LIMITED_API && !defined(PyBUF_READ)
115
+ int memview_flags = 0x100;
116
+ #else
117
+ int memview_flags = PyBUF_READ;
118
+ #endif
119
+
120
+ compressed_bytes = PyMemoryView_FromMemory(memview_bytes, length, memview_flags);
121
+ }
122
+
123
+ if (unlikely(!compressed_bytes)) {
124
+ Py_DECREF(decompress);
125
+ goto bad;
126
+ }
127
+
128
+ decompressed = PyObject_CallFunctionObjArgs(decompress, compressed_bytes, NULL);
129
+
130
+ Py_DECREF(compressed_bytes);
131
+ Py_DECREF(decompress);
132
+ Py_DECREF(module);
133
+ Py_DECREF(methodname);
134
+
135
+ return decompressed;
136
+
137
+ import_failed:
138
+ PyErr_Format(PyExc_ImportError,
139
+ "Failed to import '%.20s.decompress' - cannot initialise module strings. "
140
+ "String compression was configured with the C macro 'CYTHON_COMPRESS_STRINGS=%d'.",
141
+ module_name, algo);
142
+ bad:
143
+ Py_XDECREF(module);
144
+ Py_DECREF(methodname);
145
+ return NULL;
146
+ #endif
147
+ }
148
+
149
+
150
+ //////////////////// DecompressString_LZSS.proto ////////////////////
151
+ // TODO: Move to the shared module if we can import that before initialising the strings.
152
+
153
+ static PyObject *__Pyx_DecompressString_LZSS(const char *s, size_t compressed_length, size_t uncompressed_length); /*proto*/
154
+
155
+ //////////////////// DecompressString_LZSS ////////////////////
156
+ //@requires: IncludeStringH
157
+
158
+ #ifndef __Pyx_DecompressString_LZSS_UNUSED
159
+ // Depends on <stdint.h>, which is globally included in the module preamble.
160
+ CYTHON_UNUSED
161
+ static CYTHON_SMALL_CODE size_t __pyx_lzss_decompress(const uint8_t* src, uint8_t* dst, size_t dst_len) {
162
+ size_t pos = 0, out_pos = 0;
163
+
164
+ while (1) {
165
+ // Process 8 bytes/backreferences at a time.
166
+ uint32_t flags = src[pos++] | 0xFF00;
167
+ while (flags & 0x100) {
168
+ if (flags & 1) {
169
+ // plain byte
170
+ dst[out_pos++] = src[pos++];
171
+ } else {
172
+ // back reference, 2 or 3 bytes
173
+ uint32_t lo = src[pos++], hi = src[pos++];
174
+ uint32_t end_offset_of_last_occurrence, match_length;
175
+ if (!(lo & 0x80)) {
176
+ // 7 bit offset + 8 bit length
177
+ end_offset_of_last_occurrence = lo;
178
+ match_length = hi;
179
+ } else if (!(hi & 0x80)) {
180
+ // 2+7 bit offset + 5 bit length
181
+ end_offset_of_last_occurrence = 0x80 + (((hi << 2) & 0x180) | (lo & 0x7F));
182
+ match_length = hi & 0x1F;
183
+ } else {
184
+ // 7+7 bit offset + 8 bit length
185
+ end_offset_of_last_occurrence = 0x80 + ((hi & 0x7F) << 7 | (lo & 0x7F));
186
+ match_length = src[pos++];
187
+ }
188
+
189
+ match_length += 3;
190
+ size_t ref_pos = out_pos - end_offset_of_last_occurrence - match_length;
191
+
192
+ memcpy(dst + out_pos, dst + ref_pos, match_length);
193
+ out_pos += match_length;
194
+ }
195
+
196
+ if (out_pos >= dst_len) return pos;
197
+ flags >>= 1;
198
+ }
199
+ }
200
+ }
201
+ #endif
202
+
203
+ static CYTHON_SMALL_CODE PyObject *__Pyx_DecompressString_LZSS(const char *s, size_t compressed_length, size_t uncompressed_length) {
204
+ #ifdef __Pyx_DecompressString_LZSS_UNUSED
205
+ CYTHON_UNUSED_VAR(s);
206
+ CYTHON_UNUSED_VAR(compressed_length);
207
+ CYTHON_UNUSED_VAR(uncompressed_length);
208
+ return NULL;
209
+ #else
210
+ PyObject *result;
211
+ unsigned char *result_data;
212
+ size_t src_length;
213
+
214
+ result = PyBytes_FromStringAndSize(NULL, (Py_ssize_t) uncompressed_length);
215
+ if (unlikely(!result)) return NULL;
216
+
217
+ result_data = __Pyx_PyBytes_AsWritableUString(result);
218
+ if (unlikely(!result_data)) goto bad;
219
+
220
+ src_length = __pyx_lzss_decompress((const uint8_t*) s, result_data, uncompressed_length);
221
+ if (unlikely(src_length != compressed_length)) goto decompression_failed;
222
+
223
+ return result;
224
+
225
+ decompression_failed:
226
+ PyErr_SetString(PyExc_RuntimeError, "LZSS string data decompression failed");
227
+
228
+ bad:
229
+ Py_DECREF(result);
230
+ return NULL;
231
+ #endif
232
+ }
233
+
234
+ //////////////////// BytesContains.proto ////////////////////
235
+
236
+ static CYTHON_INLINE int __Pyx_BytesContains(char character, PyObject* bytes, int eq); /*proto*/
237
+
238
+ //////////////////// BytesContains ////////////////////
239
+ //@requires: IncludeStringH
240
+
241
+ static CYTHON_INLINE int __Pyx_BytesContains(char character, PyObject* bytes, int eq) {
242
+ const Py_ssize_t length = __Pyx_PyBytes_GET_SIZE(bytes);
243
+ #if !CYTHON_ASSUME_SAFE_SIZE
244
+ if (unlikely(length == -1)) return -1;
245
+ #endif
246
+ const char* char_start = __Pyx_PyBytes_AsString(bytes);
247
+ #if !CYTHON_ASSUME_SAFE_MACROS
248
+ if (unlikely(!char_start)) return -1;
249
+ #endif
250
+
251
+ int result = memchr(char_start, (unsigned char)character, (size_t)length) != NULL;
252
+ return (result == (eq == Py_EQ));
253
+ }
254
+
255
+
256
+ //////////////////// ByteArrayContains.proto ////////////////////
257
+
258
+ static CYTHON_INLINE int __Pyx_ByteArrayContains(char character, PyObject* bytearray, int eq); /*proto*/
259
+
260
+ //////////////////// ByteArrayContains ////////////////////
261
+ //@requires: IncludeStringH
262
+
263
+ static CYTHON_INLINE int __Pyx_ByteArrayContains(char character, PyObject* bytearray, int eq) {
264
+ const Py_ssize_t length = __Pyx_PyByteArray_GET_SIZE(bytearray);
265
+ #if !CYTHON_ASSUME_SAFE_SIZE
266
+ if (unlikely(length == -1)) return -1;
267
+ #endif
268
+ const char* char_start = __Pyx_PyByteArray_AsString(bytearray);
269
+ #if !CYTHON_ASSUME_SAFE_MACROS
270
+ if (unlikely(!char_start)) return -1;
271
+ #endif
272
+
273
+ int result = memchr(char_start, (unsigned char)character, (size_t)length) != NULL;
274
+ return (result == (eq == Py_EQ));
275
+ }
276
+
277
+
278
+ //////////////////// PyUCS4InUnicode.proto ////////////////////
279
+
280
+ static CYTHON_INLINE int __Pyx_UnicodeContainsUCS4(Py_UCS4 character, PyObject* text, int eq); /*proto*/
281
+
282
+ //////////////////// PyUCS4InUnicode ////////////////////
283
+ //@requires: IncludeStringH
284
+
285
+ static CYTHON_INLINE int __Pyx_UnicodeContainsUCS4(Py_UCS4 character, PyObject* text, int eq) {
286
+ #if !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_GRAAL)
287
+ // Not calling __Pyx_PyUnicode_READY(text) here since the "w_char" kind is simply ignored.
288
+ int str_kind = PyUnicode_KIND(text);
289
+ // A large part of real-world strings will be ASCII or Latin-1,
290
+ // especially when looking for 1-byte characters (which we often know at compile time).
291
+ if (character <= 0xFF && str_kind == 1) {
292
+ Py_ssize_t len_text = PyUnicode_GET_LENGTH(text);
293
+ return (memchr(PyUnicode_1BYTE_DATA(text), (unsigned char) character, (size_t) len_text) != NULL) == (eq == Py_EQ);
294
+ }
295
+ if (character > 0xFF && str_kind == 1) return (eq == Py_NE);
296
+ if (character > 0xFFFF && str_kind == 2) return (eq == Py_NE);
297
+ #endif
298
+ Py_ssize_t idx = PyUnicode_FindChar(text, character, 0, PY_SSIZE_T_MAX, 1);
299
+ if (unlikely(idx == -2)) return -1;
300
+
301
+ // >= 0: found the index, == -1: not found
302
+ int result = idx >= 0;
303
+ return (result == (eq == Py_EQ));
304
+ }
305
+
306
+
307
+ //////////////////// PyUnicodeContains.proto ////////////////////
308
+ //@requires: IncludeStringH
309
+
310
+ static CYTHON_INLINE int __Pyx_PyUnicode_ContainsTF(PyObject* substring, PyObject* text, int eq) {
311
+ if (substring == text) return (eq == Py_EQ);
312
+ int result = PyUnicode_Contains(text, substring);
313
+ return unlikely(result < 0) ? -1 : (result == (eq == Py_EQ));
314
+ }
315
+
316
+
317
+ //////////////////// UnicodeEquals_uchar.proto ////////////////////
318
+ //@requires: UnicodeEqualsUCS4
319
+
320
+ {{if REVERSE}}
321
+ #define __Pyx_PyObject_Equals_ch{{CHAR}}_{{'str' if IS_STR else 'obj'}}(s1, s2, equals) __Pyx_PyObject_Equals_uchar(s2, s1, {{CHAR}}, equals, {{1 if IS_STR else 0}})
322
+ {{else}}
323
+ #define __Pyx_PyObject_Equals_{{'str' if IS_STR else 'obj'}}_ch{{CHAR}}(s1, s2, equals) __Pyx_PyObject_Equals_uchar(s1, s2, {{CHAR}}, equals, {{1 if IS_STR else 0}})
324
+ {{endif}}
325
+
326
+
327
+ //////////////////// UnicodeEqualsUCS4.proto ////////////////////
328
+
329
+ #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_GRAAL
330
+ #define __Pyx_PyObject_Equals_uchar(s1, s2, ch2, equals, s1_is_str) (\
331
+ ((s1) == (s2)) ? ((equals) == Py_EQ) : \
332
+ ((s1) == Py_None) ? ((equals) == Py_NE) : \
333
+ __Pyx_PyObject_RichCompareBool(s1, s2, equals) \
334
+ )
335
+
336
+ #else
337
+ #define __Pyx_PyObject_Equals_uchar(s1, s2, ch2, equals, s1_is_str) (\
338
+ ((s1) == (s2)) ? ((equals) == Py_EQ) : \
339
+ ((s1) == Py_None) ? ((equals) == Py_NE) : \
340
+ (likely((s1_is_str) || PyUnicode_CheckExact(s1)) ? \
341
+ __Pyx__PyUnicode_EqualsUCS4(s1, ch2, equals) : \
342
+ __Pyx_PyObject_RichCompareBool(s1, s2, equals) \
343
+ ))
344
+
345
+ static CYTHON_INLINE int __Pyx__PyUnicode_EqualsUCS4(PyObject* s1, Py_UCS4 ch2, int equals); /*proto*/
346
+ #endif
347
+
348
+ //////////////////// UnicodeEqualsUCS4 ////////////////////
349
+
350
+ #if !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_GRAAL)
351
+ static CYTHON_INLINE int __Pyx__PyUnicode_EqualsUCS4(PyObject* s1, Py_UCS4 ch2, int equals) {
352
+ Py_ssize_t length;
353
+ Py_UCS4 ch1;
354
+ int kind;
355
+
356
+ if (unlikely(__Pyx_PyUnicode_READY(s1) < 0)) goto bad;
357
+ length = __Pyx_PyUnicode_GET_LENGTH(s1);
358
+ #if !CYTHON_ASSUME_SAFE_SIZE
359
+ if (unlikely(length < 0)) goto bad;
360
+ #endif
361
+ if (length != 1) goto return_ne;
362
+
363
+ kind = PyUnicode_KIND(s1);
364
+ // The following conditions are written to allow optimising on the inlined constant ch2.
365
+ if (ch2 < 256) {
366
+ if (likely(kind == PyUnicode_1BYTE_KIND)) {
367
+ ch1 = PyUnicode_1BYTE_DATA(s1)[0];
368
+ } else if (kind == PyUnicode_2BYTE_KIND) {
369
+ ch1 = PyUnicode_2BYTE_DATA(s1)[0];
370
+ } else {
371
+ ch1 = PyUnicode_4BYTE_DATA(s1)[0];
372
+ }
373
+ } else if (ch2 < 65536) {
374
+ if (kind == PyUnicode_2BYTE_KIND) {
375
+ ch1 = PyUnicode_2BYTE_DATA(s1)[0];
376
+ } else if (kind == PyUnicode_4BYTE_KIND) {
377
+ ch1 = PyUnicode_4BYTE_DATA(s1)[0];
378
+ } else {
379
+ goto return_ne;
380
+ }
381
+ } else {
382
+ if (kind == PyUnicode_4BYTE_KIND){
383
+ ch1 = PyUnicode_4BYTE_DATA(s1)[0];
384
+ } else {
385
+ goto return_ne;
386
+ }
387
+ }
388
+
389
+ if (ch1 == ch2) {
390
+ goto return_eq;
391
+ } else {
392
+ goto return_ne;
393
+ }
394
+ return_eq:
395
+ return (equals == Py_EQ);
396
+ return_ne:
397
+ return (equals == Py_NE);
398
+ bad:
399
+ return -1;
400
+ }
401
+ #endif
402
+
403
+
404
+ //////////////////// SetStringIndexingError.proto /////////////////
405
+
406
+ static void __Pyx_SetStringIndexingError(const char* message, int has_gil); /* proto */
407
+
408
+ //////////////////// SetStringIndexingError /////////////////
409
+
410
+ static void __Pyx_SetStringIndexingError(const char* message, int has_gil) {
411
+ if (!has_gil) {
412
+ PyGILState_STATE gil_state = PyGILState_Ensure();
413
+ PyErr_SetString(PyExc_IndexError, message);
414
+ PyGILState_Release(gil_state);
415
+ } else
416
+ PyErr_SetString(PyExc_IndexError, message);
417
+ }
418
+
419
+ /////////////// GetItemIntBytes.proto ///////////////
420
+ //@requires: SetStringIndexingError
421
+
422
+ #define __Pyx_GetItemInt_Bytes(o, i, type, is_signed, to_py_func, wraparound, boundscheck, has_gil, unsafe_shared) \
423
+ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \
424
+ __Pyx_GetItemInt_Bytes_Fast(o, (Py_ssize_t)i, wraparound, boundscheck, has_gil) : \
425
+ (__Pyx_SetStringIndexingError("string index out of range", has_gil), -1))
426
+
427
+ static CYTHON_INLINE int __Pyx_GetItemInt_Bytes_Fast(PyObject* bytes, Py_ssize_t index,
428
+ int wraparound, int boundscheck, int has_gil);
429
+
430
+ /////////////// GetItemIntBytes ///////////////
431
+
432
+ static CYTHON_INLINE int __Pyx_GetItemInt_Bytes_Fast(PyObject* bytes, Py_ssize_t index,
433
+ int wraparound, int boundscheck, int has_gil) {
434
+ const unsigned char *c_string;
435
+ if (wraparound && index < 0) {
436
+ Py_ssize_t size = __Pyx_PyBytes_GET_SIZE(bytes);
437
+ #if !CYTHON_ASSUME_SAFE_SIZE
438
+ if (unlikely(size < 0)) return -1;
439
+ #endif
440
+ index += size;
441
+ }
442
+ if (boundscheck) {
443
+ Py_ssize_t size = __Pyx_PyBytes_GET_SIZE(bytes);
444
+ #if !CYTHON_ASSUME_SAFE_SIZE
445
+ if (unlikely(size < 0)) return -1;
446
+ #endif
447
+ if (unlikely(!__Pyx_is_valid_index(index, size))) {
448
+ __Pyx_SetStringIndexingError("string index out of range", has_gil);
449
+ return -1;
450
+ }
451
+ }
452
+ c_string = __Pyx_PyBytes_AsUString(bytes);
453
+ #if !CYTHON_ASSUME_SAFE_MACROS
454
+ if (unlikely(!c_string)) return -1;
455
+ #endif
456
+ return (int) c_string[index];
457
+ }
458
+
459
+
460
+ //////////////////// GetItemIntByteArray.proto ////////////////////
461
+ //@requires: SetStringIndexingError
462
+
463
+ #define __Pyx_GetItemInt_ByteArray(o, i, type, is_signed, to_py_func, wraparound, boundscheck, has_gil, unsafe_shared) \
464
+ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \
465
+ __Pyx_GetItemInt_ByteArray_Fast(o, (Py_ssize_t)i, wraparound, boundscheck, has_gil, unsafe_shared) : \
466
+ (__Pyx_SetStringIndexingError("bytearray index out of range", has_gil), -1))
467
+
468
+ static CYTHON_INLINE int __Pyx_GetItemInt_ByteArray_Fast(PyObject* string, Py_ssize_t i,
469
+ int wraparound, int boundscheck, int has_gil, int unsafe_shared);
470
+
471
+ //////////////////// GetItemIntByteArray ////////////////////
472
+ //@requires: Synchronization.c::CriticalSections
473
+
474
+ static CYTHON_INLINE int __Pyx_GetItemInt_ByteArray_Fast_Locked(PyObject* string, Py_ssize_t i,
475
+ int wraparound, int boundscheck, int has_gil) {
476
+ Py_ssize_t length = __Pyx_PyByteArray_GET_SIZE(string);
477
+ #if !CYTHON_ASSUME_SAFE_SIZE
478
+ if (unlikely(length < 0)) return -1;
479
+ #endif
480
+ if (wraparound & unlikely(i < 0)) i += length;
481
+ if ((!boundscheck) || likely(__Pyx_is_valid_index(i, length))) {
482
+ #if !CYTHON_ASSUME_SAFE_MACROS
483
+ char *asString = PyByteArray_AsString(string);
484
+ return likely(asString) ? (unsigned char) asString[i] : -1;
485
+ #else
486
+ return (unsigned char) (PyByteArray_AS_STRING(string)[i]);
487
+ #endif
488
+ } else {
489
+ __Pyx_SetStringIndexingError("bytearray index out of range", has_gil);
490
+ return -1;
491
+ }
492
+ }
493
+
494
+ static CYTHON_INLINE int __Pyx_GetItemInt_ByteArray_Fast(PyObject* string, Py_ssize_t i,
495
+ int wraparound, int boundscheck, int has_gil, int unsafe_shared) {
496
+ CYTHON_MAYBE_UNUSED_VAR(unsafe_shared);
497
+ #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
498
+ // In freethreaded Python, wraparound is expensive because it involves acquiring a lock and maybe also the GIL.
499
+ // Therefore we skip it if it isn't needed.
500
+ wraparound = wraparound && i<0;
501
+ #endif
502
+ if (wraparound | boundscheck) {
503
+ int result;
504
+ // What we're guarding here is just that the size isn't mutating from under us.
505
+ // The aim isn't to make the character read-writes atomic (although practically they probably are).
506
+ // For simplicity, skip the critical section if we don't have the GIL. It's the user's problem!
507
+ __Pyx_PyCriticalSection cs;
508
+ int lock = CYTHON_COMPILING_IN_CPYTHON_FREETHREADING && has_gil && !__Pyx_IS_UNIQUELY_REFERENCED(string, unsafe_shared);
509
+ if (lock) { __Pyx_PyCriticalSection_Begin(&cs, string); }
510
+ result = __Pyx_GetItemInt_ByteArray_Fast_Locked(string, i, wraparound, boundscheck, has_gil);
511
+ if (lock) { __Pyx_PyCriticalSection_End(&cs); }
512
+ return result;
513
+ } else {
514
+ #if !CYTHON_ASSUME_SAFE_MACROS
515
+ char *asString = PyByteArray_AsString(string);
516
+ return likely(asString) ? (unsigned char) asString[i] : -1;
517
+ #else
518
+ return (unsigned char) (PyByteArray_AS_STRING(string)[i]);
519
+ #endif
520
+ }
521
+ }
522
+
523
+
524
+ //////////////////// SetItemIntByteArray.proto ////////////////////
525
+ //@requires: SetStringIndexingError
526
+
527
+ #define __Pyx_SetItemInt_ByteArray(o, i, v, type, is_signed, to_py_func, wraparound, boundscheck, has_gil, unsafe_shared) \
528
+ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \
529
+ __Pyx_SetItemInt_ByteArray_Fast(o, (Py_ssize_t)i, v, wraparound, boundscheck, has_gil, unsafe_shared) : \
530
+ (__Pyx_SetStringIndexingError("bytearray index out of range", has_gil), -1))
531
+
532
+ static CYTHON_INLINE int __Pyx_SetItemInt_ByteArray_Fast(PyObject* string, Py_ssize_t i, unsigned char v,
533
+ int wraparound, int boundscheck, int has_gil, int unsafe_shared);
534
+
535
+ //////////////////// SetItemIntByteArray ////////////////////
536
+ //@requires: Synchronization.c::CriticalSections
537
+
538
+ static CYTHON_INLINE int __Pyx_SetItemInt_ByteArray_Fast_Locked(PyObject* string, Py_ssize_t i, unsigned char v,
539
+ int wraparound, int boundscheck, int has_gil) {
540
+ Py_ssize_t length = __Pyx_PyByteArray_GET_SIZE(string);
541
+ #if !CYTHON_ASSUME_SAFE_SIZE
542
+ if (unlikely(length < 0)) return -1;
543
+ #endif
544
+ if (wraparound & unlikely(i < 0)) i += length;
545
+ if ((!boundscheck) || likely(__Pyx_is_valid_index(i, length))) {
546
+ #if !CYTHON_ASSUME_SAFE_MACROS
547
+ char *asString = PyByteArray_AsString(string);
548
+ if (unlikely(!asString)) return -1;
549
+ asString[i] = (char)v;
550
+ #else
551
+ PyByteArray_AS_STRING(string)[i] = (char) v;
552
+ #endif
553
+ return 0;
554
+ } else {
555
+ __Pyx_SetStringIndexingError("bytearray index out of range", has_gil);
556
+ return -1;
557
+ }
558
+ }
559
+
560
+ static CYTHON_INLINE int __Pyx_SetItemInt_ByteArray_Fast(PyObject* string, Py_ssize_t i, unsigned char v,
561
+ int wraparound, int boundscheck, int has_gil, int unsafe_shared) {
562
+ CYTHON_MAYBE_UNUSED_VAR(unsafe_shared);
563
+ #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
564
+ // In freethreaded Python, wraparound is expensive because it involves acquiring a lock and maybe also the GIL.
565
+ // Therefore we skip it if it isn't needed.
566
+ wraparound = wraparound && i<0;
567
+ #endif
568
+ if (wraparound | boundscheck) {
569
+ int result;
570
+ // What we're guarding here is just that the size isn't mutating from under us.
571
+ // The aim isn't to make the character read-writes atomic (although practically they probably are).
572
+ // For simplicity, skip the critical section if we don't have the GIL. It's the user's problem!
573
+ __Pyx_PyCriticalSection cs;
574
+ int lock = CYTHON_COMPILING_IN_CPYTHON_FREETHREADING && has_gil && !__Pyx_IS_UNIQUELY_REFERENCED(string, unsafe_shared);
575
+ if (lock) { __Pyx_PyCriticalSection_Begin(&cs, string); }
576
+ result = __Pyx_SetItemInt_ByteArray_Fast_Locked(string, i, v, wraparound, boundscheck, has_gil);
577
+ if (lock) { __Pyx_PyCriticalSection_End(&cs); }
578
+ return result;
579
+ } else {
580
+ #if !CYTHON_ASSUME_SAFE_MACROS
581
+ char *asString = PyByteArray_AsString(string);
582
+ if (unlikely(!asString)) return -1;
583
+ asString[i] = (char)v;
584
+ #else
585
+ PyByteArray_AS_STRING(string)[i] = (char) v;
586
+ #endif
587
+ return 0;
588
+ }
589
+ }
590
+
591
+
592
+ //////////////////// GetItemIntUnicode.proto ////////////////////
593
+ //@requires: SetStringIndexingError
594
+
595
+ #define __Pyx_GetItemInt_Unicode(o, i, type, is_signed, to_py_func, wraparound, boundscheck, has_gil, unsafe_shared) \
596
+ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \
597
+ __Pyx_GetItemInt_Unicode_Fast(o, (Py_ssize_t)i, wraparound, boundscheck, has_gil) : \
598
+ (__Pyx_SetStringIndexingError("string index out of range", has_gil), (Py_UCS4)-1))
599
+
600
+ static CYTHON_INLINE Py_UCS4 __Pyx_GetItemInt_Unicode_Fast(PyObject* ustring, Py_ssize_t i,
601
+ int wraparound, int boundscheck, int has_gil);
602
+
603
+ //////////////////// GetItemIntUnicode ////////////////////
604
+
605
+ static CYTHON_INLINE Py_UCS4 __Pyx_GetItemInt_Unicode_Fast(PyObject* ustring, Py_ssize_t i,
606
+ int wraparound, int boundscheck, int has_gil) {
607
+ Py_ssize_t length;
608
+ if (unlikely(__Pyx_PyUnicode_READY(ustring) < 0)) return (Py_UCS4)-1;
609
+ if (wraparound | boundscheck) {
610
+ length = __Pyx_PyUnicode_GET_LENGTH(ustring);
611
+ #if !CYTHON_ASSUME_SAFE_SIZE
612
+ if (unlikely(length < 0)) return (Py_UCS4)-1;
613
+ #endif
614
+ if (wraparound & unlikely(i < 0)) i += length;
615
+ if ((!boundscheck) || likely(__Pyx_is_valid_index(i, length))) {
616
+ return __Pyx_PyUnicode_READ_CHAR(ustring, i);
617
+ } else {
618
+ __Pyx_SetStringIndexingError("string index out of range", has_gil);
619
+ return (Py_UCS4)-1;
620
+ }
621
+ } else {
622
+ return __Pyx_PyUnicode_READ_CHAR(ustring, i);
623
+ }
624
+ }
625
+
626
+
627
+ /////////////// decode_c_string_utf16.proto ///////////////
628
+
629
+ static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16(const char *s, Py_ssize_t size, const char *errors) {
630
+ int byteorder = 0;
631
+ return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
632
+ }
633
+ static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16LE(const char *s, Py_ssize_t size, const char *errors) {
634
+ int byteorder = -1;
635
+ return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
636
+ }
637
+ static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16BE(const char *s, Py_ssize_t size, const char *errors) {
638
+ int byteorder = 1;
639
+ return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
640
+ }
641
+
642
+ /////////////// decode_cpp_string.proto ///////////////
643
+ //@requires: IncludeCppStringH
644
+ //@requires: decode_c_bytes
645
+
646
+ static CYTHON_INLINE PyObject* __Pyx_decode_cpp_string(
647
+ std::string cppstring, Py_ssize_t start, Py_ssize_t stop,
648
+ const char* encoding, const char* errors,
649
+ PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) {
650
+ return __Pyx_decode_c_bytes(
651
+ cppstring.data(), (Py_ssize_t) cppstring.size(), start, stop, encoding, errors, decode_func);
652
+ }
653
+
654
+ /////////////// decode_cpp_string_view.proto ///////////////
655
+ //@requires: IncludeCppStringViewH
656
+ //@requires: decode_c_bytes
657
+
658
+ static CYTHON_INLINE PyObject* __Pyx_decode_cpp_string_view(
659
+ std::string_view cppstring, Py_ssize_t start, Py_ssize_t stop,
660
+ const char* encoding, const char* errors,
661
+ PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) {
662
+ return __Pyx_decode_c_bytes(
663
+ cppstring.data(), (Py_ssize_t) cppstring.size(), start, stop, encoding, errors, decode_func);
664
+ }
665
+
666
+ /////////////// decode_c_string.proto ///////////////
667
+
668
+ static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
669
+ const char* cstring, Py_ssize_t start, Py_ssize_t stop,
670
+ const char* encoding, const char* errors,
671
+ PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors));
672
+
673
+ /////////////// decode_c_string ///////////////
674
+ //@requires: IncludeStringH
675
+ //@requires: decode_c_string_utf16
676
+
677
+ /* duplicate code to avoid calling strlen() if start >= 0 and stop >= 0 */
678
+ static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
679
+ const char* cstring, Py_ssize_t start, Py_ssize_t stop,
680
+ const char* encoding, const char* errors,
681
+ PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) {
682
+ Py_ssize_t length;
683
+ if (unlikely((start < 0) | (stop < 0))) {
684
+ size_t slen = strlen(cstring);
685
+ if (unlikely(slen > (size_t) PY_SSIZE_T_MAX)) {
686
+ PyErr_SetString(PyExc_OverflowError,
687
+ "c-string too long to convert to Python");
688
+ return NULL;
689
+ }
690
+ length = (Py_ssize_t) slen;
691
+ if (start < 0) {
692
+ start += length;
693
+ if (start < 0)
694
+ start = 0;
695
+ }
696
+ if (stop < 0)
697
+ stop += length;
698
+ }
699
+ if (unlikely(stop <= start))
700
+ return __Pyx_NewRef(EMPTY(unicode));
701
+ length = stop - start;
702
+ cstring += start;
703
+ if (decode_func) {
704
+ return decode_func(cstring, length, errors);
705
+ } else {
706
+ return PyUnicode_Decode(cstring, length, encoding, errors);
707
+ }
708
+ }
709
+
710
+ /////////////// decode_c_bytes.proto ///////////////
711
+
712
+ static CYTHON_INLINE PyObject* __Pyx_decode_c_bytes(
713
+ const char* cstring, Py_ssize_t length, Py_ssize_t start, Py_ssize_t stop,
714
+ const char* encoding, const char* errors,
715
+ PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors));
716
+
717
+ /////////////// decode_c_bytes ///////////////
718
+ //@requires: decode_c_string_utf16
719
+
720
+ static CYTHON_INLINE PyObject* __Pyx_decode_c_bytes(
721
+ const char* cstring, Py_ssize_t length, Py_ssize_t start, Py_ssize_t stop,
722
+ const char* encoding, const char* errors,
723
+ PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) {
724
+ if (unlikely((start < 0) | (stop < 0))) {
725
+ if (start < 0) {
726
+ start += length;
727
+ if (start < 0)
728
+ start = 0;
729
+ }
730
+ if (stop < 0)
731
+ stop += length;
732
+ }
733
+ if (stop > length)
734
+ stop = length;
735
+ if (unlikely(stop <= start))
736
+ return __Pyx_NewRef(EMPTY(unicode));
737
+ length = stop - start;
738
+ cstring += start;
739
+ if (decode_func) {
740
+ return decode_func(cstring, length, errors);
741
+ } else {
742
+ return PyUnicode_Decode(cstring, length, encoding, errors);
743
+ }
744
+ }
745
+
746
+ /////////////// decode_bytes.proto ///////////////
747
+ //@requires: decode_c_bytes
748
+
749
+ static CYTHON_INLINE PyObject* __Pyx_decode_bytes(
750
+ PyObject* string, Py_ssize_t start, Py_ssize_t stop,
751
+ const char* encoding, const char* errors,
752
+ PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) {
753
+ char* as_c_string;
754
+ Py_ssize_t size;
755
+ #if CYTHON_ASSUME_SAFE_MACROS && CYTHON_ASSUME_SAFE_SIZE
756
+ as_c_string = PyBytes_AS_STRING(string);
757
+ size = PyBytes_GET_SIZE(string);
758
+ #else
759
+ if (PyBytes_AsStringAndSize(string, &as_c_string, &size) < 0) {
760
+ return NULL;
761
+ }
762
+ #endif
763
+ return __Pyx_decode_c_bytes(
764
+ as_c_string, size,
765
+ start, stop, encoding, errors, decode_func);
766
+ }
767
+
768
+ /////////////// decode_bytearray.proto ///////////////
769
+ //@requires: decode_c_bytes
770
+
771
+ static CYTHON_INLINE PyObject* __Pyx_decode_bytearray(
772
+ PyObject* string, Py_ssize_t start, Py_ssize_t stop,
773
+ const char* encoding, const char* errors,
774
+ PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) {
775
+ char* as_c_string;
776
+ Py_ssize_t size;
777
+ #if CYTHON_ASSUME_SAFE_MACROS && CYTHON_ASSUME_SAFE_SIZE
778
+ as_c_string = PyByteArray_AS_STRING(string);
779
+ size = PyByteArray_GET_SIZE(string);
780
+ #else
781
+ if (!(as_c_string = PyByteArray_AsString(string))) return NULL;
782
+ if ((size = PyByteArray_Size(string)) < 0) return NULL;
783
+ #endif
784
+ return __Pyx_decode_c_bytes(
785
+ as_c_string, size,
786
+ start, stop, encoding, errors, decode_func);
787
+ }
788
+
789
+ /////////////// PyUnicode_Substring.proto ///////////////
790
+
791
+ static CYTHON_INLINE PyObject* __Pyx_PyUnicode_Substring(
792
+ PyObject* text, Py_ssize_t start, Py_ssize_t stop);
793
+
794
+ /////////////// PyUnicode_Substring ///////////////
795
+
796
+ static CYTHON_INLINE PyObject* __Pyx_PyUnicode_Substring(
797
+ PyObject* text, Py_ssize_t start, Py_ssize_t stop) {
798
+ Py_ssize_t length;
799
+ if (unlikely(__Pyx_PyUnicode_READY(text) == -1)) return NULL;
800
+ length = __Pyx_PyUnicode_GET_LENGTH(text);
801
+ #if !CYTHON_ASSUME_SAFE_SIZE
802
+ if (unlikely(length < 0)) return NULL;
803
+ #endif
804
+ if (start < 0) {
805
+ start += length;
806
+ if (start < 0)
807
+ start = 0;
808
+ }
809
+ if (stop < 0)
810
+ stop += length;
811
+ else if (stop > length)
812
+ stop = length;
813
+ if (stop <= start)
814
+ return __Pyx_NewRef(EMPTY(unicode));
815
+ if (start == 0 && stop == length)
816
+ return __Pyx_NewRef(text);
817
+ #if CYTHON_COMPILING_IN_LIMITED_API
818
+ // PyUnicode_Substring() does not support negative indexing but is otherwise fine to use.
819
+ return PyUnicode_Substring(text, start, stop);
820
+ #else
821
+ return PyUnicode_FromKindAndData(PyUnicode_KIND(text),
822
+ PyUnicode_1BYTE_DATA(text) + start*PyUnicode_KIND(text), stop-start);
823
+ #endif
824
+ }
825
+
826
+ /////////////// py_unicode_predicate.proto ///////////////
827
+
828
+ // isprintable() is lacking C-API support in PyPy
829
+ #if CYTHON_COMPILING_IN_LIMITED_API{{if method_name == 'isprintable'}} || (CYTHON_COMPILING_IN_PYPY && !defined(Py_UNICODE_ISPRINTABLE)){{endif}}
830
+ static int __Pyx_Py_UNICODE_{{method_name.upper()}}(Py_UCS4 uchar);/*proto*/
831
+ #else
832
+ {{if method_name == 'istitle'}}
833
+ // Py_UNICODE_ISTITLE() doesn't match unicode.istitle() as the latter
834
+ // additionally allows character that comply with Py_UNICODE_ISUPPER()
835
+ static CYTHON_INLINE int __Pyx_Py_UNICODE_ISTITLE(Py_UCS4 uchar) {
836
+ return Py_UNICODE_ISTITLE(uchar) || Py_UNICODE_ISUPPER(uchar);
837
+ }
838
+ {{else}}
839
+ // Use bitwise and to try to make it clear to the compiler that -1 error code will never be seen.
840
+ #define __Pyx_Py_UNICODE_{{method_name.upper()}}(u) (Py_UNICODE_{{method_name.upper()}}(u) & 1)
841
+ {{endif}}
842
+ #endif
843
+
844
+ /////////////// py_unicode_predicate ///////////////
845
+
846
+ {{py:
847
+ from operator import methodcaller
848
+
849
+ char_matches_unicode_type = methodcaller(method_name)
850
+
851
+ def first_nonascii_chr(method_name, _matches=char_matches_unicode_type):
852
+ from sys import maxunicode
853
+
854
+ for code_point in range(128, maxunicode):
855
+ if _matches(chr(code_point)):
856
+ return code_point
857
+ return maxunicode
858
+
859
+ def format_chr_for_c(i):
860
+ c = chr(i)
861
+ if c == "'":
862
+ return r"(Py_UCS4)'\''"
863
+ if c == '\\':
864
+ return r"(Py_UCS4)'\\'"
865
+ if c.isprintable():
866
+ return f"(Py_UCS4)'{c}'"
867
+ return str(i)
868
+ }}
869
+
870
+ #if CYTHON_COMPILING_IN_LIMITED_API{{if method_name == 'isprintable'}} || (CYTHON_COMPILING_IN_PYPY && !defined(Py_UNICODE_ISPRINTABLE)){{endif}}
871
+ static int __Pyx_Py_UNICODE_{{method_name.upper()}}(Py_UCS4 uchar) {
872
+ int result;
873
+ PyObject *py_result, *ustring;
874
+ // Add a fast path for ascii - the switch statements get prohibitively big if we try to include
875
+ // all of unicode.
876
+ if (uchar < {{first_nonascii_chr(method_name)}}) {
877
+ switch (uchar) {
878
+ {{for i in range(128):}}
879
+ {{if char_matches_unicode_type(chr(i)) }}
880
+ case {{format_chr_for_c(i)}}:
881
+ {{endif}}
882
+ {{endfor}}
883
+ return 1;
884
+ }
885
+ return 0;
886
+ }
887
+ ustring = PyUnicode_FromOrdinal(uchar);
888
+ if (!ustring) return -1;
889
+ py_result = PyObject_CallMethod(ustring, "{{method_name}}", NULL);
890
+ Py_DECREF(ustring);
891
+ if (!py_result) return -1;
892
+ result = PyObject_IsTrue(py_result);
893
+ Py_DECREF(py_result);
894
+ if (result == -1) return -1;
895
+ return result != 0;
896
+ }
897
+ #endif
898
+
899
+
900
+ /////////////// unicode_tailmatch.proto ///////////////
901
+
902
+ static int __Pyx_PyUnicode_Tailmatch(
903
+ PyObject* s, PyObject* substr, Py_ssize_t start, Py_ssize_t end, int direction); /*proto*/
904
+
905
+ /////////////// unicode_tailmatch ///////////////
906
+
907
+ // Python's unicode.startswith() and unicode.endswith() support a
908
+ // tuple of prefixes/suffixes, whereas it's much more common to
909
+ // test for a single unicode string.
910
+
911
+ static int __Pyx_PyUnicode_TailmatchTuple(PyObject* s, PyObject* substrings,
912
+ Py_ssize_t start, Py_ssize_t end, int direction) {
913
+ Py_ssize_t i, count = __Pyx_PyTuple_GET_SIZE(substrings);
914
+ #if !CYTHON_ASSUME_SAFE_SIZE
915
+ if (unlikely(count < 0)) return -1;
916
+ #endif
917
+ for (i = 0; i < count; i++) {
918
+ Py_ssize_t result;
919
+ #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
920
+ result = PyUnicode_Tailmatch(s, PyTuple_GET_ITEM(substrings, i),
921
+ start, end, direction);
922
+ #else
923
+ PyObject* sub = __Pyx_PySequence_ITEM(substrings, i);
924
+ if (unlikely(!sub)) return -1;
925
+ result = PyUnicode_Tailmatch(s, sub, start, end, direction);
926
+ Py_DECREF(sub);
927
+ #endif
928
+ if (result) {
929
+ return (int) result;
930
+ }
931
+ }
932
+ return 0;
933
+ }
934
+
935
+ static int __Pyx_PyUnicode_Tailmatch(PyObject* s, PyObject* substr,
936
+ Py_ssize_t start, Py_ssize_t end, int direction) {
937
+ if (unlikely(PyTuple_Check(substr))) {
938
+ return __Pyx_PyUnicode_TailmatchTuple(s, substr, start, end, direction);
939
+ }
940
+ return (int) PyUnicode_Tailmatch(s, substr, start, end, direction);
941
+ }
942
+
943
+
944
+ /////////////// bytes_tailmatch.proto ///////////////
945
+
946
+ static int __Pyx_PyBytes_SingleTailmatch(PyObject* self, PyObject* arg,
947
+ Py_ssize_t start, Py_ssize_t end, int direction); /*proto*/
948
+ static int __Pyx_PyBytes_Tailmatch(PyObject* self, PyObject* substr,
949
+ Py_ssize_t start, Py_ssize_t end, int direction); /*proto*/
950
+
951
+ /////////////// bytes_tailmatch ///////////////
952
+
953
+ static int __Pyx_PyBytes_SingleTailmatch(PyObject* self, PyObject* arg,
954
+ Py_ssize_t start, Py_ssize_t end, int direction) {
955
+ char* self_ptr;
956
+ Py_ssize_t self_len;
957
+ char* sub_ptr;
958
+ Py_ssize_t sub_len;
959
+ int retval;
960
+
961
+ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030b0000
962
+ PyObject *converted_arg = NULL;
963
+ #else
964
+ Py_buffer view;
965
+ view.obj = NULL;
966
+ #endif
967
+
968
+ #if !(CYTHON_ASSUME_SAFE_MACROS && CYTHON_ASSUME_SAFE_SIZE)
969
+ if (PyBytes_AsStringAndSize(self, &self_ptr, &self_len) == -1) return -1;
970
+ #else
971
+ self_ptr = PyBytes_AS_STRING(self);
972
+ self_len = PyBytes_GET_SIZE(self);
973
+ #endif
974
+
975
+ if (PyBytes_Check(arg)) {
976
+ #if !(CYTHON_ASSUME_SAFE_MACROS && CYTHON_ASSUME_SAFE_SIZE)
977
+ if (PyBytes_AsStringAndSize(arg, &sub_ptr, &sub_len) == -1) return -1;
978
+ #else
979
+ sub_ptr = PyBytes_AS_STRING(arg);
980
+ sub_len = PyBytes_GET_SIZE(arg);
981
+ #endif
982
+ }
983
+ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030b0000
984
+ else if (PyByteArray_Check(arg)) {
985
+ // The Limited API fallback is inefficient,
986
+ // so special-case bytearray to be a bit faster. Keep this to the Limited
987
+ // API only since the buffer protocol code is good enough otherwise.
988
+ sub_ptr = PyByteArray_AsString(arg);
989
+ if (unlikely(!sub_ptr)) return -1;
990
+ sub_len = PyByteArray_Size(arg);
991
+ if (unlikely(sub_len < 0)) return -1;
992
+ } else {
993
+ // Where buffer protocol is unavailable, just convert to bytes
994
+ // (which is probably inefficient, but does work)
995
+ // First check that the object is a buffer (since PyBytes_FromObject)
996
+ // is more flexible than what endswith accepts.
997
+ PyObject *as_memoryview = PyMemoryView_FromObject(arg);
998
+ if (!as_memoryview) return -1;
999
+ Py_DECREF(as_memoryview);
1000
+ converted_arg = PyBytes_FromObject(arg);
1001
+ if (!converted_arg) return -1;
1002
+ if (PyBytes_AsStringAndSize(converted_arg, &sub_ptr, &sub_len) == -1) {
1003
+ Py_DECREF(converted_arg);
1004
+ return -1;
1005
+ }
1006
+
1007
+ }
1008
+ #else // LIMITED_API >= 030B0000 or !LIMITED_API
1009
+ else {
1010
+ if (unlikely(PyObject_GetBuffer(arg, &view, PyBUF_SIMPLE) == -1))
1011
+ return -1;
1012
+ sub_ptr = (char*) view.buf;
1013
+ sub_len = view.len;
1014
+ }
1015
+ #endif
1016
+
1017
+ if (end > self_len)
1018
+ end = self_len;
1019
+ else if (end < 0)
1020
+ end += self_len;
1021
+ if (end < 0)
1022
+ end = 0;
1023
+ if (start < 0)
1024
+ start += self_len;
1025
+ if (start < 0)
1026
+ start = 0;
1027
+
1028
+ if (direction > 0) {
1029
+ /* endswith */
1030
+ if (end-sub_len > start)
1031
+ start = end - sub_len;
1032
+ }
1033
+
1034
+ if (start + sub_len <= end)
1035
+ retval = !memcmp(self_ptr+start, sub_ptr, (size_t)sub_len);
1036
+ else
1037
+ retval = 0;
1038
+
1039
+ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030b0000
1040
+ Py_XDECREF(converted_arg);
1041
+ #else
1042
+ if (view.obj)
1043
+ PyBuffer_Release(&view);
1044
+ #endif
1045
+
1046
+ return retval;
1047
+ }
1048
+
1049
+ static int __Pyx_PyBytes_TailmatchTuple(PyObject* self, PyObject* substrings,
1050
+ Py_ssize_t start, Py_ssize_t end, int direction) {
1051
+ Py_ssize_t i, count = __Pyx_PyTuple_GET_SIZE(substrings);
1052
+ #if !CYTHON_ASSUME_SAFE_SIZE
1053
+ if (unlikely(count < 0)) return -1;
1054
+ #endif
1055
+ for (i = 0; i < count; i++) {
1056
+ int result;
1057
+ #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
1058
+ result = __Pyx_PyBytes_SingleTailmatch(self, PyTuple_GET_ITEM(substrings, i),
1059
+ start, end, direction);
1060
+ #else
1061
+ PyObject* sub = __Pyx_PySequence_ITEM(substrings, i);
1062
+ if (unlikely(!sub)) return -1;
1063
+ result = __Pyx_PyBytes_SingleTailmatch(self, sub, start, end, direction);
1064
+ Py_DECREF(sub);
1065
+ #endif
1066
+ if (result) {
1067
+ return result;
1068
+ }
1069
+ }
1070
+ return 0;
1071
+ }
1072
+
1073
+ static int __Pyx_PyBytes_Tailmatch(PyObject* self, PyObject* substr,
1074
+ Py_ssize_t start, Py_ssize_t end, int direction) {
1075
+ if (unlikely(PyTuple_Check(substr))) {
1076
+ return __Pyx_PyBytes_TailmatchTuple(self, substr, start, end, direction);
1077
+ }
1078
+
1079
+ return __Pyx_PyBytes_SingleTailmatch(self, substr, start, end, direction);
1080
+ }
1081
+
1082
+
1083
+ //////////////////// StringJoin.proto ////////////////////
1084
+
1085
+ static CYTHON_INLINE PyObject* __Pyx_PyBytes_Join(PyObject* sep, PyObject* values); /*proto*/
1086
+
1087
+ //////////////////// StringJoin ////////////////////
1088
+ //@requires: ObjectHandling.c::PyObjectCallMethod1
1089
+
1090
+ static CYTHON_INLINE PyObject* __Pyx_PyBytes_Join(PyObject* sep, PyObject* values) {
1091
+ // avoid unused function
1092
+ (void) &__Pyx_PyObject_CallMethod1;
1093
+ #if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030e0000 || defined(PyBytes_Join)
1094
+ return PyBytes_Join(sep, values);
1095
+ #elif CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030d0000 || defined(_PyBytes_Join)
1096
+ return _PyBytes_Join(sep, values);
1097
+ #else
1098
+ return __Pyx_PyObject_CallMethod1(sep, PYIDENT("join"), values);
1099
+ #endif
1100
+ }
1101
+
1102
+
1103
+ /////////////// JoinPyUnicode.export ///////////////
1104
+
1105
+ static PyObject* __Pyx_PyUnicode_Join(PyObject** values, Py_ssize_t value_count, Py_ssize_t result_ulength, int kind); /*proto*/
1106
+
1107
+ /////////////// JoinPyUnicode.proto ///////////////
1108
+
1109
+ // This macro guard excludes the kind and length calculation on platforms where we definitely don't need it.
1110
+ // If the function lives in the shared module, user modules must provide kind and length on all other
1111
+ // platforms to prevent incorrect argument values if the shared module implementation requires it.
1112
+ #define __Pyx_PyUnicode_Join_CAN_USE_KIND_AND_LENGTH \
1113
+ (!CYTHON_COMPILING_IN_GRAAL && !CYTHON_COMPILING_IN_PYPY && !CYTHON_COMPILING_IN_LIMITED_API)
1114
+
1115
+ /////////////// JoinPyUnicode ///////////////
1116
+ //@requires: IncludeStringH
1117
+
1118
+ static PyObject* __Pyx_PyUnicode_Join(PyObject** values, Py_ssize_t value_count, Py_ssize_t result_ulength, int kind) {
1119
+ #if __Pyx_PyUnicode_Join_CAN_USE_KIND_AND_LENGTH && CYTHON_USE_UNICODE_INTERNALS
1120
+ PyObject *result_uval;
1121
+ int result_ukind, kind_shift;
1122
+ Py_ssize_t i, char_pos;
1123
+ void *result_udata;
1124
+
1125
+ // We use '|' to combine the substring kinds, so index 3 actually means 1|2 => 2.
1126
+ static const Py_UCS4 max_char[5] = {0x7fU, 0xffU, 0xffffU, 0xffffU, 0x10ffffU};
1127
+ assert (kind >= 0); /* ASCII */
1128
+ if (kind > PyUnicode_4BYTE_KIND) kind = PyUnicode_4BYTE_KIND;
1129
+
1130
+ result_uval = PyUnicode_New(result_ulength, max_char[kind]);
1131
+ if (unlikely(!result_uval)) return NULL;
1132
+
1133
+ kind_shift = kind >> 1; // 0, 1, 2
1134
+ result_ukind = 1 << kind_shift; // 1, 2, 4
1135
+ result_udata = PyUnicode_DATA(result_uval);
1136
+
1137
+ assert(kind_shift == 2 || kind_shift == 1 || kind_shift == 0);
1138
+ if (unlikely((PY_SSIZE_T_MAX >> kind_shift) - result_ulength < 0))
1139
+ goto overflow;
1140
+
1141
+ char_pos = 0;
1142
+ for (i=0; i < value_count; i++) {
1143
+ int ukind;
1144
+ Py_ssize_t ulength;
1145
+ void *udata;
1146
+ PyObject *uval = values[i];
1147
+ if (__Pyx_PyUnicode_READY(uval) == (-1))
1148
+ goto bad;
1149
+ ulength = __Pyx_PyUnicode_GET_LENGTH(uval);
1150
+ #if !CYTHON_ASSUME_SAFE_SIZE
1151
+ if (unlikely(ulength < 0)) goto bad;
1152
+ #endif
1153
+ if (unlikely(!ulength))
1154
+ continue;
1155
+ if (unlikely((PY_SSIZE_T_MAX >> kind_shift) - ulength < char_pos))
1156
+ goto overflow;
1157
+ ukind = __Pyx_PyUnicode_KIND(uval);
1158
+ udata = __Pyx_PyUnicode_DATA(uval);
1159
+ if (ukind == result_ukind) {
1160
+ memcpy((char *)result_udata + (char_pos << kind_shift), udata, (size_t) (ulength << kind_shift));
1161
+ } else {
1162
+ #if PY_VERSION_HEX >= 0x030d0000
1163
+ if (unlikely(PyUnicode_CopyCharacters(result_uval, char_pos, uval, 0, ulength) < 0)) goto bad;
1164
+ #elif CYTHON_COMPILING_IN_CPYTHON || defined(_PyUnicode_FastCopyCharacters)
1165
+ _PyUnicode_FastCopyCharacters(result_uval, char_pos, uval, 0, ulength);
1166
+ #else
1167
+ Py_ssize_t j;
1168
+ for (j=0; j < ulength; j++) {
1169
+ Py_UCS4 uchar = __Pyx_PyUnicode_READ(ukind, udata, j);
1170
+ __Pyx_PyUnicode_WRITE(result_ukind, result_udata, char_pos+j, uchar);
1171
+ }
1172
+ #endif
1173
+ }
1174
+ char_pos += ulength;
1175
+ }
1176
+ return result_uval;
1177
+
1178
+ overflow:
1179
+ PyErr_SetString(PyExc_OverflowError, "join() result is too long for a Python string");
1180
+ bad:
1181
+ Py_DECREF(result_uval);
1182
+ return NULL;
1183
+
1184
+ #else
1185
+ // non-CPython fallback
1186
+ Py_ssize_t i;
1187
+ PyObject *result = NULL;
1188
+ PyObject *value_tuple = PyTuple_New(value_count);
1189
+ if (unlikely(!value_tuple)) return NULL;
1190
+ CYTHON_UNUSED_VAR(kind);
1191
+ CYTHON_UNUSED_VAR(result_ulength);
1192
+
1193
+ for (i=0; i<value_count; i++) {
1194
+ Py_INCREF(values[i]);
1195
+ if (__Pyx_PyTuple_SET_ITEM(value_tuple, i, values[i]) != (0)) goto bad;
1196
+ }
1197
+
1198
+ result = PyUnicode_Join(EMPTY(unicode), value_tuple);
1199
+
1200
+ bad:
1201
+ Py_DECREF(value_tuple);
1202
+ return result;
1203
+ #endif
1204
+ }
1205
+
1206
+
1207
+ /////////////// BuildPyUnicode.proto ///////////////
1208
+
1209
+ static PyObject* __Pyx_PyUnicode_BuildFromAscii(Py_ssize_t ulength, const char* chars, int clength,
1210
+ int prepend_sign, char padding_char);
1211
+
1212
+ /////////////// BuildPyUnicode ///////////////
1213
+
1214
+ // Create a PyUnicode object from an ASCII char*, e.g. a formatted number.
1215
+
1216
+ static PyObject* __Pyx_PyUnicode_BuildFromAscii(Py_ssize_t ulength, const char* chars, int clength,
1217
+ int prepend_sign, char padding_char) {
1218
+ PyObject *uval;
1219
+ Py_ssize_t uoffset = ulength - clength;
1220
+ #if CYTHON_USE_UNICODE_INTERNALS
1221
+ Py_ssize_t i;
1222
+ void *udata;
1223
+ uval = PyUnicode_New(ulength, 127);
1224
+ if (unlikely(!uval)) return NULL;
1225
+ udata = PyUnicode_DATA(uval);
1226
+ if (uoffset > 0) {
1227
+ i = 0;
1228
+ if (prepend_sign) {
1229
+ __Pyx_PyUnicode_WRITE(PyUnicode_1BYTE_KIND, udata, 0, '-');
1230
+ i++;
1231
+ }
1232
+ for (; i < uoffset; i++) {
1233
+ __Pyx_PyUnicode_WRITE(PyUnicode_1BYTE_KIND, udata, i, padding_char);
1234
+ }
1235
+ }
1236
+ for (i=0; i < clength; i++) {
1237
+ __Pyx_PyUnicode_WRITE(PyUnicode_1BYTE_KIND, udata, uoffset+i, chars[i]);
1238
+ }
1239
+
1240
+ #else
1241
+ // non-CPython
1242
+ {
1243
+ PyObject *sign = NULL, *padding = NULL;
1244
+ uval = NULL;
1245
+ if (uoffset > 0) {
1246
+ prepend_sign = !!prepend_sign;
1247
+ if (uoffset > prepend_sign) {
1248
+ padding = PyUnicode_FromOrdinal(padding_char);
1249
+ if (likely(padding) && uoffset > prepend_sign + 1) {
1250
+ PyObject *tmp = PySequence_Repeat(padding, uoffset - prepend_sign);
1251
+ Py_DECREF(padding);
1252
+ padding = tmp;
1253
+ }
1254
+ if (unlikely(!padding)) goto done_or_error;
1255
+ }
1256
+ if (prepend_sign) {
1257
+ sign = PyUnicode_FromOrdinal('-');
1258
+ if (unlikely(!sign)) goto done_or_error;
1259
+ }
1260
+ }
1261
+
1262
+ uval = PyUnicode_DecodeASCII(chars, clength, NULL);
1263
+ if (likely(uval) && padding) {
1264
+ PyObject *tmp = PyUnicode_Concat(padding, uval);
1265
+ Py_DECREF(uval);
1266
+ uval = tmp;
1267
+ }
1268
+ if (likely(uval) && sign) {
1269
+ PyObject *tmp = PyUnicode_Concat(sign, uval);
1270
+ Py_DECREF(uval);
1271
+ uval = tmp;
1272
+ }
1273
+ done_or_error:
1274
+ Py_XDECREF(padding);
1275
+ Py_XDECREF(sign);
1276
+ }
1277
+ #endif
1278
+
1279
+ return uval;
1280
+ }
1281
+
1282
+
1283
+ //////////////////// ByteArrayAppendObject.proto ////////////////////
1284
+
1285
+ static CYTHON_INLINE int __Pyx_PyByteArray_AppendObject(PyObject* bytearray, PyObject* value);
1286
+
1287
+ //////////////////// ByteArrayAppendObject ////////////////////
1288
+ //@requires: ByteArrayAppend
1289
+
1290
+ static CYTHON_INLINE int __Pyx_PyByteArray_AppendObject(PyObject* bytearray, PyObject* value) {
1291
+ Py_ssize_t ival;
1292
+ #if CYTHON_USE_PYLONG_INTERNALS
1293
+ if (likely(PyLong_CheckExact(value)) && likely(__Pyx_PyLong_IsCompact(value))) {
1294
+ if (__Pyx_PyLong_IsZero(value)) {
1295
+ ival = 0;
1296
+ } else {
1297
+ ival = __Pyx_PyLong_CompactValue(value);
1298
+ if (unlikely(!__Pyx_is_valid_index(ival, 256))) goto bad_range;
1299
+ }
1300
+ } else
1301
+ #endif
1302
+ {
1303
+ // CPython calls PyNumber_Index() internally
1304
+ ival = __Pyx_PyIndex_AsSsize_t(value);
1305
+ if (unlikely(!__Pyx_is_valid_index(ival, 256))) {
1306
+ if (ival == -1 && PyErr_Occurred())
1307
+ return -1;
1308
+ goto bad_range;
1309
+ }
1310
+ }
1311
+ return __Pyx_PyByteArray_Append(bytearray, (int) ival);
1312
+
1313
+ bad_range:
1314
+ PyErr_SetString(PyExc_ValueError, "byte must be in range(0, 256)");
1315
+ return -1;
1316
+ }
1317
+
1318
+ //////////////////// ByteArrayAppend.proto ////////////////////
1319
+
1320
+ static CYTHON_INLINE int __Pyx_PyByteArray_Append(PyObject* bytearray, int value);
1321
+
1322
+ //////////////////// ByteArrayAppend ////////////////////
1323
+ //@requires: ObjectHandling.c::PyObjectCallMethod1
1324
+
1325
+ static int __Pyx_PyByteArray_Append_fallback(PyObject* bytearray, int value) {
1326
+ PyObject *pyval, *retval;
1327
+ pyval = PyLong_FromLong(value);
1328
+ if (unlikely(!pyval))
1329
+ return -1;
1330
+ retval = __Pyx_PyObject_CallMethod1(bytearray, PYIDENT("append"), pyval);
1331
+ Py_DECREF(pyval);
1332
+ if (unlikely(!retval))
1333
+ return -1;
1334
+ Py_DECREF(retval);
1335
+ return 0;
1336
+ }
1337
+
1338
+ static CYTHON_INLINE int __Pyx_PyByteArray_Append(PyObject* bytearray, int value) {
1339
+ #if CYTHON_COMPILING_IN_CPYTHON
1340
+ if (likely(__Pyx_is_valid_index(value, 256))) {
1341
+ int retval = 1;
1342
+ __Pyx_BEGIN_CRITICAL_SECTION(bytearray);
1343
+ Py_ssize_t n = Py_SIZE(bytearray);
1344
+ if (likely(n != PY_SSIZE_T_MAX)) {
1345
+ retval = PyByteArray_Resize(bytearray, n + 1);
1346
+ if (likely(retval == 0)) {
1347
+ PyByteArray_AS_STRING(bytearray)[n] = (char) (unsigned char) value;
1348
+ }
1349
+ }
1350
+ __Pyx_END_CRITICAL_SECTION();
1351
+ if (likely(retval != 1)) {
1352
+ return retval;
1353
+ }
1354
+ } else {
1355
+ PyErr_SetString(PyExc_ValueError, "byte must be in range(0, 256)");
1356
+ return -1;
1357
+ }
1358
+ #endif
1359
+
1360
+ return __Pyx_PyByteArray_Append_fallback(bytearray, value);
1361
+ }
1362
+
1363
+
1364
+ //////////////////// ByteArrayExtend.proto ////////////////////
1365
+
1366
+ static int __Pyx_PyByteArray_Extend_fallback(PyObject* bytearray, PyObject* value); /*proto*/
1367
+ #if CYTHON_COMPILING_IN_CPYTHON
1368
+ static CYTHON_INLINE int __Pyx_PyByteArray_ExtendBuffer(PyObject* bytearray, PyObject *value, const char* bytes, Py_ssize_t length); /*proto*/
1369
+ #endif
1370
+
1371
+ //////////////////// ByteArrayExtend ////////////////////
1372
+ //@requires: ObjectHandling.c::PyObjectCallMethod1
1373
+ //@requires: IncludeStringH
1374
+
1375
+ static int __Pyx_PyByteArray_Extend_fallback(PyObject* bytearray, PyObject* value) {
1376
+ PyObject *retval = __Pyx_PyObject_CallMethod1(bytearray, PYIDENT("extend"), value);
1377
+ if (unlikely(!retval))
1378
+ return -1;
1379
+ Py_DECREF(retval);
1380
+ return 0;
1381
+ }
1382
+
1383
+ #if CYTHON_COMPILING_IN_CPYTHON
1384
+ static CYTHON_INLINE int __Pyx_PyByteArray_ExtendBuffer(PyObject* bytearray, PyObject *value, const char* bytes, Py_ssize_t length) {
1385
+ int retval = 1;
1386
+ __Pyx_BEGIN_CRITICAL_SECTION(bytearray);
1387
+ Py_ssize_t n = Py_SIZE(bytearray);
1388
+ if (likely(n < PY_SSIZE_T_MAX - length)) {
1389
+ retval = PyByteArray_Resize(bytearray, n + length);
1390
+ if (likely(retval == 0)) {
1391
+ char *buffer = PyByteArray_AS_STRING(bytearray) + n;
1392
+ memcpy(buffer, bytes, (size_t) length);
1393
+ }
1394
+ }
1395
+ __Pyx_END_CRITICAL_SECTION();
1396
+ if (likely(retval != 1)) {
1397
+ return retval;
1398
+ }
1399
+
1400
+ return __Pyx_PyByteArray_Extend_fallback(bytearray, value);
1401
+ }
1402
+ #endif
1403
+
1404
+
1405
+ //////////////////// ByteArrayExtendBytes.proto ////////////////////
1406
+
1407
+ static CYTHON_INLINE int __Pyx_PyByteArray_ExtendBytes(PyObject* bytearray, PyObject* value); /*proto*/
1408
+
1409
+ #define __Pyx_PyByteArray_ExtendObject(bytearray, value) (PyBytes_CheckExact(value) ? \
1410
+ __Pyx_PyByteArray_ExtendBytes(bytearray, value) : \
1411
+ __Pyx_PyByteArray_Extend_fallback(bytearray, value))
1412
+
1413
+ //////////////////// ByteArrayExtendBytes ////////////////////
1414
+ //@requires: ByteArrayExtend
1415
+
1416
+ static CYTHON_INLINE int __Pyx_PyByteArray_ExtendBytes(PyObject* bytearray, PyObject* value) {
1417
+ #if CYTHON_COMPILING_IN_CPYTHON
1418
+ char* bytes;
1419
+ Py_ssize_t length;
1420
+ if (unlikely(PyBytes_AsStringAndSize(value, &bytes, &length) == -1)) {
1421
+ return -1;
1422
+ }
1423
+ if (unlikely(length == 0)) {
1424
+ return 0;
1425
+ }
1426
+ return __Pyx_PyByteArray_ExtendBuffer(bytearray, value, bytes, length);
1427
+ #else
1428
+ return __Pyx_PyByteArray_Extend_fallback(bytearray, value);
1429
+ #endif
1430
+ }
1431
+
1432
+
1433
+ //////////////////// PyObjectFormat.proto ////////////////////
1434
+
1435
+ #if CYTHON_USE_UNICODE_WRITER
1436
+ static PyObject* __Pyx_PyObject_Format(PyObject* s, PyObject* f);
1437
+ #else
1438
+ #define __Pyx_PyObject_Format(s, f) PyObject_Format(s, f)
1439
+ #endif
1440
+
1441
+ //////////////////// PyObjectFormat ////////////////////
1442
+
1443
+ #if CYTHON_USE_UNICODE_WRITER
1444
+ static PyObject* __Pyx_PyObject_Format(PyObject* obj, PyObject* format_spec) {
1445
+ int ret;
1446
+ _PyUnicodeWriter writer;
1447
+
1448
+ if (likely(PyFloat_CheckExact(obj))) {
1449
+ // copied from CPython 3.5 "float__format__()" in floatobject.c
1450
+ _PyUnicodeWriter_Init(&writer);
1451
+ ret = _PyFloat_FormatAdvancedWriter(
1452
+ &writer,
1453
+ obj,
1454
+ format_spec, 0, PyUnicode_GET_LENGTH(format_spec));
1455
+ } else if (likely(PyLong_CheckExact(obj))) {
1456
+ // copied from CPython 3.5 "long__format__()" in longobject.c
1457
+ _PyUnicodeWriter_Init(&writer);
1458
+ ret = _PyLong_FormatAdvancedWriter(
1459
+ &writer,
1460
+ obj,
1461
+ format_spec, 0, PyUnicode_GET_LENGTH(format_spec));
1462
+ } else {
1463
+ return PyObject_Format(obj, format_spec);
1464
+ }
1465
+
1466
+ if (unlikely(ret == -1)) {
1467
+ _PyUnicodeWriter_Dealloc(&writer);
1468
+ return NULL;
1469
+ }
1470
+ return _PyUnicodeWriter_Finish(&writer);
1471
+ }
1472
+ #endif
1473
+
1474
+
1475
+ //////////////////// PyObjectFormatSimple.proto ////////////////////
1476
+
1477
+ #if CYTHON_COMPILING_IN_PYPY
1478
+ #define __Pyx_PyObject_FormatSimple(s, f) ( \
1479
+ likely(PyUnicode_CheckExact(s)) ? (Py_INCREF(s), s) : \
1480
+ PyObject_Format(s, f))
1481
+ #elif CYTHON_USE_TYPE_SLOTS
1482
+ // Py3 nicely returns unicode strings from str() and repr(), which makes this quite efficient for builtin types.
1483
+ // In Py3.8+, tp_str() delegates to tp_repr(), so we call tp_repr() directly here.
1484
+ #define __Pyx_PyObject_FormatSimple(s, f) ( \
1485
+ likely(PyUnicode_CheckExact(s)) ? (Py_INCREF(s), s) : \
1486
+ likely(PyLong_CheckExact(s)) ? PyLong_Type.tp_repr(s) : \
1487
+ likely(PyFloat_CheckExact(s)) ? PyFloat_Type.tp_repr(s) : \
1488
+ PyObject_Format(s, f))
1489
+ #else
1490
+ #define __Pyx_PyObject_FormatSimple(s, f) ( \
1491
+ likely(PyUnicode_CheckExact(s)) ? (Py_INCREF(s), s) : \
1492
+ PyObject_Format(s, f))
1493
+ #endif
1494
+
1495
+
1496
+ //////////////////// PyObjectFormatAndDecref.proto ////////////////////
1497
+
1498
+ static CYTHON_INLINE PyObject* __Pyx_PyObject_FormatSimpleAndDecref(PyObject* s, PyObject* f);
1499
+ static CYTHON_INLINE PyObject* __Pyx_PyObject_FormatAndDecref(PyObject* s, PyObject* f);
1500
+
1501
+ //////////////////// PyObjectFormatAndDecref ////////////////////
1502
+
1503
+ static CYTHON_INLINE PyObject* __Pyx_PyObject_FormatSimpleAndDecref(PyObject* s, PyObject* f) {
1504
+ if (unlikely(!s)) return NULL;
1505
+ if (likely(PyUnicode_CheckExact(s))) return s;
1506
+ return __Pyx_PyObject_FormatAndDecref(s, f);
1507
+ }
1508
+
1509
+ static CYTHON_INLINE PyObject* __Pyx_PyObject_FormatAndDecref(PyObject* s, PyObject* f) {
1510
+ PyObject *result;
1511
+ if (unlikely(!s)) return NULL;
1512
+ result = PyObject_Format(s, f);
1513
+ Py_DECREF(s);
1514
+ return result;
1515
+ }
1516
+
1517
+
1518
+ //////////////////// PyUnicode_Unicode.proto ////////////////////
1519
+
1520
+ static CYTHON_INLINE PyObject* __Pyx_PyUnicode_Unicode(PyObject *obj);/*proto*/
1521
+
1522
+ //////////////////// PyUnicode_Unicode ////////////////////
1523
+
1524
+ static CYTHON_INLINE PyObject* __Pyx_PyUnicode_Unicode(PyObject *obj) {
1525
+ if (unlikely(obj == Py_None))
1526
+ obj = PYUNICODE("None");
1527
+ return __Pyx_NewRef(obj);
1528
+ }
1529
+
1530
+
1531
+ //////////////////// PyObject_Unicode.proto ////////////////////
1532
+
1533
+ #define __Pyx_PyObject_Unicode(obj) \
1534
+ (likely(PyUnicode_CheckExact(obj)) ? __Pyx_NewRef(obj) : PyObject_Str(obj))