pyscriptc 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. pyscriptc/__init__.py +3 -0
  2. pyscriptc/__main__.py +3 -0
  3. pyscriptc/_posthog_token.py +1 -0
  4. pyscriptc/builtins.py +156 -0
  5. pyscriptc/canonical.py +167 -0
  6. pyscriptc/check.py +49 -0
  7. pyscriptc/cli.py +271 -0
  8. pyscriptc/coverage.py +388 -0
  9. pyscriptc/debug.py +120 -0
  10. pyscriptc/diagnostics.py +179 -0
  11. pyscriptc/errors.py +56 -0
  12. pyscriptc/ir.py +365 -0
  13. pyscriptc/llvm.py +2129 -0
  14. pyscriptc/log.py +127 -0
  15. pyscriptc/lower/__init__.py +1071 -0
  16. pyscriptc/lower/_calls.py +1499 -0
  17. pyscriptc/lower/_classes.py +969 -0
  18. pyscriptc/lower/_core.py +301 -0
  19. pyscriptc/lower/_expr.py +886 -0
  20. pyscriptc/lower/_stdlib.py +491 -0
  21. pyscriptc/lower/_stdlib_shared.py +93 -0
  22. pyscriptc/lower/_stmt.py +1173 -0
  23. pyscriptc/package.py +249 -0
  24. pyscriptc/restlower.py +1008 -0
  25. pyscriptc/runtime/ps_argv.c +28 -0
  26. pyscriptc/runtime/ps_b64.c +168 -0
  27. pyscriptc/runtime/ps_coll.c +133 -0
  28. pyscriptc/runtime/ps_dt.c +388 -0
  29. pyscriptc/runtime/ps_hash.c +411 -0
  30. pyscriptc/runtime/ps_help.c +219 -0
  31. pyscriptc/runtime/ps_hmac.c +120 -0
  32. pyscriptc/runtime/ps_io.c +198 -0
  33. pyscriptc/runtime/ps_island.c +272 -0
  34. pyscriptc/runtime/ps_json.c +402 -0
  35. pyscriptc/runtime/ps_mix.c +47 -0
  36. pyscriptc/runtime/ps_more.c +1089 -0
  37. pyscriptc/runtime/ps_osmore.c +447 -0
  38. pyscriptc/runtime/ps_path.c +547 -0
  39. pyscriptc/runtime/ps_re.c +1102 -0
  40. pyscriptc/runtime/ps_rt.c +1175 -0
  41. pyscriptc/runtime/ps_rt.h +189 -0
  42. pyscriptc/runtime/ps_struct.c +291 -0
  43. pyscriptc/runtime/ps_time.c +207 -0
  44. pyscriptc/runtime/ps_unicode.c +1521 -0
  45. pyscriptc/runtime/ps_url.c +327 -0
  46. pyscriptc/stdlib_queue.py +191 -0
  47. pyscriptc/stdmore.py +1596 -0
  48. pyscriptc/telemetry.py +219 -0
  49. pyscriptc-0.1.0.dist-info/METADATA +187 -0
  50. pyscriptc-0.1.0.dist-info/RECORD +54 -0
  51. pyscriptc-0.1.0.dist-info/WHEEL +5 -0
  52. pyscriptc-0.1.0.dist-info/entry_points.txt +2 -0
  53. pyscriptc-0.1.0.dist-info/licenses/LICENSE +201 -0
  54. pyscriptc-0.1.0.dist-info/top_level.txt +1 -0
