numba-cuda 0.22.0__cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.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 (487) hide show
  1. _numba_cuda_redirector.pth +4 -0
  2. _numba_cuda_redirector.py +89 -0
  3. numba_cuda/VERSION +1 -0
  4. numba_cuda/__init__.py +6 -0
  5. numba_cuda/_version.py +11 -0
  6. numba_cuda/numba/cuda/__init__.py +70 -0
  7. numba_cuda/numba/cuda/_internal/cuda_bf16.py +16394 -0
  8. numba_cuda/numba/cuda/_internal/cuda_fp16.py +8112 -0
  9. numba_cuda/numba/cuda/api.py +580 -0
  10. numba_cuda/numba/cuda/api_util.py +76 -0
  11. numba_cuda/numba/cuda/args.py +72 -0
  12. numba_cuda/numba/cuda/bf16.py +397 -0
  13. numba_cuda/numba/cuda/cache_hints.py +287 -0
  14. numba_cuda/numba/cuda/cext/__init__.py +2 -0
  15. numba_cuda/numba/cuda/cext/_devicearray.cpp +159 -0
  16. numba_cuda/numba/cuda/cext/_devicearray.cpython-313-aarch64-linux-gnu.so +0 -0
  17. numba_cuda/numba/cuda/cext/_devicearray.h +29 -0
  18. numba_cuda/numba/cuda/cext/_dispatcher.cpp +1098 -0
  19. numba_cuda/numba/cuda/cext/_dispatcher.cpython-313-aarch64-linux-gnu.so +0 -0
  20. numba_cuda/numba/cuda/cext/_hashtable.cpp +532 -0
  21. numba_cuda/numba/cuda/cext/_hashtable.h +135 -0
  22. numba_cuda/numba/cuda/cext/_helperlib.c +71 -0
  23. numba_cuda/numba/cuda/cext/_helperlib.cpython-313-aarch64-linux-gnu.so +0 -0
  24. numba_cuda/numba/cuda/cext/_helpermod.c +82 -0
  25. numba_cuda/numba/cuda/cext/_pymodule.h +38 -0
  26. numba_cuda/numba/cuda/cext/_typeconv.cpp +206 -0
  27. numba_cuda/numba/cuda/cext/_typeconv.cpython-313-aarch64-linux-gnu.so +0 -0
  28. numba_cuda/numba/cuda/cext/_typeof.cpp +1159 -0
  29. numba_cuda/numba/cuda/cext/_typeof.h +19 -0
  30. numba_cuda/numba/cuda/cext/capsulethunk.h +111 -0
  31. numba_cuda/numba/cuda/cext/mviewbuf.c +385 -0
  32. numba_cuda/numba/cuda/cext/mviewbuf.cpython-313-aarch64-linux-gnu.so +0 -0
  33. numba_cuda/numba/cuda/cext/typeconv.cpp +212 -0
  34. numba_cuda/numba/cuda/cext/typeconv.hpp +101 -0
  35. numba_cuda/numba/cuda/cg.py +67 -0
  36. numba_cuda/numba/cuda/cgutils.py +1294 -0
  37. numba_cuda/numba/cuda/cloudpickle/__init__.py +21 -0
  38. numba_cuda/numba/cuda/cloudpickle/cloudpickle.py +1598 -0
  39. numba_cuda/numba/cuda/cloudpickle/cloudpickle_fast.py +17 -0
  40. numba_cuda/numba/cuda/codegen.py +541 -0
  41. numba_cuda/numba/cuda/compiler.py +1396 -0
  42. numba_cuda/numba/cuda/core/analysis.py +758 -0
  43. numba_cuda/numba/cuda/core/annotations/__init__.py +0 -0
  44. numba_cuda/numba/cuda/core/annotations/pretty_annotate.py +288 -0
  45. numba_cuda/numba/cuda/core/annotations/type_annotations.py +305 -0
  46. numba_cuda/numba/cuda/core/base.py +1332 -0
  47. numba_cuda/numba/cuda/core/boxing.py +1411 -0
  48. numba_cuda/numba/cuda/core/bytecode.py +728 -0
  49. numba_cuda/numba/cuda/core/byteflow.py +2346 -0
  50. numba_cuda/numba/cuda/core/caching.py +744 -0
  51. numba_cuda/numba/cuda/core/callconv.py +392 -0
  52. numba_cuda/numba/cuda/core/codegen.py +171 -0
  53. numba_cuda/numba/cuda/core/compiler.py +199 -0
  54. numba_cuda/numba/cuda/core/compiler_lock.py +85 -0
  55. numba_cuda/numba/cuda/core/compiler_machinery.py +497 -0
  56. numba_cuda/numba/cuda/core/config.py +650 -0
  57. numba_cuda/numba/cuda/core/consts.py +124 -0
  58. numba_cuda/numba/cuda/core/controlflow.py +989 -0
  59. numba_cuda/numba/cuda/core/entrypoints.py +57 -0
  60. numba_cuda/numba/cuda/core/environment.py +66 -0
  61. numba_cuda/numba/cuda/core/errors.py +917 -0
  62. numba_cuda/numba/cuda/core/event.py +511 -0
  63. numba_cuda/numba/cuda/core/funcdesc.py +330 -0
  64. numba_cuda/numba/cuda/core/generators.py +387 -0
  65. numba_cuda/numba/cuda/core/imputils.py +509 -0
  66. numba_cuda/numba/cuda/core/inline_closurecall.py +1787 -0
  67. numba_cuda/numba/cuda/core/interpreter.py +3617 -0
  68. numba_cuda/numba/cuda/core/ir.py +1812 -0
  69. numba_cuda/numba/cuda/core/ir_utils.py +2638 -0
  70. numba_cuda/numba/cuda/core/optional.py +129 -0
  71. numba_cuda/numba/cuda/core/options.py +262 -0
  72. numba_cuda/numba/cuda/core/postproc.py +249 -0
  73. numba_cuda/numba/cuda/core/pythonapi.py +1859 -0
  74. numba_cuda/numba/cuda/core/registry.py +46 -0
  75. numba_cuda/numba/cuda/core/removerefctpass.py +123 -0
  76. numba_cuda/numba/cuda/core/rewrites/__init__.py +26 -0
  77. numba_cuda/numba/cuda/core/rewrites/ir_print.py +91 -0
  78. numba_cuda/numba/cuda/core/rewrites/registry.py +104 -0
  79. numba_cuda/numba/cuda/core/rewrites/static_binop.py +41 -0
  80. numba_cuda/numba/cuda/core/rewrites/static_getitem.py +189 -0
  81. numba_cuda/numba/cuda/core/rewrites/static_raise.py +100 -0
  82. numba_cuda/numba/cuda/core/sigutils.py +68 -0
  83. numba_cuda/numba/cuda/core/ssa.py +498 -0
  84. numba_cuda/numba/cuda/core/targetconfig.py +330 -0
  85. numba_cuda/numba/cuda/core/tracing.py +231 -0
  86. numba_cuda/numba/cuda/core/transforms.py +956 -0
  87. numba_cuda/numba/cuda/core/typed_passes.py +867 -0
  88. numba_cuda/numba/cuda/core/typeinfer.py +1950 -0
  89. numba_cuda/numba/cuda/core/unsafe/__init__.py +0 -0
  90. numba_cuda/numba/cuda/core/unsafe/bytes.py +67 -0
  91. numba_cuda/numba/cuda/core/unsafe/eh.py +67 -0
  92. numba_cuda/numba/cuda/core/unsafe/refcount.py +98 -0
  93. numba_cuda/numba/cuda/core/untyped_passes.py +1979 -0
  94. numba_cuda/numba/cuda/cpython/builtins.py +1153 -0
  95. numba_cuda/numba/cuda/cpython/charseq.py +1218 -0
  96. numba_cuda/numba/cuda/cpython/cmathimpl.py +560 -0
  97. numba_cuda/numba/cuda/cpython/enumimpl.py +103 -0
  98. numba_cuda/numba/cuda/cpython/iterators.py +167 -0
  99. numba_cuda/numba/cuda/cpython/listobj.py +1326 -0
  100. numba_cuda/numba/cuda/cpython/mathimpl.py +499 -0
  101. numba_cuda/numba/cuda/cpython/numbers.py +1475 -0
  102. numba_cuda/numba/cuda/cpython/rangeobj.py +289 -0
  103. numba_cuda/numba/cuda/cpython/slicing.py +322 -0
  104. numba_cuda/numba/cuda/cpython/tupleobj.py +456 -0
  105. numba_cuda/numba/cuda/cpython/unicode.py +2865 -0
  106. numba_cuda/numba/cuda/cpython/unicode_support.py +1597 -0
  107. numba_cuda/numba/cuda/cpython/unsafe/__init__.py +0 -0
  108. numba_cuda/numba/cuda/cpython/unsafe/numbers.py +64 -0
  109. numba_cuda/numba/cuda/cpython/unsafe/tuple.py +92 -0
  110. numba_cuda/numba/cuda/cuda_paths.py +691 -0
  111. numba_cuda/numba/cuda/cudadecl.py +543 -0
  112. numba_cuda/numba/cuda/cudadrv/__init__.py +14 -0
  113. numba_cuda/numba/cuda/cudadrv/devicearray.py +954 -0
  114. numba_cuda/numba/cuda/cudadrv/devices.py +249 -0
  115. numba_cuda/numba/cuda/cudadrv/driver.py +3238 -0
  116. numba_cuda/numba/cuda/cudadrv/drvapi.py +435 -0
  117. numba_cuda/numba/cuda/cudadrv/dummyarray.py +562 -0
  118. numba_cuda/numba/cuda/cudadrv/enums.py +613 -0
  119. numba_cuda/numba/cuda/cudadrv/error.py +48 -0
  120. numba_cuda/numba/cuda/cudadrv/libs.py +220 -0
  121. numba_cuda/numba/cuda/cudadrv/linkable_code.py +184 -0
  122. numba_cuda/numba/cuda/cudadrv/mappings.py +14 -0
  123. numba_cuda/numba/cuda/cudadrv/ndarray.py +26 -0
  124. numba_cuda/numba/cuda/cudadrv/nvrtc.py +193 -0
  125. numba_cuda/numba/cuda/cudadrv/nvvm.py +756 -0
  126. numba_cuda/numba/cuda/cudadrv/rtapi.py +13 -0
  127. numba_cuda/numba/cuda/cudadrv/runtime.py +34 -0
  128. numba_cuda/numba/cuda/cudaimpl.py +983 -0
  129. numba_cuda/numba/cuda/cudamath.py +149 -0
  130. numba_cuda/numba/cuda/datamodel/__init__.py +7 -0
  131. numba_cuda/numba/cuda/datamodel/cuda_manager.py +66 -0
  132. numba_cuda/numba/cuda/datamodel/cuda_models.py +1446 -0
  133. numba_cuda/numba/cuda/datamodel/cuda_packer.py +224 -0
  134. numba_cuda/numba/cuda/datamodel/cuda_registry.py +22 -0
  135. numba_cuda/numba/cuda/datamodel/cuda_testing.py +153 -0
  136. numba_cuda/numba/cuda/datamodel/manager.py +11 -0
  137. numba_cuda/numba/cuda/datamodel/models.py +9 -0
  138. numba_cuda/numba/cuda/datamodel/packer.py +9 -0
  139. numba_cuda/numba/cuda/datamodel/registry.py +11 -0
  140. numba_cuda/numba/cuda/datamodel/testing.py +11 -0
  141. numba_cuda/numba/cuda/debuginfo.py +997 -0
  142. numba_cuda/numba/cuda/decorators.py +294 -0
  143. numba_cuda/numba/cuda/descriptor.py +35 -0
  144. numba_cuda/numba/cuda/device_init.py +155 -0
  145. numba_cuda/numba/cuda/deviceufunc.py +1021 -0
  146. numba_cuda/numba/cuda/dispatcher.py +2463 -0
  147. numba_cuda/numba/cuda/errors.py +72 -0
  148. numba_cuda/numba/cuda/extending.py +697 -0
  149. numba_cuda/numba/cuda/flags.py +178 -0
  150. numba_cuda/numba/cuda/fp16.py +357 -0
  151. numba_cuda/numba/cuda/include/12/cuda_bf16.h +5118 -0
  152. numba_cuda/numba/cuda/include/12/cuda_bf16.hpp +3865 -0
  153. numba_cuda/numba/cuda/include/12/cuda_fp16.h +5363 -0
  154. numba_cuda/numba/cuda/include/12/cuda_fp16.hpp +3483 -0
  155. numba_cuda/numba/cuda/include/13/cuda_bf16.h +5118 -0
  156. numba_cuda/numba/cuda/include/13/cuda_bf16.hpp +3865 -0
  157. numba_cuda/numba/cuda/include/13/cuda_fp16.h +5363 -0
  158. numba_cuda/numba/cuda/include/13/cuda_fp16.hpp +3483 -0
  159. numba_cuda/numba/cuda/initialize.py +24 -0
  160. numba_cuda/numba/cuda/intrinsics.py +531 -0
  161. numba_cuda/numba/cuda/itanium_mangler.py +214 -0
  162. numba_cuda/numba/cuda/kernels/__init__.py +2 -0
  163. numba_cuda/numba/cuda/kernels/reduction.py +265 -0
  164. numba_cuda/numba/cuda/kernels/transpose.py +65 -0
  165. numba_cuda/numba/cuda/libdevice.py +3386 -0
  166. numba_cuda/numba/cuda/libdevicedecl.py +20 -0
  167. numba_cuda/numba/cuda/libdevicefuncs.py +1060 -0
  168. numba_cuda/numba/cuda/libdeviceimpl.py +88 -0
  169. numba_cuda/numba/cuda/locks.py +19 -0
  170. numba_cuda/numba/cuda/lowering.py +1980 -0
  171. numba_cuda/numba/cuda/mathimpl.py +374 -0
  172. numba_cuda/numba/cuda/memory_management/__init__.py +4 -0
  173. numba_cuda/numba/cuda/memory_management/memsys.cu +99 -0
  174. numba_cuda/numba/cuda/memory_management/memsys.cuh +22 -0
  175. numba_cuda/numba/cuda/memory_management/nrt.cu +212 -0
  176. numba_cuda/numba/cuda/memory_management/nrt.cuh +48 -0
  177. numba_cuda/numba/cuda/memory_management/nrt.py +390 -0
  178. numba_cuda/numba/cuda/memory_management/nrt_context.py +438 -0
  179. numba_cuda/numba/cuda/misc/appdirs.py +594 -0
  180. numba_cuda/numba/cuda/misc/cffiimpl.py +24 -0
  181. numba_cuda/numba/cuda/misc/coverage_support.py +43 -0
  182. numba_cuda/numba/cuda/misc/dump_style.py +41 -0
  183. numba_cuda/numba/cuda/misc/findlib.py +75 -0
  184. numba_cuda/numba/cuda/misc/firstlinefinder.py +96 -0
  185. numba_cuda/numba/cuda/misc/gdb_hook.py +240 -0
  186. numba_cuda/numba/cuda/misc/literal.py +28 -0
  187. numba_cuda/numba/cuda/misc/llvm_pass_timings.py +412 -0
  188. numba_cuda/numba/cuda/misc/special.py +94 -0
  189. numba_cuda/numba/cuda/models.py +56 -0
  190. numba_cuda/numba/cuda/np/arraymath.py +5130 -0
  191. numba_cuda/numba/cuda/np/arrayobj.py +7635 -0
  192. numba_cuda/numba/cuda/np/extensions.py +11 -0
  193. numba_cuda/numba/cuda/np/linalg.py +3087 -0
  194. numba_cuda/numba/cuda/np/math/__init__.py +0 -0
  195. numba_cuda/numba/cuda/np/math/cmathimpl.py +558 -0
  196. numba_cuda/numba/cuda/np/math/mathimpl.py +487 -0
  197. numba_cuda/numba/cuda/np/math/numbers.py +1461 -0
  198. numba_cuda/numba/cuda/np/npdatetime.py +969 -0
  199. numba_cuda/numba/cuda/np/npdatetime_helpers.py +217 -0
  200. numba_cuda/numba/cuda/np/npyfuncs.py +1808 -0
  201. numba_cuda/numba/cuda/np/npyimpl.py +1027 -0
  202. numba_cuda/numba/cuda/np/numpy_support.py +798 -0
  203. numba_cuda/numba/cuda/np/polynomial/__init__.py +4 -0
  204. numba_cuda/numba/cuda/np/polynomial/polynomial_core.py +242 -0
  205. numba_cuda/numba/cuda/np/polynomial/polynomial_functions.py +380 -0
  206. numba_cuda/numba/cuda/np/ufunc/__init__.py +4 -0
  207. numba_cuda/numba/cuda/np/ufunc/decorators.py +203 -0
  208. numba_cuda/numba/cuda/np/ufunc/sigparse.py +68 -0
  209. numba_cuda/numba/cuda/np/ufunc/ufuncbuilder.py +65 -0
  210. numba_cuda/numba/cuda/np/ufunc_db.py +1282 -0
  211. numba_cuda/numba/cuda/np/unsafe/__init__.py +0 -0
  212. numba_cuda/numba/cuda/np/unsafe/ndarray.py +84 -0
  213. numba_cuda/numba/cuda/nvvmutils.py +254 -0
  214. numba_cuda/numba/cuda/printimpl.py +126 -0
  215. numba_cuda/numba/cuda/random.py +308 -0
  216. numba_cuda/numba/cuda/reshape_funcs.cu +156 -0
  217. numba_cuda/numba/cuda/serialize.py +267 -0
  218. numba_cuda/numba/cuda/simulator/__init__.py +63 -0
  219. numba_cuda/numba/cuda/simulator/_internal/__init__.py +4 -0
  220. numba_cuda/numba/cuda/simulator/_internal/cuda_bf16.py +2 -0
  221. numba_cuda/numba/cuda/simulator/api.py +179 -0
  222. numba_cuda/numba/cuda/simulator/bf16.py +4 -0
  223. numba_cuda/numba/cuda/simulator/compiler.py +38 -0
  224. numba_cuda/numba/cuda/simulator/cudadrv/__init__.py +11 -0
  225. numba_cuda/numba/cuda/simulator/cudadrv/devicearray.py +462 -0
  226. numba_cuda/numba/cuda/simulator/cudadrv/devices.py +122 -0
  227. numba_cuda/numba/cuda/simulator/cudadrv/driver.py +66 -0
  228. numba_cuda/numba/cuda/simulator/cudadrv/drvapi.py +7 -0
  229. numba_cuda/numba/cuda/simulator/cudadrv/dummyarray.py +7 -0
  230. numba_cuda/numba/cuda/simulator/cudadrv/error.py +10 -0
  231. numba_cuda/numba/cuda/simulator/cudadrv/libs.py +10 -0
  232. numba_cuda/numba/cuda/simulator/cudadrv/linkable_code.py +61 -0
  233. numba_cuda/numba/cuda/simulator/cudadrv/nvrtc.py +11 -0
  234. numba_cuda/numba/cuda/simulator/cudadrv/nvvm.py +32 -0
  235. numba_cuda/numba/cuda/simulator/cudadrv/runtime.py +22 -0
  236. numba_cuda/numba/cuda/simulator/dispatcher.py +11 -0
  237. numba_cuda/numba/cuda/simulator/kernel.py +320 -0
  238. numba_cuda/numba/cuda/simulator/kernelapi.py +509 -0
  239. numba_cuda/numba/cuda/simulator/memory_management/__init__.py +4 -0
  240. numba_cuda/numba/cuda/simulator/memory_management/nrt.py +21 -0
  241. numba_cuda/numba/cuda/simulator/reduction.py +19 -0
  242. numba_cuda/numba/cuda/simulator/tests/support.py +4 -0
  243. numba_cuda/numba/cuda/simulator/vector_types.py +65 -0
  244. numba_cuda/numba/cuda/simulator_init.py +18 -0
  245. numba_cuda/numba/cuda/stubs.py +624 -0
  246. numba_cuda/numba/cuda/target.py +505 -0
  247. numba_cuda/numba/cuda/testing.py +347 -0
  248. numba_cuda/numba/cuda/tests/__init__.py +62 -0
  249. numba_cuda/numba/cuda/tests/benchmarks/__init__.py +0 -0
  250. numba_cuda/numba/cuda/tests/benchmarks/test_kernel_launch.py +119 -0
  251. numba_cuda/numba/cuda/tests/cloudpickle_main_class.py +9 -0
  252. numba_cuda/numba/cuda/tests/core/serialize_usecases.py +113 -0
  253. numba_cuda/numba/cuda/tests/core/test_itanium_mangler.py +83 -0
  254. numba_cuda/numba/cuda/tests/core/test_serialize.py +371 -0
  255. numba_cuda/numba/cuda/tests/cudadrv/__init__.py +9 -0
  256. numba_cuda/numba/cuda/tests/cudadrv/test_array_attr.py +147 -0
  257. numba_cuda/numba/cuda/tests/cudadrv/test_context_stack.py +161 -0
  258. numba_cuda/numba/cuda/tests/cudadrv/test_cuda_array_slicing.py +397 -0
  259. numba_cuda/numba/cuda/tests/cudadrv/test_cuda_auto_context.py +24 -0
  260. numba_cuda/numba/cuda/tests/cudadrv/test_cuda_devicerecord.py +180 -0
  261. numba_cuda/numba/cuda/tests/cudadrv/test_cuda_driver.py +313 -0
  262. numba_cuda/numba/cuda/tests/cudadrv/test_cuda_memory.py +191 -0
  263. numba_cuda/numba/cuda/tests/cudadrv/test_cuda_ndarray.py +621 -0
  264. numba_cuda/numba/cuda/tests/cudadrv/test_deallocations.py +247 -0
  265. numba_cuda/numba/cuda/tests/cudadrv/test_detect.py +100 -0
  266. numba_cuda/numba/cuda/tests/cudadrv/test_emm_plugins.py +200 -0
  267. numba_cuda/numba/cuda/tests/cudadrv/test_events.py +53 -0
  268. numba_cuda/numba/cuda/tests/cudadrv/test_host_alloc.py +72 -0
  269. numba_cuda/numba/cuda/tests/cudadrv/test_init.py +138 -0
  270. numba_cuda/numba/cuda/tests/cudadrv/test_inline_ptx.py +43 -0
  271. numba_cuda/numba/cuda/tests/cudadrv/test_is_fp16.py +15 -0
  272. numba_cuda/numba/cuda/tests/cudadrv/test_linkable_code.py +58 -0
  273. numba_cuda/numba/cuda/tests/cudadrv/test_linker.py +348 -0
  274. numba_cuda/numba/cuda/tests/cudadrv/test_managed_alloc.py +128 -0
  275. numba_cuda/numba/cuda/tests/cudadrv/test_module_callbacks.py +301 -0
  276. numba_cuda/numba/cuda/tests/cudadrv/test_nvjitlink.py +174 -0
  277. numba_cuda/numba/cuda/tests/cudadrv/test_nvrtc.py +28 -0
  278. numba_cuda/numba/cuda/tests/cudadrv/test_nvvm_driver.py +185 -0
  279. numba_cuda/numba/cuda/tests/cudadrv/test_pinned.py +39 -0
  280. numba_cuda/numba/cuda/tests/cudadrv/test_profiler.py +23 -0
  281. numba_cuda/numba/cuda/tests/cudadrv/test_reset_device.py +38 -0
  282. numba_cuda/numba/cuda/tests/cudadrv/test_runtime.py +48 -0
  283. numba_cuda/numba/cuda/tests/cudadrv/test_select_device.py +44 -0
  284. numba_cuda/numba/cuda/tests/cudadrv/test_streams.py +127 -0
  285. numba_cuda/numba/cuda/tests/cudapy/__init__.py +9 -0
  286. numba_cuda/numba/cuda/tests/cudapy/cache_usecases.py +231 -0
  287. numba_cuda/numba/cuda/tests/cudapy/cache_with_cpu_usecases.py +50 -0
  288. numba_cuda/numba/cuda/tests/cudapy/cg_cache_usecases.py +36 -0
  289. numba_cuda/numba/cuda/tests/cudapy/complex_usecases.py +116 -0
  290. numba_cuda/numba/cuda/tests/cudapy/enum_usecases.py +59 -0
  291. numba_cuda/numba/cuda/tests/cudapy/extensions_usecases.py +62 -0
  292. numba_cuda/numba/cuda/tests/cudapy/jitlink.ptx +28 -0
  293. numba_cuda/numba/cuda/tests/cudapy/overload_usecases.py +33 -0
  294. numba_cuda/numba/cuda/tests/cudapy/recursion_usecases.py +104 -0
  295. numba_cuda/numba/cuda/tests/cudapy/test_alignment.py +47 -0
  296. numba_cuda/numba/cuda/tests/cudapy/test_analysis.py +1122 -0
  297. numba_cuda/numba/cuda/tests/cudapy/test_array.py +344 -0
  298. numba_cuda/numba/cuda/tests/cudapy/test_array_alignment.py +268 -0
  299. numba_cuda/numba/cuda/tests/cudapy/test_array_args.py +203 -0
  300. numba_cuda/numba/cuda/tests/cudapy/test_array_methods.py +63 -0
  301. numba_cuda/numba/cuda/tests/cudapy/test_array_reductions.py +360 -0
  302. numba_cuda/numba/cuda/tests/cudapy/test_atomics.py +1815 -0
  303. numba_cuda/numba/cuda/tests/cudapy/test_bfloat16.py +599 -0
  304. numba_cuda/numba/cuda/tests/cudapy/test_bfloat16_bindings.py +377 -0
  305. numba_cuda/numba/cuda/tests/cudapy/test_blackscholes.py +160 -0
  306. numba_cuda/numba/cuda/tests/cudapy/test_boolean.py +27 -0
  307. numba_cuda/numba/cuda/tests/cudapy/test_byteflow.py +98 -0
  308. numba_cuda/numba/cuda/tests/cudapy/test_cache_hints.py +210 -0
  309. numba_cuda/numba/cuda/tests/cudapy/test_caching.py +683 -0
  310. numba_cuda/numba/cuda/tests/cudapy/test_casting.py +265 -0
  311. numba_cuda/numba/cuda/tests/cudapy/test_cffi.py +42 -0
  312. numba_cuda/numba/cuda/tests/cudapy/test_compiler.py +718 -0
  313. numba_cuda/numba/cuda/tests/cudapy/test_complex.py +370 -0
  314. numba_cuda/numba/cuda/tests/cudapy/test_complex_kernel.py +23 -0
  315. numba_cuda/numba/cuda/tests/cudapy/test_const_string.py +142 -0
  316. numba_cuda/numba/cuda/tests/cudapy/test_constmem.py +178 -0
  317. numba_cuda/numba/cuda/tests/cudapy/test_cooperative_groups.py +193 -0
  318. numba_cuda/numba/cuda/tests/cudapy/test_copy_propagate.py +131 -0
  319. numba_cuda/numba/cuda/tests/cudapy/test_cuda_array_interface.py +438 -0
  320. numba_cuda/numba/cuda/tests/cudapy/test_cuda_jit_no_types.py +94 -0
  321. numba_cuda/numba/cuda/tests/cudapy/test_datetime.py +101 -0
  322. numba_cuda/numba/cuda/tests/cudapy/test_debug.py +105 -0
  323. numba_cuda/numba/cuda/tests/cudapy/test_debuginfo.py +978 -0
  324. numba_cuda/numba/cuda/tests/cudapy/test_debuginfo_types.py +476 -0
  325. numba_cuda/numba/cuda/tests/cudapy/test_device_func.py +500 -0
  326. numba_cuda/numba/cuda/tests/cudapy/test_dispatcher.py +820 -0
  327. numba_cuda/numba/cuda/tests/cudapy/test_enums.py +152 -0
  328. numba_cuda/numba/cuda/tests/cudapy/test_errors.py +111 -0
  329. numba_cuda/numba/cuda/tests/cudapy/test_exception.py +170 -0
  330. numba_cuda/numba/cuda/tests/cudapy/test_extending.py +1088 -0
  331. numba_cuda/numba/cuda/tests/cudapy/test_extending_types.py +71 -0
  332. numba_cuda/numba/cuda/tests/cudapy/test_fastmath.py +265 -0
  333. numba_cuda/numba/cuda/tests/cudapy/test_flow_control.py +1433 -0
  334. numba_cuda/numba/cuda/tests/cudapy/test_forall.py +57 -0
  335. numba_cuda/numba/cuda/tests/cudapy/test_freevar.py +34 -0
  336. numba_cuda/numba/cuda/tests/cudapy/test_frexp_ldexp.py +69 -0
  337. numba_cuda/numba/cuda/tests/cudapy/test_globals.py +62 -0
  338. numba_cuda/numba/cuda/tests/cudapy/test_gufunc.py +474 -0
  339. numba_cuda/numba/cuda/tests/cudapy/test_gufunc_scalar.py +167 -0
  340. numba_cuda/numba/cuda/tests/cudapy/test_gufunc_scheduling.py +92 -0
  341. numba_cuda/numba/cuda/tests/cudapy/test_idiv.py +39 -0
  342. numba_cuda/numba/cuda/tests/cudapy/test_inline.py +170 -0
  343. numba_cuda/numba/cuda/tests/cudapy/test_inspect.py +255 -0
  344. numba_cuda/numba/cuda/tests/cudapy/test_intrinsics.py +1219 -0
  345. numba_cuda/numba/cuda/tests/cudapy/test_ipc.py +263 -0
  346. numba_cuda/numba/cuda/tests/cudapy/test_ir.py +598 -0
  347. numba_cuda/numba/cuda/tests/cudapy/test_ir_utils.py +276 -0
  348. numba_cuda/numba/cuda/tests/cudapy/test_iterators.py +101 -0
  349. numba_cuda/numba/cuda/tests/cudapy/test_lang.py +68 -0
  350. numba_cuda/numba/cuda/tests/cudapy/test_laplace.py +123 -0
  351. numba_cuda/numba/cuda/tests/cudapy/test_libdevice.py +194 -0
  352. numba_cuda/numba/cuda/tests/cudapy/test_lineinfo.py +220 -0
  353. numba_cuda/numba/cuda/tests/cudapy/test_localmem.py +173 -0
  354. numba_cuda/numba/cuda/tests/cudapy/test_make_function_to_jit_function.py +364 -0
  355. numba_cuda/numba/cuda/tests/cudapy/test_mandel.py +47 -0
  356. numba_cuda/numba/cuda/tests/cudapy/test_math.py +842 -0
  357. numba_cuda/numba/cuda/tests/cudapy/test_matmul.py +76 -0
  358. numba_cuda/numba/cuda/tests/cudapy/test_minmax.py +78 -0
  359. numba_cuda/numba/cuda/tests/cudapy/test_montecarlo.py +25 -0
  360. numba_cuda/numba/cuda/tests/cudapy/test_multigpu.py +145 -0
  361. numba_cuda/numba/cuda/tests/cudapy/test_multiprocessing.py +39 -0
  362. numba_cuda/numba/cuda/tests/cudapy/test_multithreads.py +82 -0
  363. numba_cuda/numba/cuda/tests/cudapy/test_nondet.py +53 -0
  364. numba_cuda/numba/cuda/tests/cudapy/test_operator.py +504 -0
  365. numba_cuda/numba/cuda/tests/cudapy/test_optimization.py +93 -0
  366. numba_cuda/numba/cuda/tests/cudapy/test_overload.py +402 -0
  367. numba_cuda/numba/cuda/tests/cudapy/test_powi.py +128 -0
  368. numba_cuda/numba/cuda/tests/cudapy/test_print.py +193 -0
  369. numba_cuda/numba/cuda/tests/cudapy/test_py2_div_issue.py +37 -0
  370. numba_cuda/numba/cuda/tests/cudapy/test_random.py +117 -0
  371. numba_cuda/numba/cuda/tests/cudapy/test_record_dtype.py +614 -0
  372. numba_cuda/numba/cuda/tests/cudapy/test_recursion.py +130 -0
  373. numba_cuda/numba/cuda/tests/cudapy/test_reduction.py +94 -0
  374. numba_cuda/numba/cuda/tests/cudapy/test_retrieve_autoconverted_arrays.py +83 -0
  375. numba_cuda/numba/cuda/tests/cudapy/test_serialize.py +86 -0
  376. numba_cuda/numba/cuda/tests/cudapy/test_slicing.py +40 -0
  377. numba_cuda/numba/cuda/tests/cudapy/test_sm.py +457 -0
  378. numba_cuda/numba/cuda/tests/cudapy/test_sm_creation.py +233 -0
  379. numba_cuda/numba/cuda/tests/cudapy/test_ssa.py +454 -0
  380. numba_cuda/numba/cuda/tests/cudapy/test_stream_api.py +56 -0
  381. numba_cuda/numba/cuda/tests/cudapy/test_sync.py +277 -0
  382. numba_cuda/numba/cuda/tests/cudapy/test_tracing.py +200 -0
  383. numba_cuda/numba/cuda/tests/cudapy/test_transpose.py +90 -0
  384. numba_cuda/numba/cuda/tests/cudapy/test_typeconv.py +333 -0
  385. numba_cuda/numba/cuda/tests/cudapy/test_typeinfer.py +538 -0
  386. numba_cuda/numba/cuda/tests/cudapy/test_ufuncs.py +585 -0
  387. numba_cuda/numba/cuda/tests/cudapy/test_userexc.py +42 -0
  388. numba_cuda/numba/cuda/tests/cudapy/test_vector_type.py +485 -0
  389. numba_cuda/numba/cuda/tests/cudapy/test_vectorize.py +312 -0
  390. numba_cuda/numba/cuda/tests/cudapy/test_vectorize_complex.py +23 -0
  391. numba_cuda/numba/cuda/tests/cudapy/test_vectorize_decor.py +183 -0
  392. numba_cuda/numba/cuda/tests/cudapy/test_vectorize_device.py +40 -0
  393. numba_cuda/numba/cuda/tests/cudapy/test_vectorize_scalar_arg.py +40 -0
  394. numba_cuda/numba/cuda/tests/cudapy/test_warning.py +206 -0
  395. numba_cuda/numba/cuda/tests/cudapy/test_warp_ops.py +446 -0
  396. numba_cuda/numba/cuda/tests/cudasim/__init__.py +9 -0
  397. numba_cuda/numba/cuda/tests/cudasim/support.py +9 -0
  398. numba_cuda/numba/cuda/tests/cudasim/test_cudasim_issues.py +111 -0
  399. numba_cuda/numba/cuda/tests/data/__init__.py +2 -0
  400. numba_cuda/numba/cuda/tests/data/cta_barrier.cu +28 -0
  401. numba_cuda/numba/cuda/tests/data/cuda_include.cu +10 -0
  402. numba_cuda/numba/cuda/tests/data/error.cu +12 -0
  403. numba_cuda/numba/cuda/tests/data/include/add.cuh +8 -0
  404. numba_cuda/numba/cuda/tests/data/jitlink.cu +28 -0
  405. numba_cuda/numba/cuda/tests/data/jitlink.ptx +49 -0
  406. numba_cuda/numba/cuda/tests/data/warn.cu +12 -0
  407. numba_cuda/numba/cuda/tests/doc_examples/__init__.py +9 -0
  408. numba_cuda/numba/cuda/tests/doc_examples/ffi/__init__.py +2 -0
  409. numba_cuda/numba/cuda/tests/doc_examples/ffi/functions.cu +54 -0
  410. numba_cuda/numba/cuda/tests/doc_examples/ffi/include/mul.cuh +8 -0
  411. numba_cuda/numba/cuda/tests/doc_examples/ffi/saxpy.cu +14 -0
  412. numba_cuda/numba/cuda/tests/doc_examples/test_cg.py +86 -0
  413. numba_cuda/numba/cuda/tests/doc_examples/test_cpointer.py +68 -0
  414. numba_cuda/numba/cuda/tests/doc_examples/test_cpu_gpu_compat.py +81 -0
  415. numba_cuda/numba/cuda/tests/doc_examples/test_ffi.py +141 -0
  416. numba_cuda/numba/cuda/tests/doc_examples/test_laplace.py +160 -0
  417. numba_cuda/numba/cuda/tests/doc_examples/test_matmul.py +180 -0
  418. numba_cuda/numba/cuda/tests/doc_examples/test_montecarlo.py +119 -0
  419. numba_cuda/numba/cuda/tests/doc_examples/test_random.py +66 -0
  420. numba_cuda/numba/cuda/tests/doc_examples/test_reduction.py +80 -0
  421. numba_cuda/numba/cuda/tests/doc_examples/test_sessionize.py +206 -0
  422. numba_cuda/numba/cuda/tests/doc_examples/test_ufunc.py +53 -0
  423. numba_cuda/numba/cuda/tests/doc_examples/test_vecadd.py +76 -0
  424. numba_cuda/numba/cuda/tests/nocuda/__init__.py +9 -0
  425. numba_cuda/numba/cuda/tests/nocuda/test_dummyarray.py +452 -0
  426. numba_cuda/numba/cuda/tests/nocuda/test_function_resolution.py +48 -0
  427. numba_cuda/numba/cuda/tests/nocuda/test_import.py +63 -0
  428. numba_cuda/numba/cuda/tests/nocuda/test_library_lookup.py +252 -0
  429. numba_cuda/numba/cuda/tests/nocuda/test_nvvm.py +59 -0
  430. numba_cuda/numba/cuda/tests/nrt/__init__.py +9 -0
  431. numba_cuda/numba/cuda/tests/nrt/test_nrt.py +387 -0
  432. numba_cuda/numba/cuda/tests/nrt/test_nrt_refct.py +124 -0
  433. numba_cuda/numba/cuda/tests/support.py +900 -0
  434. numba_cuda/numba/cuda/typeconv/__init__.py +4 -0
  435. numba_cuda/numba/cuda/typeconv/castgraph.py +137 -0
  436. numba_cuda/numba/cuda/typeconv/rules.py +63 -0
  437. numba_cuda/numba/cuda/typeconv/typeconv.py +121 -0
  438. numba_cuda/numba/cuda/types/__init__.py +233 -0
  439. numba_cuda/numba/cuda/types/__init__.pyi +167 -0
  440. numba_cuda/numba/cuda/types/abstract.py +9 -0
  441. numba_cuda/numba/cuda/types/common.py +9 -0
  442. numba_cuda/numba/cuda/types/containers.py +9 -0
  443. numba_cuda/numba/cuda/types/cuda_abstract.py +533 -0
  444. numba_cuda/numba/cuda/types/cuda_common.py +110 -0
  445. numba_cuda/numba/cuda/types/cuda_containers.py +971 -0
  446. numba_cuda/numba/cuda/types/cuda_function_type.py +230 -0
  447. numba_cuda/numba/cuda/types/cuda_functions.py +798 -0
  448. numba_cuda/numba/cuda/types/cuda_iterators.py +120 -0
  449. numba_cuda/numba/cuda/types/cuda_misc.py +569 -0
  450. numba_cuda/numba/cuda/types/cuda_npytypes.py +690 -0
  451. numba_cuda/numba/cuda/types/cuda_scalars.py +280 -0
  452. numba_cuda/numba/cuda/types/ext_types.py +101 -0
  453. numba_cuda/numba/cuda/types/function_type.py +11 -0
  454. numba_cuda/numba/cuda/types/functions.py +9 -0
  455. numba_cuda/numba/cuda/types/iterators.py +9 -0
  456. numba_cuda/numba/cuda/types/misc.py +9 -0
  457. numba_cuda/numba/cuda/types/npytypes.py +9 -0
  458. numba_cuda/numba/cuda/types/scalars.py +9 -0
  459. numba_cuda/numba/cuda/typing/__init__.py +19 -0
  460. numba_cuda/numba/cuda/typing/arraydecl.py +939 -0
  461. numba_cuda/numba/cuda/typing/asnumbatype.py +130 -0
  462. numba_cuda/numba/cuda/typing/bufproto.py +70 -0
  463. numba_cuda/numba/cuda/typing/builtins.py +1209 -0
  464. numba_cuda/numba/cuda/typing/cffi_utils.py +219 -0
  465. numba_cuda/numba/cuda/typing/cmathdecl.py +47 -0
  466. numba_cuda/numba/cuda/typing/collections.py +138 -0
  467. numba_cuda/numba/cuda/typing/context.py +782 -0
  468. numba_cuda/numba/cuda/typing/ctypes_utils.py +125 -0
  469. numba_cuda/numba/cuda/typing/dictdecl.py +63 -0
  470. numba_cuda/numba/cuda/typing/enumdecl.py +74 -0
  471. numba_cuda/numba/cuda/typing/listdecl.py +147 -0
  472. numba_cuda/numba/cuda/typing/mathdecl.py +158 -0
  473. numba_cuda/numba/cuda/typing/npdatetime.py +322 -0
  474. numba_cuda/numba/cuda/typing/npydecl.py +749 -0
  475. numba_cuda/numba/cuda/typing/setdecl.py +115 -0
  476. numba_cuda/numba/cuda/typing/templates.py +1446 -0
  477. numba_cuda/numba/cuda/typing/typeof.py +301 -0
  478. numba_cuda/numba/cuda/ufuncs.py +746 -0
  479. numba_cuda/numba/cuda/utils.py +724 -0
  480. numba_cuda/numba/cuda/vector_types.py +214 -0
  481. numba_cuda/numba/cuda/vectorizers.py +260 -0
  482. numba_cuda-0.22.0.dist-info/METADATA +109 -0
  483. numba_cuda-0.22.0.dist-info/RECORD +487 -0
  484. numba_cuda-0.22.0.dist-info/WHEEL +6 -0
  485. numba_cuda-0.22.0.dist-info/licenses/LICENSE +26 -0
  486. numba_cuda-0.22.0.dist-info/licenses/LICENSE.numba +24 -0
  487. numba_cuda-0.22.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,1597 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2
