pystachy 0.2.0__tar.gz

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 (162) hide show
  1. pystachy-0.2.0/LICENSE +21 -0
  2. pystachy-0.2.0/PKG-INFO +93 -0
  3. pystachy-0.2.0/README.md +80 -0
  4. pystachy-0.2.0/THIRD_PARTY_NOTICES +1051 -0
  5. pystachy-0.2.0/VERSION +1 -0
  6. pystachy-0.2.0/lib/_argparse_help.py +188 -0
  7. pystachy-0.2.0/lib/_markupbase.py +399 -0
  8. pystachy-0.2.0/lib/_pyrandom.py +272 -0
  9. pystachy-0.2.0/lib/_pystachy__io.py +43 -0
  10. pystachy-0.2.0/lib/_pystachy_abc.py +105 -0
  11. pystachy-0.2.0/lib/_pystachy_atexit.py +76 -0
  12. pystachy-0.2.0/lib/_pystachy_bfile.py +245 -0
  13. pystachy-0.2.0/lib/_pystachy_binascii.py +412 -0
  14. pystachy-0.2.0/lib/_pystachy_bytescan.py +28 -0
  15. pystachy-0.2.0/lib/_pystachy_codecs.py +524 -0
  16. pystachy-0.2.0/lib/_pystachy_copy.py +43 -0
  17. pystachy-0.2.0/lib/_pystachy_iterators.py +207 -0
  18. pystachy-0.2.0/lib/_pystachy_itertools.py +996 -0
  19. pystachy-0.2.0/lib/_pystachy_json_any.py +271 -0
  20. pystachy-0.2.0/lib/_pystachy_json_int.py +6 -0
  21. pystachy-0.2.0/lib/_pystachy_mappingproxy.py +94 -0
  22. pystachy-0.2.0/lib/_pystachy_object.py +13 -0
  23. pystachy-0.2.0/lib/_pystachy_percent.py +343 -0
  24. pystachy-0.2.0/lib/_pystachy_range.py +139 -0
  25. pystachy-0.2.0/lib/_pystachy_re_specialized.py +33 -0
  26. pystachy-0.2.0/lib/_pystachy_string.py +175 -0
  27. pystachy-0.2.0/lib/_pystachy_struct.py +447 -0
  28. pystachy-0.2.0/lib/_pystachy_thread.py +433 -0
  29. pystachy-0.2.0/lib/_pystachy_time.py +15 -0
  30. pystachy-0.2.0/lib/_pystachy_types.py +13 -0
  31. pystachy-0.2.0/lib/_pystachy_unicodedata.py +873 -0
  32. pystachy-0.2.0/lib/_pystachy_unicodedata_db.py +1371 -0
  33. pystachy-0.2.0/lib/_pystachy_unicodedata_names.py +7634 -0
  34. pystachy-0.2.0/lib/_pystachy_weakref.py +111 -0
  35. pystachy-0.2.0/lib/_weakrefset.py +205 -0
  36. pystachy-0.2.0/lib/argparse.py +315 -0
  37. pystachy-0.2.0/lib/bisect.py +118 -0
  38. pystachy-0.2.0/lib/codecs.py +1135 -0
  39. pystachy-0.2.0/lib/collections/__init__.py +1282 -0
  40. pystachy-0.2.0/lib/colorsys.py +166 -0
  41. pystachy-0.2.0/lib/contextlib.py +300 -0
  42. pystachy-0.2.0/lib/copy.py +213 -0
  43. pystachy-0.2.0/lib/csv.py +1039 -0
  44. pystachy-0.2.0/lib/curses/__init__.py +4 -0
  45. pystachy-0.2.0/lib/curses/ascii.py +99 -0
  46. pystachy-0.2.0/lib/datetime.py +3044 -0
  47. pystachy-0.2.0/lib/difflib.py +2083 -0
  48. pystachy-0.2.0/lib/enum.py +854 -0
  49. pystachy-0.2.0/lib/fnmatch.py +249 -0
  50. pystachy-0.2.0/lib/functools.py +407 -0
  51. pystachy-0.2.0/lib/genericpath.py +200 -0
  52. pystachy-0.2.0/lib/getopt.py +214 -0
  53. pystachy-0.2.0/lib/gettext.py +657 -0
  54. pystachy-0.2.0/lib/glob.py +224 -0
  55. pystachy-0.2.0/lib/heapq.py +636 -0
  56. pystachy-0.2.0/lib/html/__init__.py +149 -0
  57. pystachy-0.2.0/lib/html/entities.py +2514 -0
  58. pystachy-0.2.0/lib/html/parser.py +602 -0
  59. pystachy-0.2.0/lib/io.py +1183 -0
  60. pystachy-0.2.0/lib/json.py +843 -0
  61. pystachy-0.2.0/lib/keyword.py +74 -0
  62. pystachy-0.2.0/lib/logging/__init__.py +2506 -0
  63. pystachy-0.2.0/lib/mpz.py +127 -0
  64. pystachy-0.2.0/lib/operator.py +455 -0
  65. pystachy-0.2.0/lib/pathlib.py +739 -0
  66. pystachy-0.2.0/lib/posixpath.py +578 -0
  67. pystachy-0.2.0/lib/pyobj.py +475 -0
  68. pystachy-0.2.0/lib/random.py +1174 -0
  69. pystachy-0.2.0/lib/re/__init__.py +2516 -0
  70. pystachy-0.2.0/lib/re/_constants.py +111 -0
  71. pystachy-0.2.0/lib/re/_sre.py +2108 -0
  72. pystachy-0.2.0/lib/re/_unicode.py +304 -0
  73. pystachy-0.2.0/lib/shlex.py +381 -0
  74. pystachy-0.2.0/lib/shutil.py +205 -0
  75. pystachy-0.2.0/lib/stat.py +212 -0
  76. pystachy-0.2.0/lib/statistics.py +1954 -0
  77. pystachy-0.2.0/lib/string.py +352 -0
  78. pystachy-0.2.0/lib/struct.py +15 -0
  79. pystachy-0.2.0/lib/textwrap.py +520 -0
  80. pystachy-0.2.0/lib/this.py +28 -0
  81. pystachy-0.2.0/lib/threading.py +1674 -0
  82. pystachy-0.2.0/lib/token.py +166 -0
  83. pystachy-0.2.0/lib/tomllib/__init__.py +10 -0
  84. pystachy-0.2.0/lib/tomllib/_parser.py +732 -0
  85. pystachy-0.2.0/lib/tomllib/_re.py +114 -0
  86. pystachy-0.2.0/lib/tomllib/_types.py +13 -0
  87. pystachy-0.2.0/lib/traceback.py +184 -0
  88. pystachy-0.2.0/lib/types.py +49 -0
  89. pystachy-0.2.0/lib/urllib/__init__.py +0 -0
  90. pystachy-0.2.0/lib/urllib/parse.py +1713 -0
  91. pystachy-0.2.0/lib/warnings.py +764 -0
  92. pystachy-0.2.0/lib/weakref.py +539 -0
  93. pystachy-0.2.0/mpz/mpz.c +463 -0
  94. pystachy-0.2.0/pyembed.c +373 -0
  95. pystachy-0.2.0/pyext.c +266 -0
  96. pystachy-0.2.0/pyproject.toml +35 -0
  97. pystachy-0.2.0/pystachy.egg-info/PKG-INFO +93 -0
  98. pystachy-0.2.0/pystachy.egg-info/SOURCES.txt +161 -0
  99. pystachy-0.2.0/pystachy.egg-info/dependency_links.txt +1 -0
  100. pystachy-0.2.0/pystachy.egg-info/entry_points.txt +2 -0
  101. pystachy-0.2.0/pystachy.egg-info/top_level.txt +1 -0
  102. pystachy-0.2.0/pystachy.py +34 -0
  103. pystachy-0.2.0/pystachy_cli.py +31 -0
  104. pystachy-0.2.0/pystachy_toolchain.py +152 -0
  105. pystachy-0.2.0/runtime.c +8564 -0
  106. pystachy-0.2.0/runtime.py +2276 -0
  107. pystachy-0.2.0/ryu/LICENSE-Boost +23 -0
  108. pystachy-0.2.0/ryu/common.h +114 -0
  109. pystachy-0.2.0/ryu/d2s.c +509 -0
  110. pystachy-0.2.0/ryu/d2s_intrinsics.h +357 -0
  111. pystachy-0.2.0/ryu/d2s_small_table.h +186 -0
  112. pystachy-0.2.0/ryu/digit_table.h +35 -0
  113. pystachy-0.2.0/ryu/ryu.h +46 -0
  114. pystachy-0.2.0/setup.cfg +4 -0
  115. pystachy-0.2.0/src/__init__.py +1 -0
  116. pystachy-0.2.0/src/pystachy_compiler/__init__.py +1 -0
  117. pystachy-0.2.0/src/pystachy_compiler/analysis.py +2105 -0
  118. pystachy-0.2.0/src/pystachy_compiler/argparse_schema.py +393 -0
  119. pystachy-0.2.0/src/pystachy_compiler/bigints.py +1498 -0
  120. pystachy-0.2.0/src/pystachy_compiler/builtins.py +3026 -0
  121. pystachy-0.2.0/src/pystachy_compiler/calls.py +1698 -0
  122. pystachy-0.2.0/src/pystachy_compiler/containers.py +1256 -0
  123. pystachy-0.2.0/src/pystachy_compiler/conversions.py +399 -0
  124. pystachy-0.2.0/src/pystachy_compiler/declarations.py +3000 -0
  125. pystachy-0.2.0/src/pystachy_compiler/diagnostics.py +176 -0
  126. pystachy-0.2.0/src/pystachy_compiler/driver.py +921 -0
  127. pystachy-0.2.0/src/pystachy_compiler/dynamic.py +4513 -0
  128. pystachy-0.2.0/src/pystachy_compiler/emission.py +666 -0
  129. pystachy-0.2.0/src/pystachy_compiler/exceptions.py +1642 -0
  130. pystachy-0.2.0/src/pystachy_compiler/expressions.py +5153 -0
  131. pystachy-0.2.0/src/pystachy_compiler/flow.py +972 -0
  132. pystachy-0.2.0/src/pystachy_compiler/functions.py +523 -0
  133. pystachy-0.2.0/src/pystachy_compiler/gen.py +5142 -0
  134. pystachy-0.2.0/src/pystachy_compiler/generators.py +1361 -0
  135. pystachy-0.2.0/src/pystachy_compiler/ir.py +579 -0
  136. pystachy-0.2.0/src/pystachy_compiler/ircheck.py +503 -0
  137. pystachy-0.2.0/src/pystachy_compiler/lexer.py +788 -0
  138. pystachy-0.2.0/src/pystachy_compiler/llvm_abi.py +19 -0
  139. pystachy-0.2.0/src/pystachy_compiler/loader.py +3787 -0
  140. pystachy-0.2.0/src/pystachy_compiler/local_versions.py +57 -0
  141. pystachy-0.2.0/src/pystachy_compiler/lower_module.py +754 -0
  142. pystachy-0.2.0/src/pystachy_compiler/lowering.py +625 -0
  143. pystachy-0.2.0/src/pystachy_compiler/memory_ir.py +28 -0
  144. pystachy-0.2.0/src/pystachy_compiler/module.py +55 -0
  145. pystachy-0.2.0/src/pystachy_compiler/names.py +55 -0
  146. pystachy-0.2.0/src/pystachy_compiler/optimizations.py +1445 -0
  147. pystachy-0.2.0/src/pystachy_compiler/parser.py +2465 -0
  148. pystachy-0.2.0/src/pystachy_compiler/program.py +1296 -0
  149. pystachy-0.2.0/src/pystachy_compiler/reflection.py +3073 -0
  150. pystachy-0.2.0/src/pystachy_compiler/scalar_ir.py +61 -0
  151. pystachy-0.2.0/src/pystachy_compiler/scope.py +619 -0
  152. pystachy-0.2.0/src/pystachy_compiler/specs.py +1102 -0
  153. pystachy-0.2.0/src/pystachy_compiler/statements.py +2126 -0
  154. pystachy-0.2.0/src/pystachy_compiler/structs.py +271 -0
  155. pystachy-0.2.0/src/pystachy_compiler/syntax.py +245 -0
  156. pystachy-0.2.0/src/pystachy_compiler/templates.py +998 -0
  157. pystachy-0.2.0/src/pystachy_compiler/union_arithmetic.py +161 -0
  158. pystachy-0.2.0/src/pystachy_compiler/union_proof.py +891 -0
  159. pystachy-0.2.0/src/pystachy_compiler/union_state.py +251 -0
  160. pystachy-0.2.0/src/pystachy_compiler/unions.py +591 -0
  161. pystachy-0.2.0/src/pystachy_compiler/utils.py +1124 -0
  162. pystachy-0.2.0/src/pystachy_compiler/variables.py +2323 -0
