pytron-kit 0.3.12__py3-none-macosx_11_0_universal2.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 (419) hide show
  1. pytron/__init__.py +112 -0
  2. pytron/application.py +562 -0
  3. pytron/apputils/__init__.py +0 -0
  4. pytron/apputils/chrome_ipc.py +203 -0
  5. pytron/apputils/codegen.py +261 -0
  6. pytron/apputils/config.py +303 -0
  7. pytron/apputils/deadmansswitch.py +47 -0
  8. pytron/apputils/extras.py +76 -0
  9. pytron/apputils/native.py +148 -0
  10. pytron/apputils/shell.py +73 -0
  11. pytron/apputils/windows.py +286 -0
  12. pytron/cli.py +384 -0
  13. pytron/commands/__init__.py +0 -0
  14. pytron/commands/android.py +28 -0
  15. pytron/commands/build.py +26 -0
  16. pytron/commands/doctor.py +221 -0
  17. pytron/commands/engine.py +23 -0
  18. pytron/commands/frontend.py +60 -0
  19. pytron/commands/harvest.py +112 -0
  20. pytron/commands/helpers.py +239 -0
  21. pytron/commands/info.py +50 -0
  22. pytron/commands/init.py +521 -0
  23. pytron/commands/install.py +294 -0
  24. pytron/commands/login.py +130 -0
  25. pytron/commands/package.py +228 -0
  26. pytron/commands/plugin.py +442 -0
  27. pytron/commands/run.py +312 -0
  28. pytron/commands/scan.py +210 -0
  29. pytron/commands/show.py +23 -0
  30. pytron/commands/uninstall.py +150 -0
  31. pytron/commands/utils.py +42 -0
  32. pytron/commands/workflow.py +95 -0
  33. pytron/console.py +133 -0
  34. pytron/core.py +18 -0
  35. pytron/dependencies/WebView2Loader.dll +0 -0
  36. pytron/dependencies/__init__.py +1 -0
  37. pytron/dependencies/pytron_native.so +0 -0
  38. pytron/engines/chrome/adapter.py +445 -0
  39. pytron/engines/chrome/engine.py +576 -0
  40. pytron/engines/chrome/forge.py +147 -0
  41. pytron/engines/chrome/shell/package.json +8 -0
  42. pytron/engines/chrome/shell/preload.js +12 -0
  43. pytron/engines/chrome/shell/shell.js +534 -0
  44. pytron/exceptions.py +36 -0
  45. pytron/inspector.py +201 -0
  46. pytron/inspector_ui.py +512 -0
  47. pytron/installer/Installation.nsi +236 -0
  48. pytron/installer/header.bmp +0 -0
  49. pytron/installer/pytron.ico +0 -0
  50. pytron/installer/sidebar.bmp +0 -0
  51. pytron/llms.md +98 -0
  52. pytron/manifests/README.md +29 -0
  53. pytron/manifests/windows-utf8.manifest +44 -0
  54. pytron/menu.py +128 -0
  55. pytron/nsis-setup.exe +0 -0
  56. pytron/pack/__init__.py +0 -0
  57. pytron/pack/assets.py +131 -0
  58. pytron/pack/compilers.py +289 -0
  59. pytron/pack/crystal.py +297 -0
  60. pytron/pack/graph.py +377 -0
  61. pytron/pack/inference.py +157 -0
  62. pytron/pack/installers.py +402 -0
  63. pytron/pack/introspect.py +357 -0
  64. pytron/pack/metadata.py +213 -0
  65. pytron/pack/modules.py +618 -0
  66. pytron/pack/nuitka.py +108 -0
  67. pytron/pack/pipeline.py +107 -0
  68. pytron/pack/pyinstaller.py +176 -0
  69. pytron/pack/rust_engine.py +273 -0
  70. pytron/pack/secure.py +309 -0
  71. pytron/pack/secure_loader/bin/pytron_rust_bootloader +0 -0
  72. pytron/pack/secure_loader/icon.ico +0 -0
  73. pytron/pack/utils.py +110 -0
  74. pytron/pack/virtual_root.py +124 -0
  75. pytron/platforms/__init__.py +0 -0
  76. pytron/platforms/android/__init__.py +3 -0
  77. pytron/platforms/android/android.py +103 -0
  78. pytron/platforms/android/builder.py +736 -0
  79. pytron/platforms/android/ops/build.py +79 -0
  80. pytron/platforms/android/ops/init.py +63 -0
  81. pytron/platforms/android/ops/run.py +79 -0
  82. pytron/platforms/android/ops/sync.py +770 -0
  83. pytron/platforms/android/ops/utils.py +8 -0
  84. pytron/platforms/android/shell/README.md +30 -0
  85. pytron/platforms/android/shell/app/build.gradle +64 -0
  86. pytron/platforms/android/shell/app/src/main/AndroidManifest.xml +29 -0
  87. pytron/platforms/android/shell/app/src/main/assets/python/main.py +86 -0
  88. pytron/platforms/android/shell/app/src/main/assets/python/python314.zip +0 -0
  89. pytron/platforms/android/shell/app/src/main/cpp/CMakeLists.txt +25 -0
  90. pytron/platforms/android/shell/app/src/main/cpp/include/Python.h +155 -0
  91. pytron/platforms/android/shell/app/src/main/cpp/include/abstract.h +915 -0
  92. pytron/platforms/android/shell/app/src/main/cpp/include/audit.h +30 -0
  93. pytron/platforms/android/shell/app/src/main/cpp/include/bltinmodule.h +14 -0
  94. pytron/platforms/android/shell/app/src/main/cpp/include/boolobject.h +54 -0
  95. pytron/platforms/android/shell/app/src/main/cpp/include/bytearrayobject.h +44 -0
  96. pytron/platforms/android/shell/app/src/main/cpp/include/bytesobject.h +66 -0
  97. pytron/platforms/android/shell/app/src/main/cpp/include/ceval.h +145 -0
  98. pytron/platforms/android/shell/app/src/main/cpp/include/codecs.h +176 -0
  99. pytron/platforms/android/shell/app/src/main/cpp/include/compile.h +22 -0
  100. pytron/platforms/android/shell/app/src/main/cpp/include/complexobject.h +30 -0
  101. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/abstract.h +104 -0
  102. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/audit.h +8 -0
  103. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/bytearrayobject.h +38 -0
  104. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/bytesobject.h +42 -0
  105. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/cellobject.h +50 -0
  106. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/ceval.h +43 -0
  107. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/classobject.h +71 -0
  108. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/code.h +340 -0
  109. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/compile.h +50 -0
  110. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/complexobject.h +33 -0
  111. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/context.h +107 -0
  112. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/critical_section.h +154 -0
  113. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/descrobject.h +62 -0
  114. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/dictobject.h +105 -0
  115. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/fileobject.h +16 -0
  116. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/fileutils.h +16 -0
  117. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/floatobject.h +27 -0
  118. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/frameobject.h +35 -0
  119. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/funcobject.h +185 -0
  120. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/genobject.h +56 -0
  121. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/import.h +30 -0
  122. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/initconfig.h +334 -0
  123. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/listobject.h +53 -0
  124. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/lock.h +74 -0
  125. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/longintrepr.h +184 -0
  126. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/longobject.h +89 -0
  127. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/memoryobject.h +50 -0
  128. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/methodobject.h +66 -0
  129. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/modsupport.h +26 -0
  130. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/monitoring.h +269 -0
  131. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/object.h +493 -0
  132. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/objimpl.h +104 -0
  133. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/odictobject.h +43 -0
  134. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/picklebufobject.h +31 -0
  135. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pthread_stubs.h +105 -0
  136. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyatomic.h +614 -0
  137. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyatomic_gcc.h +615 -0
  138. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyatomic_msc.h +1197 -0
  139. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyatomic_std.h +1112 -0
  140. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyctype.h +39 -0
  141. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pydebug.h +38 -0
  142. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyerrors.h +132 -0
  143. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyfpe.h +15 -0
  144. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyframe.h +45 -0
  145. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyhash.h +54 -0
  146. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pylifecycle.h +89 -0
  147. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pymem.h +84 -0
  148. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pystate.h +275 -0
  149. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pystats.h +194 -0
  150. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pythonrun.h +96 -0
  151. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pythread.h +43 -0
  152. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pytime.h +27 -0
  153. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/setobject.h +71 -0
  154. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/traceback.h +13 -0
  155. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/tracemalloc.h +32 -0
  156. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/tupleobject.h +40 -0
  157. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/unicodeobject.h +773 -0
  158. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/warnings.h +20 -0
  159. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/weakrefobject.h +66 -0
  160. pytron/platforms/android/shell/app/src/main/cpp/include/critical_section.h +16 -0
  161. pytron/platforms/android/shell/app/src/main/cpp/include/datetime.h +267 -0
  162. pytron/platforms/android/shell/app/src/main/cpp/include/descrobject.h +100 -0
  163. pytron/platforms/android/shell/app/src/main/cpp/include/dictobject.h +108 -0
  164. pytron/platforms/android/shell/app/src/main/cpp/include/dynamic_annotations.h +499 -0
  165. pytron/platforms/android/shell/app/src/main/cpp/include/enumobject.h +17 -0
  166. pytron/platforms/android/shell/app/src/main/cpp/include/errcode.h +45 -0
  167. pytron/platforms/android/shell/app/src/main/cpp/include/exports.h +105 -0
  168. pytron/platforms/android/shell/app/src/main/cpp/include/fileobject.h +41 -0
  169. pytron/platforms/android/shell/app/src/main/cpp/include/fileutils.h +62 -0
  170. pytron/platforms/android/shell/app/src/main/cpp/include/floatobject.h +54 -0
  171. pytron/platforms/android/shell/app/src/main/cpp/include/frameobject.h +20 -0
  172. pytron/platforms/android/shell/app/src/main/cpp/include/genericaliasobject.h +14 -0
  173. pytron/platforms/android/shell/app/src/main/cpp/include/import.h +103 -0
  174. pytron/platforms/android/shell/app/src/main/cpp/include/internal/mimalloc/mimalloc/atomic.h +392 -0
  175. pytron/platforms/android/shell/app/src/main/cpp/include/internal/mimalloc/mimalloc/internal.h +969 -0
  176. pytron/platforms/android/shell/app/src/main/cpp/include/internal/mimalloc/mimalloc/prim.h +329 -0
  177. pytron/platforms/android/shell/app/src/main/cpp/include/internal/mimalloc/mimalloc/track.h +147 -0
  178. pytron/platforms/android/shell/app/src/main/cpp/include/internal/mimalloc/mimalloc/types.h +721 -0
  179. pytron/platforms/android/shell/app/src/main/cpp/include/internal/mimalloc/mimalloc.h +565 -0
  180. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_abstract.h +61 -0
  181. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_asdl.h +112 -0
  182. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_ast.h +945 -0
  183. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_ast_state.h +271 -0
  184. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_atexit.h +31 -0
  185. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_audit.h +35 -0
  186. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_backoff.h +133 -0
  187. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_bitutils.h +186 -0
  188. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_blocks_output_buffer.h +321 -0
  189. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_brc.h +73 -0
  190. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_bytes_methods.h +82 -0
  191. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_bytesobject.h +149 -0
  192. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_c_array.h +39 -0
  193. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_call.h +206 -0
  194. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_capsule.h +17 -0
  195. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_cell.h +75 -0
  196. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_ceval.h +390 -0
  197. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_ceval_state.h +48 -0
  198. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_code.h +671 -0
  199. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_codecs.h +76 -0
  200. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_compile.h +230 -0
  201. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_complexobject.h +34 -0
  202. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_condvar.h +93 -0
  203. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_context.h +59 -0
  204. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_critical_section.h +237 -0
  205. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_crossinterp.h +406 -0
  206. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_crossinterp_data_registry.h +41 -0
  207. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_debug_offsets.h +379 -0
  208. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_descrobject.h +28 -0
  209. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_dict.h +410 -0
  210. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_dict_state.h +28 -0
  211. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_dtoa.h +40 -0
  212. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_emscripten_signal.h +30 -0
  213. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_emscripten_trampoline.h +70 -0
  214. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_exceptions.h +40 -0
  215. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_faulthandler.h +100 -0
  216. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_fileutils.h +320 -0
  217. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_fileutils_windows.h +98 -0
  218. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_floatobject.h +49 -0
  219. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_flowgraph.h +47 -0
  220. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_format.h +27 -0
  221. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_frame.h +61 -0
  222. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_freelist.h +111 -0
  223. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_freelist_state.h +70 -0
  224. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_function.h +53 -0
  225. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_gc.h +378 -0
  226. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_genobject.h +43 -0
  227. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_getopt.h +22 -0
  228. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_gil.h +66 -0
  229. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_global_objects.h +34 -0
  230. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_global_objects_fini_generated.h +1592 -0
  231. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_global_strings.h +854 -0
  232. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_hamt.h +113 -0
  233. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_hashtable.h +150 -0
  234. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_import.h +141 -0
  235. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_importdl.h +139 -0
  236. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_index_pool.h +36 -0
  237. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_initconfig.h +197 -0
  238. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_instruction_sequence.h +83 -0
  239. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_instruments.h +127 -0
  240. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_interp.h +109 -0
  241. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_interp_structs.h +977 -0
  242. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_interpframe.h +401 -0
  243. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_interpframe_structs.h +95 -0
  244. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_interpolation.h +26 -0
  245. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_intrinsics.h +51 -0
  246. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_jit.h +29 -0
  247. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_list.h +81 -0
  248. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_llist.h +106 -0
  249. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_lock.h +236 -0
  250. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_long.h +319 -0
  251. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_magic_number.h +305 -0
  252. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_memoryobject.h +20 -0
  253. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_mimalloc.h +69 -0
  254. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_modsupport.h +99 -0
  255. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_moduleobject.h +62 -0
  256. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_namespace.h +21 -0
  257. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_object.h +1029 -0
  258. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_object_alloc.h +71 -0
  259. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_object_deferred.h +32 -0
  260. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_object_stack.h +95 -0
  261. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_object_state.h +49 -0
  262. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_obmalloc.h +702 -0
  263. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_obmalloc_init.h +66 -0
  264. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_opcode_metadata.h +2117 -0
  265. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_opcode_utils.h +90 -0
  266. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_optimizer.h +318 -0
  267. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_parking_lot.h +97 -0
  268. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_parser.h +78 -0
  269. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pathconfig.h +26 -0
  270. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pyarena.h +68 -0
  271. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pyatomic_ft_wrappers.h +174 -0
  272. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pybuffer.h +21 -0
  273. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pyerrors.h +213 -0
  274. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pyhash.h +91 -0
  275. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pylifecycle.h +136 -0
  276. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pymath.h +205 -0
  277. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pymem.h +145 -0
  278. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pymem_init.h +103 -0
  279. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pystate.h +339 -0
  280. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pystats.h +21 -0
  281. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pythonrun.h +68 -0
  282. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pythread.h +172 -0
  283. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_qsbr.h +172 -0
  284. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_range.h +21 -0
  285. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_runtime.h +63 -0
  286. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_runtime_init.h +239 -0
  287. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_runtime_init_generated.h +1589 -0
  288. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_runtime_structs.h +310 -0
  289. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_semaphore.h +67 -0
  290. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_setobject.h +41 -0
  291. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_signal.h +108 -0
  292. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_sliceobject.h +20 -0
  293. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_stackref.h +791 -0
  294. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_stats.h +97 -0
  295. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_strhex.h +39 -0
  296. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_structs.h +88 -0
  297. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_structseq.h +40 -0
  298. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_symtable.h +201 -0
  299. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_sysmodule.h +32 -0
  300. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_template.h +26 -0
  301. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_time.h +334 -0
  302. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_token.h +110 -0
  303. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_traceback.h +111 -0
  304. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_tracemalloc.h +164 -0
  305. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_tstate.h +88 -0
  306. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_tuple.h +75 -0
  307. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_typedefs.h +18 -0
  308. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_typeobject.h +155 -0
  309. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_typevarobject.h +28 -0
  310. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_ucnhash.h +36 -0
  311. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_unicodeobject.h +308 -0
  312. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_unicodeobject_generated.h +3132 -0
  313. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_unionobject.h +26 -0
  314. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_uniqueid.h +57 -0
  315. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_uop_ids.h +335 -0
  316. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_uop_metadata.h +1204 -0
  317. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_warnings.h +21 -0
  318. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_weakref.h +133 -0
  319. pytron/platforms/android/shell/app/src/main/cpp/include/intrcheck.h +23 -0
  320. pytron/platforms/android/shell/app/src/main/cpp/include/iterobject.h +24 -0
  321. pytron/platforms/android/shell/app/src/main/cpp/include/listobject.h +55 -0
  322. pytron/platforms/android/shell/app/src/main/cpp/include/lock.h +16 -0
  323. pytron/platforms/android/shell/app/src/main/cpp/include/longobject.h +178 -0
  324. pytron/platforms/android/shell/app/src/main/cpp/include/marshal.h +31 -0
  325. pytron/platforms/android/shell/app/src/main/cpp/include/memoryobject.h +34 -0
  326. pytron/platforms/android/shell/app/src/main/cpp/include/methodobject.h +146 -0
  327. pytron/platforms/android/shell/app/src/main/cpp/include/modsupport.h +146 -0
  328. pytron/platforms/android/shell/app/src/main/cpp/include/moduleobject.h +122 -0
  329. pytron/platforms/android/shell/app/src/main/cpp/include/monitoring.h +18 -0
  330. pytron/platforms/android/shell/app/src/main/cpp/include/object.h +828 -0
  331. pytron/platforms/android/shell/app/src/main/cpp/include/objimpl.h +211 -0
  332. pytron/platforms/android/shell/app/src/main/cpp/include/opcode.h +43 -0
  333. pytron/platforms/android/shell/app/src/main/cpp/include/opcode_ids.h +259 -0
  334. pytron/platforms/android/shell/app/src/main/cpp/include/osdefs.h +57 -0
  335. pytron/platforms/android/shell/app/src/main/cpp/include/osmodule.h +17 -0
  336. pytron/platforms/android/shell/app/src/main/cpp/include/patchlevel.h +49 -0
  337. pytron/platforms/android/shell/app/src/main/cpp/include/py_curses.h +117 -0
  338. pytron/platforms/android/shell/app/src/main/cpp/include/pyatomic.h +16 -0
  339. pytron/platforms/android/shell/app/src/main/cpp/include/pybuffer.h +145 -0
  340. pytron/platforms/android/shell/app/src/main/cpp/include/pycapsule.h +58 -0
  341. pytron/platforms/android/shell/app/src/main/cpp/include/pyconfig.h +2088 -0
  342. pytron/platforms/android/shell/app/src/main/cpp/include/pydtrace.h +59 -0
  343. pytron/platforms/android/shell/app/src/main/cpp/include/pyerrors.h +335 -0
  344. pytron/platforms/android/shell/app/src/main/cpp/include/pyexpat.h +62 -0
  345. pytron/platforms/android/shell/app/src/main/cpp/include/pyframe.h +26 -0
  346. pytron/platforms/android/shell/app/src/main/cpp/include/pyhash.h +59 -0
  347. pytron/platforms/android/shell/app/src/main/cpp/include/pylifecycle.h +80 -0
  348. pytron/platforms/android/shell/app/src/main/cpp/include/pymacconfig.h +91 -0
  349. pytron/platforms/android/shell/app/src/main/cpp/include/pymacro.h +243 -0
  350. pytron/platforms/android/shell/app/src/main/cpp/include/pymath.h +65 -0
  351. pytron/platforms/android/shell/app/src/main/cpp/include/pymem.h +110 -0
  352. pytron/platforms/android/shell/app/src/main/cpp/include/pyport.h +710 -0
  353. pytron/platforms/android/shell/app/src/main/cpp/include/pystate.h +132 -0
  354. pytron/platforms/android/shell/app/src/main/cpp/include/pystats.h +28 -0
  355. pytron/platforms/android/shell/app/src/main/cpp/include/pystrcmp.h +23 -0
  356. pytron/platforms/android/shell/app/src/main/cpp/include/pystrtod.h +37 -0
  357. pytron/platforms/android/shell/app/src/main/cpp/include/pythonrun.h +42 -0
  358. pytron/platforms/android/shell/app/src/main/cpp/include/pythread.h +131 -0
  359. pytron/platforms/android/shell/app/src/main/cpp/include/pytypedefs.h +30 -0
  360. pytron/platforms/android/shell/app/src/main/cpp/include/rangeobject.h +27 -0
  361. pytron/platforms/android/shell/app/src/main/cpp/include/refcount.h +555 -0
  362. pytron/platforms/android/shell/app/src/main/cpp/include/setobject.h +49 -0
  363. pytron/platforms/android/shell/app/src/main/cpp/include/sliceobject.h +69 -0
  364. pytron/platforms/android/shell/app/src/main/cpp/include/structmember.h +56 -0
  365. pytron/platforms/android/shell/app/src/main/cpp/include/structseq.h +46 -0
  366. pytron/platforms/android/shell/app/src/main/cpp/include/sysmodule.h +27 -0
  367. pytron/platforms/android/shell/app/src/main/cpp/include/traceback.h +26 -0
  368. pytron/platforms/android/shell/app/src/main/cpp/include/tupleobject.h +46 -0
  369. pytron/platforms/android/shell/app/src/main/cpp/include/typeslots.h +96 -0
  370. pytron/platforms/android/shell/app/src/main/cpp/include/unicodeobject.h +1029 -0
  371. pytron/platforms/android/shell/app/src/main/cpp/include/warnings.h +45 -0
  372. pytron/platforms/android/shell/app/src/main/cpp/include/weakrefobject.h +46 -0
  373. pytron/platforms/android/shell/app/src/main/cpp/pytron_bridge.cpp +224 -0
  374. pytron/platforms/android/shell/app/src/main/java/com/pytron/shell/MainActivity.kt +208 -0
  375. pytron/platforms/android/shell/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
  376. pytron/platforms/android/shell/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
  377. pytron/platforms/android/shell/build.gradle +11 -0
  378. pytron/platforms/android/shell/gradle/wrapper/gradle-wrapper.jar +0 -0
  379. pytron/platforms/android/shell/gradle/wrapper/gradle-wrapper.properties +5 -0
  380. pytron/platforms/android/shell/gradle.properties +2 -0
  381. pytron/platforms/android/shell/gradlew.bat +85 -0
  382. pytron/platforms/android/shell/settings.gradle +16 -0
  383. pytron/platforms/darwin.py +82 -0
  384. pytron/platforms/darwin_ops/libs.py +31 -0
  385. pytron/platforms/darwin_ops/system.py +182 -0
  386. pytron/platforms/darwin_ops/utils.py +85 -0
  387. pytron/platforms/darwin_ops/webview.py +5 -0
  388. pytron/platforms/darwin_ops/window.py +102 -0
  389. pytron/platforms/interface.py +152 -0
  390. pytron/platforms/linux.py +82 -0
  391. pytron/platforms/linux_ops/libs.py +49 -0
  392. pytron/platforms/linux_ops/system.py +316 -0
  393. pytron/platforms/linux_ops/utils.py +19 -0
  394. pytron/platforms/linux_ops/webview.py +5 -0
  395. pytron/platforms/linux_ops/window.py +115 -0
  396. pytron/platforms/windows.py +136 -0
  397. pytron/platforms/windows_ops/__init__.py +0 -0
  398. pytron/platforms/windows_ops/constants.py +126 -0
  399. pytron/platforms/windows_ops/system.py +518 -0
  400. pytron/platforms/windows_ops/utils.py +3 -0
  401. pytron/platforms/windows_ops/webview.py +5 -0
  402. pytron/platforms/windows_ops/window.py +361 -0
  403. pytron/plugin.py +467 -0
  404. pytron/rcedit-x64.exe +0 -0
  405. pytron/router.py +146 -0
  406. pytron/serializer.py +240 -0
  407. pytron/shortcuts.py +279 -0
  408. pytron/state.py +76 -0
  409. pytron/tray.py +399 -0
  410. pytron/updater.py +181 -0
  411. pytron/utf8_hook.py +112 -0
  412. pytron/utils.py +44 -0
  413. pytron/webview.py +722 -0
  414. pytron_kit-0.3.12.dist-info/METADATA +131 -0
  415. pytron_kit-0.3.12.dist-info/RECORD +419 -0
  416. pytron_kit-0.3.12.dist-info/WHEEL +5 -0
  417. pytron_kit-0.3.12.dist-info/entry_points.txt +2 -0
  418. pytron_kit-0.3.12.dist-info/licenses/LICENSE +201 -0
  419. pytron_kit-0.3.12.dist-info/top_level.txt +1 -0
