Cython 3.1.0a1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (301) hide show
  1. Cython/Build/BuildExecutable.py +169 -0
  2. Cython/Build/Cache.py +199 -0
  3. Cython/Build/Cythonize.py +250 -0
  4. Cython/Build/Dependencies.py +1275 -0
  5. Cython/Build/Distutils.py +1 -0
  6. Cython/Build/Inline.py +342 -0
  7. Cython/Build/IpythonMagic.py +560 -0
  8. Cython/Build/Tests/TestCyCache.py +119 -0
  9. Cython/Build/Tests/TestCythonizeArgsParser.py +481 -0
  10. Cython/Build/Tests/TestDependencies.py +133 -0
  11. Cython/Build/Tests/TestInline.py +112 -0
  12. Cython/Build/Tests/TestIpythonMagic.py +287 -0
  13. Cython/Build/Tests/TestRecythonize.py +212 -0
  14. Cython/Build/Tests/TestStripLiterals.py +155 -0
  15. Cython/Build/Tests/__init__.py +1 -0
  16. Cython/Build/__init__.py +8 -0
  17. Cython/CodeWriter.py +811 -0
  18. Cython/Compiler/AnalysedTreeTransforms.py +97 -0
  19. Cython/Compiler/Annotate.py +326 -0
  20. Cython/Compiler/AutoDocTransforms.py +314 -0
  21. Cython/Compiler/Buffer.py +680 -0
  22. Cython/Compiler/Builtin.py +862 -0
  23. Cython/Compiler/CmdLine.py +243 -0
  24. Cython/Compiler/Code.pxd +145 -0
  25. Cython/Compiler/Code.py +3328 -0
  26. Cython/Compiler/CodeGeneration.py +33 -0
  27. Cython/Compiler/CythonScope.py +179 -0
  28. Cython/Compiler/Dataclass.py +868 -0
  29. Cython/Compiler/DebugFlags.py +21 -0
  30. Cython/Compiler/Errors.py +295 -0
  31. Cython/Compiler/ExprNodes.py +15051 -0
  32. Cython/Compiler/FlowControl.pxd +97 -0
  33. Cython/Compiler/FlowControl.py +1438 -0
  34. Cython/Compiler/FusedNode.py +998 -0
  35. Cython/Compiler/Future.py +16 -0
  36. Cython/Compiler/Interpreter.py +57 -0
  37. Cython/Compiler/Lexicon.py +340 -0
  38. Cython/Compiler/LineTable.py +114 -0
  39. Cython/Compiler/Main.py +779 -0
  40. Cython/Compiler/MatchCaseNodes.py +259 -0
  41. Cython/Compiler/MemoryView.py +860 -0
  42. Cython/Compiler/ModuleNode.py +4065 -0
  43. Cython/Compiler/Naming.py +369 -0
  44. Cython/Compiler/Nodes.py +10557 -0
  45. Cython/Compiler/Optimize.py +5269 -0
  46. Cython/Compiler/Options.py +828 -0
  47. Cython/Compiler/ParseTreeTransforms.pxd +78 -0
  48. Cython/Compiler/ParseTreeTransforms.py +4441 -0
  49. Cython/Compiler/Parsing.pxd +9 -0
  50. Cython/Compiler/Parsing.py +4797 -0
  51. Cython/Compiler/Pipeline.py +425 -0
  52. Cython/Compiler/PyrexTypes.py +5572 -0
  53. Cython/Compiler/Pythran.py +223 -0
  54. Cython/Compiler/Scanning.pxd +40 -0
  55. Cython/Compiler/Scanning.py +574 -0
  56. Cython/Compiler/StringEncoding.py +347 -0
  57. Cython/Compiler/Symtab.py +2998 -0
  58. Cython/Compiler/Tests/TestBuffer.py +105 -0
  59. Cython/Compiler/Tests/TestBuiltin.py +72 -0
  60. Cython/Compiler/Tests/TestCmdLine.py +573 -0
  61. Cython/Compiler/Tests/TestCode.py +86 -0
  62. Cython/Compiler/Tests/TestFlowControl.py +65 -0
  63. Cython/Compiler/Tests/TestGrammar.py +202 -0
  64. Cython/Compiler/Tests/TestMemView.py +71 -0
  65. Cython/Compiler/Tests/TestParseTreeTransforms.py +285 -0
  66. Cython/Compiler/Tests/TestScanning.py +134 -0
  67. Cython/Compiler/Tests/TestSignatureMatching.py +73 -0
  68. Cython/Compiler/Tests/TestStringEncoding.py +33 -0
  69. Cython/Compiler/Tests/TestTreeFragment.py +63 -0
  70. Cython/Compiler/Tests/TestTreePath.py +93 -0
  71. Cython/Compiler/Tests/TestTypes.py +75 -0
  72. Cython/Compiler/Tests/TestUtilityLoad.py +112 -0
  73. Cython/Compiler/Tests/TestVisitor.py +61 -0
  74. Cython/Compiler/Tests/Utils.py +36 -0
  75. Cython/Compiler/Tests/__init__.py +1 -0
  76. Cython/Compiler/TreeFragment.py +278 -0
  77. Cython/Compiler/TreePath.py +290 -0
  78. Cython/Compiler/TypeInference.py +584 -0
  79. Cython/Compiler/TypeSlots.py +1181 -0
  80. Cython/Compiler/UFuncs.py +311 -0
  81. Cython/Compiler/UtilNodes.py +387 -0
  82. Cython/Compiler/UtilityCode.py +274 -0
  83. Cython/Compiler/Version.py +8 -0
  84. Cython/Compiler/Visitor.pxd +53 -0
  85. Cython/Compiler/Visitor.py +861 -0
  86. Cython/Compiler/__init__.py +1 -0
  87. Cython/Coverage.py +443 -0
  88. Cython/Debugger/Cygdb.py +179 -0
  89. Cython/Debugger/DebugWriter.py +82 -0
  90. Cython/Debugger/Tests/TestLibCython.py +275 -0
  91. Cython/Debugger/Tests/__init__.py +1 -0
  92. Cython/Debugger/Tests/cfuncs.c +8 -0
  93. Cython/Debugger/Tests/codefile +49 -0
  94. Cython/Debugger/Tests/test_libcython_in_gdb.py +578 -0
  95. Cython/Debugger/Tests/test_libpython_in_gdb.py +90 -0
  96. Cython/Debugger/__init__.py +1 -0
  97. Cython/Debugger/libcython.py +1549 -0
  98. Cython/Debugger/libpython.py +2821 -0
  99. Cython/Debugging.py +20 -0
  100. Cython/Distutils/__init__.py +2 -0
  101. Cython/Distutils/build_ext.py +137 -0
  102. Cython/Distutils/extension.py +96 -0
  103. Cython/Distutils/old_build_ext.py +351 -0
  104. Cython/Includes/cpython/__init__.pxd +173 -0
  105. Cython/Includes/cpython/array.pxd +174 -0
  106. Cython/Includes/cpython/bool.pxd +37 -0
  107. Cython/Includes/cpython/buffer.pxd +112 -0
  108. Cython/Includes/cpython/bytearray.pxd +33 -0
  109. Cython/Includes/cpython/bytes.pxd +200 -0
  110. Cython/Includes/cpython/cellobject.pxd +35 -0
  111. Cython/Includes/cpython/ceval.pxd +8 -0
  112. Cython/Includes/cpython/codecs.pxd +121 -0
  113. Cython/Includes/cpython/complex.pxd +55 -0
  114. Cython/Includes/cpython/contextvars.pxd +141 -0
  115. Cython/Includes/cpython/conversion.pxd +36 -0
  116. Cython/Includes/cpython/datetime.pxd +384 -0
  117. Cython/Includes/cpython/descr.pxd +26 -0
  118. Cython/Includes/cpython/dict.pxd +187 -0
  119. Cython/Includes/cpython/exc.pxd +263 -0
  120. Cython/Includes/cpython/fileobject.pxd +57 -0
  121. Cython/Includes/cpython/float.pxd +47 -0
  122. Cython/Includes/cpython/function.pxd +65 -0
  123. Cython/Includes/cpython/genobject.pxd +25 -0
  124. Cython/Includes/cpython/getargs.pxd +12 -0
  125. Cython/Includes/cpython/instance.pxd +25 -0
  126. Cython/Includes/cpython/iterator.pxd +36 -0
  127. Cython/Includes/cpython/iterobject.pxd +24 -0
  128. Cython/Includes/cpython/list.pxd +92 -0
  129. Cython/Includes/cpython/long.pxd +149 -0
  130. Cython/Includes/cpython/longintrepr.pxd +19 -0
  131. Cython/Includes/cpython/mapping.pxd +63 -0
  132. Cython/Includes/cpython/marshal.pxd +66 -0
  133. Cython/Includes/cpython/mem.pxd +120 -0
  134. Cython/Includes/cpython/memoryview.pxd +50 -0
  135. Cython/Includes/cpython/method.pxd +49 -0
  136. Cython/Includes/cpython/module.pxd +208 -0
  137. Cython/Includes/cpython/number.pxd +258 -0
  138. Cython/Includes/cpython/object.pxd +433 -0
  139. Cython/Includes/cpython/pycapsule.pxd +143 -0
  140. Cython/Includes/cpython/pylifecycle.pxd +68 -0
  141. Cython/Includes/cpython/pyport.pxd +8 -0
  142. Cython/Includes/cpython/pystate.pxd +95 -0
  143. Cython/Includes/cpython/pythread.pxd +53 -0
  144. Cython/Includes/cpython/ref.pxd +67 -0
  145. Cython/Includes/cpython/sequence.pxd +134 -0
  146. Cython/Includes/cpython/set.pxd +119 -0
  147. Cython/Includes/cpython/slice.pxd +70 -0
  148. Cython/Includes/cpython/time.pxd +129 -0
  149. Cython/Includes/cpython/tuple.pxd +72 -0
  150. Cython/Includes/cpython/type.pxd +53 -0
  151. Cython/Includes/cpython/unicode.pxd +639 -0
  152. Cython/Includes/cpython/version.pxd +32 -0
  153. Cython/Includes/cpython/weakref.pxd +42 -0
  154. Cython/Includes/libc/__init__.pxd +1 -0
  155. Cython/Includes/libc/complex.pxd +35 -0
  156. Cython/Includes/libc/errno.pxd +127 -0
  157. Cython/Includes/libc/float.pxd +43 -0
  158. Cython/Includes/libc/limits.pxd +28 -0
  159. Cython/Includes/libc/locale.pxd +46 -0
  160. Cython/Includes/libc/math.pxd +209 -0
  161. Cython/Includes/libc/setjmp.pxd +10 -0
  162. Cython/Includes/libc/signal.pxd +64 -0
  163. Cython/Includes/libc/stddef.pxd +9 -0
  164. Cython/Includes/libc/stdint.pxd +105 -0
  165. Cython/Includes/libc/stdio.pxd +80 -0
  166. Cython/Includes/libc/stdlib.pxd +72 -0
  167. Cython/Includes/libc/string.pxd +50 -0
  168. Cython/Includes/libc/time.pxd +47 -0
  169. Cython/Includes/libcpp/__init__.pxd +4 -0
  170. Cython/Includes/libcpp/algorithm.pxd +320 -0
  171. Cython/Includes/libcpp/any.pxd +16 -0
  172. Cython/Includes/libcpp/atomic.pxd +59 -0
  173. Cython/Includes/libcpp/bit.pxd +29 -0
  174. Cython/Includes/libcpp/cast.pxd +12 -0
  175. Cython/Includes/libcpp/cmath.pxd +518 -0
  176. Cython/Includes/libcpp/complex.pxd +106 -0
  177. Cython/Includes/libcpp/deque.pxd +165 -0
  178. Cython/Includes/libcpp/execution.pxd +15 -0
  179. Cython/Includes/libcpp/forward_list.pxd +63 -0
  180. Cython/Includes/libcpp/functional.pxd +26 -0
  181. Cython/Includes/libcpp/iterator.pxd +34 -0
  182. Cython/Includes/libcpp/limits.pxd +61 -0
  183. Cython/Includes/libcpp/list.pxd +117 -0
  184. Cython/Includes/libcpp/map.pxd +252 -0
  185. Cython/Includes/libcpp/memory.pxd +115 -0
  186. Cython/Includes/libcpp/numbers.pxd +15 -0
  187. Cython/Includes/libcpp/numeric.pxd +131 -0
  188. Cython/Includes/libcpp/optional.pxd +34 -0
  189. Cython/Includes/libcpp/pair.pxd +1 -0
  190. Cython/Includes/libcpp/queue.pxd +25 -0
  191. Cython/Includes/libcpp/random.pxd +166 -0
  192. Cython/Includes/libcpp/set.pxd +228 -0
  193. Cython/Includes/libcpp/stack.pxd +11 -0
  194. Cython/Includes/libcpp/string.pxd +333 -0
  195. Cython/Includes/libcpp/typeindex.pxd +15 -0
  196. Cython/Includes/libcpp/typeinfo.pxd +10 -0
  197. Cython/Includes/libcpp/unordered_map.pxd +193 -0
  198. Cython/Includes/libcpp/unordered_set.pxd +152 -0
  199. Cython/Includes/libcpp/utility.pxd +30 -0
  200. Cython/Includes/libcpp/vector.pxd +167 -0
  201. Cython/Includes/openmp.pxd +50 -0
  202. Cython/Includes/posix/__init__.pxd +1 -0
  203. Cython/Includes/posix/dlfcn.pxd +14 -0
  204. Cython/Includes/posix/fcntl.pxd +86 -0
  205. Cython/Includes/posix/ioctl.pxd +4 -0
  206. Cython/Includes/posix/mman.pxd +101 -0
  207. Cython/Includes/posix/resource.pxd +57 -0
  208. Cython/Includes/posix/select.pxd +21 -0
  209. Cython/Includes/posix/signal.pxd +73 -0
  210. Cython/Includes/posix/stat.pxd +98 -0
  211. Cython/Includes/posix/stdio.pxd +37 -0
  212. Cython/Includes/posix/stdlib.pxd +29 -0
  213. Cython/Includes/posix/strings.pxd +9 -0
  214. Cython/Includes/posix/time.pxd +71 -0
  215. Cython/Includes/posix/types.pxd +30 -0
  216. Cython/Includes/posix/uio.pxd +26 -0
  217. Cython/Includes/posix/unistd.pxd +271 -0
  218. Cython/Includes/posix/wait.pxd +38 -0
  219. Cython/Plex/Actions.pxd +24 -0
  220. Cython/Plex/Actions.py +119 -0
  221. Cython/Plex/DFA.pxd +14 -0
  222. Cython/Plex/DFA.py +164 -0
  223. Cython/Plex/Errors.py +48 -0
  224. Cython/Plex/Lexicons.py +178 -0
  225. Cython/Plex/Machines.pxd +36 -0
  226. Cython/Plex/Machines.py +238 -0
  227. Cython/Plex/Regexps.py +539 -0
  228. Cython/Plex/Scanners.pxd +47 -0
  229. Cython/Plex/Scanners.py +360 -0
  230. Cython/Plex/Transitions.pxd +14 -0
  231. Cython/Plex/Transitions.py +239 -0
  232. Cython/Plex/__init__.py +34 -0
  233. Cython/Runtime/__init__.py +1 -0
  234. Cython/Runtime/refnanny.pyx +261 -0
  235. Cython/Shadow.py +656 -0
  236. Cython/Shadow.pyi +521 -0
  237. Cython/StringIOTree.py +170 -0
  238. Cython/Tempita/__init__.py +4 -0
  239. Cython/Tempita/_looper.py +154 -0
  240. Cython/Tempita/_tempita.py +1091 -0
  241. Cython/TestUtils.py +417 -0
  242. Cython/Tests/TestCodeWriter.py +128 -0
  243. Cython/Tests/TestCythonUtils.py +202 -0
  244. Cython/Tests/TestJediTyper.py +223 -0
  245. Cython/Tests/TestShadow.py +114 -0
  246. Cython/Tests/TestStringIOTree.py +67 -0
  247. Cython/Tests/TestTestUtils.py +90 -0
  248. Cython/Tests/__init__.py +1 -0
  249. Cython/Tests/xmlrunner.py +390 -0
  250. Cython/Utility/AsyncGen.c +1263 -0
  251. Cython/Utility/Buffer.c +875 -0
  252. Cython/Utility/Builtins.c +660 -0
  253. Cython/Utility/CConvert.pyx +134 -0
  254. Cython/Utility/CMath.c +95 -0
  255. Cython/Utility/CommonStructures.c +139 -0
  256. Cython/Utility/Complex.c +378 -0
  257. Cython/Utility/Coroutine.c +2413 -0
  258. Cython/Utility/CpdefEnums.pyx +108 -0
  259. Cython/Utility/CppConvert.pyx +279 -0
  260. Cython/Utility/CppSupport.cpp +133 -0
  261. Cython/Utility/CythonFunction.c +1851 -0
  262. Cython/Utility/Dataclasses.c +185 -0
  263. Cython/Utility/Dataclasses.py +112 -0
  264. Cython/Utility/Embed.c +125 -0
  265. Cython/Utility/Exceptions.c +1017 -0
  266. Cython/Utility/ExtensionTypes.c +797 -0
  267. Cython/Utility/FunctionArguments.c +573 -0
  268. Cython/Utility/ImportExport.c +912 -0
  269. Cython/Utility/MemoryView.pyx +1478 -0
  270. Cython/Utility/MemoryView_C.c +992 -0
  271. Cython/Utility/ModuleSetupCode.c +2501 -0
  272. Cython/Utility/NumpyImportArray.c +46 -0
  273. Cython/Utility/ObjectHandling.c +3054 -0
  274. Cython/Utility/Optimize.c +1533 -0
  275. Cython/Utility/Overflow.c +404 -0
  276. Cython/Utility/Printing.c +86 -0
  277. Cython/Utility/Profile.c +660 -0
  278. Cython/Utility/StringTools.c +1206 -0
  279. Cython/Utility/TestCyUtilityLoader.pyx +8 -0
  280. Cython/Utility/TestCythonScope.pyx +75 -0
  281. Cython/Utility/TestUtilityLoader.c +12 -0
  282. Cython/Utility/TypeConversion.c +1329 -0
  283. Cython/Utility/UFuncs.pyx +50 -0
  284. Cython/Utility/UFuncs_C.c +89 -0
  285. Cython/Utility/__init__.py +28 -0
  286. Cython/Utility/arrayarray.h +143 -0
  287. Cython/Utils.py +687 -0
  288. Cython/__init__.py +10 -0
  289. Cython/__init__.pyi +7 -0
  290. Cython/py.typed +0 -0
  291. Cython-3.1.0a1.dist-info/COPYING.txt +19 -0
  292. Cython-3.1.0a1.dist-info/LICENSE.txt +176 -0
  293. Cython-3.1.0a1.dist-info/METADATA +67 -0
  294. Cython-3.1.0a1.dist-info/RECORD +301 -0
  295. Cython-3.1.0a1.dist-info/WHEEL +5 -0
  296. Cython-3.1.0a1.dist-info/entry_points.txt +4 -0
  297. Cython-3.1.0a1.dist-info/top_level.txt +3 -0
  298. cython.py +29 -0
  299. pyximport/__init__.py +4 -0
  300. pyximport/pyxbuild.py +160 -0
  301. pyximport/pyximport.py +482 -0
