pyscriptc 0.1.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 (149) hide show
  1. pyscriptc-0.1.0/LICENSE +201 -0
  2. pyscriptc-0.1.0/PKG-INFO +187 -0
  3. pyscriptc-0.1.0/README.md +161 -0
  4. pyscriptc-0.1.0/pyproject.toml +77 -0
  5. pyscriptc-0.1.0/setup.cfg +4 -0
  6. pyscriptc-0.1.0/src/pyscriptc/__init__.py +3 -0
  7. pyscriptc-0.1.0/src/pyscriptc/__main__.py +3 -0
  8. pyscriptc-0.1.0/src/pyscriptc/_posthog_token.py +1 -0
  9. pyscriptc-0.1.0/src/pyscriptc/builtins.py +156 -0
  10. pyscriptc-0.1.0/src/pyscriptc/canonical.py +167 -0
  11. pyscriptc-0.1.0/src/pyscriptc/check.py +49 -0
  12. pyscriptc-0.1.0/src/pyscriptc/cli.py +271 -0
  13. pyscriptc-0.1.0/src/pyscriptc/coverage.py +388 -0
  14. pyscriptc-0.1.0/src/pyscriptc/debug.py +120 -0
  15. pyscriptc-0.1.0/src/pyscriptc/diagnostics.py +179 -0
  16. pyscriptc-0.1.0/src/pyscriptc/errors.py +56 -0
  17. pyscriptc-0.1.0/src/pyscriptc/ir.py +365 -0
  18. pyscriptc-0.1.0/src/pyscriptc/llvm.py +2129 -0
  19. pyscriptc-0.1.0/src/pyscriptc/log.py +127 -0
  20. pyscriptc-0.1.0/src/pyscriptc/lower/__init__.py +1071 -0
  21. pyscriptc-0.1.0/src/pyscriptc/lower/_calls.py +1499 -0
  22. pyscriptc-0.1.0/src/pyscriptc/lower/_classes.py +969 -0
  23. pyscriptc-0.1.0/src/pyscriptc/lower/_core.py +301 -0
  24. pyscriptc-0.1.0/src/pyscriptc/lower/_expr.py +886 -0
  25. pyscriptc-0.1.0/src/pyscriptc/lower/_stdlib.py +491 -0
  26. pyscriptc-0.1.0/src/pyscriptc/lower/_stdlib_shared.py +93 -0
  27. pyscriptc-0.1.0/src/pyscriptc/lower/_stmt.py +1173 -0
  28. pyscriptc-0.1.0/src/pyscriptc/package.py +249 -0
  29. pyscriptc-0.1.0/src/pyscriptc/restlower.py +1008 -0
  30. pyscriptc-0.1.0/src/pyscriptc/runtime/ps_argv.c +28 -0
  31. pyscriptc-0.1.0/src/pyscriptc/runtime/ps_b64.c +168 -0
  32. pyscriptc-0.1.0/src/pyscriptc/runtime/ps_coll.c +133 -0
  33. pyscriptc-0.1.0/src/pyscriptc/runtime/ps_dt.c +388 -0
  34. pyscriptc-0.1.0/src/pyscriptc/runtime/ps_hash.c +411 -0
  35. pyscriptc-0.1.0/src/pyscriptc/runtime/ps_help.c +219 -0
  36. pyscriptc-0.1.0/src/pyscriptc/runtime/ps_hmac.c +120 -0
  37. pyscriptc-0.1.0/src/pyscriptc/runtime/ps_io.c +198 -0
  38. pyscriptc-0.1.0/src/pyscriptc/runtime/ps_island.c +272 -0
  39. pyscriptc-0.1.0/src/pyscriptc/runtime/ps_json.c +402 -0
  40. pyscriptc-0.1.0/src/pyscriptc/runtime/ps_mix.c +47 -0
  41. pyscriptc-0.1.0/src/pyscriptc/runtime/ps_more.c +1089 -0
  42. pyscriptc-0.1.0/src/pyscriptc/runtime/ps_osmore.c +447 -0
  43. pyscriptc-0.1.0/src/pyscriptc/runtime/ps_path.c +547 -0
  44. pyscriptc-0.1.0/src/pyscriptc/runtime/ps_re.c +1102 -0
  45. pyscriptc-0.1.0/src/pyscriptc/runtime/ps_rt.c +1175 -0
  46. pyscriptc-0.1.0/src/pyscriptc/runtime/ps_rt.h +189 -0
  47. pyscriptc-0.1.0/src/pyscriptc/runtime/ps_struct.c +291 -0
  48. pyscriptc-0.1.0/src/pyscriptc/runtime/ps_time.c +207 -0
  49. pyscriptc-0.1.0/src/pyscriptc/runtime/ps_unicode.c +1521 -0
  50. pyscriptc-0.1.0/src/pyscriptc/runtime/ps_url.c +327 -0
  51. pyscriptc-0.1.0/src/pyscriptc/stdlib_queue.py +191 -0
  52. pyscriptc-0.1.0/src/pyscriptc/stdmore.py +1596 -0
  53. pyscriptc-0.1.0/src/pyscriptc/telemetry.py +219 -0
  54. pyscriptc-0.1.0/src/pyscriptc.egg-info/PKG-INFO +187 -0
  55. pyscriptc-0.1.0/src/pyscriptc.egg-info/SOURCES.txt +147 -0
  56. pyscriptc-0.1.0/src/pyscriptc.egg-info/dependency_links.txt +1 -0
  57. pyscriptc-0.1.0/src/pyscriptc.egg-info/entry_points.txt +2 -0
  58. pyscriptc-0.1.0/src/pyscriptc.egg-info/requires.txt +1 -0
  59. pyscriptc-0.1.0/src/pyscriptc.egg-info/top_level.txt +1 -0
  60. pyscriptc-0.1.0/tests/test_adoption.py +52 -0
  61. pyscriptc-0.1.0/tests/test_agen_closed.py +60 -0
  62. pyscriptc-0.1.0/tests/test_all_completed.py +59 -0
  63. pyscriptc-0.1.0/tests/test_assert.py +90 -0
  64. pyscriptc-0.1.0/tests/test_band.py +376 -0
  65. pyscriptc-0.1.0/tests/test_baseline.py +98 -0
  66. pyscriptc-0.1.0/tests/test_basic_format.py +60 -0
  67. pyscriptc-0.1.0/tests/test_benchmarks.py +71 -0
  68. pyscriptc-0.1.0/tests/test_bool_surface.py +44 -0
  69. pyscriptc-0.1.0/tests/test_break.py +117 -0
  70. pyscriptc-0.1.0/tests/test_canonical.py +283 -0
  71. pyscriptc-0.1.0/tests/test_census.py +21 -0
  72. pyscriptc-0.1.0/tests/test_census_self.py +24 -0
  73. pyscriptc-0.1.0/tests/test_compare_chain.py +151 -0
  74. pyscriptc-0.1.0/tests/test_compat.py +53 -0
  75. pyscriptc-0.1.0/tests/test_compat2_calibration.py +129 -0
  76. pyscriptc-0.1.0/tests/test_compat2_corpus.py +95 -0
  77. pyscriptc-0.1.0/tests/test_compat2_probes.py +157 -0
  78. pyscriptc-0.1.0/tests/test_compat2_triage.py +128 -0
  79. pyscriptc-0.1.0/tests/test_constructors.py +102 -0
  80. pyscriptc-0.1.0/tests/test_continue.py +122 -0
  81. pyscriptc-0.1.0/tests/test_coverage.py +144 -0
  82. pyscriptc-0.1.0/tests/test_cross.py +41 -0
  83. pyscriptc-0.1.0/tests/test_debug.py +111 -0
  84. pyscriptc-0.1.0/tests/test_decorator.py +79 -0
  85. pyscriptc-0.1.0/tests/test_defaultaction.py +73 -0
  86. pyscriptc-0.1.0/tests/test_del.py +92 -0
  87. pyscriptc-0.1.0/tests/test_devnull.py +49 -0
  88. pyscriptc-0.1.0/tests/test_e1_append.py +339 -0
  89. pyscriptc-0.1.0/tests/test_e1_assert.py +198 -0
  90. pyscriptc-0.1.0/tests/test_e1_boolop_value.py +131 -0
  91. pyscriptc-0.1.0/tests/test_e1_del.py +83 -0
  92. pyscriptc-0.1.0/tests/test_e1_entry.py +248 -0
  93. pyscriptc-0.1.0/tests/test_e1_fortuple.py +117 -0
  94. pyscriptc-0.1.0/tests/test_e1_intbytes.py +137 -0
  95. pyscriptc-0.1.0/tests/test_e1_loops.py +165 -0
  96. pyscriptc-0.1.0/tests/test_e1_negstep.py +206 -0
  97. pyscriptc-0.1.0/tests/test_e1_print.py +218 -0
  98. pyscriptc-0.1.0/tests/test_e1_sortedkey.py +250 -0
  99. pyscriptc-0.1.0/tests/test_e1_sysargv.py +91 -0
  100. pyscriptc-0.1.0/tests/test_e2_exc.py +111 -0
  101. pyscriptc-0.1.0/tests/test_entrypoints.py +116 -0
  102. pyscriptc-0.1.0/tests/test_errno_platform.py +41 -0
  103. pyscriptc-0.1.0/tests/test_examples.py +75 -0
  104. pyscriptc-0.1.0/tests/test_fd_hygiene.py +23 -0
  105. pyscriptc-0.1.0/tests/test_fence_messages.py +63 -0
  106. pyscriptc-0.1.0/tests/test_flipcheck.py +175 -0
  107. pyscriptc-0.1.0/tests/test_float_inf.py +76 -0
  108. pyscriptc-0.1.0/tests/test_frozenset.py +94 -0
  109. pyscriptc-0.1.0/tests/test_frozenset_str.py +68 -0
  110. pyscriptc-0.1.0/tests/test_gates.py +336 -0
  111. pyscriptc-0.1.0/tests/test_holdout_guard.py +70 -0
  112. pyscriptc-0.1.0/tests/test_ifexp.py +62 -0
  113. pyscriptc-0.1.0/tests/test_int_surface.py +55 -0
  114. pyscriptc-0.1.0/tests/test_io_annotation.py +107 -0
  115. pyscriptc-0.1.0/tests/test_irscore.py +217 -0
  116. pyscriptc-0.1.0/tests/test_is_none.py +99 -0
  117. pyscriptc-0.1.0/tests/test_list_comp_if.py +122 -0
  118. pyscriptc-0.1.0/tests/test_log.py +82 -0
  119. pyscriptc-0.1.0/tests/test_lwave.py +441 -0
  120. pyscriptc-0.1.0/tests/test_match.py +158 -0
  121. pyscriptc-0.1.0/tests/test_module_fstring.py +86 -0
  122. pyscriptc-0.1.0/tests/test_module_set.py +66 -0
  123. pyscriptc-0.1.0/tests/test_nan_in.py +65 -0
  124. pyscriptc-0.1.0/tests/test_nativeprobe.py +135 -0
  125. pyscriptc-0.1.0/tests/test_or_mixed.py +102 -0
  126. pyscriptc-0.1.0/tests/test_ordereddict.py +78 -0
  127. pyscriptc-0.1.0/tests/test_package.py +246 -0
  128. pyscriptc-0.1.0/tests/test_pow.py +135 -0
  129. pyscriptc-0.1.0/tests/test_pyjwt_compat.py +80 -0
  130. pyscriptc-0.1.0/tests/test_r_batch.py +177 -0
  131. pyscriptc-0.1.0/tests/test_re_a.py +54 -0
  132. pyscriptc-0.1.0/tests/test_re_ascii.py +31 -0
  133. pyscriptc-0.1.0/tests/test_re_compile_module.py +89 -0
  134. pyscriptc-0.1.0/tests/test_re_debug.py +50 -0
  135. pyscriptc-0.1.0/tests/test_re_dotall.py +47 -0
  136. pyscriptc-0.1.0/tests/test_reduce.py +81 -0
  137. pyscriptc-0.1.0/tests/test_rest.py +127 -0
  138. pyscriptc-0.1.0/tests/test_scripting.py +411 -0
  139. pyscriptc-0.1.0/tests/test_slice_step.py +106 -0
  140. pyscriptc-0.1.0/tests/test_spike.py +289 -0
  141. pyscriptc-0.1.0/tests/test_stdlib_bench.py +33 -0
  142. pyscriptc-0.1.0/tests/test_stdlib_wave.py +115 -0
  143. pyscriptc-0.1.0/tests/test_str_surface.py +61 -0
  144. pyscriptc-0.1.0/tests/test_telemetry.py +151 -0
  145. pyscriptc-0.1.0/tests/test_timeout_max.py +60 -0
  146. pyscriptc-0.1.0/tests/test_tuple_ellipsis.py +85 -0
  147. pyscriptc-0.1.0/tests/test_tuple_membership.py +104 -0
  148. pyscriptc-0.1.0/tests/test_type_checking.py +108 -0
  149. pyscriptc-0.1.0/tests/test_version_surface.py +62 -0
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Joaquin Terrasa and contributors
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,187 @@
1
+ Metadata-Version: 2.4
2
+ Name: pyscriptc
3
+ Version: 0.1.0
4
+ Summary: Lower a typed subset of Python to LLVM, with CPython as the island.
5
+ Author: Joaquin Terrasa
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/sigilco/pyscriptc
8
+ Project-URL: Repository, https://github.com/sigilco/pyscriptc
9
+ Project-URL: Issues, https://github.com/sigilco/pyscriptc/issues
10
+ Project-URL: Reference, https://github.com/vercel-labs/scriptc
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: Topic :: Software Development :: Compilers
21
+ Requires-Python: >=3.10
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Requires-Dist: mypy>=2.4
25
+ Dynamic: license-file
26
+
27
+ <h1 align="center">pyscriptc</h1>
28
+
29
+ <p align="center">Compile annotated Python to a native binary. No CPython at runtime.</p>
30
+
31
+ <p align="center">
32
+ <a href="https://pypi.org/project/pyscriptc/"><img alt="PyPI" src="https://img.shields.io/pypi/v/pyscriptc"></a>
33
+ <a href="https://github.com/sigilco/pyscriptc/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/sigilco/pyscriptc/actions/workflows/ci.yml/badge.svg"></a>
34
+ <a href="LICENSE"><img alt="License" src="https://img.shields.io/badge/license-Apache--2.0-blue"></a>
35
+ </p>
36
+
37
+ A compiler that lowers a small, annotated subset of Python to a typed IR and then to LLVM. Parsing is CPython’s own `ast` module. [mypy](https://mypy-lang.org/) is a preflight: its tree is not an input. Anything the subset does not prove is a fence, not a guess.
38
+
39
+ ## Try it now
40
+
41
+ ```bash
42
+ uv tool install pyscriptc # or: pipx install pyscriptc / pip install pyscriptc
43
+ pyscriptc compile examples/sum_squares.py --run --call sum_squares --args '[10]' -o /tmp/sum_squares
44
+ ```
45
+
46
+ `sum_squares(10)` prints `285`, the same value CPython prints — from a native binary.
47
+
48
+ ## Install it
49
+
50
+ ```bash
51
+ uv tool install pyscriptc
52
+ ```
53
+
54
+ Requirements: CPython 3.10 or later (the IR is stamped with the interpreter that lowered it) and a clang that can assemble textual LLVM IR. `pipx install pyscriptc` and `pip install pyscriptc` work the same way.
55
+
56
+ ## What it does
57
+
58
+ - Lowers an annotated Python subset (strict `x: T` typing, checked by mypy) to typed IR, then LLVM IR, then a native binary via clang or `zig cc`.
59
+ - Anything the subset does not prove stops at a named `PSxxxx` fence with a hint — it never guesses at semantics.
60
+ - `int` is a Python int: `i64` only when the value fits, traps on overflow, refuses literals that would truncate. `//` is floor division.
61
+ - Island calls (`subprocess.check_output`, `socket.gethostname`, `threading`, `logging`) embed CPython on first use — and only binaries that call them link libpython.
62
+ - `--emit ir` / `--emit llvm` dump the intermediate forms; `--run` compiles and executes; `--target` + `--driver zig` cross-compiles.
63
+
64
+ ## Stack
65
+
66
+ | Layer | What it is |
67
+ | --- | --- |
68
+ | Parser | CPython's own `ast` module |
69
+ | Checker | mypy preflight + the `PS1xxx`/`PS2xxx` fence tables |
70
+ | IR | typed JSON, stamped per-interpreter (`gates-v1`) |
71
+ | Backend | hand-emitted LLVM IR text → `clang` / `zig cc` |
72
+ | Island | optional embedded-CPython calls, CPython-linked only when used |
73
+ | Scoring | `benchmarks/` layout follows [scriptc](https://github.com/vercel-labs/scriptc) |
74
+
75
+ The design is in [ARCHITECTURE.md](ARCHITECTURE.md). How to compile a script is in [docs/](docs/README.md). Contributor notes are in [.agents/docs/](.agents/docs/README.md). Programs that compile today, including an invoice, an access-log gate, and a URL allow-list, are in [examples/](examples/README.md). The benchmark layout is scriptc’s `benchmarks/` directory; see [benchmarks/README.md](benchmarks/README.md).
76
+
77
+ Licensed under Apache 2.0. Copyright 2026 Joaquin Terrasa and contributors.
78
+
79
+ ## Subset
80
+
81
+ The IR stamp is `gates-v1`. Lowered:
82
+
83
+ - Annotated functions whose parameters and return use `int`, `float`, `bool`, `str`, `bytes`, `list`, `dict`, or an annotated class
84
+ - `if`, `while`, `for` over a `list` or `range`, assignment, `return`
85
+ - `int` `+`, `-`, `*`, `//`, unary `-`, and comparisons
86
+ - `float` `+`, `-`, `*`, and comparisons (`NaN` follows Python: `nan != nan`)
87
+ - `str` and `bytes` concatenation, indexing, ordering, and `in`
88
+ - `len` on `str`, `bytes`, `list`, `dict`, and `collections.deque`
89
+ - `abs`, `min`, `max`, `sum`, `sorted`, `ord`, `chr`, `round`, `isinstance`, `getattr`, and `hasattr` (the attribute name is a string literal)
90
+ - `open` with a literal mode `r`, `w`, `rb`, `wb`, `a`, or `ab`
91
+ - `int(float)` (toward zero) and `float(int)`
92
+ - Latin-1 `str` and `bytes` methods: `strip`, `lstrip`, `rstrip`, `upper`, `lower`, `startswith`, `endswith`, `find`, `replace`, `split`, `join`, plus `encode()` and `decode()` with no extra arguments
93
+ - `list` and `dict` literals, indexing, and item assignment. Assignment shares the buffer
94
+ - `try` / `except` for `ValueError`, `IndexError`, `KeyError`, `OverflowError`, `ZeroDivisionError`, `RuntimeError`, `Exception`, and a user subclass of one of those
95
+ - `*args` of one element type, lowered as a `list` of that type. A `set` of `int` or `str`: construction, `add`, membership, `len`, and iteration
96
+ - Annotated classes: fields, `__init__`, methods, and a single base. Layout is the parent's fields, then the class's own fields. Method lookup walks the parent. `@property` (getter only), `@staticmethod`, and `@classmethod` on methods. A flat `@dataclass` generates `__init__` from annotations. `enum.IntEnum` and `enum.Enum` members are integer constants. A subclass of `Exception` (or another lowered exception) can be raised and caught as its own type and as the parent
97
+ - `import` / `from` against the closed table in `pyscriptc.stdlib_queue`. `math` is lowered (`sqrt`, `fabs`, `sin`, `cos`, `tan`, `exp`, `log`, `log2`, `log10`, `hypot`, `pow`, `floor`, `ceil`, `trunc`, `isnan`, `isinf`, and `pi`, `e`, `tau`, `inf`, `nan`). The codec wave is lowered too: `re` (`escape`, `findall`, `sub`, `split`, `compile`), `json` (`loads`, `dumps`), `urllib.parse` (`quote`, `quote_plus`, `unquote`, `unquote_plus`, `urlencode`, `parse_qs`, `urlsplit`), `base64` (`b64encode`, `b64decode`, and the standard and urlsafe pairs), `hashlib` (`md5`, `sha1`, `sha256`, `sha384`, `sha512`), and `struct` (`pack`, `unpack` of a literal format). The rest of the queue is lowered as a closed surface: `datetime`, `time`, `collections`, `functools`, `itertools`, `operator`, `contextlib`, `os`, `posixpath`, `pathlib`, `stat`, `fnmatch`, `warnings`, `io`, `string`, `bisect`, `errno`, and the island modules `sys`, `importlib`, `inspect`, `threading`, `logging`, `asyncio`, `subprocess`, `socket`, `ssl`, and `ctypes`. Also lowered, as closed names: `importlib.resources.files` / `as_file`, `hmac.digest` / `new` / `compare_digest` for a literal `sha256` / `sha384` / `sha512` (and `md5` / `sha1`), Latin-1 `unicodedata`, `tempfile.gettempdir` / `gettempprefix` / `mkdtemp`, `atexit.register` of a no-argument function, `shutil.copyfile` / `rmtree`, `enum.Enum` / `enum.IntEnum` as integer members, and `dataclasses.dataclass` as a flat `__init__`. Anything outside the table fences at the import (`PS2002`). A name added to the queue and left out of the lowered set would fence with `PS2101`
98
+
99
+ Fenced (no LLVM for that file):
100
+
101
+ - `and` / `or` across two types, f-string format specs, a slice step other than 1, `break`, `continue`, `finally`, `except as`, user decorators, `super()`, multiple inheritance, `**kwargs`, keyword-only and positional-only parameters, and starred calls
102
+ - String literals outside Latin-1
103
+ - `bool` arithmetic, `list[bool]`, and `dict` values of `bool`. `bool` is not promoted to `float`
104
+ - Calls such as `str.encode("ascii")`, `math.gcd`, `functools.partial`, `itertools.count`, `operator.itemgetter`, `importlib.import_module`, and `asyncio.run` that are outside the lowered surface
105
+ - `with` except `contextlib.suppress(Exc)`, `contextlib.nullcontext()`, `with open(...) as name`, and `with importlib.resources.as_file(...) as name`
106
+ - `itertools.repeat` and `itertools.chain` except as the iterator of a `for`
107
+ - `re.findall` with more than four capturing groups. A literal pattern of two to four groups returns a tuple of strings. A dynamic pattern with two or more groups raises `ValueError`
108
+ - Float JSON, JSON null, and non-ASCII JSON text
109
+ - `struct` format `@`, a format that is not a string literal, and `Q` values that do not fit in `i64`
110
+ - Keyword arguments, including `re` flags and `base64` `validate`
111
+
112
+ `//` is Python floor division, including negative operands. Division by zero and signed `i64` overflow abort the process. They do not wrap. `math.floor`, `math.ceil`, `math.trunc`, and `int(float)` raise `OverflowError` when the result does not fit in `i64`. An uncaught exception prints its name to stderr and exits 1.
113
+
114
+ A `for` target that is new in the function is stored as `0`, `0.0`, or `""` before the loop. After `for i in range(0)`, this subset reads `i` as `0`. CPython would raise `UnboundLocalError`. A target that already had a value keeps that value when the loop body never runs.
115
+
116
+ `in` on a list uses `==`. `math.nan in [math.nan]` is false here. CPython's list finds that same object by identity before it compares.
117
+
118
+ `typing` stays in mypy. It is not a runtime lowering. Island constants (`sys.platform`, `sys.version`, `sys.executable`, `sys.maxsize`, `socket.AF_INET`, `ssl.OPENSSL_VERSION`, `ssl.HAS_SNI`, `stat.S_IFREG`, `ctypes.sizeof`) are baked from the interpreter that lowers the file. `sys.exit` is libc `exit`. `subprocess.check_output` takes a `list[str]` and returns `bytes`. `os.getenv` raises `KeyError` when the variable is unset. `date` plus `timedelta` uses the normalized day count; `datetime` plus `timedelta` uses the whole delta.
119
+
120
+ ## Requirements
121
+
122
+ - CPython 3.10 or later (the IR is stamped with the interpreter that lowered it)
123
+ - [uv](https://docs.astral.sh/uv/)
124
+ - Clang that can assemble textual LLVM IR
125
+
126
+ ## Run
127
+
128
+ ```bash
129
+ uv sync
130
+ uv run pyscriptc compile examples/sum_squares.py --run --call sum_squares --args '[10]' -o /tmp/sum_squares
131
+ ```
132
+
133
+ `sum_squares(10)` prints `285`, the same value CPython prints. `--args` is a Python literal parsed with `ast.literal_eval`, so integers are not rounded through JSON.
134
+
135
+ Other corpus programs:
136
+
137
+ ```bash
138
+ uv run pyscriptc compile examples/longer.py --run --call longer --args '["bb", "a"]' -o /tmp/longer
139
+ uv run pyscriptc compile examples/floor_div.py --run --call floor_div --args '[-3, 2]' -o /tmp/floor_div
140
+ uv run pyscriptc compile examples/gates_math.py --run --call floors -o /tmp/floors
141
+ uv run pyscriptc compile examples/gates_probe.py --run --call probe -o /tmp/probe
142
+ uv run pyscriptc compile examples/fence_method.py --emit llvm -o /tmp/fence.ll
143
+ ```
144
+
145
+ `floors()` prints `3`. `probe()` prints `0`. The fence exits nonzero, names `encode`, and does not write LLVM. `examples/wave_probe.py` prints `0` when the codec wave matches CPython. `examples/rest_probe.py` prints `0` when the rest of the queue matches CPython. `examples/fence_pickle.py` exits nonzero with `PS2002` because `pickle` is outside the import table. `examples/invoice.py`, `examples/access_log.py`, `examples/request_id.py`, `examples/release_note.py`, `examples/blob_digest.py`, `examples/url_gate.py`, and `examples/hostname.py` are the scripts in [docs/examples.md](docs/examples.md). `examples/bad_annotation.py` fails in mypy before lowering. `examples/big_literal.py` lowers to IR, then LLVM emission refuses the integer because it does not fit in `i64`.
146
+
147
+ `re.compile` returns a `Pattern` with a `pattern` field. `findall`, `sub`, and `split` on that object use the field. `hashlib` returns an opaque `Hash`; `hexdigest` and `digest` are the methods that lower. `urlsplit` returns a `SplitResult` of five strings (`scheme`, `netloc`, `path`, `query`, `fragment`). `struct.unpack` is a list, so `[0]` is the first value. `json.loads` takes its type from the annotation it is assigned to, or from the return annotation. `parse_qs` splits on `&` only, which is what CPython 3.14 does. A pattern that can match empty forever, such as `()*`, stops with `RuntimeError` once the matcher spends its fuel. `re.error`, `struct.error`, and `binascii.Error` surface here as `ValueError`.
148
+
149
+ `--emit ir` writes the JSON IR. `--emit llvm` writes textual LLVM. The CPython version is a field on the module. Emitting LLVM from an IR stamped by a different version is an error: re-lower it and re-run the corpus.
150
+
151
+ ## Benchmarks
152
+
153
+ ```bash
154
+ uv run python -m benchmarks.baseline.run --check
155
+ uv run python -m benchmarks.runtime.run --runs=5
156
+ uv run python -m benchmarks.scaling.run
157
+ ```
158
+
159
+ `benchmarks/baseline/reference.json` is the reference metric set: wall time and peak RSS for each lowered workload, against the same call under CPython. Printed figures are speedups, `Nx CPython`, the reciprocal of the stored pyscriptc/CPython ratio, so a larger number is a bigger gain. `--check` still compares the stored ratios: it fails when a time ratio grows past 2× that set, or an RSS ratio grows past 1.25×. A reference of 10.0x CPython therefore fails once the run prints less than 5.0x.
160
+
161
+ The kernel geomean is the original four loops. The stdlib rows time every module that has a lowered call, including the builtin helpers. `importlib.import_module` and `asyncio.run` are fences, so those calls are not timed. `importlib.resources`, `hmac`, and Latin-1 `unicodedata` have their own rows. Calls that embed CPython (`socket.gethostname`, `inspect.cleandoc`, `threading`, `logging`, `subprocess.check_output`) are the island group: they link libpython, and their speedup sits near 1x CPython. `benchmarks/adoption` records why pyperformance, click, typer, pip, and black are not compiled suites yet.
162
+
163
+ ## Telemetry
164
+
165
+ Release builds collect anonymous usage metrics with PostHog (EU host): the subcommand you ran, pyscriptc/python versions, platform, compile duration, and the first `PSxxxx` fence code when a file fails to lower. Never sent: file names, paths, or source text. The machine id is a salted sha256 that is not reversible.
166
+
167
+ Telemetry is off in CI and a no-op in dev checkouts (no baked-in token). One stderr line announces it on first use. Disable it with any of:
168
+
169
+ ```bash
170
+ pyscriptc telemetry disable # writes ~/.config/pyscriptc/config.toml
171
+ export PYSC_NO_TELEMETRY=1
172
+ export DO_NOT_TRACK=1
173
+ ```
174
+
175
+ `pyscriptc telemetry status` shows the effective state and why.
176
+
177
+ ## Checks
178
+
179
+ ```bash
180
+ uv run ruff check .
181
+ uv run ruff format --check .
182
+ uv run pytest
183
+ ```
184
+
185
+ ## What this does not prove
186
+
187
+ A new CPython release is not supported yet in the product sense. The stamp and the fences are the hooks that make that possible later: unknown syntax fails closed, and the backend will not silently compile IR from an interpreter it has not been run against. Island calls embed that same interpreter, and only the binary that actually calls them links libpython.
@@ -0,0 +1,161 @@
1
+ <h1 align="center">pyscriptc</h1>
2
+
3
+ <p align="center">Compile annotated Python to a native binary. No CPython at runtime.</p>
4
+
5
+ <p align="center">
6
+ <a href="https://pypi.org/project/pyscriptc/"><img alt="PyPI" src="https://img.shields.io/pypi/v/pyscriptc"></a>
7
+ <a href="https://github.com/sigilco/pyscriptc/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/sigilco/pyscriptc/actions/workflows/ci.yml/badge.svg"></a>
8
+ <a href="LICENSE"><img alt="License" src="https://img.shields.io/badge/license-Apache--2.0-blue"></a>
9
+ </p>
10
+
11
+ A compiler that lowers a small, annotated subset of Python to a typed IR and then to LLVM. Parsing is CPython’s own `ast` module. [mypy](https://mypy-lang.org/) is a preflight: its tree is not an input. Anything the subset does not prove is a fence, not a guess.
12
+
13
+ ## Try it now
14
+
15
+ ```bash
16
+ uv tool install pyscriptc # or: pipx install pyscriptc / pip install pyscriptc
17
+ pyscriptc compile examples/sum_squares.py --run --call sum_squares --args '[10]' -o /tmp/sum_squares
18
+ ```
19
+
20
+ `sum_squares(10)` prints `285`, the same value CPython prints — from a native binary.
21
+
22
+ ## Install it
23
+
24
+ ```bash
25
+ uv tool install pyscriptc
26
+ ```
27
+
28
+ Requirements: CPython 3.10 or later (the IR is stamped with the interpreter that lowered it) and a clang that can assemble textual LLVM IR. `pipx install pyscriptc` and `pip install pyscriptc` work the same way.
29
+
30
+ ## What it does
31
+
32
+ - Lowers an annotated Python subset (strict `x: T` typing, checked by mypy) to typed IR, then LLVM IR, then a native binary via clang or `zig cc`.
33
+ - Anything the subset does not prove stops at a named `PSxxxx` fence with a hint — it never guesses at semantics.
34
+ - `int` is a Python int: `i64` only when the value fits, traps on overflow, refuses literals that would truncate. `//` is floor division.
35
+ - Island calls (`subprocess.check_output`, `socket.gethostname`, `threading`, `logging`) embed CPython on first use — and only binaries that call them link libpython.
36
+ - `--emit ir` / `--emit llvm` dump the intermediate forms; `--run` compiles and executes; `--target` + `--driver zig` cross-compiles.
37
+
38
+ ## Stack
39
+
40
+ | Layer | What it is |
41
+ | --- | --- |
42
+ | Parser | CPython's own `ast` module |
43
+ | Checker | mypy preflight + the `PS1xxx`/`PS2xxx` fence tables |
44
+ | IR | typed JSON, stamped per-interpreter (`gates-v1`) |
45
+ | Backend | hand-emitted LLVM IR text → `clang` / `zig cc` |
46
+ | Island | optional embedded-CPython calls, CPython-linked only when used |
47
+ | Scoring | `benchmarks/` layout follows [scriptc](https://github.com/vercel-labs/scriptc) |
48
+
49
+ The design is in [ARCHITECTURE.md](ARCHITECTURE.md). How to compile a script is in [docs/](docs/README.md). Contributor notes are in [.agents/docs/](.agents/docs/README.md). Programs that compile today, including an invoice, an access-log gate, and a URL allow-list, are in [examples/](examples/README.md). The benchmark layout is scriptc’s `benchmarks/` directory; see [benchmarks/README.md](benchmarks/README.md).
50
+
51
+ Licensed under Apache 2.0. Copyright 2026 Joaquin Terrasa and contributors.
52
+
53
+ ## Subset
54
+
55
+ The IR stamp is `gates-v1`. Lowered:
56
+
57
+ - Annotated functions whose parameters and return use `int`, `float`, `bool`, `str`, `bytes`, `list`, `dict`, or an annotated class
58
+ - `if`, `while`, `for` over a `list` or `range`, assignment, `return`
59
+ - `int` `+`, `-`, `*`, `//`, unary `-`, and comparisons
60
+ - `float` `+`, `-`, `*`, and comparisons (`NaN` follows Python: `nan != nan`)
61
+ - `str` and `bytes` concatenation, indexing, ordering, and `in`
62
+ - `len` on `str`, `bytes`, `list`, `dict`, and `collections.deque`
63
+ - `abs`, `min`, `max`, `sum`, `sorted`, `ord`, `chr`, `round`, `isinstance`, `getattr`, and `hasattr` (the attribute name is a string literal)
64
+ - `open` with a literal mode `r`, `w`, `rb`, `wb`, `a`, or `ab`
65
+ - `int(float)` (toward zero) and `float(int)`
66
+ - Latin-1 `str` and `bytes` methods: `strip`, `lstrip`, `rstrip`, `upper`, `lower`, `startswith`, `endswith`, `find`, `replace`, `split`, `join`, plus `encode()` and `decode()` with no extra arguments
67
+ - `list` and `dict` literals, indexing, and item assignment. Assignment shares the buffer
68
+ - `try` / `except` for `ValueError`, `IndexError`, `KeyError`, `OverflowError`, `ZeroDivisionError`, `RuntimeError`, `Exception`, and a user subclass of one of those
69
+ - `*args` of one element type, lowered as a `list` of that type. A `set` of `int` or `str`: construction, `add`, membership, `len`, and iteration
70
+ - Annotated classes: fields, `__init__`, methods, and a single base. Layout is the parent's fields, then the class's own fields. Method lookup walks the parent. `@property` (getter only), `@staticmethod`, and `@classmethod` on methods. A flat `@dataclass` generates `__init__` from annotations. `enum.IntEnum` and `enum.Enum` members are integer constants. A subclass of `Exception` (or another lowered exception) can be raised and caught as its own type and as the parent
71
+ - `import` / `from` against the closed table in `pyscriptc.stdlib_queue`. `math` is lowered (`sqrt`, `fabs`, `sin`, `cos`, `tan`, `exp`, `log`, `log2`, `log10`, `hypot`, `pow`, `floor`, `ceil`, `trunc`, `isnan`, `isinf`, and `pi`, `e`, `tau`, `inf`, `nan`). The codec wave is lowered too: `re` (`escape`, `findall`, `sub`, `split`, `compile`), `json` (`loads`, `dumps`), `urllib.parse` (`quote`, `quote_plus`, `unquote`, `unquote_plus`, `urlencode`, `parse_qs`, `urlsplit`), `base64` (`b64encode`, `b64decode`, and the standard and urlsafe pairs), `hashlib` (`md5`, `sha1`, `sha256`, `sha384`, `sha512`), and `struct` (`pack`, `unpack` of a literal format). The rest of the queue is lowered as a closed surface: `datetime`, `time`, `collections`, `functools`, `itertools`, `operator`, `contextlib`, `os`, `posixpath`, `pathlib`, `stat`, `fnmatch`, `warnings`, `io`, `string`, `bisect`, `errno`, and the island modules `sys`, `importlib`, `inspect`, `threading`, `logging`, `asyncio`, `subprocess`, `socket`, `ssl`, and `ctypes`. Also lowered, as closed names: `importlib.resources.files` / `as_file`, `hmac.digest` / `new` / `compare_digest` for a literal `sha256` / `sha384` / `sha512` (and `md5` / `sha1`), Latin-1 `unicodedata`, `tempfile.gettempdir` / `gettempprefix` / `mkdtemp`, `atexit.register` of a no-argument function, `shutil.copyfile` / `rmtree`, `enum.Enum` / `enum.IntEnum` as integer members, and `dataclasses.dataclass` as a flat `__init__`. Anything outside the table fences at the import (`PS2002`). A name added to the queue and left out of the lowered set would fence with `PS2101`
72
+
73
+ Fenced (no LLVM for that file):
74
+
75
+ - `and` / `or` across two types, f-string format specs, a slice step other than 1, `break`, `continue`, `finally`, `except as`, user decorators, `super()`, multiple inheritance, `**kwargs`, keyword-only and positional-only parameters, and starred calls
76
+ - String literals outside Latin-1
77
+ - `bool` arithmetic, `list[bool]`, and `dict` values of `bool`. `bool` is not promoted to `float`
78
+ - Calls such as `str.encode("ascii")`, `math.gcd`, `functools.partial`, `itertools.count`, `operator.itemgetter`, `importlib.import_module`, and `asyncio.run` that are outside the lowered surface
79
+ - `with` except `contextlib.suppress(Exc)`, `contextlib.nullcontext()`, `with open(...) as name`, and `with importlib.resources.as_file(...) as name`
80
+ - `itertools.repeat` and `itertools.chain` except as the iterator of a `for`
81
+ - `re.findall` with more than four capturing groups. A literal pattern of two to four groups returns a tuple of strings. A dynamic pattern with two or more groups raises `ValueError`
82
+ - Float JSON, JSON null, and non-ASCII JSON text
83
+ - `struct` format `@`, a format that is not a string literal, and `Q` values that do not fit in `i64`
84
+ - Keyword arguments, including `re` flags and `base64` `validate`
85
+
86
+ `//` is Python floor division, including negative operands. Division by zero and signed `i64` overflow abort the process. They do not wrap. `math.floor`, `math.ceil`, `math.trunc`, and `int(float)` raise `OverflowError` when the result does not fit in `i64`. An uncaught exception prints its name to stderr and exits 1.
87
+
88
+ A `for` target that is new in the function is stored as `0`, `0.0`, or `""` before the loop. After `for i in range(0)`, this subset reads `i` as `0`. CPython would raise `UnboundLocalError`. A target that already had a value keeps that value when the loop body never runs.
89
+
90
+ `in` on a list uses `==`. `math.nan in [math.nan]` is false here. CPython's list finds that same object by identity before it compares.
91
+
92
+ `typing` stays in mypy. It is not a runtime lowering. Island constants (`sys.platform`, `sys.version`, `sys.executable`, `sys.maxsize`, `socket.AF_INET`, `ssl.OPENSSL_VERSION`, `ssl.HAS_SNI`, `stat.S_IFREG`, `ctypes.sizeof`) are baked from the interpreter that lowers the file. `sys.exit` is libc `exit`. `subprocess.check_output` takes a `list[str]` and returns `bytes`. `os.getenv` raises `KeyError` when the variable is unset. `date` plus `timedelta` uses the normalized day count; `datetime` plus `timedelta` uses the whole delta.
93
+
94
+ ## Requirements
95
+
96
+ - CPython 3.10 or later (the IR is stamped with the interpreter that lowered it)
97
+ - [uv](https://docs.astral.sh/uv/)
98
+ - Clang that can assemble textual LLVM IR
99
+
100
+ ## Run
101
+
102
+ ```bash
103
+ uv sync
104
+ uv run pyscriptc compile examples/sum_squares.py --run --call sum_squares --args '[10]' -o /tmp/sum_squares
105
+ ```
106
+
107
+ `sum_squares(10)` prints `285`, the same value CPython prints. `--args` is a Python literal parsed with `ast.literal_eval`, so integers are not rounded through JSON.
108
+
109
+ Other corpus programs:
110
+
111
+ ```bash
112
+ uv run pyscriptc compile examples/longer.py --run --call longer --args '["bb", "a"]' -o /tmp/longer
113
+ uv run pyscriptc compile examples/floor_div.py --run --call floor_div --args '[-3, 2]' -o /tmp/floor_div
114
+ uv run pyscriptc compile examples/gates_math.py --run --call floors -o /tmp/floors
115
+ uv run pyscriptc compile examples/gates_probe.py --run --call probe -o /tmp/probe
116
+ uv run pyscriptc compile examples/fence_method.py --emit llvm -o /tmp/fence.ll
117
+ ```
118
+
119
+ `floors()` prints `3`. `probe()` prints `0`. The fence exits nonzero, names `encode`, and does not write LLVM. `examples/wave_probe.py` prints `0` when the codec wave matches CPython. `examples/rest_probe.py` prints `0` when the rest of the queue matches CPython. `examples/fence_pickle.py` exits nonzero with `PS2002` because `pickle` is outside the import table. `examples/invoice.py`, `examples/access_log.py`, `examples/request_id.py`, `examples/release_note.py`, `examples/blob_digest.py`, `examples/url_gate.py`, and `examples/hostname.py` are the scripts in [docs/examples.md](docs/examples.md). `examples/bad_annotation.py` fails in mypy before lowering. `examples/big_literal.py` lowers to IR, then LLVM emission refuses the integer because it does not fit in `i64`.
120
+
121
+ `re.compile` returns a `Pattern` with a `pattern` field. `findall`, `sub`, and `split` on that object use the field. `hashlib` returns an opaque `Hash`; `hexdigest` and `digest` are the methods that lower. `urlsplit` returns a `SplitResult` of five strings (`scheme`, `netloc`, `path`, `query`, `fragment`). `struct.unpack` is a list, so `[0]` is the first value. `json.loads` takes its type from the annotation it is assigned to, or from the return annotation. `parse_qs` splits on `&` only, which is what CPython 3.14 does. A pattern that can match empty forever, such as `()*`, stops with `RuntimeError` once the matcher spends its fuel. `re.error`, `struct.error`, and `binascii.Error` surface here as `ValueError`.
122
+
123
+ `--emit ir` writes the JSON IR. `--emit llvm` writes textual LLVM. The CPython version is a field on the module. Emitting LLVM from an IR stamped by a different version is an error: re-lower it and re-run the corpus.
124
+
125
+ ## Benchmarks
126
+
127
+ ```bash
128
+ uv run python -m benchmarks.baseline.run --check
129
+ uv run python -m benchmarks.runtime.run --runs=5
130
+ uv run python -m benchmarks.scaling.run
131
+ ```
132
+
133
+ `benchmarks/baseline/reference.json` is the reference metric set: wall time and peak RSS for each lowered workload, against the same call under CPython. Printed figures are speedups, `Nx CPython`, the reciprocal of the stored pyscriptc/CPython ratio, so a larger number is a bigger gain. `--check` still compares the stored ratios: it fails when a time ratio grows past 2× that set, or an RSS ratio grows past 1.25×. A reference of 10.0x CPython therefore fails once the run prints less than 5.0x.
134
+
135
+ The kernel geomean is the original four loops. The stdlib rows time every module that has a lowered call, including the builtin helpers. `importlib.import_module` and `asyncio.run` are fences, so those calls are not timed. `importlib.resources`, `hmac`, and Latin-1 `unicodedata` have their own rows. Calls that embed CPython (`socket.gethostname`, `inspect.cleandoc`, `threading`, `logging`, `subprocess.check_output`) are the island group: they link libpython, and their speedup sits near 1x CPython. `benchmarks/adoption` records why pyperformance, click, typer, pip, and black are not compiled suites yet.
136
+
137
+ ## Telemetry
138
+
139
+ Release builds collect anonymous usage metrics with PostHog (EU host): the subcommand you ran, pyscriptc/python versions, platform, compile duration, and the first `PSxxxx` fence code when a file fails to lower. Never sent: file names, paths, or source text. The machine id is a salted sha256 that is not reversible.
140
+
141
+ Telemetry is off in CI and a no-op in dev checkouts (no baked-in token). One stderr line announces it on first use. Disable it with any of:
142
+
143
+ ```bash
144
+ pyscriptc telemetry disable # writes ~/.config/pyscriptc/config.toml
145
+ export PYSC_NO_TELEMETRY=1
146
+ export DO_NOT_TRACK=1
147
+ ```
148
+
149
+ `pyscriptc telemetry status` shows the effective state and why.
150
+
151
+ ## Checks
152
+
153
+ ```bash
154
+ uv run ruff check .
155
+ uv run ruff format --check .
156
+ uv run pytest
157
+ ```
158
+
159
+ ## What this does not prove
160
+
161
+ A new CPython release is not supported yet in the product sense. The stamp and the fences are the hooks that make that possible later: unknown syntax fails closed, and the backend will not silently compile IR from an interpreter it has not been run against. Island calls embed that same interpreter, and only the binary that actually calls them links libpython.
@@ -0,0 +1,77 @@
1
+ [project]
2
+ name = "pyscriptc"
3
+ version = "0.1.0"
4
+ description = "Lower a typed subset of Python to LLVM, with CPython as the island."
5
+ readme = "README.md"
6
+ requires-python = ">=3.10"
7
+ license = "Apache-2.0"
8
+ license-files = ["LICENSE"]
9
+ authors = [{ name = "Joaquin Terrasa" }]
10
+ classifiers = [
11
+ "Development Status :: 3 - Alpha",
12
+ "Intended Audience :: Developers",
13
+ "Operating System :: OS Independent",
14
+ "Programming Language :: Python :: 3",
15
+ "Programming Language :: Python :: 3.10",
16
+ "Programming Language :: Python :: 3.11",
17
+ "Programming Language :: Python :: 3.12",
18
+ "Programming Language :: Python :: 3.13",
19
+ "Programming Language :: Python :: 3.14",
20
+ "Topic :: Software Development :: Compilers",
21
+ ]
22
+ dependencies = ["mypy>=2.4"]
23
+
24
+ [project.urls]
25
+ Homepage = "https://github.com/sigilco/pyscriptc"
26
+ Repository = "https://github.com/sigilco/pyscriptc"
27
+ Issues = "https://github.com/sigilco/pyscriptc/issues"
28
+ Reference = "https://github.com/vercel-labs/scriptc"
29
+
30
+ [project.scripts]
31
+ pyscriptc = "pyscriptc.cli:main"
32
+
33
+ [dependency-groups]
34
+ dev = ["pytest>=8", "ruff>=0.14"]
35
+ # Release binary build only (packaging/). Not installed by a plain `uv sync`.
36
+ packaging = ["nuitka>=4.0", "zstandard>=0.23", "ordered-set>=4.1"]
37
+
38
+ [build-system]
39
+ requires = ["setuptools>=77"]
40
+ build-backend = "setuptools.build_meta"
41
+
42
+ [tool.setuptools.packages.find]
43
+ where = ["src"]
44
+
45
+ [tool.setuptools.package-data]
46
+ pyscriptc = ["runtime/*.c", "runtime/*.h"]
47
+
48
+ [tool.pytest.ini_options]
49
+ testpaths = ["tests"]
50
+ pythonpath = ["src", "."]
51
+ markers = [
52
+ "linux_container: Linux dev container suite (HEAVY=1 .agents/docker/run.sh). Shells out to clang or only passes on Linux. CI does not run these.",
53
+ ]
54
+
55
+ [tool.ruff]
56
+ target-version = "py314"
57
+ line-length = 120
58
+ src = ["src", "tests", "benchmarks"]
59
+ extend-exclude = [
60
+ "benchmarks/compat/top100",
61
+ "benchmarks/compat/pyjwt/src/jwt",
62
+ "benchmarks/compat2/corpus/src",
63
+ "benchmarks/compat2/corpus/tests",
64
+ "benchmarks/compat2/corpus/holdout/src",
65
+ "benchmarks/compat2/corpus/holdout/tests",
66
+ "benchmarks/compat2/corpus/scripts",
67
+ "benchmarks/compat2/corpus/holdout/scripts",
68
+ ]
69
+
70
+ [tool.ruff.lint]
71
+ select = ["E", "F", "I", "UP", "B"]
72
+
73
+ [tool.ruff.lint.isort]
74
+ known-first-party = ["pyscriptc"]
75
+
76
+ [tool.ruff.format]
77
+ quote-style = "double"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,3 @@
1
+ """Spike compiler: CPython ast to a Python typed IR to LLVM."""
2
+
3
+ __version__ = "0.1.0"