Skip to content

Standard Library

Pyle’s standard library is split across two layers. Which functions you can call depends on how the interpreter was built.

These are compiled into the embeddable library and are available to every host that registers the core natives:

Module Purpose
os Time, environment, paths, process info, sleeping, workers
path Pure string path manipulation, no syscalls
fs Filesystem queries and file operations
math Constants, numeric functions, and random numbers
encoding Base64, hex, and URL coding
io Console input, output, and flushing
color ANSI terminal color codes
proc Spawning processes, pipes, capture (when process support is compiled in)

These ship with the pyle binary and are not part of libpyle:

Module Purpose
json Parse and serialize JSON
http HTTP client and server
crypto Hashing, HMAC, PBKDF2, random bytes
worker Multi-process worker pool written in Pyle

Methods on strings, arrays, maps, bytes, files, futures, and coroutines are always available because they are part of the VM:

Native modules are loaded with import:

let os = import("os")
let math = import("math")
let json = import("json")
printf("sqrt(144) = {}", math.sqrt(144))

An unregistered module fails with NameError. On the CLI, import("worker") resolves std/worker.pyl because the interpreter adds its bundled std/ directory to the import path.

Scripts are imported the same way:

let helpers = import("lib/helpers")

See Modules & Imports for search paths, caching, and module globals.

print, printf, write, format, typeof, pcall, import, and the rest are documented in Built-in Functions.

The following are not part of the core library and are unavailable in a library-only build:

The playground is a libpyle build, so it includes the core modules and excludes the CLI-only modules.