Appearance
Module support
pystd includes standard-library APIs that can be represented by a stable, typed WIT boundary and behave consistently in browsers, Node.js, and other WebAssembly hosts. “All modules that make sense” means all modules meeting those constraints, not every module shipped with desktop CPython.
Support matrix
| Group | Status | Examples | Portability notes |
|---|---|---|---|
| Pure numeric and deterministic algorithms | Supported and expanding | math, random, statistics, fractions, decimal | Strong fit when values have an unambiguous typed representation. |
| Hashing and binary transforms | Supported and expanding | hashlib, hmac, base64, binascii | Cryptographic entropy and unavailable native backends remain excluded. |
| Finite collection algorithms | Supported and expanding | itertools, bisect, heapq | APIs accepting arbitrary Python iterators, callbacks, or objects need a narrower typed surface. |
| Text and structured data | Supported and expanding | string, textwrap, csv, json, html, urllib.parse | Pure transformations are supported; file-oriented convenience APIs are excluded. |
| Date and identifiers | Supported and expanding | datetime, calendar, deterministic uuid operations | Explicit values are supported; ambient local time, locale, timezone databases, and entropy are excluded. |
| Compression and archives | Candidate | zlib, gzip, bz2, lzma, zipfile, tarfile | In-memory APIs fit when the native codec is available; filesystem APIs do not. |
| Filesystem and process integration | Excluded from the portable package | os, pathlib, tempfile, shutil, subprocess, multiprocessing | These require host-specific WASI capabilities and cannot behave uniformly in a browser. |
| Networking and services | Excluded from the portable package | socket, ssl, http, ftplib, smtplib, urllib.request | Networking must be supplied by the JavaScript host, with a separate capability-oriented API. |
| Runtime, compiler, and debugging internals | Excluded | sys, gc, inspect, importlib, ast, dis, trace, pdb | They expose the embedded interpreter rather than a reusable standard-library operation. |
| UI, platform, and database bindings | Excluded | tkinter, curses, winreg, sqlite3, dbm | They depend on platform libraries, persistent storage, or UI systems absent from the portable runtime. |
Selection rules
A module is included when its useful core can be kept small, represented with typed values, and verified against pinned CPython without filesystem, network, subprocess, locale, or ambient OS entropy. Narrow typed subsets are preferred over pretending that arbitrary Python objects cross the component boundary.
The portable surface now includes:
- numeric algorithms:
math,random,statistics,fractions, anddecimal; - hashing and binary transforms:
hashlib,hmac,base64, andbinascii; - finite collections:
itertools,bisect, andheapq; - text and structured data:
string,textwrap,csv,json,html, andurllib.parse; - explicit dates and identifiers:
datetime,calendar, and deterministicuuidoperations.
Each module has a typed subpath under pystd/<module>. urllib.parse uses the npm-safe subpath pystd/urllib-parse and root namespace urllibParse.
Representation boundaries
fractions and decimal use canonical strings so values do not lose precision at the JavaScript boundary. Finite integer collection APIs use signed 64-bit bigint typed arrays. json.loads and json.dumps convert between JSON text and JavaScript JSON values; Python-specific object hooks are not exposed. Date/time APIs accept ISO 8601 strings or explicit Unix timestamps and interpret naive datetime timestamps as UTC.
uuid3 and uuid5 are supported because their output is deterministic. Random UUID construction is excluded until the host provides explicit secure entropy and clock capabilities.
Randomness
pystd/random implements CPython's deterministic random.Random behavior for reproducible simulations and tests. Explicit integer seeds match CPython. The portable runtime deliberately does not expose ambient OS entropy, so SystemRandom and secrets are not provided and the omitted-seed convenience uses the current JavaScript time. This module must not be used for security.