@@ -0,0 +1,1206 @@
1
+
2
+ //////////////////// IncludeStringH.proto ////////////////////
3
+
4
+ #include <string.h>
5
+
6
+ //////////////////// IncludeCppStringH.proto ////////////////////
7
+
8
+ #include <string>
9
+
10
+
11
+ //////////////////// ssize_pyunicode_strlen.proto ////////////////////
12
+
13
+ static CYTHON_INLINE Py_ssize_t __Pyx_Py_UNICODE_ssize_strlen(const Py_UNICODE *u);/*proto*/
14
+
15
+ //////////////////// ssize_pyunicode_strlen ////////////////////
16
+ //@requires: pyunicode_strlen
17
+
18
+ static CYTHON_INLINE Py_ssize_t __Pyx_Py_UNICODE_ssize_strlen(const Py_UNICODE *u) {
19
+ size_t len = __Pyx_Py_UNICODE_strlen(u);
20
+ if (unlikely(len > PY_SSIZE_T_MAX)) {
21
+ PyErr_SetString(PyExc_OverflowError, "Py_UNICODE string is too long");
22
+ return -1;
23
+ }
24
+ return (Py_ssize_t) len;
25
+ }
26
+
27
+ //////////////////// pyunicode_strlen.proto ///////////////
28
+
29
+ // There used to be a Py_UNICODE_strlen() in CPython 3.x, but it is deprecated since Py3.3.
30
+ static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u); /* proto */
31
+
32
+ //////////////////// pyunicode_strlen /////////////////////
33
+
34
+ // Note: will not work in the limited API since Py_UNICODE is not available there.
35
+ // May stop working at some point after Python 3.13 (deprecated)
36
+ static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u)
37
+ {
38
+ const Py_UNICODE *u_end = u;
39
+ while (*u_end++) ;
40
+ return (size_t)(u_end - u - 1);
41
+ }
42
+
43
+ //////////////////// pyunicode_from_unicode.proto //////////////////////
44
+ //@requires: pyunicode_strlen
45
+
46
+ #define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
47
+ #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
48
+
49
+
50
+ //////////////////// InitStrings.proto ////////////////////
51
+ //@proto_block: pystring_table
52
+
53
+ static int __Pyx_InitStrings(__Pyx_StringTabEntry const *t, PyObject **target, const char* const* encoding_names); /*proto*/
54
+
55
+ //////////////////// InitStrings ////////////////////
56
+
57
+ static int __Pyx_InitStrings(__Pyx_StringTabEntry const *t, PyObject **target, const char* const* encoding_names) {
58
+ while (t->s) {
59
+ PyObject *str;
60
+ if (t->is_unicode) {
61
+ if (t->intern) {
62
+ str = PyUnicode_InternFromString(t->s);
63
+ } else if (t->encoding) {
64
+ str = PyUnicode_Decode(t->s, t->n - 1, encoding_names[t->encoding], NULL);
65
+ } else {
66
+ str = PyUnicode_FromStringAndSize(t->s, t->n - 1);
67
+ }
68
+ } else {
69
+ str = PyBytes_FromStringAndSize(t->s, t->n - 1);
70
+ }
71
+ if (!str)
72
+ return -1;
73
+ *target = str;
74
+ // initialise cached hash value
75
+ if (PyObject_Hash(str) == -1)
76
+ return -1;
77
+ ++t;
78
+ ++target;
79
+ }
80
+ return 0;
81
+ }
82
+
83
+ //////////////////// BytesContains.proto ////////////////////
84
+
85
+ static CYTHON_INLINE int __Pyx_BytesContains(PyObject* bytes, char character); /*proto*/
86
+
87
+ //////////////////// BytesContains ////////////////////
88
+ //@requires: IncludeStringH
89
+
90
+ static CYTHON_INLINE int __Pyx_BytesContains(PyObject* bytes, char character) {
91
+ const Py_ssize_t length = __Pyx_PyBytes_GET_SIZE(bytes);
92
+ #if !CYTHON_ASSUME_SAFE_SIZE
93
+ if (unlikely(length == -1)) return -1;
94
+ #endif
95
+ const char* char_start = __Pyx_PyBytes_AsString(bytes);
96
+ #if !CYTHON_ASSUME_SAFE_MACROS
97
+ if (unlikely(!char_start)) return -1;
98
+ #endif
99
+ return memchr(char_start, (unsigned char)character, (size_t)length) != NULL;
100
+ }
101
+
102
+
103
+ //////////////////// PyUCS4InUnicode.proto ////////////////////
104
+
105
+ static CYTHON_INLINE int __Pyx_UnicodeContainsUCS4(PyObject* unicode, Py_UCS4 character); /*proto*/
106
+
107
+ //////////////////// PyUCS4InUnicode ////////////////////
108
+
109
+ static CYTHON_INLINE int __Pyx_UnicodeContainsUCS4(PyObject* unicode, Py_UCS4 character) {
110
+ // Note that from Python 3.7, the indices of FindChar are adjusted to match the bounds
111
+ // so need to check the length
112
+ Py_ssize_t idx = PyUnicode_FindChar(unicode, character, 0, PY_SSIZE_T_MAX, 1);
113
+ if (unlikely(idx == -2)) return -1;
114
+ // >= 0: found the index, == -1: not found
115
+ return idx >= 0;
116
+ }
117
+
118
+
119
+ //////////////////// PyUnicodeContains.proto ////////////////////
120
+
121
+ static CYTHON_INLINE int __Pyx_PyUnicode_ContainsTF(PyObject* substring, PyObject* text, int eq) {
122
+ int result = PyUnicode_Contains(text, substring);
123
+ return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
124
+ }
125
+
126
+
127
+ //////////////////// CStringEquals.proto ////////////////////
128
+
129
+ static CYTHON_INLINE int __Pyx_StrEq(const char *, const char *); /*proto*/
130
+
131
+ //////////////////// CStringEquals ////////////////////
132
+
133
+ static CYTHON_INLINE int __Pyx_StrEq(const char *s1, const char *s2) {
134
+ while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
135
+ return *s1 == *s2;
136
+ }
137
+
138
+
139
+ //////////////////// UnicodeEquals.proto ////////////////////
140
+
141
+ static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals); /*proto*/
142
+
143
+ //////////////////// UnicodeEquals ////////////////////
144
+ //@requires: BytesEquals
145
+
146
+ static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
147
+ #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_GRAAL
148
+ return PyObject_RichCompareBool(s1, s2, equals);
149
+ #else
150
+ int s1_is_unicode, s2_is_unicode;
151
+ if (s1 == s2) {
152
+ /* as done by PyObject_RichCompareBool(); also catches the (interned) empty string */
153
+ goto return_eq;
154
+ }
155
+ s1_is_unicode = PyUnicode_CheckExact(s1);
156
+ s2_is_unicode = PyUnicode_CheckExact(s2);
157
+ if (s1_is_unicode & s2_is_unicode) {
158
+ Py_ssize_t length, length2;
159
+ int kind;
160
+ void *data1, *data2;
161
+ #if !CYTHON_COMPILING_IN_LIMITED_API
162
+ if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0))
163
+ return -1;
164
+ #endif
165
+ length = __Pyx_PyUnicode_GET_LENGTH(s1);
166
+ #if !CYTHON_ASSUME_SAFE_SIZE
167
+ if (unlikely(length < 0)) return -1;
168
+ #endif
169
+ length2 = __Pyx_PyUnicode_GET_LENGTH(s2);
170
+ #if !CYTHON_ASSUME_SAFE_SIZE
171
+ if (unlikely(length2 < 0)) return -1;
172
+ #endif
173
+ if (length != length2) {
174
+ goto return_ne;
175
+ }
176
+ #if CYTHON_USE_UNICODE_INTERNALS
177
+ {
178
+ Py_hash_t hash1, hash2;
179
+ hash1 = ((PyASCIIObject*)s1)->hash;
180
+ hash2 = ((PyASCIIObject*)s2)->hash;
181
+ if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
182
+ goto return_ne;
183
+ }
184
+ }
185
+ #endif
186
+ // len(s1) == len(s2) >= 1 (empty string is interned, and "s1 is not s2")
187
+ kind = __Pyx_PyUnicode_KIND(s1);
188
+ if (kind != __Pyx_PyUnicode_KIND(s2)) {
189
+ goto return_ne;
190
+ }
191
+ data1 = __Pyx_PyUnicode_DATA(s1);
192
+ data2 = __Pyx_PyUnicode_DATA(s2);
193
+ if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) {
194
+ goto return_ne;
195
+ } else if (length == 1) {
196
+ goto return_eq;
197
+ } else {
198
+ int result = memcmp(data1, data2, (size_t)(length * kind));
199
+ return (equals == Py_EQ) ? (result == 0) : (result != 0);
200
+ }
201
+ } else if ((s1 == Py_None) & s2_is_unicode) {
202
+ goto return_ne;
203
+ } else if ((s2 == Py_None) & s1_is_unicode) {
204
+ goto return_ne;
205
+ } else {
206
+ int result;
207
+ PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
208
+ if (!py_result)
209
+ return -1;
210
+ result = __Pyx_PyObject_IsTrue(py_result);
211
+ Py_DECREF(py_result);
212
+ return result;
213
+ }
214
+ return_eq:
215
+ return (equals == Py_EQ);
216
+ return_ne:
217
+ return (equals == Py_NE);
218
+ #endif
219
+ }
220
+
221
+
222
+ //////////////////// BytesEquals.proto ////////////////////
223
+
224
+ static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals); /*proto*/
225
+
226
+ //////////////////// BytesEquals ////////////////////
227
+ //@requires: IncludeStringH
228
+
229
+ static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
230
+ #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_GRAAL || \
231
+ !(CYTHON_ASSUME_SAFE_SIZE && CYTHON_ASSUME_SAFE_MACROS)
232
+ return PyObject_RichCompareBool(s1, s2, equals);
233
+ #else
234
+ if (s1 == s2) {
235
+ /* as done by PyObject_RichCompareBool(); also catches the (interned) empty string */
236
+ return (equals == Py_EQ);
237
+ } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
238
+ const char *ps1, *ps2;
239
+ Py_ssize_t length = PyBytes_GET_SIZE(s1);
240
+ if (length != PyBytes_GET_SIZE(s2))
241
+ return (equals == Py_NE);
242
+ // len(s1) == len(s2) >= 1 (empty string is interned, and "s1 is not s2")
243
+ ps1 = PyBytes_AS_STRING(s1);
244
+ ps2 = PyBytes_AS_STRING(s2);
245
+ if (ps1[0] != ps2[0]) {
246
+ return (equals == Py_NE);
247
+ } else if (length == 1) {
248
+ return (equals == Py_EQ);
249
+ } else {
250
+ int result;
251
+ #if CYTHON_USE_UNICODE_INTERNALS && (PY_VERSION_HEX < 0x030B0000)
252
+ Py_hash_t hash1, hash2;
253
+ hash1 = ((PyBytesObject*)s1)->ob_shash;
254
+ hash2 = ((PyBytesObject*)s2)->ob_shash;
255
+ if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
256
+ return (equals == Py_NE);
257
+ }
258
+ #endif
259
+ result = memcmp(ps1, ps2, (size_t)length);
260
+ return (equals == Py_EQ) ? (result == 0) : (result != 0);
261
+ }
262
+ } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
263
+ return (equals == Py_NE);
264
+ } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
265
+ return (equals == Py_NE);
266
+ } else {
267
+ int result;
268
+ PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
269
+ if (!py_result)
270
+ return -1;
271
+ result = __Pyx_PyObject_IsTrue(py_result);
272
+ Py_DECREF(py_result);
273
+ return result;
274
+ }
275
+ #endif
276
+ }
277
+
278
+ //////////////////// GetItemIntByteArray.proto ////////////////////
279
+
280
+ #define __Pyx_GetItemInt_ByteArray(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \
281
+ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \
282
+ __Pyx_GetItemInt_ByteArray_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) : \
283
+ (PyErr_SetString(PyExc_IndexError, "bytearray index out of range"), -1))
284
+
285
+ static CYTHON_INLINE int __Pyx_GetItemInt_ByteArray_Fast(PyObject* string, Py_ssize_t i,
286
+ int wraparound, int boundscheck);
287
+
288
+ //////////////////// GetItemIntByteArray ////////////////////
289
+
290
+ static CYTHON_INLINE int __Pyx_GetItemInt_ByteArray_Fast(PyObject* string, Py_ssize_t i,
291
+ int wraparound, int boundscheck) {
292
+ Py_ssize_t length;
293
+ if (wraparound | boundscheck) {
294
+ length = __Pyx_PyByteArray_GET_SIZE(string);
295
+ #if !CYTHON_ASSUME_SAFE_SIZE
296
+ if (unlikely(length < 0)) return -1;
297
+ #endif
298
+ if (wraparound & unlikely(i < 0)) i += length;
299
+ if ((!boundscheck) || likely(__Pyx_is_valid_index(i, length))) {
300
+ #if !CYTHON_ASSUME_SAFE_MACROS
301
+ char *asString = PyByteArray_AsString(string);
302
+ return likely(asString) ? (unsigned char) asString[i] : -1;
303
+ #else
304
+ return (unsigned char) (PyByteArray_AS_STRING(string)[i]);
305
+ #endif
306
+ } else {
307
+ PyErr_SetString(PyExc_IndexError, "bytearray index out of range");
308
+ return -1;
309
+ }
310
+ } else {
311
+ #if !CYTHON_ASSUME_SAFE_MACROS
312
+ char *asString = PyByteArray_AsString(string);
313
+ return likely(asString) ? (unsigned char) asString[i] : -1;
314
+ #else
315
+ return (unsigned char) (PyByteArray_AS_STRING(string)[i]);
316
+ #endif
317
+ }
318
+ }
319
+
320
+
321
+ //////////////////// SetItemIntByteArray.proto ////////////////////
322
+
323
+ #define __Pyx_SetItemInt_ByteArray(o, i, v, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \
324
+ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \
325
+ __Pyx_SetItemInt_ByteArray_Fast(o, (Py_ssize_t)i, v, wraparound, boundscheck) : \
326
+ (PyErr_SetString(PyExc_IndexError, "bytearray index out of range"), -1))
327
+
328
+ static CYTHON_INLINE int __Pyx_SetItemInt_ByteArray_Fast(PyObject* string, Py_ssize_t i, unsigned char v,
329
+ int wraparound, int boundscheck);
330
+
331
+ //////////////////// SetItemIntByteArray ////////////////////
332
+
333
+ static CYTHON_INLINE int __Pyx_SetItemInt_ByteArray_Fast(PyObject* string, Py_ssize_t i, unsigned char v,
334
+ int wraparound, int boundscheck) {
335
+ Py_ssize_t length;
336
+ if (wraparound | boundscheck) {
337
+ length = __Pyx_PyByteArray_GET_SIZE(string);
338
+ #if !CYTHON_ASSUME_SAFE_SIZE
339
+ if (unlikely(length < 0)) return -1;
340
+ #endif
341
+ if (wraparound & unlikely(i < 0)) i += length;
342
+ if ((!boundscheck) || likely(__Pyx_is_valid_index(i, length))) {
343
+ #if !CYTHON_ASSUME_SAFE_MACROS
344
+ char *asString = PyByteArray_AsString(string);
345
+ if (unlikely(!asString)) return -1;
346
+ asString[i] = (char)v;
347
+ #else
348
+ PyByteArray_AS_STRING(string)[i] = (char) v;
349
+ #endif
350
+ return 0;
351
+ } else {
352
+ PyErr_SetString(PyExc_IndexError, "bytearray index out of range");
353
+ return -1;
354
+ }
355
+ } else {
356
+ #if !CYTHON_ASSUME_SAFE_MACROS
357
+ char *asString = PyByteArray_AsString(string);
358
+ if (unlikely(!asString)) return -1;
359
+ asString[i] = (char)v;
360
+ #else
361
+ PyByteArray_AS_STRING(string)[i] = (char) v;
362
+ #endif
363
+ return 0;
364
+ }
365
+ }
366
+
367
+
368
+ //////////////////// GetItemIntUnicode.proto ////////////////////
369
+
370
+ #define __Pyx_GetItemInt_Unicode(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \
371
+ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \
372
+ __Pyx_GetItemInt_Unicode_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) : \
373
+ (PyErr_SetString(PyExc_IndexError, "string index out of range"), (Py_UCS4)-1))
374
+
375
+ static CYTHON_INLINE Py_UCS4 __Pyx_GetItemInt_Unicode_Fast(PyObject* ustring, Py_ssize_t i,
376
+ int wraparound, int boundscheck);
377
+
378
+ //////////////////// GetItemIntUnicode ////////////////////
379
+
380
+ static CYTHON_INLINE Py_UCS4 __Pyx_GetItemInt_Unicode_Fast(PyObject* ustring, Py_ssize_t i,
381
+ int wraparound, int boundscheck) {
382
+ Py_ssize_t length;
383
+ if (unlikely(__Pyx_PyUnicode_READY(ustring) < 0)) return (Py_UCS4)-1;
384
+ if (wraparound | boundscheck) {
385
+ length = __Pyx_PyUnicode_GET_LENGTH(ustring);
386
+ #if !CYTHON_ASSUME_SAFE_SIZE
387
+ if (unlikely(length < 0)) return (Py_UCS4)-1;
388
+ #endif
389
+ if (wraparound & unlikely(i < 0)) i += length;
390
+ if ((!boundscheck) || likely(__Pyx_is_valid_index(i, length))) {
391
+ return __Pyx_PyUnicode_READ_CHAR(ustring, i);
392
+ } else {
393
+ PyErr_SetString(PyExc_IndexError, "string index out of range");
394
+ return (Py_UCS4)-1;
395
+ }
396
+ } else {
397
+ return __Pyx_PyUnicode_READ_CHAR(ustring, i);
398
+ }
399
+ }
400
+
401
+
402
+ /////////////// decode_c_string_utf16.proto ///////////////
403
+
404
+ static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16(const char *s, Py_ssize_t size, const char *errors) {
405
+ int byteorder = 0;
406
+ return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
407
+ }
408
+ static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16LE(const char *s, Py_ssize_t size, const char *errors) {
409
+ int byteorder = -1;
410
+ return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
411
+ }
412
+ static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16BE(const char *s, Py_ssize_t size, const char *errors) {
413
+ int byteorder = 1;
414
+ return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
415
+ }
416
+
417
+ /////////////// decode_cpp_string.proto ///////////////
418
+ //@requires: IncludeCppStringH
419
+ //@requires: decode_c_bytes
420
+
421
+ static CYTHON_INLINE PyObject* __Pyx_decode_cpp_string(
422
+ std::string cppstring, Py_ssize_t start, Py_ssize_t stop,
423
+ const char* encoding, const char* errors,
424
+ PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) {
425
+ return __Pyx_decode_c_bytes(
426
+ cppstring.data(), cppstring.size(), start, stop, encoding, errors, decode_func);
427
+ }
428
+
429
+ /////////////// decode_c_string.proto ///////////////
430
+
431
+ static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
432
+ const char* cstring, Py_ssize_t start, Py_ssize_t stop,
433
+ const char* encoding, const char* errors,
434
+ PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors));
435
+
436
+ /////////////// decode_c_string ///////////////
437
+ //@requires: IncludeStringH
438
+ //@requires: decode_c_string_utf16
439
+
440
+ /* duplicate code to avoid calling strlen() if start >= 0 and stop >= 0 */
441
+ static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
442
+ const char* cstring, Py_ssize_t start, Py_ssize_t stop,
443
+ const char* encoding, const char* errors,
444
+ PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) {
445
+ Py_ssize_t length;
446
+ if (unlikely((start < 0) | (stop < 0))) {
447
+ size_t slen = strlen(cstring);
448
+ if (unlikely(slen > (size_t) PY_SSIZE_T_MAX)) {
449
+ PyErr_SetString(PyExc_OverflowError,
450
+ "c-string too long to convert to Python");
451
+ return NULL;
452
+ }
453
+ length = (Py_ssize_t) slen;
454
+ if (start < 0) {
455
+ start += length;
456
+ if (start < 0)
457
+ start = 0;
458
+ }
459
+ if (stop < 0)
460
+ stop += length;
461
+ }
462
+ if (unlikely(stop <= start))
463
+ return __Pyx_NewRef(EMPTY(unicode));
464
+ length = stop - start;
465
+ cstring += start;
466
+ if (decode_func) {
467
+ return decode_func(cstring, length, errors);
468
+ } else {
469
+ return PyUnicode_Decode(cstring, length, encoding, errors);
470
+ }
471
+ }
472
+
473
+ /////////////// decode_c_bytes.proto ///////////////
474
+
475
+ static CYTHON_INLINE PyObject* __Pyx_decode_c_bytes(
476
+ const char* cstring, Py_ssize_t length, Py_ssize_t start, Py_ssize_t stop,
477
+ const char* encoding, const char* errors,
478
+ PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors));
479
+
480
+ /////////////// decode_c_bytes ///////////////
481
+ //@requires: decode_c_string_utf16
482
+
483
+ static CYTHON_INLINE PyObject* __Pyx_decode_c_bytes(
484
+ const char* cstring, Py_ssize_t length, Py_ssize_t start, Py_ssize_t stop,
485
+ const char* encoding, const char* errors,
486
+ PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) {
487
+ if (unlikely((start < 0) | (stop < 0))) {
488
+ if (start < 0) {
489
+ start += length;
490
+ if (start < 0)
491
+ start = 0;
492
+ }
493
+ if (stop < 0)
494
+ stop += length;
495
+ }
496
+ if (stop > length)
497
+ stop = length;
498
+ if (unlikely(stop <= start))
499
+ return __Pyx_NewRef(EMPTY(unicode));
500
+ length = stop - start;
501
+ cstring += start;
502
+ if (decode_func) {
503
+ return decode_func(cstring, length, errors);
504
+ } else {
505
+ return PyUnicode_Decode(cstring, length, encoding, errors);
506
+ }
507
+ }
508
+
509
+ /////////////// decode_bytes.proto ///////////////
510
+ //@requires: decode_c_bytes
511
+
512
+ static CYTHON_INLINE PyObject* __Pyx_decode_bytes(
513
+ PyObject* string, Py_ssize_t start, Py_ssize_t stop,
514
+ const char* encoding, const char* errors,
515
+ PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) {
516
+ char* as_c_string;
517
+ Py_ssize_t size;
518
+ #if CYTHON_ASSUME_SAFE_MACROS && CYTHON_ASSUME_SAFE_SIZE
519
+ as_c_string = PyBytes_AS_STRING(string);
520
+ size = PyBytes_GET_SIZE(string);
521
+ #else
522
+ if (PyBytes_AsStringAndSize(string, &as_c_string, &size) < 0) {
523
+ return NULL;
524
+ }
525
+ #endif
526
+ return __Pyx_decode_c_bytes(
527
+ as_c_string, size,
528
+ start, stop, encoding, errors, decode_func);
529
+ }
530
+
531
+ /////////////// decode_bytearray.proto ///////////////
532
+ //@requires: decode_c_bytes
533
+
534
+ static CYTHON_INLINE PyObject* __Pyx_decode_bytearray(
535
+ PyObject* string, Py_ssize_t start, Py_ssize_t stop,
536
+ const char* encoding, const char* errors,
537
+ PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) {
538
+ char* as_c_string;
539
+ Py_ssize_t size;
540
+ #if CYTHON_ASSUME_SAFE_MACROS && CYTHON_ASSUME_SAFE_SIZE
541
+ as_c_string = PyByteArray_AS_STRING(string);
542
+ size = PyByteArray_GET_SIZE(string);
543
+ #else
544
+ if (!(as_c_string = PyByteArray_AsString(string))) return NULL;
545
+ if ((size = PyByteArray_Size(string)) < 0) return NULL;
546
+ #endif
547
+ return __Pyx_decode_c_bytes(
548
+ as_c_string, size,
549
+ start, stop, encoding, errors, decode_func);
550
+ }
551
+
552
+ /////////////// PyUnicode_Substring.proto ///////////////
553
+
554
+ static CYTHON_INLINE PyObject* __Pyx_PyUnicode_Substring(
555
+ PyObject* text, Py_ssize_t start, Py_ssize_t stop);
556
+
557
+ /////////////// PyUnicode_Substring ///////////////
558
+
559
+ static CYTHON_INLINE PyObject* __Pyx_PyUnicode_Substring(
560
+ PyObject* text, Py_ssize_t start, Py_ssize_t stop) {
561
+ Py_ssize_t length;
562
+ #if !CYTHON_COMPILING_IN_LIMITED_API
563
+ if (unlikely(__Pyx_PyUnicode_READY(text) == -1)) return NULL;
564
+ #endif
565
+ length = __Pyx_PyUnicode_GET_LENGTH(text);
566
+ #if !CYTHON_ASSUME_SAFE_SIZE
567
+ if (unlikely(length < 0)) return NULL;
568
+ #endif
569
+ if (start < 0) {
570
+ start += length;
571
+ if (start < 0)
572
+ start = 0;
573
+ }
574
+ if (stop < 0)
575
+ stop += length;
576
+ else if (stop > length)
577
+ stop = length;
578
+ if (stop <= start)
579
+ return __Pyx_NewRef(EMPTY(unicode));
580
+ if (start == 0 && stop == length)
581
+ return __Pyx_NewRef(text);
582
+ #if CYTHON_COMPILING_IN_LIMITED_API
583
+ // PyUnicode_Substring() does not support negative indexing but is otherwise fine to use.
584
+ return PyUnicode_Substring(text, start, stop);
585
+ #else
586
+ return PyUnicode_FromKindAndData(PyUnicode_KIND(text),
587
+ PyUnicode_1BYTE_DATA(text) + start*PyUnicode_KIND(text), stop-start);
588
+ #endif
589
+ }
590
+
591
+
592
+ /////////////// py_unicode_istitle.proto ///////////////
593
+
594
+ // Py_UNICODE_ISTITLE() doesn't match unicode.istitle() as the latter
595
+ // additionally allows character that comply with Py_UNICODE_ISUPPER()
596
+
597
+ static CYTHON_INLINE int __Pyx_Py_UNICODE_ISTITLE(Py_UCS4 uchar) {
598
+ return Py_UNICODE_ISTITLE(uchar) || Py_UNICODE_ISUPPER(uchar);
599
+ }
600
+
601
+
602
+ /////////////// py_unicode_isprintable.proto ///////////////
603
+
604
+ #if CYTHON_COMPILING_IN_PYPY && !defined(Py_UNICODE_ISPRINTABLE)
605
+ static int __Pyx_Py_UNICODE_ISPRINTABLE(Py_UCS4 uchar);/*proto*/
606
+ #else
607
+ #define __Pyx_Py_UNICODE_ISPRINTABLE(u) Py_UNICODE_ISPRINTABLE(u)
608
+ #endif
609
+
610
+ /////////////// py_unicode_isprintable ///////////////
611
+
612
+ #if CYTHON_COMPILING_IN_PYPY && !defined(Py_UNICODE_ISPRINTABLE)
613
+ static int __Pyx_Py_UNICODE_ISPRINTABLE(Py_UCS4 uchar) {
614
+ int result;
615
+ PyObject* py_result;
616
+ PyObject* ustring = PyUnicode_FromOrdinal(uchar);
617
+ if (!ustring) goto bad;
618
+ py_result = PyObject_CallMethod(ustring, "isprintable", NULL);
619
+ Py_DECREF(ustring);
620
+ if (!py_result) goto bad;
621
+ result = PyObject_IsTrue(py_result);
622
+ Py_DECREF(py_result);
623
+ if (result == -1) goto bad;
624
+ return result != 0;
625
+
626
+ bad:
627
+ PyErr_Clear();
628
+ return 0; /* cannot fail */
629
+ }
630
+ #endif
631
+
632
+
633
+ /////////////// unicode_tailmatch.proto ///////////////
634
+
635
+ static int __Pyx_PyUnicode_Tailmatch(
636
+ PyObject* s, PyObject* substr, Py_ssize_t start, Py_ssize_t end, int direction); /*proto*/
637
+
638
+ /////////////// unicode_tailmatch ///////////////
639
+
640
+ // Python's unicode.startswith() and unicode.endswith() support a
641
+ // tuple of prefixes/suffixes, whereas it's much more common to
642
+ // test for a single unicode string.
643
+
644
+ static int __Pyx_PyUnicode_TailmatchTuple(PyObject* s, PyObject* substrings,
645
+ Py_ssize_t start, Py_ssize_t end, int direction) {
646
+ Py_ssize_t i, count = __Pyx_PyTuple_GET_SIZE(substrings);
647
+ #if !CYTHON_ASSUME_SAFE_SIZE
648
+ if (unlikely(count < 0)) return -1;
649
+ #endif
650
+ for (i = 0; i < count; i++) {
651
+ Py_ssize_t result;
652
+ #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
653
+ result = PyUnicode_Tailmatch(s, PyTuple_GET_ITEM(substrings, i),
654
+ start, end, direction);
655
+ #else
656
+ PyObject* sub = __Pyx_PySequence_ITEM(substrings, i);
657
+ if (unlikely(!sub)) return -1;
658
+ result = PyUnicode_Tailmatch(s, sub, start, end, direction);
659
+ Py_DECREF(sub);
660
+ #endif
661
+ if (result) {
662
+ return (int) result;
663
+ }
664
+ }
665
+ return 0;
666
+ }
667
+
668
+ static int __Pyx_PyUnicode_Tailmatch(PyObject* s, PyObject* substr,
669
+ Py_ssize_t start, Py_ssize_t end, int direction) {
670
+ if (unlikely(PyTuple_Check(substr))) {
671
+ return __Pyx_PyUnicode_TailmatchTuple(s, substr, start, end, direction);
672
+ }
673
+ return (int) PyUnicode_Tailmatch(s, substr, start, end, direction);
674
+ }
675
+
676
+
677
+ /////////////// bytes_tailmatch.proto ///////////////
678
+
679
+ static int __Pyx_PyBytes_SingleTailmatch(PyObject* self, PyObject* arg,
680
+ Py_ssize_t start, Py_ssize_t end, int direction); /*proto*/
681
+ static int __Pyx_PyBytes_Tailmatch(PyObject* self, PyObject* substr,
682
+ Py_ssize_t start, Py_ssize_t end, int direction); /*proto*/
683
+
684
+ /////////////// bytes_tailmatch ///////////////
685
+
686
+ static int __Pyx_PyBytes_SingleTailmatch(PyObject* self, PyObject* arg,
687
+ Py_ssize_t start, Py_ssize_t end, int direction) {
688
+ char* self_ptr;
689
+ Py_ssize_t self_len;
690
+ char* sub_ptr;
691
+ Py_ssize_t sub_len;
692
+ int retval;
693
+
694
+ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030B0000
695
+ PyObject *converted_arg = NULL;
696
+ #else
697
+ Py_buffer view;
698
+ view.obj = NULL;
699
+ #endif
700
+
701
+ #if !(CYTHON_ASSUME_SAFE_MACROS && CYTHON_ASSUME_SAFE_SIZE)
702
+ if (PyBytes_AsStringAndSize(self, &self_ptr, &self_len) == -1) return -1;
703
+ #else
704
+ self_ptr = PyBytes_AS_STRING(self);
705
+ self_len = PyBytes_GET_SIZE(self);
706
+ #endif
707
+
708
+ if (PyBytes_Check(arg)) {
709
+ #if !(CYTHON_ASSUME_SAFE_MACROS && CYTHON_ASSUME_SAFE_SIZE)
710
+ if (PyBytes_AsStringAndSize(arg, &sub_ptr, &sub_len) == -1) return -1;
711
+ #else
712
+ sub_ptr = PyBytes_AS_STRING(arg);
713
+ sub_len = PyBytes_GET_SIZE(arg);
714
+ #endif
715
+ }
716
+ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030B0000
717
+ else if (PyByteArray_Check(arg)) {
718
+ // The Limited API fallback is inefficient,
719
+ // so special-case bytearray to be a bit faster. Keep this to the Limited
720
+ // API only since the buffer protocol code is good enough otherwise.
721
+ sub_ptr = PyByteArray_AsString(arg);
722
+ if (unlikely(!sub_ptr)) return -1;
723
+ sub_len = PyByteArray_Size(arg);
724
+ if (unlikely(sub_len < 0)) return -1;
725
+ } else {
726
+ // Where buffer protocol is unavailable, just convert to bytes
727
+ // (which is probably inefficient, but does work)
728
+ // First check that the object is a buffer (since PyBytes_FromObject)
729
+ // is more flexible than what endswith accepts.
730
+ PyObject *as_memoryview = PyMemoryView_FromObject(arg);
731
+ if (!as_memoryview) return -1;
732
+ Py_DECREF(as_memoryview);
733
+ converted_arg = PyBytes_FromObject(arg);
734
+ if (!converted_arg) return -1;
735
+ if (PyBytes_AsStringAndSize(converted_arg, &sub_ptr, &sub_len) == -1) {
736
+ Py_DECREF(converted_arg);
737
+ return -1;
738
+ }
739
+
740
+ }
741
+ #else // LIMITED_API >= 030B0000 or !LIMITED_API
742
+ else {
743
+ if (unlikely(PyObject_GetBuffer(arg, &view, PyBUF_SIMPLE) == -1))
744
+ return -1;
745
+ sub_ptr = (char*) view.buf;
746
+ sub_len = view.len;
747
+ }
748
+ #endif
749
+
750
+ if (end > self_len)
751
+ end = self_len;
752
+ else if (end < 0)
753
+ end += self_len;
754
+ if (end < 0)
755
+ end = 0;
756
+ if (start < 0)
757
+ start += self_len;
758
+ if (start < 0)
759
+ start = 0;
760
+
761
+ if (direction > 0) {
762
+ /* endswith */
763
+ if (end-sub_len > start)
764
+ start = end - sub_len;
765
+ }
766
+
767
+ if (start + sub_len <= end)
768
+ retval = !memcmp(self_ptr+start, sub_ptr, (size_t)sub_len);
769
+ else
770
+ retval = 0;
771
+
772
+ #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030B0000
773
+ Py_XDECREF(converted_arg);
774
+ #else
775
+ if (view.obj)
776
+ PyBuffer_Release(&view);
777
+ #endif
778
+
779
+ return retval;
780
+ }
781
+
782
+ static int __Pyx_PyBytes_TailmatchTuple(PyObject* self, PyObject* substrings,
783
+ Py_ssize_t start, Py_ssize_t end, int direction) {
784
+ Py_ssize_t i, count = __Pyx_PyTuple_GET_SIZE(substrings);
785
+ #if !CYTHON_ASSUME_SAFE_SIZE
786
+ if (unlikely(count < 0)) return -1;
787
+ #endif
788
+ for (i = 0; i < count; i++) {
789
+ int result;
790
+ #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
791
+ result = __Pyx_PyBytes_SingleTailmatch(self, PyTuple_GET_ITEM(substrings, i),
792
+ start, end, direction);
793
+ #else
794
+ PyObject* sub = __Pyx_PySequence_ITEM(substrings, i);
795
+ if (unlikely(!sub)) return -1;
796
+ result = __Pyx_PyBytes_SingleTailmatch(self, sub, start, end, direction);
797
+ Py_DECREF(sub);
798
+ #endif
799
+ if (result) {
800
+ return result;
801
+ }
802
+ }
803
+ return 0;
804
+ }
805
+
806
+ static int __Pyx_PyBytes_Tailmatch(PyObject* self, PyObject* substr,
807
+ Py_ssize_t start, Py_ssize_t end, int direction) {
808
+ if (unlikely(PyTuple_Check(substr))) {
809
+ return __Pyx_PyBytes_TailmatchTuple(self, substr, start, end, direction);
810
+ }
811
+
812
+ return __Pyx_PyBytes_SingleTailmatch(self, substr, start, end, direction);
813
+ }
814
+
815
+
816
+ /////////////// bytes_index.proto ///////////////
817
+
818
+ static CYTHON_INLINE char __Pyx_PyBytes_GetItemInt(PyObject* bytes, Py_ssize_t index, int check_bounds); /*proto*/
819
+
820
+ /////////////// bytes_index ///////////////
821
+
822
+ static CYTHON_INLINE char __Pyx_PyBytes_GetItemInt(PyObject* bytes, Py_ssize_t index, int check_bounds) {
823
+ const char *asString;
824
+ if (index < 0) {
825
+ Py_ssize_t size = __Pyx_PyBytes_GET_SIZE(bytes);
826
+ #if !CYTHON_ASSUME_SAFE_SIZE
827
+ if (unlikely(size < 0)) return (char) -1;
828
+ #endif
829
+ index += size;
830
+ }
831
+ if (check_bounds) {
832
+ Py_ssize_t size = __Pyx_PyBytes_GET_SIZE(bytes);
833
+ #if !CYTHON_ASSUME_SAFE_SIZE
834
+ if (unlikely(size < 0)) return (char) -1;
835
+ #endif
836
+ if (unlikely(!__Pyx_is_valid_index(index, size))) {
837
+ PyErr_SetString(PyExc_IndexError, "string index out of range");
838
+ return (char) -1;
839
+ }
840
+ }
841
+ asString = __Pyx_PyBytes_AsString(bytes);
842
+ #if !CYTHON_ASSUME_SAFE_MACROS
843
+ if (unlikely(!asString)) return (char)-1;
844
+ #endif
845
+ return asString[index];
846
+ }
847
+
848
+
849
+ //////////////////// StringJoin.proto ////////////////////
850
+
851
+ static CYTHON_INLINE PyObject* __Pyx_PyBytes_Join(PyObject* sep, PyObject* values); /*proto*/
852
+
853
+ //////////////////// StringJoin ////////////////////
854
+ //@requires: ObjectHandling.c::PyObjectCallMethod1
855
+
856
+ static CYTHON_INLINE PyObject* __Pyx_PyBytes_Join(PyObject* sep, PyObject* values) {
857
+ // avoid unused function
858
+ (void) __Pyx_PyObject_CallMethod1;
859
+ #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030d0000
860
+ return _PyBytes_Join(sep, values);
861
+ #else
862
+ return __Pyx_PyObject_CallMethod1(sep, PYIDENT("join"), values);
863
+ #endif
864
+ }
865
+
866
+
867
+ /////////////// JoinPyUnicode.proto ///////////////
868
+
869
+ static PyObject* __Pyx_PyUnicode_Join(PyObject** values, Py_ssize_t value_count, Py_ssize_t result_ulength,
870
+ Py_UCS4 max_char);
871
+
872
+ /////////////// JoinPyUnicode ///////////////
873
+ //@requires: IncludeStringH
874
+
875
+ static PyObject* __Pyx_PyUnicode_Join(PyObject** values, Py_ssize_t value_count, Py_ssize_t result_ulength,
876
+ Py_UCS4 max_char) {
877
+ #if CYTHON_USE_UNICODE_INTERNALS && CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
878
+ PyObject *result_uval;
879
+ int result_ukind, kind_shift;
880
+ Py_ssize_t i, char_pos;
881
+ void *result_udata;
882
+
883
+ if (max_char > 1114111) max_char = 1114111;
884
+ result_uval = PyUnicode_New(result_ulength, max_char);
885
+ if (unlikely(!result_uval)) return NULL;
886
+ result_ukind = (max_char <= 255) ? PyUnicode_1BYTE_KIND : (max_char <= 65535) ? PyUnicode_2BYTE_KIND : PyUnicode_4BYTE_KIND;
887
+ kind_shift = (result_ukind == PyUnicode_4BYTE_KIND) ? 2 : result_ukind - 1;
888
+ result_udata = PyUnicode_DATA(result_uval);
889
+ assert(kind_shift == 2 || kind_shift == 1 || kind_shift == 0);
890
+
891
+ if (unlikely((PY_SSIZE_T_MAX >> kind_shift) - result_ulength < 0))
892
+ goto overflow;
893
+
894
+ char_pos = 0;
895
+ for (i=0; i < value_count; i++) {
896
+ int ukind;
897
+ Py_ssize_t ulength;
898
+ void *udata;
899
+ PyObject *uval = values[i];
900
+ #if !CYTHON_COMPILING_IN_LIMITED_API
901
+ if (__Pyx_PyUnicode_READY(uval) == (-1))
902
+ goto bad;
903
+ #endif
904
+ ulength = __Pyx_PyUnicode_GET_LENGTH(uval);
905
+ #if !CYTHON_ASSUME_SAFE_SIZE
906
+ if (unlikely(ulength < 0)) goto bad;
907
+ #endif
908
+ if (unlikely(!ulength))
909
+ continue;
910
+ if (unlikely((PY_SSIZE_T_MAX >> kind_shift) - ulength < char_pos))
911
+ goto overflow;
912
+ ukind = __Pyx_PyUnicode_KIND(uval);
913
+ udata = __Pyx_PyUnicode_DATA(uval);
914
+ if (ukind == result_ukind) {
915
+ memcpy((char *)result_udata + (char_pos << kind_shift), udata, (size_t) (ulength << kind_shift));
916
+ } else {
917
+ #if PY_VERSION_HEX >= 0x030d0000
918
+ if (unlikely(PyUnicode_CopyCharacters(result_uval, char_pos, uval, 0, ulength) < 0)) goto bad;
919
+ #elif CYTHON_COMPILING_IN_CPYTHON || defined(_PyUnicode_FastCopyCharacters)
920
+ _PyUnicode_FastCopyCharacters(result_uval, char_pos, uval, 0, ulength);
921
+ #else
922
+ Py_ssize_t j;
923
+ for (j=0; j < ulength; j++) {
924
+ Py_UCS4 uchar = __Pyx_PyUnicode_READ(ukind, udata, j);
925
+ __Pyx_PyUnicode_WRITE(result_ukind, result_udata, char_pos+j, uchar);
926
+ }
927
+ #endif
928
+ }
929
+ char_pos += ulength;
930
+ }
931
+ return result_uval;
932
+ overflow:
933
+ PyErr_SetString(PyExc_OverflowError, "join() result is too long for a Python string");
934
+ bad:
935
+ Py_DECREF(result_uval);
936
+ return NULL;
937
+ #else
938
+ // non-CPython fallback
939
+ Py_ssize_t i;
940
+ PyObject *result = NULL;
941
+ PyObject *value_tuple = PyTuple_New(value_count);
942
+ if (unlikely(!value_tuple)) return NULL;
943
+ CYTHON_UNUSED_VAR(max_char);
944
+ CYTHON_UNUSED_VAR(result_ulength);
945
+
946
+ for (i=0; i<value_count; i++) {
947
+ if (__Pyx_PyTuple_SET_ITEM(value_tuple, i, values[i]) != (0)) goto bad;
948
+ Py_INCREF(values[i]);
949
+ }
950
+
951
+ result = PyUnicode_Join(EMPTY(unicode), value_tuple);
952
+
953
+ bad:
954
+ Py_DECREF(value_tuple);
955
+ return result;
956
+ #endif
957
+ }
958
+
959
+
960
+ /////////////// BuildPyUnicode.proto ///////////////
961
+
962
+ static PyObject* __Pyx_PyUnicode_BuildFromAscii(Py_ssize_t ulength, const char* chars, int clength,
963
+ int prepend_sign, char padding_char);
964
+
965
+ /////////////// BuildPyUnicode ///////////////
966
+
967
+ // Create a PyUnicode object from an ASCII char*, e.g. a formatted number.
968
+
969
+ static PyObject* __Pyx_PyUnicode_BuildFromAscii(Py_ssize_t ulength, const char* chars, int clength,
970
+ int prepend_sign, char padding_char) {
971
+ PyObject *uval;
972
+ Py_ssize_t uoffset = ulength - clength;
973
+ #if CYTHON_USE_UNICODE_INTERNALS
974
+ Py_ssize_t i;
975
+ void *udata;
976
+ uval = PyUnicode_New(ulength, 127);
977
+ if (unlikely(!uval)) return NULL;
978
+ udata = PyUnicode_DATA(uval);
979
+ if (uoffset > 0) {
980
+ i = 0;
981
+ if (prepend_sign) {
982
+ __Pyx_PyUnicode_WRITE(PyUnicode_1BYTE_KIND, udata, 0, '-');
983
+ i++;
984
+ }
985
+ for (; i < uoffset; i++) {
986
+ __Pyx_PyUnicode_WRITE(PyUnicode_1BYTE_KIND, udata, i, padding_char);
987
+ }
988
+ }
989
+ for (i=0; i < clength; i++) {
990
+ __Pyx_PyUnicode_WRITE(PyUnicode_1BYTE_KIND, udata, uoffset+i, chars[i]);
991
+ }
992
+
993
+ #else
994
+ // non-CPython
995
+ {
996
+ PyObject *sign = NULL, *padding = NULL;
997
+ uval = NULL;
998
+ if (uoffset > 0) {
999
+ prepend_sign = !!prepend_sign;
1000
+ if (uoffset > prepend_sign) {
1001
+ padding = PyUnicode_FromOrdinal(padding_char);
1002
+ if (likely(padding) && uoffset > prepend_sign + 1) {
1003
+ PyObject *tmp = PySequence_Repeat(padding, uoffset - prepend_sign);
1004
+ Py_DECREF(padding);
1005
+ padding = tmp;
1006
+ }
1007
+ if (unlikely(!padding)) goto done_or_error;
1008
+ }
1009
+ if (prepend_sign) {
1010
+ sign = PyUnicode_FromOrdinal('-');
1011
+ if (unlikely(!sign)) goto done_or_error;
1012
+ }
1013
+ }
1014
+
1015
+ uval = PyUnicode_DecodeASCII(chars, clength, NULL);
1016
+ if (likely(uval) && padding) {
1017
+ PyObject *tmp = PyUnicode_Concat(padding, uval);
1018
+ Py_DECREF(uval);
1019
+ uval = tmp;
1020
+ }
1021
+ if (likely(uval) && sign) {
1022
+ PyObject *tmp = PyUnicode_Concat(sign, uval);
1023
+ Py_DECREF(uval);
1024
+ uval = tmp;
1025
+ }
1026
+ done_or_error:
1027
+ Py_XDECREF(padding);
1028
+ Py_XDECREF(sign);
1029
+ }
1030
+ #endif
1031
+
1032
+ return uval;
1033
+ }
1034
+
1035
+
1036
+ //////////////////// ByteArrayAppendObject.proto ////////////////////
1037
+
1038
+ static CYTHON_INLINE int __Pyx_PyByteArray_AppendObject(PyObject* bytearray, PyObject* value);
1039
+
1040
+ //////////////////// ByteArrayAppendObject ////////////////////
1041
+ //@requires: ByteArrayAppend
1042
+
1043
+ static CYTHON_INLINE int __Pyx_PyByteArray_AppendObject(PyObject* bytearray, PyObject* value) {
1044
+ Py_ssize_t ival;
1045
+ #if CYTHON_USE_PYLONG_INTERNALS
1046
+ if (likely(PyLong_CheckExact(value)) && likely(__Pyx_PyLong_IsCompact(value))) {
1047
+ if (__Pyx_PyLong_IsZero(value)) {
1048
+ ival = 0;
1049
+ } else {
1050
+ ival = __Pyx_PyLong_CompactValue(value);
1051
+ if (unlikely(ival > 255)) goto bad_range;
1052
+ }
1053
+ } else
1054
+ #endif
1055
+ {
1056
+ // CPython calls PyNumber_Index() internally
1057
+ ival = __Pyx_PyIndex_AsSsize_t(value);
1058
+ if (unlikely(!__Pyx_is_valid_index(ival, 256))) {
1059
+ if (ival == -1 && PyErr_Occurred())
1060
+ return -1;
1061
+ goto bad_range;
1062
+ }
1063
+ }
1064
+ return __Pyx_PyByteArray_Append(bytearray, ival);
1065
+ bad_range:
1066
+ PyErr_SetString(PyExc_ValueError, "byte must be in range(0, 256)");
1067
+ return -1;
1068
+ }
1069
+
1070
+ //////////////////// ByteArrayAppend.proto ////////////////////
1071
+
1072
+ static CYTHON_INLINE int __Pyx_PyByteArray_Append(PyObject* bytearray, int value);
1073
+
1074
+ //////////////////// ByteArrayAppend ////////////////////
1075
+ //@requires: ObjectHandling.c::PyObjectCallMethod1
1076
+
1077
+ static CYTHON_INLINE int __Pyx_PyByteArray_Append(PyObject* bytearray, int value) {
1078
+ PyObject *pyval, *retval;
1079
+ #if CYTHON_COMPILING_IN_CPYTHON
1080
+ if (likely(__Pyx_is_valid_index(value, 256))) {
1081
+ Py_ssize_t n = Py_SIZE(bytearray);
1082
+ if (likely(n != PY_SSIZE_T_MAX)) {
1083
+ if (unlikely(PyByteArray_Resize(bytearray, n + 1) < 0))
1084
+ return -1;
1085
+ PyByteArray_AS_STRING(bytearray)[n] = value;
1086
+ return 0;
1087
+ }
1088
+ } else {
1089
+ PyErr_SetString(PyExc_ValueError, "byte must be in range(0, 256)");
1090
+ return -1;
1091
+ }
1092
+ #endif
1093
+ pyval = PyLong_FromLong(value);
1094
+ if (unlikely(!pyval))
1095
+ return -1;
1096
+ retval = __Pyx_PyObject_CallMethod1(bytearray, PYIDENT("append"), pyval);
1097
+ Py_DECREF(pyval);
1098
+ if (unlikely(!retval))
1099
+ return -1;
1100
+ Py_DECREF(retval);
1101
+ return 0;
1102
+ }
1103
+
1104
+
1105
+ //////////////////// PyObjectFormat.proto ////////////////////
1106
+
1107
+ #if CYTHON_USE_UNICODE_WRITER
1108
+ static PyObject* __Pyx_PyObject_Format(PyObject* s, PyObject* f);
1109
+ #else
1110
+ #define __Pyx_PyObject_Format(s, f) PyObject_Format(s, f)
1111
+ #endif
1112
+
1113
+ //////////////////// PyObjectFormat ////////////////////
1114
+
1115
+ #if CYTHON_USE_UNICODE_WRITER
1116
+ static PyObject* __Pyx_PyObject_Format(PyObject* obj, PyObject* format_spec) {
1117
+ int ret;
1118
+ _PyUnicodeWriter writer;
1119
+
1120
+ if (likely(PyFloat_CheckExact(obj))) {
1121
+ // copied from CPython 3.5 "float__format__()" in floatobject.c
1122
+ _PyUnicodeWriter_Init(&writer);
1123
+ ret = _PyFloat_FormatAdvancedWriter(
1124
+ &writer,
1125
+ obj,
1126
+ format_spec, 0, PyUnicode_GET_LENGTH(format_spec));
1127
+ } else if (likely(PyLong_CheckExact(obj))) {
1128
+ // copied from CPython 3.5 "long__format__()" in longobject.c
1129
+ _PyUnicodeWriter_Init(&writer);
1130
+ ret = _PyLong_FormatAdvancedWriter(
1131
+ &writer,
1132
+ obj,
1133
+ format_spec, 0, PyUnicode_GET_LENGTH(format_spec));
1134
+ } else {
1135
+ return PyObject_Format(obj, format_spec);
1136
+ }
1137
+
1138
+ if (unlikely(ret == -1)) {
1139
+ _PyUnicodeWriter_Dealloc(&writer);
1140
+ return NULL;
1141
+ }
1142
+ return _PyUnicodeWriter_Finish(&writer);
1143
+ }
1144
+ #endif
1145
+
1146
+
1147
+ //////////////////// PyObjectFormatSimple.proto ////////////////////
1148
+
1149
+ #if CYTHON_COMPILING_IN_PYPY
1150
+ #define __Pyx_PyObject_FormatSimple(s, f) ( \
1151
+ likely(PyUnicode_CheckExact(s)) ? (Py_INCREF(s), s) : \
1152
+ PyObject_Format(s, f))
1153
+ #elif CYTHON_USE_TYPE_SLOTS
1154
+ // Py3 nicely returns unicode strings from str() and repr(), which makes this quite efficient for builtin types.
1155
+ // In Py3.8+, tp_str() delegates to tp_repr(), so we call tp_repr() directly here.
1156
+ #define __Pyx_PyObject_FormatSimple(s, f) ( \
1157
+ likely(PyUnicode_CheckExact(s)) ? (Py_INCREF(s), s) : \
1158
+ likely(PyLong_CheckExact(s)) ? PyLong_Type.tp_repr(s) : \
1159
+ likely(PyFloat_CheckExact(s)) ? PyFloat_Type.tp_repr(s) : \
1160
+ PyObject_Format(s, f))
1161
+ #else
1162
+ #define __Pyx_PyObject_FormatSimple(s, f) ( \
1163
+ likely(PyUnicode_CheckExact(s)) ? (Py_INCREF(s), s) : \
1164
+ PyObject_Format(s, f))
1165
+ #endif
1166
+
1167
+
1168
+ //////////////////// PyObjectFormatAndDecref.proto ////////////////////
1169
+
1170
+ static CYTHON_INLINE PyObject* __Pyx_PyObject_FormatSimpleAndDecref(PyObject* s, PyObject* f);
1171
+ static CYTHON_INLINE PyObject* __Pyx_PyObject_FormatAndDecref(PyObject* s, PyObject* f);
1172
+
1173
+ //////////////////// PyObjectFormatAndDecref ////////////////////
1174
+
1175
+ static CYTHON_INLINE PyObject* __Pyx_PyObject_FormatSimpleAndDecref(PyObject* s, PyObject* f) {
1176
+ if (unlikely(!s)) return NULL;
1177
+ if (likely(PyUnicode_CheckExact(s))) return s;
1178
+ return __Pyx_PyObject_FormatAndDecref(s, f);
1179
+ }
1180
+
1181
+ static CYTHON_INLINE PyObject* __Pyx_PyObject_FormatAndDecref(PyObject* s, PyObject* f) {
1182
+ PyObject *result;
1183
+ if (unlikely(!s)) return NULL;
1184
+ result = PyObject_Format(s, f);
1185
+ Py_DECREF(s);
1186
+ return result;
1187
+ }
1188
+
1189
+
1190
+ //////////////////// PyUnicode_Unicode.proto ////////////////////
1191
+
1192
+ static CYTHON_INLINE PyObject* __Pyx_PyUnicode_Unicode(PyObject *obj);/*proto*/
1193
+
1194
+ //////////////////// PyUnicode_Unicode ////////////////////
1195
+
1196
+ static CYTHON_INLINE PyObject* __Pyx_PyUnicode_Unicode(PyObject *obj) {
1197
+ if (unlikely(obj == Py_None))
1198
+ obj = PYUNICODE("None");
1199
+ return __Pyx_NewRef(obj);
1200
+ }
1201
+
1202
+
1203
+ //////////////////// PyObject_Unicode.proto ////////////////////
1204
+
1205
+ #define __Pyx_PyObject_Unicode(obj) \
1206
+ (likely(PyUnicode_CheckExact(obj)) ? __Pyx_NewRef(obj) : PyObject_Str(obj))