@@ -0,0 +1,702 @@
1
+ #ifndef Py_INTERNAL_OBMALLOC_H
2
+ #define Py_INTERNAL_OBMALLOC_H
3
+ #ifdef __cplusplus
4
+ extern "C" {
5
+ #endif
6
+
7
+ #ifndef Py_BUILD_CORE
8
+ # error "this header requires Py_BUILD_CORE define"
9
+ #endif
10
+
11
+
12
+ typedef unsigned int pymem_uint; /* assuming >= 16 bits */
13
+
14
+ #undef uint
15
+ #define uint pymem_uint
16
+
17
+
18
+ /* An object allocator for Python.
19
+
20
+ Here is an introduction to the layers of the Python memory architecture,
21
+ showing where the object allocator is actually used (layer +2), It is
22
+ called for every object allocation and deallocation (PyObject_New/Del),
23
+ unless the object-specific allocators implement a proprietary allocation
24
+ scheme (ex.: ints use a simple free list). This is also the place where
25
+ the cyclic garbage collector operates selectively on container objects.
26
+
27
+
28
+ Object-specific allocators
29
+ _____ ______ ______ ________
30
+ [ int ] [ dict ] [ list ] ... [ string ] Python core |
31
+ +3 | <----- Object-specific memory -----> | <-- Non-object memory --> |
32
+ _______________________________ | |
33
+ [ Python's object allocator ] | |
34
+ +2 | ####### Object memory ####### | <------ Internal buffers ------> |
35
+ ______________________________________________________________ |
36
+ [ Python's raw memory allocator (PyMem_ API) ] |
37
+ +1 | <----- Python memory (under PyMem manager's control) ------> | |
38
+ __________________________________________________________________
39
+ [ Underlying general-purpose allocator (ex: C library malloc) ]
40
+ 0 | <------ Virtual memory allocated for the python process -------> |
41
+
42
+ =========================================================================
43
+ _______________________________________________________________________
44
+ [ OS-specific Virtual Memory Manager (VMM) ]
45
+ -1 | <--- Kernel dynamic storage allocation & management (page-based) ---> |
46
+ __________________________________ __________________________________
47
+ [ ] [ ]
48
+ -2 | <-- Physical memory: ROM/RAM --> | | <-- Secondary storage (swap) --> |
49
+
50
+ */
51
+ /*==========================================================================*/
52
+
53
+ /* A fast, special-purpose memory allocator for small blocks, to be used
54
+ on top of a general-purpose malloc -- heavily based on previous art. */
55
+
56
+ /* Vladimir Marangozov -- August 2000 */
57
+
58
+ /*
59
+ * "Memory management is where the rubber meets the road -- if we do the wrong
60
+ * thing at any level, the results will not be good. And if we don't make the
61
+ * levels work well together, we are in serious trouble." (1)
62
+ *
63
+ * (1) Paul R. Wilson, Mark S. Johnstone, Michael Neely, and David Boles,
64
+ * "Dynamic Storage Allocation: A Survey and Critical Review",
65
+ * in Proc. 1995 Int'l. Workshop on Memory Management, September 1995.
66
+ */
67
+
68
+ /* #undef WITH_MEMORY_LIMITS */ /* disable mem limit checks */
69
+
70
+ /*==========================================================================*/
71
+
72
+ /*
73
+ * Allocation strategy abstract:
74
+ *
75
+ * For small requests, the allocator sub-allocates <Big> blocks of memory.
76
+ * Requests greater than SMALL_REQUEST_THRESHOLD bytes are routed to the
77
+ * system's allocator.
78
+ *
79
+ * Small requests are grouped in size classes spaced 8 bytes apart, due
80
+ * to the required valid alignment of the returned address. Requests of
81
+ * a particular size are serviced from memory pools of 4K (one VMM page).
82
+ * Pools are fragmented on demand and contain free lists of blocks of one
83
+ * particular size class. In other words, there is a fixed-size allocator
84
+ * for each size class. Free pools are shared by the different allocators
85
+ * thus minimizing the space reserved for a particular size class.
86
+ *
87
+ * This allocation strategy is a variant of what is known as "simple
88
+ * segregated storage based on array of free lists". The main drawback of
89
+ * simple segregated storage is that we might end up with lot of reserved
90
+ * memory for the different free lists, which degenerate in time. To avoid
91
+ * this, we partition each free list in pools and we share dynamically the
92
+ * reserved space between all free lists. This technique is quite efficient
93
+ * for memory intensive programs which allocate mainly small-sized blocks.
94
+ *
95
+ * For small requests we have the following table:
96
+ *
97
+ * Request in bytes Size of allocated block Size class idx
98
+ * ----------------------------------------------------------------
99
+ * 1-8 8 0
100
+ * 9-16 16 1
101
+ * 17-24 24 2
102
+ * 25-32 32 3
103
+ * 33-40 40 4
104
+ * 41-48 48 5
105
+ * 49-56 56 6
106
+ * 57-64 64 7
107
+ * 65-72 72 8
108
+ * ... ... ...
109
+ * 497-504 504 62
110
+ * 505-512 512 63
111
+ *
112
+ * 0, SMALL_REQUEST_THRESHOLD + 1 and up: routed to the underlying
113
+ * allocator.
114
+ */
115
+
116
+ /*==========================================================================*/
117
+
118
+ /*
119
+ * -- Main tunable settings section --
120
+ */
121
+
122
+ /*
123
+ * Alignment of addresses returned to the user. 8-bytes alignment works
124
+ * on most current architectures (with 32-bit or 64-bit address buses).
125
+ * The alignment value is also used for grouping small requests in size
126
+ * classes spaced ALIGNMENT bytes apart.
127
+ *
128
+ * You shouldn't change this unless you know what you are doing.
129
+ */
130
+
131
+ #if SIZEOF_VOID_P > 4
132
+ #define ALIGNMENT 16 /* must be 2^N */
133
+ #define ALIGNMENT_SHIFT 4
134
+ #else
135
+ #define ALIGNMENT 8 /* must be 2^N */
136
+ #define ALIGNMENT_SHIFT 3
137
+ #endif
138
+
139
+ /* Return the number of bytes in size class I, as a uint. */
140
+ #define INDEX2SIZE(I) (((pymem_uint)(I) + 1) << ALIGNMENT_SHIFT)
141
+
142
+ /*
143
+ * Max size threshold below which malloc requests are considered to be
144
+ * small enough in order to use preallocated memory pools. You can tune
145
+ * this value according to your application behaviour and memory needs.
146
+ *
147
+ * Note: a size threshold of 512 guarantees that newly created dictionaries
148
+ * will be allocated from preallocated memory pools on 64-bit.
149
+ *
150
+ * The following invariants must hold:
151
+ * 1) ALIGNMENT <= SMALL_REQUEST_THRESHOLD <= 512
152
+ * 2) SMALL_REQUEST_THRESHOLD is evenly divisible by ALIGNMENT
153
+ *
154
+ * Although not required, for better performance and space efficiency,
155
+ * it is recommended that SMALL_REQUEST_THRESHOLD is set to a power of 2.
156
+ */
157
+ #define SMALL_REQUEST_THRESHOLD 512
158
+ #define NB_SMALL_SIZE_CLASSES (SMALL_REQUEST_THRESHOLD / ALIGNMENT)
159
+
160
+ /*
161
+ * The system's VMM page size can be obtained on most unices with a
162
+ * getpagesize() call or deduced from various header files. To make
163
+ * things simpler, we assume that it is 4K, which is OK for most systems.
164
+ * It is probably better if this is the native page size, but it doesn't
165
+ * have to be. In theory, if SYSTEM_PAGE_SIZE is larger than the native page
166
+ * size, then `POOL_ADDR(p)->arenaindex' could rarely cause a segmentation
167
+ * violation fault. 4K is apparently OK for all the platforms that python
168
+ * currently targets.
169
+ */
170
+ #define SYSTEM_PAGE_SIZE (4 * 1024)
171
+
172
+ /*
173
+ * Maximum amount of memory managed by the allocator for small requests.
174
+ */
175
+ #ifdef WITH_MEMORY_LIMITS
176
+ #ifndef SMALL_MEMORY_LIMIT
177
+ #define SMALL_MEMORY_LIMIT (64 * 1024 * 1024) /* 64 MB -- more? */
178
+ #endif
179
+ #endif
180
+
181
+ #if !defined(WITH_PYMALLOC_RADIX_TREE)
182
+ /* Use radix-tree to track arena memory regions, for address_in_range().
183
+ * Enable by default since it allows larger pool sizes. Can be disabled
184
+ * using -DWITH_PYMALLOC_RADIX_TREE=0 */
185
+ #define WITH_PYMALLOC_RADIX_TREE 1
186
+ #endif
187
+
188
+ #if SIZEOF_VOID_P > 4
189
+ /* on 64-bit platforms use larger pools and arenas if we can */
190
+ #define USE_LARGE_ARENAS
191
+ #if WITH_PYMALLOC_RADIX_TREE
192
+ /* large pools only supported if radix-tree is enabled */
193
+ #define USE_LARGE_POOLS
194
+ #endif
195
+ #endif
196
+
197
+ /*
198
+ * The allocator sub-allocates <Big> blocks of memory (called arenas) aligned
199
+ * on a page boundary. This is a reserved virtual address space for the
200
+ * current process (obtained through a malloc()/mmap() call). In no way this
201
+ * means that the memory arenas will be used entirely. A malloc(<Big>) is
202
+ * usually an address range reservation for <Big> bytes, unless all pages within
203
+ * this space are referenced subsequently. So malloc'ing big blocks and not
204
+ * using them does not mean "wasting memory". It's an addressable range
205
+ * wastage...
206
+ *
207
+ * Arenas are allocated with mmap() on systems supporting anonymous memory
208
+ * mappings to reduce heap fragmentation.
209
+ */
210
+ #ifdef USE_LARGE_ARENAS
211
+ #define ARENA_BITS 20 /* 1 MiB */
212
+ #else
213
+ #define ARENA_BITS 18 /* 256 KiB */
214
+ #endif
215
+ #define ARENA_SIZE (1 << ARENA_BITS)
216
+ #define ARENA_SIZE_MASK (ARENA_SIZE - 1)
217
+
218
+ #ifdef WITH_MEMORY_LIMITS
219
+ #define MAX_ARENAS (SMALL_MEMORY_LIMIT / ARENA_SIZE)
220
+ #endif
221
+
222
+ /*
223
+ * Size of the pools used for small blocks. Must be a power of 2.
224
+ */
225
+ #ifdef USE_LARGE_POOLS
226
+ #define POOL_BITS 14 /* 16 KiB */
227
+ #else
228
+ #define POOL_BITS 12 /* 4 KiB */
229
+ #endif
230
+ #define POOL_SIZE (1 << POOL_BITS)
231
+ #define POOL_SIZE_MASK (POOL_SIZE - 1)
232
+
233
+ #if !WITH_PYMALLOC_RADIX_TREE
234
+ #if POOL_SIZE != SYSTEM_PAGE_SIZE
235
+ # error "pool size must be equal to system page size"
236
+ #endif
237
+ #endif
238
+
239
+ #define MAX_POOLS_IN_ARENA (ARENA_SIZE / POOL_SIZE)
240
+ #if MAX_POOLS_IN_ARENA * POOL_SIZE != ARENA_SIZE
241
+ # error "arena size not an exact multiple of pool size"
242
+ #endif
243
+
244
+ /*
245
+ * -- End of tunable settings section --
246
+ */
247
+
248
+ /*==========================================================================*/
249
+
250
+ /* When you say memory, my mind reasons in terms of (pointers to) blocks */
251
+ typedef uint8_t pymem_block;
252
+
253
+ /* Pool for small blocks. */
254
+ struct pool_header {
255
+ union { pymem_block *_padding;
256
+ uint count; } ref; /* number of allocated blocks */
257
+ pymem_block *freeblock; /* pool's free list head */
258
+ struct pool_header *nextpool; /* see "Pool table" for meaning */
259
+ struct pool_header *prevpool; /* " */
260
+ uint arenaindex; /* index into arenas of base adr */
261
+ uint szidx; /* block size class index */
262
+ uint nextoffset; /* bytes to virgin block */
263
+ uint maxnextoffset; /* largest valid nextoffset */
264
+ };
265
+
266
+ typedef struct pool_header *poolp;
267
+
268
+ /* Record keeping for arenas. */
269
+ struct arena_object {
270
+ /* The address of the arena, as returned by malloc. Note that 0
271
+ * will never be returned by a successful malloc, and is used
272
+ * here to mark an arena_object that doesn't correspond to an
273
+ * allocated arena.
274
+ */
275
+ uintptr_t address;
276
+
277
+ /* Pool-aligned pointer to the next pool to be carved off. */
278
+ pymem_block* pool_address;
279
+
280
+ /* The number of available pools in the arena: free pools + never-
281
+ * allocated pools.
282
+ */
283
+ uint nfreepools;
284
+
285
+ /* The total number of pools in the arena, whether or not available. */
286
+ uint ntotalpools;
287
+
288
+ /* Singly-linked list of available pools. */
289
+ struct pool_header* freepools;
290
+
291
+ /* Whenever this arena_object is not associated with an allocated
292
+ * arena, the nextarena member is used to link all unassociated
293
+ * arena_objects in the singly-linked `unused_arena_objects` list.
294
+ * The prevarena member is unused in this case.
295
+ *
296
+ * When this arena_object is associated with an allocated arena
297
+ * with at least one available pool, both members are used in the
298
+ * doubly-linked `usable_arenas` list, which is maintained in
299
+ * increasing order of `nfreepools` values.
300
+ *
301
+ * Else this arena_object is associated with an allocated arena
302
+ * all of whose pools are in use. `nextarena` and `prevarena`
303
+ * are both meaningless in this case.
304
+ */
305
+ struct arena_object* nextarena;
306
+ struct arena_object* prevarena;
307
+ };
308
+
309
+ #define POOL_OVERHEAD _Py_SIZE_ROUND_UP(sizeof(struct pool_header), ALIGNMENT)
310
+
311
+ #define DUMMY_SIZE_IDX 0xffff /* size class of newly cached pools */
312
+
313
+ /* Round pointer P down to the closest pool-aligned address <= P, as a poolp */
314
+ #define POOL_ADDR(P) ((poolp)_Py_ALIGN_DOWN((P), POOL_SIZE))
315
+
316
+ /* Return total number of blocks in pool of size index I, as a uint. */
317
+ #define NUMBLOCKS(I) ((pymem_uint)(POOL_SIZE - POOL_OVERHEAD) / INDEX2SIZE(I))
318
+
319
+ /*==========================================================================*/
320
+
321
+ /*
322
+ * Pool table -- headed, circular, doubly-linked lists of partially used pools.
323
+
324
+ This is involved. For an index i, usedpools[i+i] is the header for a list of
325
+ all partially used pools holding small blocks with "size class idx" i. So
326
+ usedpools[0] corresponds to blocks of size 8, usedpools[2] to blocks of size
327
+ 16, and so on: index 2*i <-> blocks of size (i+1)<<ALIGNMENT_SHIFT.
328
+
329
+ Pools are carved off an arena's highwater mark (an arena_object's pool_address
330
+ member) as needed. Once carved off, a pool is in one of three states forever
331
+ after:
332
+
333
+ used == partially used, neither empty nor full
334
+ At least one block in the pool is currently allocated, and at least one
335
+ block in the pool is not currently allocated (note this implies a pool
336
+ has room for at least two blocks).
337
+ This is a pool's initial state, as a pool is created only when malloc
338
+ needs space.
339
+ The pool holds blocks of a fixed size, and is in the circular list headed
340
+ at usedpools[i] (see above). It's linked to the other used pools of the
341
+ same size class via the pool_header's nextpool and prevpool members.
342
+ If all but one block is currently allocated, a malloc can cause a
343
+ transition to the full state. If all but one block is not currently
344
+ allocated, a free can cause a transition to the empty state.
345
+
346
+ full == all the pool's blocks are currently allocated
347
+ On transition to full, a pool is unlinked from its usedpools[] list.
348
+ It's not linked to from anything then anymore, and its nextpool and
349
+ prevpool members are meaningless until it transitions back to used.
350
+ A free of a block in a full pool puts the pool back in the used state.
351
+ Then it's linked in at the front of the appropriate usedpools[] list, so
352
+ that the next allocation for its size class will reuse the freed block.
353
+
354
+ empty == all the pool's blocks are currently available for allocation
355
+ On transition to empty, a pool is unlinked from its usedpools[] list,
356
+ and linked to the front of its arena_object's singly-linked freepools list,
357
+ via its nextpool member. The prevpool member has no meaning in this case.
358
+ Empty pools have no inherent size class: the next time a malloc finds
359
+ an empty list in usedpools[], it takes the first pool off of freepools.
360
+ If the size class needed happens to be the same as the size class the pool
361
+ last had, some pool initialization can be skipped.
362
+
363
+
364
+ Block Management
365
+
366
+ Blocks within pools are again carved out as needed. pool->freeblock points to
367
+ the start of a singly-linked list of free blocks within the pool. When a
368
+ block is freed, it's inserted at the front of its pool's freeblock list. Note
369
+ that the available blocks in a pool are *not* linked all together when a pool
370
+ is initialized. Instead only "the first two" (lowest addresses) blocks are
371
+ set up, returning the first such block, and setting pool->freeblock to a
372
+ one-block list holding the second such block. This is consistent with that
373
+ pymalloc strives at all levels (arena, pool, and block) never to touch a piece
374
+ of memory until it's actually needed.
375
+
376
+ So long as a pool is in the used state, we're certain there *is* a block
377
+ available for allocating, and pool->freeblock is not NULL. If pool->freeblock
378
+ points to the end of the free list before we've carved the entire pool into
379
+ blocks, that means we simply haven't yet gotten to one of the higher-address
380
+ blocks. The offset from the pool_header to the start of "the next" virgin
381
+ block is stored in the pool_header nextoffset member, and the largest value
382
+ of nextoffset that makes sense is stored in the maxnextoffset member when a
383
+ pool is initialized. All the blocks in a pool have been passed out at least
384
+ once when and only when nextoffset > maxnextoffset.
385
+
386
+
387
+ Major obscurity: While the usedpools vector is declared to have poolp
388
+ entries, it doesn't really. It really contains two pointers per (conceptual)
389
+ poolp entry, the nextpool and prevpool members of a pool_header. The
390
+ excruciating initialization code below fools C so that
391
+
392
+ usedpool[i+i]
393
+
394
+ "acts like" a genuine poolp, but only so long as you only reference its
395
+ nextpool and prevpool members. The "- 2*sizeof(pymem_block *)" gibberish is
396
+ compensating for that a pool_header's nextpool and prevpool members
397
+ immediately follow a pool_header's first two members:
398
+
399
+ union { pymem_block *_padding;
400
+ uint count; } ref;
401
+ pymem_block *freeblock;
402
+
403
+ each of which consume sizeof(pymem_block *) bytes. So what usedpools[i+i] really
404
+ contains is a fudged-up pointer p such that *if* C believes it's a poolp
405
+ pointer, then p->nextpool and p->prevpool are both p (meaning that the headed
406
+ circular list is empty).
407
+
408
+ It's unclear why the usedpools setup is so convoluted. It could be to
409
+ minimize the amount of cache required to hold this heavily-referenced table
410
+ (which only *needs* the two interpool pointer members of a pool_header). OTOH,
411
+ referencing code has to remember to "double the index" and doing so isn't
412
+ free, usedpools[0] isn't a strictly legal pointer, and we're crucially relying
413
+ on that C doesn't insert any padding anywhere in a pool_header at or before
414
+ the prevpool member.
415
+ **************************************************************************** */
416
+
417
+ #define OBMALLOC_USED_POOLS_SIZE (2 * ((NB_SMALL_SIZE_CLASSES + 7) / 8) * 8)
418
+
419
+ struct _obmalloc_pools {
420
+ poolp used[OBMALLOC_USED_POOLS_SIZE];
421
+ };
422
+
423
+
424
+ /*==========================================================================
425
+ Arena management.
426
+
427
+ `arenas` is a vector of arena_objects. It contains maxarenas entries, some of
428
+ which may not be currently used (== they're arena_objects that aren't
429
+ currently associated with an allocated arena). Note that arenas proper are
430
+ separately malloc'ed.
431
+
432
+ Prior to Python 2.5, arenas were never free()'ed. Starting with Python 2.5,
433
+ we do try to free() arenas, and use some mild heuristic strategies to increase
434
+ the likelihood that arenas eventually can be freed.
435
+
436
+ unused_arena_objects
437
+
438
+ This is a singly-linked list of the arena_objects that are currently not
439
+ being used (no arena is associated with them). Objects are taken off the
440
+ head of the list in new_arena(), and are pushed on the head of the list in
441
+ PyObject_Free() when the arena is empty. Key invariant: an arena_object
442
+ is on this list if and only if its .address member is 0.
443
+
444
+ usable_arenas
445
+
446
+ This is a doubly-linked list of the arena_objects associated with arenas
447
+ that have pools available. These pools are either waiting to be reused,
448
+ or have not been used before. The list is sorted to have the most-
449
+ allocated arenas first (ascending order based on the nfreepools member).
450
+ This means that the next allocation will come from a heavily used arena,
451
+ which gives the nearly empty arenas a chance to be returned to the system.
452
+ In my unscientific tests this dramatically improved the number of arenas
453
+ that could be freed.
454
+
455
+ Note that an arena_object associated with an arena all of whose pools are
456
+ currently in use isn't on either list.
457
+
458
+ Changed in Python 3.8: keeping usable_arenas sorted by number of free pools
459
+ used to be done by one-at-a-time linear search when an arena's number of
460
+ free pools changed. That could, overall, consume time quadratic in the
461
+ number of arenas. That didn't really matter when there were only a few
462
+ hundred arenas (typical!), but could be a timing disaster when there were
463
+ hundreds of thousands. See bpo-37029.
464
+
465
+ Now we have a vector of "search fingers" to eliminate the need to search:
466
+ nfp2lasta[nfp] returns the last ("rightmost") arena in usable_arenas
467
+ with nfp free pools. This is NULL if and only if there is no arena with
468
+ nfp free pools in usable_arenas.
469
+ */
470
+
471
+ /* How many arena_objects do we initially allocate?
472
+ * 16 = can allocate 16 arenas = 16 * ARENA_SIZE = 4MB before growing the
473
+ * `arenas` vector.
474
+ */
475
+ #define INITIAL_ARENA_OBJECTS 16
476
+
477
+ struct _obmalloc_mgmt {
478
+ /* Array of objects used to track chunks of memory (arenas). */
479
+ struct arena_object* arenas;
480
+ /* Number of slots currently allocated in the `arenas` vector. */
481
+ uint maxarenas;
482
+
483
+ /* The head of the singly-linked, NULL-terminated list of available
484
+ * arena_objects.
485
+ */
486
+ struct arena_object* unused_arena_objects;
487
+
488
+ /* The head of the doubly-linked, NULL-terminated at each end, list of
489
+ * arena_objects associated with arenas that have pools available.
490
+ */
491
+ struct arena_object* usable_arenas;
492
+
493
+ /* nfp2lasta[nfp] is the last arena in usable_arenas with nfp free pools */
494
+ struct arena_object* nfp2lasta[MAX_POOLS_IN_ARENA + 1];
495
+
496
+ /* Number of arenas allocated that haven't been free()'d. */
497
+ size_t narenas_currently_allocated;
498
+
499
+ /* Total number of times malloc() called to allocate an arena. */
500
+ size_t ntimes_arena_allocated;
501
+ /* High water mark (max value ever seen) for narenas_currently_allocated. */
502
+ size_t narenas_highwater;
503
+
504
+ Py_ssize_t raw_allocated_blocks;
505
+ };
506
+
507
+
508
+ #if WITH_PYMALLOC_RADIX_TREE
509
+ /*==========================================================================*/
510
+ /* radix tree for tracking arena usage. If enabled, used to implement
511
+ address_in_range().
512
+
513
+ memory address bit allocation for keys
514
+
515
+ 64-bit pointers, IGNORE_BITS=0 and 2^20 arena size:
516
+ 15 -> MAP_TOP_BITS
517
+ 15 -> MAP_MID_BITS
518
+ 14 -> MAP_BOT_BITS
519
+ 20 -> ideal aligned arena
520
+ ----
521
+ 64
522
+
523
+ 64-bit pointers, IGNORE_BITS=16, and 2^20 arena size:
524
+ 16 -> IGNORE_BITS
525
+ 10 -> MAP_TOP_BITS
526
+ 10 -> MAP_MID_BITS
527
+ 8 -> MAP_BOT_BITS
528
+ 20 -> ideal aligned arena
529
+ ----
530
+ 64
531
+
532
+ 32-bit pointers and 2^18 arena size:
533
+ 14 -> MAP_BOT_BITS
534
+ 18 -> ideal aligned arena
535
+ ----
536
+ 32
537
+
538
+ */
539
+
540
+ #if SIZEOF_VOID_P == 8
541
+
542
+ /* number of bits in a pointer */
543
+ #define POINTER_BITS 64
544
+
545
+ /* High bits of memory addresses that will be ignored when indexing into the
546
+ * radix tree. Setting this to zero is the safe default. For most 64-bit
547
+ * machines, setting this to 16 would be safe. The kernel would not give
548
+ * user-space virtual memory addresses that have significant information in
549
+ * those high bits. The main advantage to setting IGNORE_BITS > 0 is that less
550
+ * virtual memory will be used for the top and middle radix tree arrays. Those
551
+ * arrays are allocated in the BSS segment and so will typically consume real
552
+ * memory only if actually accessed.
553
+ */
554
+ #define IGNORE_BITS 0
555
+
556
+ /* use the top and mid layers of the radix tree */
557
+ #define USE_INTERIOR_NODES
558
+
559
+ #elif SIZEOF_VOID_P == 4
560
+
561
+ #define POINTER_BITS 32
562
+ #define IGNORE_BITS 0
563
+
564
+ #else
565
+
566
+ /* Currently this code works for 64-bit or 32-bit pointers only. */
567
+ #error "obmalloc radix tree requires 64-bit or 32-bit pointers."
568
+
569
+ #endif /* SIZEOF_VOID_P */
570
+
571
+ /* arena_coverage_t members require this to be true */
572
+ #if ARENA_BITS >= 32
573
+ # error "arena size must be < 2^32"
574
+ #endif
575
+
576
+ /* the lower bits of the address that are not ignored */
577
+ #define ADDRESS_BITS (POINTER_BITS - IGNORE_BITS)
578
+
579
+ #ifdef USE_INTERIOR_NODES
580
+ /* number of bits used for MAP_TOP and MAP_MID nodes */
581
+ #define INTERIOR_BITS ((ADDRESS_BITS - ARENA_BITS + 2) / 3)
582
+ #else
583
+ #define INTERIOR_BITS 0
584
+ #endif
585
+
586
+ #define MAP_TOP_BITS INTERIOR_BITS
587
+ #define MAP_TOP_LENGTH (1 << MAP_TOP_BITS)
588
+ #define MAP_TOP_MASK (MAP_TOP_LENGTH - 1)
589
+
590
+ #define MAP_MID_BITS INTERIOR_BITS
591
+ #define MAP_MID_LENGTH (1 << MAP_MID_BITS)
592
+ #define MAP_MID_MASK (MAP_MID_LENGTH - 1)
593
+
594
+ #define MAP_BOT_BITS (ADDRESS_BITS - ARENA_BITS - 2*INTERIOR_BITS)
595
+ #define MAP_BOT_LENGTH (1 << MAP_BOT_BITS)
596
+ #define MAP_BOT_MASK (MAP_BOT_LENGTH - 1)
597
+
598
+ #define MAP_BOT_SHIFT ARENA_BITS
599
+ #define MAP_MID_SHIFT (MAP_BOT_BITS + MAP_BOT_SHIFT)
600
+ #define MAP_TOP_SHIFT (MAP_MID_BITS + MAP_MID_SHIFT)
601
+
602
+ #define AS_UINT(p) ((uintptr_t)(p))
603
+ #define MAP_BOT_INDEX(p) ((AS_UINT(p) >> MAP_BOT_SHIFT) & MAP_BOT_MASK)
604
+ #define MAP_MID_INDEX(p) ((AS_UINT(p) >> MAP_MID_SHIFT) & MAP_MID_MASK)
605
+ #define MAP_TOP_INDEX(p) ((AS_UINT(p) >> MAP_TOP_SHIFT) & MAP_TOP_MASK)
606
+
607
+ #if IGNORE_BITS > 0
608
+ /* Return the ignored part of the pointer address. Those bits should be same
609
+ * for all valid pointers if IGNORE_BITS is set correctly.
610
+ */
611
+ #define HIGH_BITS(p) (AS_UINT(p) >> ADDRESS_BITS)
612
+ #else
613
+ #define HIGH_BITS(p) 0
614
+ #endif
615
+
616
+
617
+ /* This is the leaf of the radix tree. See arena_map_mark_used() for the
618
+ * meaning of these members. */
619
+ typedef struct {
620
+ int32_t tail_hi;
621
+ int32_t tail_lo;
622
+ } arena_coverage_t;
623
+
624
+ typedef struct arena_map_bot {
625
+ /* The members tail_hi and tail_lo are accessed together. So, it
626
+ * better to have them as an array of structs, rather than two
627
+ * arrays.
628
+ */
629
+ arena_coverage_t arenas[MAP_BOT_LENGTH];
630
+ } arena_map_bot_t;
631
+
632
+ #ifdef USE_INTERIOR_NODES
633
+ typedef struct arena_map_mid {
634
+ struct arena_map_bot *ptrs[MAP_MID_LENGTH];
635
+ } arena_map_mid_t;
636
+
637
+ typedef struct arena_map_top {
638
+ struct arena_map_mid *ptrs[MAP_TOP_LENGTH];
639
+ } arena_map_top_t;
640
+ #endif
641
+
642
+ struct _obmalloc_usage {
643
+ /* The root of radix tree. Note that by initializing like this, the memory
644
+ * should be in the BSS. The OS will only memory map pages as the MAP_MID
645
+ * nodes get used (OS pages are demand loaded as needed).
646
+ */
647
+ #ifdef USE_INTERIOR_NODES
648
+ arena_map_top_t arena_map_root;
649
+ /* accounting for number of used interior nodes */
650
+ int arena_map_mid_count;
651
+ int arena_map_bot_count;
652
+ #else
653
+ arena_map_bot_t arena_map_root;
654
+ #endif
655
+ };
656
+
657
+ #endif /* WITH_PYMALLOC_RADIX_TREE */
658
+
659
+
660
+ struct _obmalloc_global_state {
661
+ int dump_debug_stats;
662
+ Py_ssize_t interpreter_leaks;
663
+ };
664
+
665
+ struct _obmalloc_state {
666
+ struct _obmalloc_pools pools;
667
+ struct _obmalloc_mgmt mgmt;
668
+ #if WITH_PYMALLOC_RADIX_TREE
669
+ struct _obmalloc_usage usage;
670
+ #endif
671
+ };
672
+
673
+
674
+ #undef uint
675
+
676
+
677
+ /* Allocate memory directly from the O/S virtual memory system,
678
+ * where supported. Otherwise fallback on malloc */
679
+ void *_PyObject_VirtualAlloc(size_t size);
680
+ void _PyObject_VirtualFree(void *, size_t size);
681
+
682
+
683
+ /* This function returns the number of allocated memory blocks, regardless of size */
684
+ extern Py_ssize_t _Py_GetGlobalAllocatedBlocks(void);
685
+ #define _Py_GetAllocatedBlocks() \
686
+ _Py_GetGlobalAllocatedBlocks()
687
+ extern Py_ssize_t _PyInterpreterState_GetAllocatedBlocks(PyInterpreterState *);
688
+ extern void _PyInterpreterState_FinalizeAllocatedBlocks(PyInterpreterState *);
689
+ extern int _PyMem_init_obmalloc(PyInterpreterState *interp);
690
+ extern bool _PyMem_obmalloc_state_on_heap(PyInterpreterState *interp);
691
+
692
+
693
+ #ifdef WITH_PYMALLOC
694
+ // Export the symbol for the 3rd party 'guppy3' project
695
+ PyAPI_FUNC(int) _PyObject_DebugMallocStats(FILE *out);
696
+ #endif
697
+
698
+
699
+ #ifdef __cplusplus
700
+ }
701
+ #endif
702
+ #endif // !Py_INTERNAL_OBMALLOC_H