Module reference

pocketpy includes a focused set of Python modules and game-oriented extensions. These pages describe the APIs shipped in this repository, including differences from CPython. They are not a reference to the full Python standard library.

Most native functions accept positional arguments. Examples show supported call forms; see the argument rules.

Data and algorithms

Module Use
bisect Binary search and insertion into sorted lists.
collections Counts, default dictionaries, and double-ended queues.
dataclasses Small data classes from annotations.
enum Named constants.
functools Caching, reductions, and partial calls.
heapq Min-heaps and priority queues.
operator Operators and accessors as functions.
typing Placeholders for type hints.

Numbers, time, and text

Module Use
math, cmath Real and complex mathematics.
random Pseudo-random values and independent generators.
time, datetime Clocks and basic local date/time values.
unicodedata East Asian character-width classification.
base64 Binary-to-text encoding.
json JSON output and trusted-input expression loading.
pickle pocketpy object serialization.

Runtime and host integration

Module Use
gc Garbage collection control.
importlib Source module reloads.
inspect and dis Function metadata and bytecode inspection.
os and io Files and host OS access; requires PK_ENABLE_OS.
pkpy VM diagnostics, profiling, timeouts, and compute threads.
stdc Native memory and typed C storage.
sys Version, platform, arguments, and recursion limit.
traceback Exception reports.
picoterm and conio Terminal text and platform keyboard input.

Games and grids

Module Use
array2d Grids, views, masks, and chunked maps.
vmath Native vectors, matrices, and colors.
easing Animation interpolation curves.

Optional native modules

These modules default to off in CMake. See build configuration for enabling them and initializing native dependencies.

Module Required option
cute_png PK_BUILD_MODULE_CUTE_PNG=ON
lz4 PK_BUILD_MODULE_LZ4=ON
msgpack PK_BUILD_MODULE_MSGPACK=ON
periphery PK_BUILD_MODULE_PERIPHERY=ON, Linux target

A host application may add or replace modules. If an import fails, check the running build's capabilities and module loader. Installing a CPython package does not automatically make it available to pocketpy.