Skip to content

Commit aebfe13

Browse files
docs: Clean redundancy in docs and typos.
1 parent 8db83de commit aebfe13

11 files changed

Lines changed: 222 additions & 223 deletions

File tree

docs/pages/getting-started/introduction.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: "What Edge Python is and where to go next."
55

66
# Introduction
77

8-
Edge Python is a sandboxed Python subset compiled to a ~170 KB WebAssembly module built in Rust to run on Cloudflare Workers, Fastly Compute, and the browser.
8+
Edge Python is a sandboxed Python subset compiled to a less 200 KB WebAssembly module release, built in Rust to run on Cloudflare Workers, and the browser.
99

1010
## Explore
1111

@@ -18,7 +18,7 @@ Edge Python is a sandboxed Python subset compiled to a ~170 KB WebAssembly modul
1818

1919
### Browser:
2020

21-
Run Edge Python live in your browser at [demo.edgepython.com](https://demo.edgepython.com/).
21+
Run live in your browser at [demo.edgepython.com](https://demo.edgepython.com/).
2222

2323
### Command Line Interface:
2424

docs/pages/getting-started/quickstart.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: "Run your first Edge Python program in under a minute."
55

66
## Run it
77

8-
Edge Python ships as a 170 KB WebAssembly module. Fastest way to try it, the playground, no install, fully client-side.
8+
Edge Python ships as a less 200 KB WASM module. Fastest way to try it, the playground, no install, fully client-side.
99

1010
[Open the playground ->](https://demo.edgepython.com)
1111

@@ -21,12 +21,12 @@ In the browser, the runtime's `<edge-python>` element runs a `.py` file declarat
2121
<!DOCTYPE html>
2222
<html>
2323
<head>
24-
<meta charset="UTF-8">
25-
<script type="module" src="https://runtime.edgepython.com/js/src/element.js"></script>
24+
<meta charset="UTF-8">
25+
<script type="module" src="https://runtime.edgepython.com/js/src/element.js"></script>
2626
</head>
2727
<body>
28-
<div id="app"></div>
29-
<edge-python entry="./app/hello.py" packages="./app/packages.json"></edge-python>
28+
<div id="app"></div>
29+
<edge-python entry="./app/hello.py" packages="./app/packages.json"></edge-python>
3030
</body>
3131
</html>
3232
```
@@ -42,7 +42,7 @@ from dom import query, set_text
4242
set_text(query("#app"), "Hello from Python")
4343
```
4444

45-
`dom` is one of the official [host libraries](/reference/packages#host-libraries) (`dom`, `network`, `storage` and more); standard `.wasm` packages like [`json`](/reference/packages#json) sit alongside them. The `packages.json` above declares `dom` explicitly, but the browser runtime also resolves the official packages by bare name with no manifest at all (see [Defaults](/reference/packages#defaults)), fetching each lazily on first import. See [Official packages](/reference/packages) for the full catalog, and the [runtime README](https://github.com/dylan-sutton-chavez/edge-python/tree/main/runtime) for all `<edge-python>` attributes and the `imports` field for `.py` / `.wasm` modules.
45+
`dom` is one of the official [host libraries](/reference/packages#host-libraries) (`dom`, `network`, `storage`,...); standard `.wasm` packages like [`json`](/reference/packages#json) sit alongside them. The `packages.json` above declares `dom` explicitly, but the browser runtime also resolves the official packages by bare name with no manifest at all (see [Defaults](/reference/packages#defaults)), fetching each lazily on first import. See [Official packages](/reference/packages) for the full catalog, and the [runtime README](https://github.com/dylan-sutton-chavez/edge-python/tree/main/runtime) for all `<edge-python>` attributes and the `imports` field for `.py` / `.wasm` modules.
4646

4747
## Your first program
4848

docs/pages/implementation/design.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: "Compiler architecture, dispatch model, and runtime layout."
55

66
## Overview
77

8-
Release build is around 170 KB on `wasm32-unknown-unknown` (`panic=abort`, `opt-level=z`, `lto=true`, `codegen-units=1`). Pipeline: LUT-driven lexer -> single-pass Pratt parser emitting SSA-versioned bytecode directly -> peephole constant-folding optimiser -> token-threaded interpreter with two layers of adaptive specialisation.
8+
Release build, is a 200 KB on `wasm32-unknown-unknown` (`panic=abort`, `opt-level=z`, `lto=true`, `codegen-units=1`). Where the path is: LUT-driven lexer -> single-pass Pratt parser emitting SSA-versioned bytecode directly -> peephole constant-folding optimiser -> token-threaded interpreter with two layers of adaptive specialisation.
99

1010
No AST, no IR, bytecode is the only intermediate representation. Around 13,000 lines of Rust; production deps are `hashbrown` and `itoa` (SHA-256 in-tree). WASM build adds `lol_alloc` for a single-threaded leaking bump allocator.
1111

@@ -26,13 +26,13 @@ Classes support single-level inheritance, `super()`, full dunder dispatch, `@pro
2626
Each `Instruction` is 4 bytes: 1-byte `OpCode` (`#[repr(u8)]` planned), 2-byte operand, 1 byte padding. Opcodes span 17 categories, load, store, arith, bitwise, compare, logic, identity, control flow, iter, build, container, comprehension, function, ssa (Phi), yield, side effects, unsupported (raises at runtime). Around 40 specialised `Call*` variants for hot builtins; `LoadAttr + Call(0)` pairs fuse into `CallMethod + CallMethodArgs` after first dispatch.
2727

2828
```text
29-
OpCode::LoadConst operand = constant index
30-
OpCode::LoadName operand = name slot
31-
OpCode::StoreName operand = name slot
32-
OpCode::Add / Sub operand = 0 (IC slot derived from ip)
33-
OpCode::Call operand = (kw << 8) | pos
34-
OpCode::Phi operand = target slot, sources in chunk.phi_sources
35-
OpCode::ForIter operand = jump target on iterator exhaustion
29+
OpCode::LoadConst -> operand = constant index
30+
OpCode::LoadName -> operand = name slot
31+
OpCode::StoreName -> operand = name slot
32+
OpCode::Add / Sub -> operand = 0 (IC slot derived from ip)
33+
OpCode::Call -> operand = (kw << 8) | pos
34+
OpCode::Phi -> operand = target slot, sources in chunk.phi_sources
35+
OpCode::ForIter -> operand = jump target on iterator exhaustion
3636
```
3737

3838
## Dispatch shape

docs/pages/implementation/lexical.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,10 @@ A `Token` carries a kind tag plus three byte offsets:
161161

162162
```rust
163163
pub struct Token {
164-
pub kind: TokenType,
165-
pub line: usize,
166-
pub start: usize,
167-
pub end: usize,
164+
pub kind: TokenType,
165+
pub line: usize,
166+
pub start: usize,
167+
pub end: usize,
168168
}
169169
```
170170

docs/pages/language/async.md

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import asyncio # ModuleNotFoundError: there is no asyncio
1414
```python
1515
# Idiomatic edge-python: call the primitives directly.
1616
async def main():
17-
sleep(0.01)
18-
return "ok"
17+
sleep(0.01)
18+
return "ok"
1919

2020
print(run(main()))
2121
```
@@ -32,14 +32,14 @@ A plain `def` inside a coroutine (or at module top-level) can still call yieldin
3232

3333
```python
3434
def routine():
35-
return 1
35+
return 1
3636

3737
async def coro():
38-
return 1
38+
return 1
3939

4040
print(routine()) # 1
41-
print(coro()) # <coroutine> (does not run yet)
42-
print(run(coro())) # 1 (run drives it to completion)
41+
print(coro()) # <coroutine> (does not run yet)
42+
print(run(coro())) # 1 (run drives it to completion)
4343
```
4444

4545
## Driving coroutines
@@ -48,7 +48,7 @@ print(run(coro())) # 1 (run drives it to completion)
4848

4949
```python
5050
async def square(n):
51-
return n * n
51+
return n * n
5252

5353
print(run(square(5)))
5454
```
@@ -65,9 +65,9 @@ print(run(square(5)))
6565

6666
```python
6767
async def task(name):
68-
print(f"{name} step 1")
69-
sleep(0) # yield to the scheduler
70-
print(f"{name} step 2")
68+
print(f"{name} step 1")
69+
sleep(0) # yield to the scheduler
70+
print(f"{name} step 2")
7171

7272
run(task("a"), task("b"))
7373
```
@@ -85,8 +85,8 @@ b step 2
8585

8686
```python
8787
async def fetch(name, delay):
88-
sleep(delay)
89-
return name + "!"
88+
sleep(delay)
89+
return name + "!"
9090

9191
print(gather(fetch("a", 0.05), fetch("b", 0.02), fetch("c", 0.03)))
9292
```
@@ -104,9 +104,9 @@ async def good(): return 1
104104
async def bad(): raise ValueError
105105

106106
try:
107-
gather(good(), bad())
107+
gather(good(), bad())
108108
except ValueError:
109-
print("caught")
109+
print("caught")
110110
```
111111

112112
```text Output
@@ -121,15 +121,14 @@ Deferred host calls (e.g. `network.fetch`) run concurrently under `gather`: each
121121
from network import fetch_text
122122

123123
async def status(url):
124-
try:
125-
fetch_text(url)
126-
return "ok"
127-
except:
128-
return "failed"
124+
try:
125+
fetch_text(url)
126+
return "ok"
127+
except:
128+
return "failed"
129129

130130
# The bad URL raises inside its own coroutine; the others still resolve.
131-
print(gather(status("https://example.com/a"),
132-
status("https://nope.invalid/x")))
131+
print(gather(status("https://example.com/a"), status("https://nope.invalid/x")))
133132
```
134133

135134
```text Output
@@ -142,13 +141,13 @@ print(gather(status("https://example.com/a"),
142141

143142
```python
144143
async def slow():
145-
sleep(10)
146-
return "never"
144+
sleep(10)
145+
return "never"
147146

148147
try:
149-
with_timeout(0.1, slow())
148+
with_timeout(0.1, slow())
150149
except TimeoutError:
151-
print("timed out")
150+
print("timed out")
152151
```
153152

154153
```text Output
@@ -165,9 +164,9 @@ A coroutine in a tight synchronous loop without `await`/`sleep` cannot be cancel
165164

166165
```python
167166
async def loop_forever():
168-
for i in range(1_000_000):
169-
pass # no yield, not cancellable here
170-
sleep(0) # cancellable from this point on
167+
for i in range(1_000_000):
168+
pass # no yield, not cancellable here
169+
sleep(0) # cancellable from this point on
171170
```
172171

173172
For deadline-driven cancellation use `with_timeout`.

docs/pages/language/classes.md

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ Single-level inheritance with `super()`, `@property` / `@x.setter`, full dunder
1111

1212
```python
1313
class Counter:
14-
def __init__(self, n=0):
15-
self.n = n
16-
def tick(self):
17-
self.n += 1
18-
def value(self):
19-
return self.n
14+
def __init__(self, n=0):
15+
self.n = n
16+
def tick(self):
17+
self.n += 1
18+
def value(self):
19+
return self.n
2020

2121
c = Counter()
2222
c.tick()
@@ -35,16 +35,16 @@ A class with no `__init__` and no per-instance state is a namespace. Methods cal
3535

3636
```python
3737
class Status:
38-
IDLE = 0
39-
RUNNING = 1
40-
DONE = 2
38+
IDLE = 0
39+
RUNNING = 1
40+
DONE = 2
4141

4242
class Math:
43-
PI = 3.14159
44-
def square(x):
45-
return x * x
46-
def cube(x):
47-
return x * x * x
43+
PI = 3.14159
44+
def square(x):
45+
return x * x
46+
def cube(x):
47+
return x * x * x
4848

4949
print(Status.IDLE)
5050
print(Math.PI)
@@ -67,17 +67,17 @@ Single base via `class Sub(Base):`. Methods not on the subclass are looked up li
6767

6868
```python
6969
class Animal:
70-
def __init__(self, name):
71-
self.name = name
72-
def describe(self):
73-
return self.name
70+
def __init__(self, name):
71+
self.name = name
72+
def describe(self):
73+
return self.name
7474

7575
class Dog(Animal):
76-
def __init__(self, name, breed):
77-
super().__init__(name)
78-
self.breed = breed
79-
def describe(self):
80-
return super().describe() + " (" + self.breed + ")"
76+
def __init__(self, name, breed):
77+
super().__init__(name)
78+
self.breed = breed
79+
def describe(self):
80+
return super().describe() + " (" + self.breed + ")"
8181

8282
d = Dog("Rex", "lab")
8383
print(d.describe())
@@ -106,13 +106,13 @@ A class decorator wraps the class object the same way it wraps a function, the d
106106

107107
```python
108108
def tag(cls):
109-
cls.kind = "tagged"
110-
return cls
109+
cls.kind = "tagged"
110+
return cls
111111

112112
@tag
113113
class Box:
114-
def __init__(self, v):
115-
self.v = v
114+
def __init__(self, v):
115+
self.v = v
116116

117117
print(Box.kind)
118118
print(Box(7).v)
@@ -129,17 +129,17 @@ tagged
129129

130130
```python
131131
class Temp:
132-
def __init__(self, c):
133-
self._c = c
134-
@property
135-
def celsius(self):
136-
return self._c
137-
@celsius.setter
138-
def celsius(self, value):
139-
self._c = value
140-
@property
141-
def fahrenheit(self):
142-
return self._c * 9 / 5 + 32
132+
def __init__(self, c):
133+
self._c = c
134+
@property
135+
def celsius(self):
136+
return self._c
137+
@celsius.setter
138+
def celsius(self, value):
139+
self._c = value
140+
@property
141+
def fahrenheit(self):
142+
return self._c * 9 / 5 + 32
143143

144144
t = Temp(20)
145145
print(t.celsius)
@@ -162,10 +162,10 @@ Operators, indexing, iteration, context managers, hashing, `repr` / `str` / `for
162162

163163
```python
164164
class Vec:
165-
def __init__(self, x, y):
166-
self.x, self.y = x, y
167-
def __add__(self, other):
168-
return Vec(self.x + other.x, self.y + other.y)
165+
def __init__(self, x, y):
166+
self.x, self.y = x, y
167+
def __add__(self, other):
168+
return Vec(self.x + other.x, self.y + other.y)
169169
```
170170

171171
See [Dunder methods](/language/dunders) for the full matrix.

0 commit comments

Comments
 (0)