pyscriptc/telemetry.py ADDED
@@ -0,0 +1,219 @@
1
+ """Anonymous usage telemetry via PostHog.
2
+
3
+ What is sent: a short event payload (subcommand, version, python/platform, and
4
+ for `compile` a duration plus the first PSxxxx fence code when the lower fences
5
+ the file). Never sent: file names, paths, source text, or anything derived from
6
+ the compiled program.
7
+
8
+ Token flow. The PostHog project token is baked in at release time, not read
9
+ from the environment at run time: the release workflow writes
10
+ `src/pyscriptc/_posthog_token.py` (gitignored, `TOKEN = "..."`) from the
11
+ `POSTHOG_PROJECT_TOKEN` repo variable before `packaging/build.sh` and before
12
+ `uv build`. Dev checkouts and contributor installs have no such file, so
13
+ `_token()` returns "" and every telemetry call is a silent no-op. For local
14
+ testing set `PYSC_POSTHOG_TOKEN`; it wins over the baked-in file.
15
+
16
+ Opt-out, first match wins:
17
+
18
+ - `CI` env var set: telemetry is off and the first-use notice never prints.
19
+ - `PYSC_NO_TELEMETRY` set to any truthy value.
20
+ - `DO_NOT_TRACK` set to any truthy value.
21
+ - `pyscriptc telemetry disable` writes `telemetry = false` to the config file.
22
+ - No token (see above): silent no-op.
23
+
24
+ Config file: `$XDG_CONFIG_HOME/pyscriptc/config.toml` (default
25
+ `~/.config/pyscriptc/config.toml`). It is a flat `key = value` TOML file; the
26
+ two keys are `telemetry` (bool) and `notice_seen` (bool).
27
+
28
+ Sending is fire-and-forget: each `track()` posts the event on a daemon thread
29
+ with a 1.5 s socket timeout and swallows every failure. Nothing here can slow
30
+ down or break a compile.
31
+ """
32
+
33
+ from __future__ import annotations
34
+
35
+ import hashlib
36
+ import json
37
+ import os
38
+ import platform
39
+ import socket
40
+ import sys
41
+ import threading
42
+ import urllib.request
43
+ import uuid
44
+ from pathlib import Path
45
+
46
+ POSTHOG_HOST = "https://eu.i.posthog.com"
47
+
48
+ _SALT = b"pyscriptc-v1"
49
+ _TIMEOUT_S = 1.5
50
+
51
+ try: # release builds stamp this file; see the module docstring
52
+ from pyscriptc._posthog_token import TOKEN as _BAKED_TOKEN
53
+ except ImportError:
54
+ _BAKED_TOKEN = ""
55
+
56
+
57
+ def _token() -> str:
58
+ return os.environ.get("PYSC_POSTHOG_TOKEN", "") or _BAKED_TOKEN
59
+
60
+
61
+ def _truthy(name: str) -> bool:
62
+ return os.environ.get(name, "").strip().lower() not in ("", "0", "false", "no", "off")
63
+
64
+
65
+ def _config_path() -> Path:
66
+ base = os.environ.get("XDG_CONFIG_HOME") or str(Path.home() / ".config")
67
+ return Path(base) / "pyscriptc" / "config.toml"
68
+
69
+
70
+ def _read_config() -> dict[str, str]:
71
+ """Parse the flat `key = value` TOML file. Unknown lines are ignored."""
72
+ values: dict[str, str] = {}
73
+ try:
74
+ for line in _config_path().read_text(encoding="utf-8").splitlines():
75
+ line = line.split("#", 1)[0].strip()
76
+ if not line or "=" not in line:
77
+ continue
78
+ key, _, value = line.partition("=")
79
+ values[key.strip()] = value.strip().strip('"').strip("'")
80
+ except OSError:
81
+ pass
82
+ return values
83
+
84
+
85
+ def _write_config(values: dict[str, str]) -> None:
86
+ path = _config_path()
87
+ path.parent.mkdir(parents=True, exist_ok=True)
88
+ lines = [f"{key} = {_toml_value(value)}" for key, value in sorted(values.items())]
89
+ path.write_text("\n".join(lines) + "\n", encoding="utf-8")
90
+
91
+
92
+ def _toml_value(value: str) -> str:
93
+ if value in ("true", "false"):
94
+ return value
95
+ return json.dumps(value)
96
+
97
+
98
+ def _machine_id() -> str:
99
+ """Stable anonymous machine hash. Not reversible, carries no raw identity."""
100
+ parts = [_SALT]
101
+ for candidate in ("/etc/machine-id", "/var/lib/dbus/machine-id"):
102
+ try:
103
+ parts.append(Path(candidate).read_bytes().strip())
104
+ break
105
+ except OSError:
106
+ continue
107
+ try:
108
+ parts.append(str(uuid.getnode()).encode())
109
+ except Exception:
110
+ pass
111
+ try:
112
+ parts.append(socket.gethostname().encode())
113
+ except Exception:
114
+ pass
115
+ return hashlib.sha256(b"|".join(parts)).hexdigest()
116
+
117
+
118
+ def ci() -> bool:
119
+ return bool(os.environ.get("CI"))
120
+
121
+
122
+ def enabled() -> bool:
123
+ if ci() or _truthy("PYSC_NO_TELEMETRY") or _truthy("DO_NOT_TRACK"):
124
+ return False
125
+ if _read_config().get("telemetry") == "false":
126
+ return False
127
+ return bool(_token())
128
+
129
+
130
+ def maybe_print_notice() -> None:
131
+ """One stderr line on first non-CI, opted-in invocation; never twice."""
132
+ if not enabled():
133
+ return
134
+ config = _read_config()
135
+ if config.get("notice_seen") == "true":
136
+ return
137
+ print(
138
+ "pyscriptc collects anonymous usage metrics (no source/paths). "
139
+ "Disable: PYSC_NO_TELEMETRY=1 or `pyscriptc telemetry disable`",
140
+ file=sys.stderr,
141
+ )
142
+ config["notice_seen"] = "true"
143
+ try:
144
+ _write_config(config)
145
+ except OSError:
146
+ pass
147
+
148
+
149
+ def track(event: str, properties: dict | None = None) -> None:
150
+ """Queue one event on a daemon thread. Every failure is swallowed."""
151
+ if not enabled():
152
+ return
153
+ payload = {
154
+ "api_key": _token(),
155
+ "event": event,
156
+ "distinct_id": _machine_id(),
157
+ "properties": properties or {},
158
+ }
159
+ thread = threading.Thread(target=_post, args=(payload,), daemon=True)
160
+ try:
161
+ thread.start()
162
+ except Exception:
163
+ pass
164
+
165
+
166
+ def _post(payload: dict) -> None:
167
+ try:
168
+ body = json.dumps(payload).encode()
169
+ request = urllib.request.Request(
170
+ f"{POSTHOG_HOST}/capture/",
171
+ data=body,
172
+ headers={"Content-Type": "application/json"},
173
+ )
174
+ with urllib.request.urlopen(request, timeout=_TIMEOUT_S):
175
+ pass
176
+ except Exception:
177
+ pass
178
+
179
+
180
+ def base_properties() -> dict:
181
+ from pyscriptc import __version__
182
+
183
+ return {
184
+ "pyscriptc_version": __version__,
185
+ "python_version": platform.python_version(),
186
+ "platform": sys.platform,
187
+ "ci": ci(),
188
+ }
189
+
190
+
191
+ def telemetry_cmd(action: str) -> int:
192
+ """Implement `pyscriptc telemetry disable|enable|status`."""
193
+ if action == "status":
194
+ config = _read_config()
195
+ print(f"telemetry: {'on' if enabled() else 'off'}")
196
+ print(f"config: {_config_path()} ({'exists' if _config_path().exists() else 'absent'})")
197
+ if ci():
198
+ print("reason: CI env var set")
199
+ elif _truthy("PYSC_NO_TELEMETRY"):
200
+ print("reason: PYSC_NO_TELEMETRY set")
201
+ elif _truthy("DO_NOT_TRACK"):
202
+ print("reason: DO_NOT_TRACK set")
203
+ elif config.get("telemetry") == "false":
204
+ print("reason: telemetry = false in config")
205
+ elif not _token():
206
+ print("reason: no PostHog token (dev install)")
207
+ return 0
208
+ if action not in ("enable", "disable"):
209
+ print("usage: pyscriptc telemetry disable|enable|status", file=sys.stderr)
210
+ return 2
211
+ config = _read_config()
212
+ config["telemetry"] = "true" if action == "enable" else "false"
213
+ try:
214
+ _write_config(config)
215
+ except OSError as exc:
216
+ print(f"cannot write {_config_path()}: {exc}", file=sys.stderr)
217
+ return 1
218
+ print(f"telemetry {'enabled' if action == 'enable' else 'disabled'} in {_config_path()}")
219
+ return 0
@@ -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,54 @@
1
+ pyscriptc/__init__.py,sha256=chqxwWgRDbtqL9f-NvcRi19VyxeoeA4PnkPhkMgQq5c,87
2
+ pyscriptc/__main__.py,sha256=4vCzPwJUIKd51IfGCMR5OIat-NjaEge3JxXT02U-NVQ,57
3
+ pyscriptc/_posthog_token.py,sha256=JPgt6HkDBOvRiGEiedZoVYG0Zd0d-HKD8yEhJ5xHMYE,59
4
+ pyscriptc/builtins.py,sha256=ABof65cmVFoiLVQpf28kGqvBR4aIbpmvhJExxQWjgng,6117
5
+ pyscriptc/canonical.py,sha256=fU7dhy0E0rChEl9pcdULpdS6jSQxEzzuUjbgnhx1PuU,6485
6
+ pyscriptc/check.py,sha256=SoWfgSWOypvE_dqfrYj1USovFTjuSXeU700G2oPwQxY,1441
7
+ pyscriptc/cli.py,sha256=QE0ViPBzvXM8fhevq257kkhKiSDXycL3uY1FN8Mx9z8,10205
8
+ pyscriptc/coverage.py,sha256=hrfqDw3Kc97QA_4RwGwI2jY9utzJCIVUj5k0Lx-RYhM,16119
9
+ pyscriptc/debug.py,sha256=IzvWQOa0FhWcsSneUgC0A7zUNRumtDvsXJk88VbVgfI,4914
10
+ pyscriptc/diagnostics.py,sha256=xaV1JxIShcimuPzxsbVVg0JbGu4PypYe6F1mv9DrR0E,6354
11
+ pyscriptc/errors.py,sha256=ALE4mab7BWsucVlaxUX3bOExOeRYcQKOjfs4hhtr3hE,1627
12
+ pyscriptc/ir.py,sha256=E82FaVwlGGI8bz0BJOM0WBEbP03WYmcMwLu_Ys8QR9w,15212
13
+ pyscriptc/llvm.py,sha256=cCO2QnMJoVQ_83n7sBYqXoo-LEHuTwfXKo_Gr0gKsbc,91601
14
+ pyscriptc/log.py,sha256=8p0c66QMkYvGnA5gBEZ1P18DS5MGL1J6ZkQDnKo3pME,3884
15
+ pyscriptc/package.py,sha256=S_i67i-WAcWV0LjC64VPZhHZNrFoO4O6GzuSWUy6jM8,9557
16
+ pyscriptc/restlower.py,sha256=159OJXNwsEAvK1obcsKLhCnR5T5prTxb63JGZ3GxrDk,40526
17
+ pyscriptc/stdlib_queue.py,sha256=POmLTIfVEA6-tpiOq9ATPO2gITij2ThyYEvazHnM5U8,6081
18
+ pyscriptc/stdmore.py,sha256=NcYVNSGIeweuSF4EzmCGOGEv7ALKAEY94TKNRQfRGN8,44069
19
+ pyscriptc/telemetry.py,sha256=cpt-951K5ok-g85Lwf6tvyC84nE8mHfbGjrC4JPenZc,7007
20
+ pyscriptc/lower/__init__.py,sha256=fuVv6PrNmCdx9uHonthkzqrMKVy1X4D2myGpVP-q5QQ,47054
21
+ pyscriptc/lower/_calls.py,sha256=6cvqhRHX5BFCB1wh5Da1PeoHrnTknViTpBBudWpGVJ4,70672
22
+ pyscriptc/lower/_classes.py,sha256=4SbeDCVby03QWBIBSH3nuGGpJoy_EWw054og8H8N6mY,45159
23
+ pyscriptc/lower/_core.py,sha256=rxS6aL7T24-ZIRgd6JaroRcwn0mmWRMWj59IUFsgkgY,9397
24
+ pyscriptc/lower/_expr.py,sha256=rUOMGERL2f-UrLTLgM6x3h793Z9ACKAa75JNWXS8wPo,42941
25
+ pyscriptc/lower/_stdlib.py,sha256=t0x9Bi04Jz2Wtj3XIEge9KeGQiY-Zu7xiXQqahL4w1U,21997
26
+ pyscriptc/lower/_stdlib_shared.py,sha256=3CoUqv9iWBU0R8giZ3nzHxIlxe6wi1G4HJcWtmzxS7Y,3130
27
+ pyscriptc/lower/_stmt.py,sha256=-Cbb1uKMWq9ft353_EOXYiNnkEw3FpFqRW-YRcedfL4,51796
28
+ pyscriptc/runtime/ps_argv.c,sha256=jQm8ba29rkMSL6ykC1oIAo_VQUmdJ3sfC30Vrbp5rHY,781
29
+ pyscriptc/runtime/ps_b64.c,sha256=sN3vMYYQDc4ergNLTR6gyrRRJrbK2eqNzaD97_dG8NI,5124
30
+ pyscriptc/runtime/ps_coll.c,sha256=pj8s3PQZkpWTCT1gN3oFod4J6DKgLKQV8-16WEOJtSU,2998
31
+ pyscriptc/runtime/ps_dt.c,sha256=KV_jiSwgH5Inzm6CQmmhi32nCvfGWQYfseOKjUcknGk,11031
32
+ pyscriptc/runtime/ps_hash.c,sha256=UdpeGlre7xJX_QM2mUspJLbCQv8jOUMemp-5x8X0n54,14261
33
+ pyscriptc/runtime/ps_help.c,sha256=_lu7957yNF93Bwo_MNTJbDqi7lIhyhdFPhcKNLgFoEs,5668
34
+ pyscriptc/runtime/ps_hmac.c,sha256=O1Bmh54KhaSHC9rwLVXGZLNoozXB-M47JYj_cS7-43U,3248
35
+ pyscriptc/runtime/ps_io.c,sha256=d22sEqSqCf02iDLjsx4z9h1pl8QdV6gIKpYsexCiJN4,4758
36
+ pyscriptc/runtime/ps_island.c,sha256=3CtwH1apF9UxPd8GtdcTzJ3fOMJAJCfFjKTvVJcAnyk,7151
37
+ pyscriptc/runtime/ps_json.c,sha256=1tNQ9p_lUokPyA8nfZzcbavrIBIaoErZGbvIkykpgtc,11587
38
+ pyscriptc/runtime/ps_mix.c,sha256=GJX11vWLg1MeNKiTrme5eNiWQ_JchsP4tDxT5gn90e0,1446
39
+ pyscriptc/runtime/ps_more.c,sha256=AFwDR_y1cqnUqvlkCjqHW3WB2SyonlmM1bwQN3EBSGY,30647
40
+ pyscriptc/runtime/ps_osmore.c,sha256=47ThjGqjOTLutL-G6KLm1HcuijWUZBs7RDy2zIDGuaI,12284
41
+ pyscriptc/runtime/ps_path.c,sha256=yH4KXm0dwsrrntRNWzETnTG9zB_8THUFlpVudtGP6no,14443
42
+ pyscriptc/runtime/ps_re.c,sha256=_JjaFkgt3YAwXX3fkqkmqipzaNJkUec6sZw99eoeLG0,27518
43
+ pyscriptc/runtime/ps_rt.c,sha256=S2huTAEBxmk55VqISSDM1yyFeOwBae6-arhuuzlkdNw,30620
44
+ pyscriptc/runtime/ps_rt.h,sha256=ylfv1ANMO12pe1LfurRd1R2aLTPpNpFcEF71Az6aCso,6577
45
+ pyscriptc/runtime/ps_struct.c,sha256=YQCgX95nEUqL6EZQpgO_9dTG1KdW21UBXGc-lj5V2B0,9025
46
+ pyscriptc/runtime/ps_time.c,sha256=WjFhx2Qzhz1qNVazE3MHSIjkzknTS4yh5KrdocWZfXE,5419
47
+ pyscriptc/runtime/ps_unicode.c,sha256=AG4Vtybdx0E0Ls4W7TUiIy8Vhxxin0o9N4VElukZDHU,80823
48
+ pyscriptc/runtime/ps_url.c,sha256=0hnuXzgykla6f2-hIdd_dzG7LcZac7NbMEzKre4UQmM,9394
49
+ pyscriptc-0.1.0.dist-info/licenses/LICENSE,sha256=nsEoTHAXYOICwFfkx-wyZ0_iOkysThv0FOzfcY47www,11362
50
+ pyscriptc-0.1.0.dist-info/METADATA,sha256=Yg4JDWOfhlirMcPK7j7l80bvh_t-Mih-UWZF5TvWgk0,15171
51
+ pyscriptc-0.1.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
52
+ pyscriptc-0.1.0.dist-info/entry_points.txt,sha256=nD2UuZMF268ZZV_rC1zbBbj0QMCq4RZoYi3Ky15oYIs,49
53
+ pyscriptc-0.1.0.dist-info/top_level.txt,sha256=Ako6qEZO1JlY8_lWibH_8rhbWk4mKu2vjdiC9retqIw,10
54
+ pyscriptc-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ pyscriptc = pyscriptc.cli:main