pystachy-0.2.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Denis Akhiyarov
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,93 @@
1
+ Metadata-Version: 2.4
2
+ Name: pystachy
3
+ Version: 0.2.0
4
+ Summary: Compile a typed subset of Python to native code through LLVM
5
+ License-Expression: MIT
6
+ Project-URL: Source, https://github.com/den-run-ai/pystachy
7
+ Requires-Python: >=3.11
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ License-File: THIRD_PARTY_NOTICES
11
+ License-File: ryu/LICENSE-Boost
12
+ Dynamic: license-file
13
+
14
+ # Pystachy
15
+
16
+ [![CI](https://github.com/den-run-ai/pystachy/actions/workflows/ci.yml/badge.svg?branch=main&event=push)](https://github.com/den-run-ai/pystachy/actions/workflows/ci.yml?query=branch%3Amain+event%3Apush)
17
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
18
+
19
+ Pystachy compiles a typed subset of Python to native code through LLVM. Use it
20
+ for CPU-bound work such as text processing, data repair, and simulation while
21
+ keeping your code in Python. The compiler is self-hosting, and its JIT and AOT
22
+ modes share the same [typed intermediate representation](docs/typed-ir.md).
23
+
24
+ ## Quick start
25
+
26
+ Follow the [installation guide](docs/install.md), then save this as `demo.py`:
27
+
28
+ ```python
29
+ from fnmatch import fnmatchcase
30
+ from functools import lru_cache
31
+
32
+
33
+ @lru_cache(maxsize=256)
34
+ def classify(name: str) -> str:
35
+ return "api" if fnmatchcase(name, "api.*") else "other"
36
+
37
+
38
+ print(classify("api.request"), classify("worker.done"))
39
+ ```
40
+
41
+ ```sh
42
+ python3 demo.py # CPython reference
43
+ pystachy run demo.py # Compile and run with JIT
44
+ pystachy build demo.py -o demo # Build a native executable
45
+ ./demo
46
+ ```
47
+
48
+ All three executions print `api other`. The executable runs without Python.
49
+ The [getting started guide](docs/getting-started.md) walks through a diagnostic
50
+ and shows how to measure compilation and execution separately.
51
+
52
+ ## What you can build
53
+
54
+ | Example | What it shows |
55
+ |---|---|
56
+ | [Event router](examples/route/README.md) | Route logs and traces using pattern matching and memoization. |
57
+ | [JSON repair](examples/json_repair/README.md) | Repair malformed JSON through a native CLI or a CPython extension. |
58
+ | [Coding agent](examples/agent/README.md) | Run a typed tool loop and edit files from a native executable. |
59
+ | [nanoGPT](examples/nanogpt/README.md) | Run inference and training with native arrays and optional BLAS. |
60
+
61
+ See the [performance guide](docs/performance.md) for measured workloads, startup
62
+ and memory costs, and reproduction commands. `run` compiles the program on every
63
+ invocation. `build` lets you reuse the executable.
64
+
65
+ ## Compatibility
66
+
67
+ Pystachy is experimental. It supports typed containers, classes, generators and
68
+ other common Python constructs. General multiple inheritance, `async` and
69
+ `match` are outside the supported subset. Integers are checked 64-bit values by
70
+ default. [Promoting integers](docs/python-int.md) and [dynamic `Any`](docs/dynamic-any.md)
71
+ are opt-in.
72
+
73
+ Check the [language guide](docs/language.md#support-at-a-glance) and
74
+ [library support table](docs/stdlib.md#library-support-at-a-glance) for the
75
+ features and APIs your code uses. The library includes bounded `argparse` and
76
+ `enum` support. Some packages compile from installed sources, and others need
77
+ adaptations like the [maintained ports](ports/README.md). The optional
78
+ [CPython bridge](docs/ffi.md#calling-cpython) lets native code call
79
+ packages that need CPython at runtime.
80
+
81
+ ## Roadmap
82
+
83
+ Pystachy is focused on stronger type inference, broader library support backed by
84
+ CPython comparisons, and lower compilation and execution costs.
85
+
86
+ ## Learn more
87
+
88
+ - [Documentation](docs/README.md) covers installation, packaging, interoperability and compiler internals.
89
+ - [Testing](docs/testing.md) explains CPython comparisons, bootstrap checks and CI.
90
+ - [Contributing](CONTRIBUTING.md) covers development setup, focused tests and submissions.
91
+
92
+ Pystachy is [MIT-licensed](LICENSE). See the [third-party notices](THIRD_PARTY_NOTICES)
93
+ for licenses of adapted code.
@@ -0,0 +1,80 @@
1
+ # Pystachy
2
+
3
+ [![CI](https://github.com/den-run-ai/pystachy/actions/workflows/ci.yml/badge.svg?branch=main&event=push)](https://github.com/den-run-ai/pystachy/actions/workflows/ci.yml?query=branch%3Amain+event%3Apush)
4
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
5
+
6
+ Pystachy compiles a typed subset of Python to native code through LLVM. Use it
7
+ for CPU-bound work such as text processing, data repair, and simulation while
8
+ keeping your code in Python. The compiler is self-hosting, and its JIT and AOT
9
+ modes share the same [typed intermediate representation](docs/typed-ir.md).
10
+
11
+ ## Quick start
12
+
13
+ Follow the [installation guide](docs/install.md), then save this as `demo.py`:
14
+
15
+ ```python
16
+ from fnmatch import fnmatchcase
17
+ from functools import lru_cache
18
+
19
+
20
+ @lru_cache(maxsize=256)
21
+ def classify(name: str) -> str:
22
+ return "api" if fnmatchcase(name, "api.*") else "other"
23
+
24
+
25
+ print(classify("api.request"), classify("worker.done"))
26
+ ```
27
+
28
+ ```sh
29
+ python3 demo.py # CPython reference
30
+ pystachy run demo.py # Compile and run with JIT
31
+ pystachy build demo.py -o demo # Build a native executable
32
+ ./demo
33
+ ```
34
+
35
+ All three executions print `api other`. The executable runs without Python.
36
+ The [getting started guide](docs/getting-started.md) walks through a diagnostic
37
+ and shows how to measure compilation and execution separately.
38
+
39
+ ## What you can build
40
+
41
+ | Example | What it shows |
42
+ |---|---|
43
+ | [Event router](examples/route/README.md) | Route logs and traces using pattern matching and memoization. |
44
+ | [JSON repair](examples/json_repair/README.md) | Repair malformed JSON through a native CLI or a CPython extension. |
45
+ | [Coding agent](examples/agent/README.md) | Run a typed tool loop and edit files from a native executable. |
46
+ | [nanoGPT](examples/nanogpt/README.md) | Run inference and training with native arrays and optional BLAS. |
47
+
48
+ See the [performance guide](docs/performance.md) for measured workloads, startup
49
+ and memory costs, and reproduction commands. `run` compiles the program on every
50
+ invocation. `build` lets you reuse the executable.
51
+
52
+ ## Compatibility
53
+
54
+ Pystachy is experimental. It supports typed containers, classes, generators and
55
+ other common Python constructs. General multiple inheritance, `async` and
56
+ `match` are outside the supported subset. Integers are checked 64-bit values by
57
+ default. [Promoting integers](docs/python-int.md) and [dynamic `Any`](docs/dynamic-any.md)
58
+ are opt-in.
59
+
60
+ Check the [language guide](docs/language.md#support-at-a-glance) and
61
+ [library support table](docs/stdlib.md#library-support-at-a-glance) for the
62
+ features and APIs your code uses. The library includes bounded `argparse` and
63
+ `enum` support. Some packages compile from installed sources, and others need
64
+ adaptations like the [maintained ports](ports/README.md). The optional
65
+ [CPython bridge](docs/ffi.md#calling-cpython) lets native code call
66
+ packages that need CPython at runtime.
67
+
68
+ ## Roadmap
69
+
70
+ Pystachy is focused on stronger type inference, broader library support backed by
71
+ CPython comparisons, and lower compilation and execution costs.
72
+
73
+ ## Learn more
74
+
75
+ - [Documentation](docs/README.md) covers installation, packaging, interoperability and compiler internals.
76
+ - [Testing](docs/testing.md) explains CPython comparisons, bootstrap checks and CI.
77
+ - [Contributing](CONTRIBUTING.md) covers development setup, focused tests and submissions.
78
+
79
+ Pystachy is [MIT-licensed](LICENSE). See the [third-party notices](THIRD_PARTY_NOTICES)
80
+ for licenses of adapted code.