+ # SPDX-License-Identifier: BSD-2-Clause
3
+
4
+ """
5
+ This module contains support functions for more advanced unicode operations.
6
+ This is not a public API and is for Numba internal use only. Most of the
7
+ functions are relatively straightforward translations of the functions with the
8
+ same name in CPython.
9
+ """
10
+
11
+ from collections import namedtuple
12
+ from enum import IntEnum
13
+
14
+ import llvmlite.ir
15
+ import numpy as np
16
+
17
+ from numba.cuda import types
18
+ from numba.cuda import cgutils
19
+ from numba.cuda.core.imputils import impl_ret_untracked
20
+
21
+ from numba.cuda.extending import overload, register_jitable
22
+ from numba.cuda.extending import intrinsic
23
+ from numba.cuda.core.errors import TypingError
24
+
25
+ # This is equivalent to the struct `_PyUnicode_TypeRecord defined in CPython's
26
+ # Objects/unicodectype.c
27
+ typerecord = namedtuple("typerecord", "upper lower title decimal digit flags")
28
+
29
+ # The Py_UCS4 type from CPython:
30
+ # https://github.com/python/cpython/blob/1d4b6ba19466aba0eb91c4ba01ba509acf18c723/Include/unicodeobject.h#L112 # noqa: E501
31
+ _Py_UCS4 = types.uint32
32
+
33
+ # ------------------------------------------------------------------------------
34
+ # Start code related to/from CPython's unicodectype impl
35
+ #
36
+ # NOTE: the original source at:
37
+ # https://github.com/python/cpython/blob/1d4b6ba19466aba0eb91c4ba01ba509acf18c723/Objects/unicodectype.c # noqa: E501
38
+ # contains this statement:
39
+ #
40
+ # /*
41
+ # Unicode character type helpers.
42
+ #
43
+ # Written by Marc-Andre Lemburg (mal@lemburg.com).
44
+ # Modified for Python 2.0 by Fredrik Lundh (fredrik@pythonware.com)
45
+ #
46
+ # Copyright (c) Corporation for National Research Initiatives.
47
+ #
48
+ # */
49
+
50
+
51
+ # This enum contains the values defined in CPython's Objects/unicodectype.c that
52
+ # provide masks for use against the various members of the typerecord
53
+ #
54
+ # See: https://github.com/python/cpython/blob/1d4b6ba19466aba0eb91c4ba01ba509acf18c723/Objects/unicodectype.c#L13-L27 # noqa: E501
55
+ #
56
+
57
+
58
+ _Py_TAB = 0x9
59
+ _Py_LINEFEED = 0xA
60
+ _Py_CARRIAGE_RETURN = 0xD
61
+ _Py_SPACE = 0x20
62
+
63
+
64
+ class _PyUnicode_TyperecordMasks(IntEnum):
65
+ ALPHA_MASK = 0x01
66
+ DECIMAL_MASK = 0x02
67
+ DIGIT_MASK = 0x04
68
+ LOWER_MASK = 0x08
69
+ LINEBREAK_MASK = 0x10
70
+ SPACE_MASK = 0x20
71
+ TITLE_MASK = 0x40
72
+ UPPER_MASK = 0x80
73
+ XID_START_MASK = 0x100
74
+ XID_CONTINUE_MASK = 0x200
75
+ PRINTABLE_MASK = 0x400
76
+ NUMERIC_MASK = 0x800
77
+ CASE_IGNORABLE_MASK = 0x1000
78
+ CASED_MASK = 0x2000
79
+ EXTENDED_CASE_MASK = 0x4000
80
+
81
+
82
+ def _PyUnicode_gettyperecord(a):
83
+ raise RuntimeError("Calling the Python definition is invalid")
84
+
85
+
86
+ @intrinsic
87
+ def _gettyperecord_impl(typingctx, codepoint):
88
+ """
89
+ Provides the binding to numba_gettyperecord, returns a `typerecord`
90
+ namedtuple of properties from the codepoint.
91
+ """
92
+ if not isinstance(codepoint, types.Integer):
93
+ raise TypingError("codepoint must be an integer")
94
+
95
+ def details(context, builder, signature, args):
96
+ ll_void = context.get_value_type(types.void)
97
+ ll_Py_UCS4 = context.get_value_type(_Py_UCS4)
98
+ ll_intc = context.get_value_type(types.intc)
99
+ ll_intc_ptr = ll_intc.as_pointer()
100
+ ll_uchar = context.get_value_type(types.uchar)
101
+ ll_uchar_ptr = ll_uchar.as_pointer()
102
+ ll_ushort = context.get_value_type(types.ushort)
103
+ ll_ushort_ptr = ll_ushort.as_pointer()
104
+ fnty = llvmlite.ir.FunctionType(
105
+ ll_void,
106
+ [
107
+ ll_Py_UCS4, # code
108
+ ll_intc_ptr, # upper
109
+ ll_intc_ptr, # lower
110
+ ll_intc_ptr, # title
111
+ ll_uchar_ptr, # decimal
112
+ ll_uchar_ptr, # digit
113
+ ll_ushort_ptr, # flags
114
+ ],
115
+ )
116
+ fn = cgutils.get_or_insert_function(
117
+ builder.module, fnty, name="numba_gettyperecord"
118
+ )
119
+ upper = cgutils.alloca_once(builder, ll_intc, name="upper")
120
+ lower = cgutils.alloca_once(builder, ll_intc, name="lower")
121
+ title = cgutils.alloca_once(builder, ll_intc, name="title")
122
+ decimal = cgutils.alloca_once(builder, ll_uchar, name="decimal")
123
+ digit = cgutils.alloca_once(builder, ll_uchar, name="digit")
124
+ flags = cgutils.alloca_once(builder, ll_ushort, name="flags")
125
+
126
+ byref = [upper, lower, title, decimal, digit, flags]
127
+ builder.call(fn, [args[0]] + byref)
128
+ buf = []
129
+ for x in byref:
130
+ buf.append(builder.load(x))
131
+
132
+ res = context.make_tuple(builder, signature.return_type, tuple(buf))
133
+ return impl_ret_untracked(context, builder, signature.return_type, res)
134
+
135
+ tupty = types.NamedTuple(
136
+ [
137
+ types.intc,
138
+ types.intc,
139
+ types.intc,
140
+ types.uchar,
141
+ types.uchar,
142
+ types.ushort,
143
+ ],
144
+ typerecord,
145
+ )
146
+ sig = tupty(_Py_UCS4)
147
+ return sig, details
148
+
149
+
150
+ @overload(_PyUnicode_gettyperecord)
151
+ def gettyperecord_impl(a):
152
+ """
153
+ Provides a _PyUnicode_gettyperecord binding, for convenience it will accept
154
+ single character strings and code points.
155
+ """
156
+ if isinstance(a, types.UnicodeType):
157
+ from numba.cuda.cpython.unicode import _get_code_point
158
+
159
+ def impl(a):
160
+ if len(a) > 1:
161
+ msg = "gettyperecord takes a single unicode character"
162
+ raise ValueError(msg)
163
+ code_point = _get_code_point(a, 0)
164
+ data = _gettyperecord_impl(_Py_UCS4(code_point))
165
+ return data
166
+
167
+ return impl
168
+ if isinstance(a, types.Integer):
169
+ return lambda a: _gettyperecord_impl(_Py_UCS4(a))
170
+
171
+
172
+ # whilst it's possible to grab the _PyUnicode_ExtendedCase symbol as it's global
173
+ # it is safer to use a defined api:
174
+ @intrinsic
175
+ def _PyUnicode_ExtendedCase(typingctx, index):
176
+ """
177
+ Accessor function for the _PyUnicode_ExtendedCase array, binds to
178
+ numba_get_PyUnicode_ExtendedCase which wraps the array and does the lookup
179
+ """
180
+ if not isinstance(index, types.Integer):
181
+ raise TypingError("Expected an index")
182
+
183
+ def details(context, builder, signature, args):
184
+ ll_Py_UCS4 = context.get_value_type(_Py_UCS4)
185
+ ll_intc = context.get_value_type(types.intc)
186
+ fnty = llvmlite.ir.FunctionType(ll_Py_UCS4, [ll_intc])
187
+ fn = cgutils.get_or_insert_function(
188
+ builder.module, fnty, name="numba_get_PyUnicode_ExtendedCase"
189
+ )
190
+ return builder.call(fn, [args[0]])
191
+
192
+ sig = _Py_UCS4(types.intc)
193
+ return sig, details
194
+
195
+
196
+ # The following functions are replications of the functions with the same name
197
+ # in CPython's Objects/unicodectype.c
198
+
199
+
200
+ # From: https://github.com/python/cpython/blob/1d4b6ba19466aba0eb91c4ba01ba509acf18c723/Objects/unicodectype.c#L64-L71 # noqa: E501
201
+ @register_jitable
202
+ def _PyUnicode_ToTitlecase(ch):
203
+ ctype = _PyUnicode_gettyperecord(ch)
204
+ if ctype.flags & _PyUnicode_TyperecordMasks.EXTENDED_CASE_MASK:
205
+ return _PyUnicode_ExtendedCase(ctype.title & 0xFFFF)
206
+ return ch + ctype.title
207
+
208
+
209
+ # From: https://github.com/python/cpython/blob/1d4b6ba19466aba0eb91c4ba01ba509acf18c723/Objects/unicodectype.c#L76-L81 # noqa: E501
210
+ @register_jitable
211
+ def _PyUnicode_IsTitlecase(ch):
212
+ ctype = _PyUnicode_gettyperecord(ch)
213
+ return ctype.flags & _PyUnicode_TyperecordMasks.TITLE_MASK != 0
214
+
215
+
216
+ # From: https://github.com/python/cpython/blob/1d4b6ba19466aba0eb91c4ba01ba509acf18c723/Objects/unicodectype.c#L86-L91 # noqa: E501
217
+ @register_jitable
218
+ def _PyUnicode_IsXidStart(ch):
219
+ ctype = _PyUnicode_gettyperecord(ch)
220
+ return ctype.flags & _PyUnicode_TyperecordMasks.XID_START_MASK != 0
221
+
222
+
223
+ # From: https://github.com/python/cpython/blob/1d4b6ba19466aba0eb91c4ba01ba509acf18c723/Objects/unicodectype.c#L96-L101 # noqa: E501
224
+ @register_jitable
225
+ def _PyUnicode_IsXidContinue(ch):
226
+ ctype = _PyUnicode_gettyperecord(ch)
227
+ return ctype.flags & _PyUnicode_TyperecordMasks.XID_CONTINUE_MASK != 0
228
+
229
+
230
+ @register_jitable
231
+ def _PyUnicode_ToDecimalDigit(ch):
232
+ ctype = _PyUnicode_gettyperecord(ch)
233
+ if ctype.flags & _PyUnicode_TyperecordMasks.DECIMAL_MASK:
234
+ return ctype.decimal
235
+ return -1
236
+
237
+
238
+ # From: https://github.com/python/cpython/blob/1d4b6ba19466aba0eb91c4ba01ba509acf18c723/Objects/unicodectype.c#L123-L1128 # noqa: E501
239
+ @register_jitable
240
+ def _PyUnicode_ToDigit(ch):
241
+ ctype = _PyUnicode_gettyperecord(ch)
242
+ if ctype.flags & _PyUnicode_TyperecordMasks.DIGIT_MASK:
243
+ return ctype.digit
244
+ return -1
245
+
246
+
247
+ # From: https://github.com/python/cpython/blob/1d4b6ba19466aba0eb91c4ba01ba509acf18c723/Objects/unicodectype.c#L140-L145 # noqa: E501
248
+ @register_jitable
249
+ def _PyUnicode_IsNumeric(ch):
250
+ ctype = _PyUnicode_gettyperecord(ch)
251
+ return ctype.flags & _PyUnicode_TyperecordMasks.NUMERIC_MASK != 0
252
+
253
+
254
+ # From: https://github.com/python/cpython/blob/1d4b6ba19466aba0eb91c4ba01ba509acf18c723/Objects/unicodectype.c#L160-L165 # noqa: E501
255
+ @register_jitable
256
+ def _PyUnicode_IsPrintable(ch):
257
+ ctype = _PyUnicode_gettyperecord(ch)
258
+ return ctype.flags & _PyUnicode_TyperecordMasks.PRINTABLE_MASK != 0
259
+
260
+
261
+ # From: https://github.com/python/cpython/blob/1d4b6ba19466aba0eb91c4ba01ba509acf18c723/Objects/unicodectype.c#L170-L175 # noqa: E501
262
+ @register_jitable
263
+ def _PyUnicode_IsLowercase(ch):
264
+ ctype = _PyUnicode_gettyperecord(ch)
265
+ return ctype.flags & _PyUnicode_TyperecordMasks.LOWER_MASK != 0
266
+
267
+
268
+ # From: https://github.com/python/cpython/blob/1d4b6ba19466aba0eb91c4ba01ba509acf18c723/Objects/unicodectype.c#L180-L185 # noqa: E501
269
+ @register_jitable
270
+ def _PyUnicode_IsUppercase(ch):
271
+ ctype = _PyUnicode_gettyperecord(ch)
272
+ return ctype.flags & _PyUnicode_TyperecordMasks.UPPER_MASK != 0
273
+
274
+
275
+ @register_jitable
276
+ def _PyUnicode_IsLineBreak(ch):
277
+ ctype = _PyUnicode_gettyperecord(ch)
278
+ return ctype.flags & _PyUnicode_TyperecordMasks.LINEBREAK_MASK != 0
279
+
280
+
281
+ @register_jitable
282
+ def _PyUnicode_ToUppercase(ch):
283
+ raise NotImplementedError
284
+
285
+
286
+ @register_jitable
287
+ def _PyUnicode_ToLowercase(ch):
288
+ raise NotImplementedError
289
+
290
+
291
+ # From: https://github.com/python/cpython/blob/201c8f79450628241574fba940e08107178dc3a5/Objects/unicodectype.c#L211-L225 # noqa: E501
292
+ @register_jitable
293
+ def _PyUnicode_ToLowerFull(ch, res):
294
+ ctype = _PyUnicode_gettyperecord(ch)
295
+ if ctype.flags & _PyUnicode_TyperecordMasks.EXTENDED_CASE_MASK:
296
+ index = ctype.lower & 0xFFFF
297
+ n = ctype.lower >> 24
298
+ for i in range(n):
299
+ res[i] = _PyUnicode_ExtendedCase(index + i)
300
+ return n
301
+ res[0] = ch + ctype.lower
302
+ return 1
303
+
304
+
305
+ # From: https://github.com/python/cpython/blob/201c8f79450628241574fba940e08107178dc3a5/Objects/unicodectype.c#L227-L241 # noqa: E501
306
+ @register_jitable
307
+ def _PyUnicode_ToTitleFull(ch, res):
308
+ ctype = _PyUnicode_gettyperecord(ch)
309
+ if ctype.flags & _PyUnicode_TyperecordMasks.EXTENDED_CASE_MASK:
310
+ index = ctype.title & 0xFFFF
311
+ n = ctype.title >> 24
312
+ for i in range(n):
313
+ res[i] = _PyUnicode_ExtendedCase(index + i)
314
+ return n
315
+ res[0] = ch + ctype.title
316
+ return 1
317
+
318
+
319
+ # From: https://github.com/python/cpython/blob/1d4b6ba19466aba0eb91c4ba01ba509acf18c723/Objects/unicodectype.c#L243-L257 # noqa: E501
320
+ @register_jitable
321
+ def _PyUnicode_ToUpperFull(ch, res):
322
+ ctype = _PyUnicode_gettyperecord(ch)
323
+ if ctype.flags & _PyUnicode_TyperecordMasks.EXTENDED_CASE_MASK:
324
+ index = ctype.upper & 0xFFFF
325
+ n = ctype.upper >> 24
326
+ for i in range(n):
327
+ # Perhaps needed to use unicode._set_code_point() here
328
+ res[i] = _PyUnicode_ExtendedCase(index + i)
329
+ return n
330
+ res[0] = ch + ctype.upper
331
+ return 1
332
+
333
+
334
+ # From: https://github.com/python/cpython/blob/1d4b6ba19466aba0eb91c4ba01ba509acf18c723/Objects/unicodectype.c#L259-L272 # noqa: E501
335
+ @register_jitable
336
+ def _PyUnicode_ToFoldedFull(ch, res):
337
+ ctype = _PyUnicode_gettyperecord(ch)
338
+ extended_case_mask = _PyUnicode_TyperecordMasks.EXTENDED_CASE_MASK
339
+ if ctype.flags & extended_case_mask and (ctype.lower >> 20) & 7:
340
+ index = (ctype.lower & 0xFFFF) + (ctype.lower >> 24)
341
+ n = (ctype.lower >> 20) & 7
342
+ for i in range(n):
343
+ res[i] = _PyUnicode_ExtendedCase(index + i)
344
+ return n
345
+ return _PyUnicode_ToLowerFull(ch, res)
346
+
347
+
348
+ # From: https://github.com/python/cpython/blob/1d4b6ba19466aba0eb91c4ba01ba509acf18c723/Objects/unicodectype.c#L274-L279 # noqa: E501
349
+ @register_jitable
350
+ def _PyUnicode_IsCased(ch):
351
+ ctype = _PyUnicode_gettyperecord(ch)
352
+ return ctype.flags & _PyUnicode_TyperecordMasks.CASED_MASK != 0
353
+
354
+
355
+ # From: https://github.com/python/cpython/blob/1d4b6ba19466aba0eb91c4ba01ba509acf18c723/Objects/unicodectype.c#L281-L286 # noqa: E501
356
+ @register_jitable
357
+ def _PyUnicode_IsCaseIgnorable(ch):
358
+ ctype = _PyUnicode_gettyperecord(ch)
359
+ return ctype.flags & _PyUnicode_TyperecordMasks.CASE_IGNORABLE_MASK != 0
360
+
361
+
362
+ # From: https://github.com/python/cpython/blob/1d4b6ba19466aba0eb91c4ba01ba509acf18c723/Objects/unicodectype.c#L123-L135 # noqa: E501
363
+ @register_jitable
364
+ def _PyUnicode_IsDigit(ch):
365
+ if _PyUnicode_ToDigit(ch) < 0:
366
+ return 0
367
+ return 1
368
+
369
+
370
+ # From: https://github.com/python/cpython/blob/1d4b6ba19466aba0eb91c4ba01ba509acf18c723/Objects/unicodectype.c#L106-L118 # noqa: E501
371
+ @register_jitable
372
+ def _PyUnicode_IsDecimalDigit(ch):
373
+ if _PyUnicode_ToDecimalDigit(ch) < 0:
374
+ return 0
375
+ return 1
376
+
377
+
378
+ # From: https://github.com/python/cpython/blob/1d4b6ba19466aba0eb91c4ba01ba509acf18c723/Objects/unicodectype.c#L291-L296 # noqa: E501
379
+ @register_jitable
380
+ def _PyUnicode_IsSpace(ch):
381
+ ctype = _PyUnicode_gettyperecord(ch)
382
+ return ctype.flags & _PyUnicode_TyperecordMasks.SPACE_MASK != 0
383
+
384
+
385
+ @register_jitable
386
+ def _PyUnicode_IsAlpha(ch):
387
+ ctype = _PyUnicode_gettyperecord(ch)
388
+ return ctype.flags & _PyUnicode_TyperecordMasks.ALPHA_MASK != 0
389
+
390
+
391
+ # End code related to/from CPython's unicodectype impl
392
+ # ------------------------------------------------------------------------------
393
+
394
+
395
+ # ------------------------------------------------------------------------------
396
+ # Start code related to/from CPython's pyctype
397
+
398
+
399
+ # From the definition in CPython's Include/pyctype.h
400
+ # From: https://github.com/python/cpython/blob/1d4b6ba19466aba0eb91c4ba01ba509acf18c723/Include/pyctype.h#L5-L11 # noqa: E501
401
+ class _PY_CTF(IntEnum):
402
+ LOWER = 0x01
403
+ UPPER = 0x02
404
+ ALPHA = 0x01 | 0x02
405
+ DIGIT = 0x04
406
+ ALNUM = 0x01 | 0x02 | 0x04
407
+ SPACE = 0x08
408
+ XDIGIT = 0x10
409
+
410
+
411
+ # From the definition in CPython's Python/pyctype.c
412
+ # https://github.com/python/cpython/blob/1d4b6ba19466aba0eb91c4ba01ba509acf18c723/Python/pyctype.c#L5 # noqa: E501
413
+ _Py_ctype_table = np.array(
414
+ [
415
+ 0, # 0x0 '\x00'
416
+ 0, # 0x1 '\x01'
417
+ 0, # 0x2 '\x02'
418
+ 0, # 0x3 '\x03'
419
+ 0, # 0x4 '\x04'
420
+ 0, # 0x5 '\x05'
421
+ 0, # 0x6 '\x06'
422
+ 0, # 0x7 '\x07'
423
+ 0, # 0x8 '\x08'
424
+ _PY_CTF.SPACE, # 0x9 '\t'
425
+ _PY_CTF.SPACE, # 0xa '\n'
426
+ _PY_CTF.SPACE, # 0xb '\v'
427
+ _PY_CTF.SPACE, # 0xc '\f'
428
+ _PY_CTF.SPACE, # 0xd '\r'
429
+ 0, # 0xe '\x0e'
430
+ 0, # 0xf '\x0f'
431
+ 0, # 0x10 '\x10'
432
+ 0, # 0x11 '\x11'
433
+ 0, # 0x12 '\x12'
434
+ 0, # 0x13 '\x13'
435
+ 0, # 0x14 '\x14'
436
+ 0, # 0x15 '\x15'
437
+ 0, # 0x16 '\x16'
438
+ 0, # 0x17 '\x17'
439
+ 0, # 0x18 '\x18'
440
+ 0, # 0x19 '\x19'
441
+ 0, # 0x1a '\x1a'
442
+ 0, # 0x1b '\x1b'
443
+ 0, # 0x1c '\x1c'
444
+ 0, # 0x1d '\x1d'
445
+ 0, # 0x1e '\x1e'
446
+ 0, # 0x1f '\x1f'
447
+ _PY_CTF.SPACE, # 0x20 ' '
448
+ 0, # 0x21 '!'
449
+ 0, # 0x22 '"'
450
+ 0, # 0x23 '#'
451
+ 0, # 0x24 '$'
452
+ 0, # 0x25 '%'
453
+ 0, # 0x26 '&'
454
+ 0, # 0x27 "'"
455
+ 0, # 0x28 '('
456
+ 0, # 0x29 ')'
457
+ 0, # 0x2a '*'
458
+ 0, # 0x2b '+'
459
+ 0, # 0x2c ','
460
+ 0, # 0x2d '-'
461
+ 0, # 0x2e '.'
462
+ 0, # 0x2f '/'
463
+ _PY_CTF.DIGIT | _PY_CTF.XDIGIT, # 0x30 '0'
464
+ _PY_CTF.DIGIT | _PY_CTF.XDIGIT, # 0x31 '1'
465
+ _PY_CTF.DIGIT | _PY_CTF.XDIGIT, # 0x32 '2'
466
+ _PY_CTF.DIGIT | _PY_CTF.XDIGIT, # 0x33 '3'
467
+ _PY_CTF.DIGIT | _PY_CTF.XDIGIT, # 0x34 '4'
468
+ _PY_CTF.DIGIT | _PY_CTF.XDIGIT, # 0x35 '5'
469
+ _PY_CTF.DIGIT | _PY_CTF.XDIGIT, # 0x36 '6'
470
+ _PY_CTF.DIGIT | _PY_CTF.XDIGIT, # 0x37 '7'
471
+ _PY_CTF.DIGIT | _PY_CTF.XDIGIT, # 0x38 '8'
472
+ _PY_CTF.DIGIT | _PY_CTF.XDIGIT, # 0x39 '9'
473
+ 0, # 0x3a ':'
474
+ 0, # 0x3b ';'
475
+ 0, # 0x3c '<'
476
+ 0, # 0x3d '='
477
+ 0, # 0x3e '>'
478
+ 0, # 0x3f '?'
479
+ 0, # 0x40 '@'
480
+ _PY_CTF.UPPER | _PY_CTF.XDIGIT, # 0x41 'A'
481
+ _PY_CTF.UPPER | _PY_CTF.XDIGIT, # 0x42 'B'
482
+ _PY_CTF.UPPER | _PY_CTF.XDIGIT, # 0x43 'C'
483
+ _PY_CTF.UPPER | _PY_CTF.XDIGIT, # 0x44 'D'
484
+ _PY_CTF.UPPER | _PY_CTF.XDIGIT, # 0x45 'E'
485
+ _PY_CTF.UPPER | _PY_CTF.XDIGIT, # 0x46 'F'
486
+ _PY_CTF.UPPER, # 0x47 'G'
487
+ _PY_CTF.UPPER, # 0x48 'H'
488
+ _PY_CTF.UPPER, # 0x49 'I'
489
+ _PY_CTF.UPPER, # 0x4a 'J'
490
+ _PY_CTF.UPPER, # 0x4b 'K'
491
+ _PY_CTF.UPPER, # 0x4c 'L'
492
+ _PY_CTF.UPPER, # 0x4d 'M'
493
+ _PY_CTF.UPPER, # 0x4e 'N'
494
+ _PY_CTF.UPPER, # 0x4f 'O'
495
+ _PY_CTF.UPPER, # 0x50 'P'
496
+ _PY_CTF.UPPER, # 0x51 'Q'
497
+ _PY_CTF.UPPER, # 0x52 'R'
498
+ _PY_CTF.UPPER, # 0x53 'S'
499
+ _PY_CTF.UPPER, # 0x54 'T'
500
+ _PY_CTF.UPPER, # 0x55 'U'
501
+ _PY_CTF.UPPER, # 0x56 'V'
502
+ _PY_CTF.UPPER, # 0x57 'W'
503
+ _PY_CTF.UPPER, # 0x58 'X'
504
+ _PY_CTF.UPPER, # 0x59 'Y'
505
+ _PY_CTF.UPPER, # 0x5a 'Z'
506
+ 0, # 0x5b '['
507
+ 0, # 0x5c '\\'
508
+ 0, # 0x5d ']'
509
+ 0, # 0x5e '^'
510
+ 0, # 0x5f '_'
511
+ 0, # 0x60 '`'
512
+ _PY_CTF.LOWER | _PY_CTF.XDIGIT, # 0x61 'a'
513
+ _PY_CTF.LOWER | _PY_CTF.XDIGIT, # 0x62 'b'
514
+ _PY_CTF.LOWER | _PY_CTF.XDIGIT, # 0x63 'c'
515
+ _PY_CTF.LOWER | _PY_CTF.XDIGIT, # 0x64 'd'
516
+ _PY_CTF.LOWER | _PY_CTF.XDIGIT, # 0x65 'e'
517
+ _PY_CTF.LOWER | _PY_CTF.XDIGIT, # 0x66 'f'
518
+ _PY_CTF.LOWER, # 0x67 'g'
519
+ _PY_CTF.LOWER, # 0x68 'h'
520
+ _PY_CTF.LOWER, # 0x69 'i'
521
+ _PY_CTF.LOWER, # 0x6a 'j'
522
+ _PY_CTF.LOWER, # 0x6b 'k'
523
+ _PY_CTF.LOWER, # 0x6c 'l'
524
+ _PY_CTF.LOWER, # 0x6d 'm'
525
+ _PY_CTF.LOWER, # 0x6e 'n'
526
+ _PY_CTF.LOWER, # 0x6f 'o'
527
+ _PY_CTF.LOWER, # 0x70 'p'
528
+ _PY_CTF.LOWER, # 0x71 'q'
529
+ _PY_CTF.LOWER, # 0x72 'r'
530
+ _PY_CTF.LOWER, # 0x73 's'
531
+ _PY_CTF.LOWER, # 0x74 't'
532
+ _PY_CTF.LOWER, # 0x75 'u'
533
+ _PY_CTF.LOWER, # 0x76 'v'
534
+ _PY_CTF.LOWER, # 0x77 'w'
535
+ _PY_CTF.LOWER, # 0x78 'x'
536
+ _PY_CTF.LOWER, # 0x79 'y'
537
+ _PY_CTF.LOWER, # 0x7a 'z'
538
+ 0, # 0x7b '{'
539
+ 0, # 0x7c '|'
540
+ 0, # 0x7d '}'
541
+ 0, # 0x7e '~'
542
+ 0, # 0x7f '\x7f'
543
+ 0,
544
+ 0,
545
+ 0,
546
+ 0,
547
+ 0,
548
+ 0,
549
+ 0,
550
+ 0,
551
+ 0,
552
+ 0,
553
+ 0,
554
+ 0,
555
+ 0,
556
+ 0,
557
+ 0,
558
+ 0,
559
+ 0,
560
+ 0,
561
+ 0,
562
+ 0,
563
+ 0,
564
+ 0,
565
+ 0,
566
+ 0,
567
+ 0,
568
+ 0,
569
+ 0,
570
+ 0,
571
+ 0,
572
+ 0,
573
+ 0,
574
+ 0,
575
+ 0,
576
+ 0,
577
+ 0,
578
+ 0,
579
+ 0,
580
+ 0,
581
+ 0,
582
+ 0,
583
+ 0,
584
+ 0,
585
+ 0,
586
+ 0,
587
+ 0,
588
+ 0,
589
+ 0,
590
+ 0,
591
+ 0,
592
+ 0,
593
+ 0,
594
+ 0,
595
+ 0,
596
+ 0,
597
+ 0,
598
+ 0,
599
+ 0,
600
+ 0,
601
+ 0,
602
+ 0,
603
+ 0,
604
+ 0,
605
+ 0,
606
+ 0,
607
+ 0,
608
+ 0,
609
+ 0,
610
+ 0,
611
+ 0,
612
+ 0,
613
+ 0,
614
+ 0,
615
+ 0,
616
+ 0,
617
+ 0,
618
+ 0,
619
+ 0,
620
+ 0,
621
+ 0,
622
+ 0,
623
+ 0,
624
+ 0,
625
+ 0,
626
+ 0,
627
+ 0,
628
+ 0,
629
+ 0,
630
+ 0,
631
+ 0,
632
+ 0,
633
+ 0,
634
+ 0,
635
+ 0,
636
+ 0,
637
+ 0,
638
+ 0,
639
+ 0,
640
+ 0,
641
+ 0,
642
+ 0,
643
+ 0,
644
+ 0,
645
+ 0,
646
+ 0,
647
+ 0,
648
+ 0,
649
+ 0,
650
+ 0,
651
+ 0,
652
+ 0,
653
+ 0,
654
+ 0,
655
+ 0,
656
+ 0,
657
+ 0,
658
+ 0,
659
+ 0,
660
+ 0,
661
+ 0,
662
+ 0,
663
+ 0,
664
+ 0,
665
+ 0,
666
+ 0,
667
+ 0,
668
+ 0,
669
+ 0,
670
+ 0,
671
+ ],
672
+ dtype=np.intc,
673
+ )
674
+
675
+
676
+ # From the definition in CPython's Python/pyctype.c
677
+ # https://github.com/python/cpython/blob/1d4b6ba19466aba0eb91c4ba01ba509acf18c723/Python/pyctype.c#L145 # noqa: E501
678
+ _Py_ctype_tolower = np.array(
679
+ [
680
+ 0x00,
681
+ 0x01,
682
+ 0x02,
683
+ 0x03,
684
+ 0x04,
685
+ 0x05,
686
+ 0x06,
687
+ 0x07,
688
+ 0x08,
689
+ 0x09,
690
+ 0x0A,
691
+ 0x0B,
692
+ 0x0C,
693
+ 0x0D,
694
+ 0x0E,
695
+ 0x0F,
696
+ 0x10,
697
+ 0x11,
698
+ 0x12,
699
+ 0x13,
700
+ 0x14,
701
+ 0x15,
702
+ 0x16,
703
+ 0x17,
704
+ 0x18,
705
+ 0x19,
706
+ 0x1A,
707
+ 0x1B,
708
+ 0x1C,
709
+ 0x1D,
710
+ 0x1E,
711
+ 0x1F,
712
+ 0x20,
713
+ 0x21,
714
+ 0x22,
715
+ 0x23,
716
+ 0x24,
717
+ 0x25,
718
+ 0x26,
719
+ 0x27,
720
+ 0x28,
721
+ 0x29,
722
+ 0x2A,
723
+ 0x2B,
724
+ 0x2C,
725
+ 0x2D,
726
+ 0x2E,
727
+ 0x2F,
728
+ 0x30,
729
+ 0x31,
730
+ 0x32,
731
+ 0x33,
732
+ 0x34,
733
+ 0x35,
734
+ 0x36,
735
+ 0x37,
736
+ 0x38,
737
+ 0x39,
738
+ 0x3A,
739
+ 0x3B,
740
+ 0x3C,
741
+ 0x3D,
742
+ 0x3E,
743
+ 0x3F,
744
+ 0x40,
745
+ 0x61,
746
+ 0x62,
747
+ 0x63,
748
+ 0x64,
749
+ 0x65,
750
+ 0x66,
751
+ 0x67,
752
+ 0x68,
753
+ 0x69,
754
+ 0x6A,
755
+ 0x6B,
756
+ 0x6C,
757
+ 0x6D,
758
+ 0x6E,
759
+ 0x6F,
760
+ 0x70,
761
+ 0x71,
762
+ 0x72,
763
+ 0x73,
764
+ 0x74,
765
+ 0x75,
766
+ 0x76,
767
+ 0x77,
768
+ 0x78,
769
+ 0x79,
770
+ 0x7A,
771
+ 0x5B,
772
+ 0x5C,
773
+ 0x5D,
774
+ 0x5E,
775
+ 0x5F,
776
+ 0x60,
777
+ 0x61,
778
+ 0x62,
779
+ 0x63,
780
+ 0x64,
781
+ 0x65,
782
+ 0x66,
783
+ 0x67,
784
+ 0x68,
785
+ 0x69,
786
+ 0x6A,
787
+ 0x6B,
788
+ 0x6C,
789
+ 0x6D,
790
+ 0x6E,
791
+ 0x6F,
792
+ 0x70,
793
+ 0x71,
794
+ 0x72,
795
+ 0x73,
796
+ 0x74,
797
+ 0x75,
798
+ 0x76,
799
+ 0x77,
800
+ 0x78,
801
+ 0x79,
802
+ 0x7A,
803
+ 0x7B,
804
+ 0x7C,
805
+ 0x7D,
806
+ 0x7E,
807
+ 0x7F,
808
+ 0x80,
809
+ 0x81,
810
+ 0x82,
811
+ 0x83,
812
+ 0x84,
813
+ 0x85,
814
+ 0x86,
815
+ 0x87,
816
+ 0x88,
817
+ 0x89,
818
+ 0x8A,
819
+ 0x8B,
820
+ 0x8C,
821
+ 0x8D,
822
+ 0x8E,
823
+ 0x8F,
824
+ 0x90,
825
+ 0x91,
826
+ 0x92,
827
+ 0x93,
828
+ 0x94,
829
+ 0x95,
830
+ 0x96,
831
+ 0x97,
832
+ 0x98,
833
+ 0x99,
834
+ 0x9A,
835
+ 0x9B,
836
+ 0x9C,
837
+ 0x9D,
838
+ 0x9E,
839
+ 0x9F,
840
+ 0xA0,
841
+ 0xA1,
842
+ 0xA2,
843
+ 0xA3,
844
+ 0xA4,
845
+ 0xA5,
846
+ 0xA6,
847
+ 0xA7,
848
+ 0xA8,
849
+ 0xA9,
850
+ 0xAA,
851
+ 0xAB,
852
+ 0xAC,
853
+ 0xAD,
854
+ 0xAE,
855
+ 0xAF,
856
+ 0xB0,
857
+ 0xB1,
858
+ 0xB2,
859
+ 0xB3,
860
+ 0xB4,
861
+ 0xB5,
862
+ 0xB6,
863
+ 0xB7,
864
+ 0xB8,
865
+ 0xB9,
866
+ 0xBA,
867
+ 0xBB,
868
+ 0xBC,
869
+ 0xBD,
870
+ 0xBE,
871
+ 0xBF,
872
+ 0xC0,
873
+ 0xC1,
874
+ 0xC2,
875
+ 0xC3,
876
+ 0xC4,
877
+ 0xC5,
878
+ 0xC6,
879
+ 0xC7,
880
+ 0xC8,
881
+ 0xC9,
882
+ 0xCA,
883
+ 0xCB,
884
+ 0xCC,
885
+ 0xCD,
886
+ 0xCE,
887
+ 0xCF,
888
+ 0xD0,
889
+ 0xD1,
890
+ 0xD2,
891
+ 0xD3,
892
+ 0xD4,
893
+ 0xD5,
894
+ 0xD6,
895
+ 0xD7,
896
+ 0xD8,
897
+ 0xD9,
898
+ 0xDA,
899
+ 0xDB,
900
+ 0xDC,
901
+ 0xDD,
902
+ 0xDE,
903
+ 0xDF,
904
+ 0xE0,
905
+ 0xE1,
906
+ 0xE2,
907
+ 0xE3,
908
+ 0xE4,
909
+ 0xE5,
910
+ 0xE6,
911
+ 0xE7,
912
+ 0xE8,
913
+ 0xE9,
914
+ 0xEA,
915
+ 0xEB,
916
+ 0xEC,
917
+ 0xED,
918
+ 0xEE,
919
+ 0xEF,
920
+ 0xF0,
921
+ 0xF1,
922
+ 0xF2,
923
+ 0xF3,
924
+ 0xF4,
925
+ 0xF5,
926
+ 0xF6,
927
+ 0xF7,
928
+ 0xF8,
929
+ 0xF9,
930
+ 0xFA,
931
+ 0xFB,
932
+ 0xFC,
933
+ 0xFD,
934
+ 0xFE,
935
+ 0xFF,
936
+ ],
937
+ dtype=np.uint8,
938
+ )
939
+
940
+
941
+ # From the definition in CPython's Python/pyctype.c
942
+ # https://github.com/python/cpython/blob/1d4b6ba19466aba0eb91c4ba01ba509acf18c723/Python/pyctype.c#L180
943
+ _Py_ctype_toupper = np.array(
944
+ [
945
+ 0x00,
946
+ 0x01,
947
+ 0x02,
948
+ 0x03,
949
+ 0x04,
950
+ 0x05,
951
+ 0x06,
952
+ 0x07,
953
+ 0x08,
954
+ 0x09,
955
+ 0x0A,
956
+ 0x0B,
957
+ 0x0C,
958
+ 0x0D,
959
+ 0x0E,
960
+ 0x0F,
961
+ 0x10,
962
+ 0x11,
963
+ 0x12,
964
+ 0x13,
965
+ 0x14,
966
+ 0x15,
967
+ 0x16,
968
+ 0x17,
969
+ 0x18,
970
+ 0x19,
971
+ 0x1A,
972
+ 0x1B,
973
+ 0x1C,
974
+ 0x1D,
975
+ 0x1E,
976
+ 0x1F,
977
+ 0x20,
978
+ 0x21,
979
+ 0x22,
980
+ 0x23,
981
+ 0x24,
982
+ 0x25,
983
+ 0x26,
984
+ 0x27,
985
+ 0x28,
986
+ 0x29,
987
+ 0x2A,
988
+ 0x2B,
989
+ 0x2C,
990
+ 0x2D,
991
+ 0x2E,
992
+ 0x2F,
993
+ 0x30,
994
+ 0x31,
995
+ 0x32,
996
+ 0x33,
997
+ 0x34,
998
+ 0x35,
999
+ 0x36,
1000
+ 0x37,
1001
+ 0x38,
1002
+ 0x39,
1003
+ 0x3A,
1004
+ 0x3B,
1005
+ 0x3C,
1006
+ 0x3D,
1007
+ 0x3E,
1008
+ 0x3F,
1009
+ 0x40,
1010
+ 0x41,
1011
+ 0x42,
1012
+ 0x43,
1013
+ 0x44,
1014
+ 0x45,
1015
+ 0x46,
1016
+ 0x47,
1017
+ 0x48,
1018
+ 0x49,
1019
+ 0x4A,
1020
+ 0x4B,
1021
+ 0x4C,
1022
+ 0x4D,
1023
+ 0x4E,
1024
+ 0x4F,
1025
+ 0x50,
1026
+ 0x51,
1027
+ 0x52,
1028
+ 0x53,
1029
+ 0x54,
1030
+ 0x55,
1031
+ 0x56,
1032
+ 0x57,
1033
+ 0x58,
1034
+ 0x59,
1035
+ 0x5A,
1036
+ 0x5B,
1037
+ 0x5C,
1038
+ 0x5D,
1039
+ 0x5E,
1040
+ 0x5F,
1041
+ 0x60,
1042
+ 0x41,
1043
+ 0x42,
1044
+ 0x43,
1045
+ 0x44,
1046
+ 0x45,
1047
+ 0x46,
1048
+ 0x47,
1049
+ 0x48,
1050
+ 0x49,
1051
+ 0x4A,
1052
+ 0x4B,
1053
+ 0x4C,
1054
+ 0x4D,
1055
+ 0x4E,
1056
+ 0x4F,
1057
+ 0x50,
1058
+ 0x51,
1059
+ 0x52,
1060
+ 0x53,
1061
+ 0x54,
1062
+ 0x55,
1063
+ 0x56,
1064
+ 0x57,
1065
+ 0x58,
1066
+ 0x59,
1067
+ 0x5A,
1068
+ 0x7B,
1069
+ 0x7C,
1070
+ 0x7D,
1071
+ 0x7E,
1072
+ 0x7F,
1073
+ 0x80,
1074
+ 0x81,
1075
+ 0x82,
1076
+ 0x83,
1077
+ 0x84,
1078
+ 0x85,
1079
+ 0x86,
1080
+ 0x87,
1081
+ 0x88,
1082
+ 0x89,
1083
+ 0x8A,
1084
+ 0x8B,
1085
+ 0x8C,
1086
+ 0x8D,
1087
+ 0x8E,
1088
+ 0x8F,
1089
+ 0x90,
1090
+ 0x91,
1091
+ 0x92,
1092
+ 0x93,
1093
+ 0x94,
1094
+ 0x95,
1095
+ 0x96,
1096
+ 0x97,
1097
+ 0x98,
1098
+ 0x99,
1099
+ 0x9A,
1100
+ 0x9B,
1101
+ 0x9C,
1102
+ 0x9D,
1103
+ 0x9E,
1104
+ 0x9F,
1105
+ 0xA0,
1106
+ 0xA1,
1107
+ 0xA2,
1108
+ 0xA3,
1109
+ 0xA4,
1110
+ 0xA5,
1111
+ 0xA6,
1112
+ 0xA7,
1113
+ 0xA8,
1114
+ 0xA9,
1115
+ 0xAA,
1116
+ 0xAB,
1117
+ 0xAC,
1118
+ 0xAD,
1119
+ 0xAE,
1120
+ 0xAF,
1121
+ 0xB0,
1122
+ 0xB1,
1123
+ 0xB2,
1124
+ 0xB3,
1125
+ 0xB4,
1126
+ 0xB5,
1127
+ 0xB6,
1128
+ 0xB7,
1129
+ 0xB8,
1130
+ 0xB9,
1131
+ 0xBA,
1132
+ 0xBB,
1133
+ 0xBC,
1134
+ 0xBD,
1135
+ 0xBE,
1136
+ 0xBF,
1137
+ 0xC0,
1138
+ 0xC1,
1139
+ 0xC2,
1140
+ 0xC3,
1141
+ 0xC4,
1142
+ 0xC5,
1143
+ 0xC6,
1144
+ 0xC7,
1145
+ 0xC8,
1146
+ 0xC9,
1147
+ 0xCA,
1148
+ 0xCB,
1149
+ 0xCC,
1150
+ 0xCD,
1151
+ 0xCE,
1152
+ 0xCF,
1153
+ 0xD0,
1154
+ 0xD1,
1155
+ 0xD2,
1156
+ 0xD3,
1157
+ 0xD4,
1158
+ 0xD5,
1159
+ 0xD6,
1160
+ 0xD7,
1161
+ 0xD8,
1162
+ 0xD9,
1163
+ 0xDA,
1164
+ 0xDB,
1165
+ 0xDC,
1166
+ 0xDD,
1167
+ 0xDE,
1168
+ 0xDF,
1169
+ 0xE0,
1170
+ 0xE1,
1171
+ 0xE2,
1172
+ 0xE3,
1173
+ 0xE4,
1174
+ 0xE5,
1175
+ 0xE6,
1176
+ 0xE7,
1177
+ 0xE8,
1178
+ 0xE9,
1179
+ 0xEA,
1180
+ 0xEB,
1181
+ 0xEC,
1182
+ 0xED,
1183
+ 0xEE,
1184
+ 0xEF,
1185
+ 0xF0,
1186
+ 0xF1,
1187
+ 0xF2,
1188
+ 0xF3,
1189
+ 0xF4,
1190
+ 0xF5,
1191
+ 0xF6,
1192
+ 0xF7,
1193
+ 0xF8,
1194
+ 0xF9,
1195
+ 0xFA,
1196
+ 0xFB,
1197
+ 0xFC,
1198
+ 0xFD,
1199
+ 0xFE,
1200
+ 0xFF,
1201
+ ],
1202
+ dtype=np.uint8,
1203
+ )
1204
+
1205
+
1206
+ class _PY_CTF_LB(IntEnum):
1207
+ LINE_BREAK = 0x01
1208
+ LINE_FEED = 0x02
1209
+ CARRIAGE_RETURN = 0x04
1210
+
1211
+
1212
+ _Py_ctype_islinebreak = np.array(
1213
+ [
1214
+ 0,
1215
+ 0,
1216
+ 0,
1217
+ 0,
1218
+ 0,
1219
+ 0,
1220
+ 0,
1221
+ 0,
1222
+ 0,
1223
+ 0,
1224
+ _PY_CTF_LB.LINE_BREAK | _PY_CTF_LB.LINE_FEED, # 0xa '\n'
1225
+ _PY_CTF_LB.LINE_BREAK, # 0xb '\v'
1226
+ _PY_CTF_LB.LINE_BREAK, # 0xc '\f'
1227
+ _PY_CTF_LB.LINE_BREAK | _PY_CTF_LB.CARRIAGE_RETURN, # 0xd '\r'
1228
+ 0,
1229
+ 0,
1230
+ 0,
1231
+ 0,
1232
+ 0,
1233
+ 0,
1234
+ 0,
1235
+ 0,
1236
+ 0,
1237
+ 0,
1238
+ 0,
1239
+ 0,
1240
+ 0,
1241
+ 0,
1242
+ _PY_CTF_LB.LINE_BREAK, # 0x1c '\x1c'
1243
+ _PY_CTF_LB.LINE_BREAK, # 0x1d '\x1d'
1244
+ _PY_CTF_LB.LINE_BREAK, # 0x1e '\x1e'
1245
+ 0,
1246
+ 0,
1247
+ 0,
1248
+ 0,
1249
+ 0,
1250
+ 0,
1251
+ 0,
1252
+ 0,
1253
+ 0,
1254
+ 0,
1255
+ 0,
1256
+ 0,
1257
+ 0,
1258
+ 0,
1259
+ 0,
1260
+ 0,
1261
+ 0,
1262
+ 0,
1263
+ 0,
1264
+ 0,
1265
+ 0,
1266
+ 0,
1267
+ 0,
1268
+ 0,
1269
+ 0,
1270
+ 0,
1271
+ 0,
1272
+ 0,
1273
+ 0,
1274
+ 0,
1275
+ 0,
1276
+ 0,
1277
+ 0,
1278
+ 0,
1279
+ 0,
1280
+ 0,
1281
+ 0,
1282
+ 0,
1283
+ 0,
1284
+ 0,
1285
+ 0,
1286
+ 0,
1287
+ 0,
1288
+ 0,
1289
+ 0,
1290
+ 0,
1291
+ 0,
1292
+ 0,
1293
+ 0,
1294
+ 0,
1295
+ 0,
1296
+ 0,
1297
+ 0,
1298
+ 0,
1299
+ 0,
1300
+ 0,
1301
+ 0,
1302
+ 0,
1303
+ 0,
1304
+ 0,
1305
+ 0,
1306
+ 0,
1307
+ 0,
1308
+ 0,
1309
+ 0,
1310
+ 0,
1311
+ 0,
1312
+ 0,
1313
+ 0,
1314
+ 0,
1315
+ 0,
1316
+ 0,
1317
+ 0,
1318
+ 0,
1319
+ 0,
1320
+ 0,
1321
+ 0,
1322
+ 0,
1323
+ 0,
1324
+ 0,
1325
+ 0,
1326
+ 0,
1327
+ 0,
1328
+ 0,
1329
+ 0,
1330
+ 0,
1331
+ 0,
1332
+ 0,
1333
+ 0,
1334
+ 0,
1335
+ 0,
1336
+ 0,
1337
+ 0,
1338
+ 0,
1339
+ 0,
1340
+ 0,
1341
+ 0,
1342
+ 0,
1343
+ 0,
1344
+ 0,
1345
+ 0,
1346
+ 0,
1347
+ _PY_CTF_LB.LINE_BREAK, # 0x85 '\x85'
1348
+ 0,
1349
+ 0,
1350
+ 0,
1351
+ 0,
1352
+ 0,
1353
+ 0,
1354
+ 0,
1355
+ 0,
1356
+ 0,
1357
+ 0,
1358
+ 0,
1359
+ 0,
1360
+ 0,
1361
+ 0,
1362
+ 0,
1363
+ 0,
1364
+ 0,
1365
+ 0,
1366
+ 0,
1367
+ 0,
1368
+ 0,
1369
+ 0,
1370
+ 0,
1371
+ 0,
1372
+ 0,
1373
+ 0,
1374
+ 0,
1375
+ 0,
1376
+ 0,
1377
+ 0,
1378
+ 0,
1379
+ 0,
1380
+ 0,
1381
+ 0,
1382
+ 0,
1383
+ 0,
1384
+ 0,
1385
+ 0,
1386
+ 0,
1387
+ 0,
1388
+ 0,
1389
+ 0,
1390
+ 0,
1391
+ 0,
1392
+ 0,
1393
+ 0,
1394
+ 0,
1395
+ 0,
1396
+ 0,
1397
+ 0,
1398
+ 0,
1399
+ 0,
1400
+ 0,
1401
+ 0,
1402
+ 0,
1403
+ 0,
1404
+ 0,
1405
+ 0,
1406
+ 0,
1407
+ 0,
1408
+ 0,
1409
+ 0,
1410
+ 0,
1411
+ 0,
1412
+ 0,
1413
+ 0,
1414
+ 0,
1415
+ 0,
1416
+ 0,
1417
+ 0,
1418
+ 0,
1419
+ 0,
1420
+ 0,
1421
+ 0,
1422
+ 0,
1423
+ 0,
1424
+ 0,
1425
+ 0,
1426
+ 0,
1427
+ 0,
1428
+ 0,
1429
+ 0,
1430
+ 0,
1431
+ 0,
1432
+ 0,
1433
+ 0,
1434
+ 0,
1435
+ 0,
1436
+ 0,
1437
+ 0,
1438
+ 0,
1439
+ 0,
1440
+ 0,
1441
+ 0,
1442
+ 0,
1443
+ 0,
1444
+ 0,
1445
+ 0,
1446
+ 0,
1447
+ 0,
1448
+ 0,
1449
+ 0,
1450
+ 0,
1451
+ 0,
1452
+ 0,
1453
+ 0,
1454
+ 0,
1455
+ 0,
1456
+ 0,
1457
+ 0,
1458
+ 0,
1459
+ 0,
1460
+ 0,
1461
+ 0,
1462
+ 0,
1463
+ 0,
1464
+ 0,
1465
+ 0,
1466
+ 0,
1467
+ 0,
1468
+ 0,
1469
+ 0,
1470
+ ],
1471
+ dtype=np.intc,
1472
+ )
1473
+
1474
+
1475
+ # Translation of:
1476
+ # https://github.com/python/cpython/blob/1d4b6ba19466aba0eb91c4ba01ba509acf18c723/Include/pymacro.h#L25 # noqa: E501
1477
+ @register_jitable
1478
+ def _Py_CHARMASK(ch):
1479
+ """
1480
+ Equivalent to the CPython macro `Py_CHARMASK()`, masks off all but the
1481
+ lowest 256 bits of ch.
1482
+ """
1483
+ return types.uint8(ch) & types.uint8(0xFF)
1484
+
1485
+
1486
+ # Translation of:
1487
+ # https://github.com/python/cpython/blob/1d4b6ba19466aba0eb91c4ba01ba509acf18c723/Include/pyctype.h#L30 # noqa: E501
1488
+ @register_jitable
1489
+ def _Py_TOUPPER(ch):
1490
+ """
1491
+ Equivalent to the CPython macro `Py_TOUPPER()` converts an ASCII range
1492
+ code point to the upper equivalent
1493
+ """
1494
+ return _Py_ctype_toupper[_Py_CHARMASK(ch)]
1495
+
1496
+
1497
+ # Translation of:
1498
+ # https://github.com/python/cpython/blob/1d4b6ba19466aba0eb91c4ba01ba509acf18c723/Include/pyctype.h#L29 # noqa: E501
1499
+ @register_jitable
1500
+ def _Py_TOLOWER(ch):
1501
+ """
1502
+ Equivalent to the CPython macro `Py_TOLOWER()` converts an ASCII range
1503
+ code point to the lower equivalent
1504
+ """
1505
+ return _Py_ctype_tolower[_Py_CHARMASK(ch)]
1506
+
1507
+
1508
+ # Translation of:
1509
+ # https://github.com/python/cpython/blob/1d4b6ba19466aba0eb91c4ba01ba509acf18c723/Include/pyctype.h#L18 # noqa: E501
1510
+ @register_jitable
1511
+ def _Py_ISLOWER(ch):
1512
+ """
1513
+ Equivalent to the CPython macro `Py_ISLOWER()`
1514
+ """
1515
+ return _Py_ctype_table[_Py_CHARMASK(ch)] & _PY_CTF.LOWER
1516
+
1517
+
1518
+ # Translation of:
1519
+ # https://github.com/python/cpython/blob/1d4b6ba19466aba0eb91c4ba01ba509acf18c723/Include/pyctype.h#L19 # noqa: E501
1520
+ @register_jitable
1521
+ def _Py_ISUPPER(ch):
1522
+ """
1523
+ Equivalent to the CPython macro `Py_ISUPPER()`
1524
+ """
1525
+ return _Py_ctype_table[_Py_CHARMASK(ch)] & _PY_CTF.UPPER
1526
+
1527
+
1528
+ # Translation of:
1529
+ # https://github.com/python/cpython/blob/1d4b6ba19466aba0eb91c4ba01ba509acf18c723/Include/pyctype.h#L20 # noqa: E501
1530
+ @register_jitable
1531
+ def _Py_ISALPHA(ch):
1532
+ """
1533
+ Equivalent to the CPython macro `Py_ISALPHA()`
1534
+ """
1535
+ return _Py_ctype_table[_Py_CHARMASK(ch)] & _PY_CTF.ALPHA
1536
+
1537
+
1538
+ # Translation of:
1539
+ # https://github.com/python/cpython/blob/1d4b6ba19466aba0eb91c4ba01ba509acf18c723/Include/pyctype.h#L21 # noqa: E501
1540
+ @register_jitable
1541
+ def _Py_ISDIGIT(ch):
1542
+ """
1543
+ Equivalent to the CPython macro `Py_ISDIGIT()`
1544
+ """
1545
+ return _Py_ctype_table[_Py_CHARMASK(ch)] & _PY_CTF.DIGIT
1546
+
1547
+
1548
+ # Translation of:
1549
+ # https://github.com/python/cpython/blob/1d4b6ba19466aba0eb91c4ba01ba509acf18c723/Include/pyctype.h#L22 # noqa: E501
1550
+ @register_jitable
1551
+ def _Py_ISXDIGIT(ch):
1552
+ """
1553
+ Equivalent to the CPython macro `Py_ISXDIGIT()`
1554
+ """
1555
+ return _Py_ctype_table[_Py_CHARMASK(ch)] & _PY_CTF.XDIGIT
1556
+
1557
+
1558
+ # Translation of:
1559
+ # https://github.com/python/cpython/blob/1d4b6ba19466aba0eb91c4ba01ba509acf18c723/Include/pyctype.h#L23 # noqa: E501
1560
+ @register_jitable
1561
+ def _Py_ISALNUM(ch):
1562
+ """
1563
+ Equivalent to the CPython macro `Py_ISALNUM()`
1564
+ """
1565
+ return _Py_ctype_table[_Py_CHARMASK(ch)] & _PY_CTF.ALNUM
1566
+
1567
+
1568
+ # Translation of:
1569
+ # https://github.com/python/cpython/blob/1d4b6ba19466aba0eb91c4ba01ba509acf18c723/Include/pyctype.h#L24 # noqa: E501
1570
+ @register_jitable
1571
+ def _Py_ISSPACE(ch):
1572
+ """
1573
+ Equivalent to the CPython macro `Py_ISSPACE()`
1574
+ """
1575
+ return _Py_ctype_table[_Py_CHARMASK(ch)] & _PY_CTF.SPACE
1576
+
1577
+
1578
+ @register_jitable
1579
+ def _Py_ISLINEBREAK(ch):
1580
+ """Check if character is ASCII line break"""
1581
+ return _Py_ctype_islinebreak[_Py_CHARMASK(ch)] & _PY_CTF_LB.LINE_BREAK
1582
+
1583
+
1584
+ @register_jitable
1585
+ def _Py_ISLINEFEED(ch):
1586
+ """Check if character is line feed `\n`"""
1587
+ return _Py_ctype_islinebreak[_Py_CHARMASK(ch)] & _PY_CTF_LB.LINE_FEED
1588
+
1589
+
1590
+ @register_jitable
1591
+ def _Py_ISCARRIAGERETURN(ch):
1592
+ """Check if character is carriage return `\r`"""
1593
+ return _Py_ctype_islinebreak[_Py_CHARMASK(ch)] & _PY_CTF_LB.CARRIAGE_RETURN
1594
+
1595
+
1596
+ # End code related to/from CPython's pyctype
1597
+ # ------------------------------------------------------------------------------