sifr.* namespace. Every module is designed with Rust-backed safety guarantees — predictable ownership, explicit error types, and no hidden global mutation. Because Sifr compiles to Rust rather than running on the CPython interpreter, the standard library is its own surface; it is not a thin wrapper around CPython’s built-in modules.
How to Import
Usefrom sifr.<module> import <symbol> for every standard library import:
import sifr.math (module-object form) is also unsupported in the current release. Always import the specific symbols you need using from sifr.<module> import <symbol>.math, json, or similar exists in your project, the normal top-level resolution imports it without a diagnostic. The SIFR-IMPORT-0008 error only fires when no real top-level module matches the bare name.
Available Modules
Math, Data, and Serialization
Math, Data, and Serialization
| Module | Description |
|---|---|
sifr.math | Mathematical functions: sqrt, floor, ceil, log, trigonometric helpers, and numeric constants. |
sifr.json | JSON serialization and deserialization. loads returns a typed JsonValue; dumps serializes Sifr values to JSON strings. Malformed input raises JSONDecodeError. |
sifr.re | Regular expression matching and substitution with Unicode-aware patterns. |
sifr.datetime | Date and time values, durations, timezone-aware timestamps, and formatting. |
sifr.random | Cryptographically seeded random number generation. |
sifr.hashlib | Hash functions: SHA-256, SHA-512, MD5 (legacy), BLAKE3, and HMAC construction. |
sifr.uuid | UUID generation (uuid4) and parsing for v4 and v5 identifiers. |
Collections
Collections
| Module | Description |
|---|---|
sifr.collections | Counter, deque, defaultdict, and set helpers (set_from_list, set_union, set_intersection). Safe indexing returns Option instead of raising KeyError or IndexError. |
Filesystem and Environment
Filesystem and Environment
| Module | Description |
|---|---|
sifr.io | open_text for text files with a required explicit encoding, and binary file I/O. Text-mode open() without encoding= is unsupported (SIFR-IO-0801). |
sifr.pathlib | Path construction, joining, extension manipulation, existence checks, and directory traversal. |
sifr.os | File and directory operations: remove_file, rename, mkdir, listdir, and stat helpers. |
sifr.env | Read and write process environment variables as explicit typed values. |
sifr.sys | Process arguments (argv), exit helpers, and platform query values. |
Text, Encoding, and Internationalization
Text, Encoding, and Internationalization
| Module | Description |
|---|---|
sifr.encoding | Byte/text boundary conversions: encode, decode, codec descriptors (ascii(), latin1()), error handlers, and typed DecodeError / EncodeError. |
sifr.unicode | Unicode 17.0.0 data: normalize (NFC/NFD/NFKC/NFKD), name, category, graphemes, words, and scalar properties. |
sifr.i18n | Locale-aware formatting: LocaleId, NumberFormatter, PluralRules, bundle_from_mo_bytes, and translator with explicit fallback chains. |
Concurrency and Parallelism
Concurrency and Parallelism
| Module | Description |
|---|---|
sifr.task | Structured task management: TaskGroup, TaskHandle[T, E], scoped spawn, timeout, deadline, join, race, and select. |
sifr.sync | Same-process synchronization: Shared[T], channel, bounded_channel, Lock, RwLock, Semaphore, and Notify. |
sifr.parallel | CPU-parallel map over owned data: map, try_map, Pool, and PoolConfig. |
sifr.runtime | Structured runtime diagnostics: DiagnosticEvent, DiagnosticLevel, emit_diagnostic, and DiagnosticError. |
sifr.resource | Deterministic cleanup helpers: nullcontext and NullContext[T]. |
sifr.ipc | Typed IPC substrate for Sifr-native process workers: SchemaId, FrameKind, BackpressurePolicy, and IpcError. |
Networking
Networking
| Module | Description |
|---|---|
sifr.net | Async TCP client and server primitives: connect_tcp and listen_tcp. |
sifr.http | HTTP protocol substrate: methods, status codes, HeaderMap, RequestHead, ResponseHead, BodyStream, and cookie parsing. |
sifr.tls | Rustls-backed TLS client configurations and encrypted streams over sifr.net. |
sifr.url | Typed URL parsing, query-string manipulation, and percent-encoding helpers. |
Process, Signal, and Time
Process, Signal, and Time
| Module | Description |
|---|---|
sifr.process | Subprocess management: run, spawn, output, output_text, shell helpers, and async variants. Handles are owned resources with typed ProcessError. |
sifr.signal | Structured shutdown signals: ctrl_c, shutdown_stream, SIGINT, SIGTERM, and strsignal. |
sifr.time | Monotonic and wall-clock time, sleep, and interval helpers. |
sifr.logging | Structured log emission with levels (DEBUG, INFO, WARN, ERROR) and typed diagnostic events. |
What Sifr Does Not Expose
Several CPython-shaped names are intentionally absent because they rely on global mutable state or interpreter-specific behavior that conflicts with Sifr’s safety model:asyncioevent-loop objects and loop-policy mutationthreading.Lock,queue.Queue, andmultiprocessing.*codecs.register,locale.setlocale, andgettext.installsignal.signalandset_wakeup_fdfor arbitrary handler registration
sifr.* namespace. See the individual module pages for details.