Documentation
¶
Overview ¶
Package micropython embeds MicroPython in Go without CGO.
Use NewInstance for an interpreter that keeps state between calls, or NewProgram to start each run from the same initialized Python state. Close instances and programs when done.
Calls accept Go values and return Value results. Use Value.Export for ordinary Go data or the As methods for checked, type-specific access.
Host access is opt-in. Use WithFS for files, WithEnv for environment variables, WithStdout for output, and WithHostFunc for Go callbacks. WithTCPAccess and WithUDPAccess grant outbound connections; WithDNSResolver separately enables DNS. These options work with both instances and programs. They do not impose a hard CPU or total-memory limit.
Example ¶
The README's quick start: one interpreter, a script, and a call.
package main
import (
"context"
"fmt"
"log"
micropython "github.com/gregfurman/micropython-go"
)
func main() {
ctx := context.Background()
in, err := micropython.NewInstance(ctx)
if err != nil {
log.Fatal(err)
}
defer in.Close()
if err := in.Exec(ctx, "double = lambda x: x * 2"); err != nil {
log.Fatal(err)
}
got, err := in.Call(ctx, "double", 10)
if err != nil {
log.Fatal(err)
}
fmt.Println(got.Export())
}
Output: 20
Index ¶
- Constants
- Variables
- func Raise(typ, msg string) error
- func ReadOnly(filesystem fs.FS) fs.FS
- type BorrowedInstance
- func (o *BorrowedInstance) Call(ctx context.Context, name string, args ...any) (Value, error)
- func (o *BorrowedInstance) Eval(ctx context.Context, expr string) (Value, error)
- func (o *BorrowedInstance) Exec(ctx context.Context, src string) error
- func (o *BorrowedInstance) Get(ctx context.Context, name string) (Value, error)
- func (o *BorrowedInstance) Set(ctx context.Context, name string, v any) error
- type Func
- type Globals
- type HostFunc
- type Instance
- func (i *Instance) AsCallable(v Value) (Func, error)
- func (i *Instance) AsIterator(v Value) (Iterator, error)
- func (i *Instance) Call(ctx context.Context, name string, args ...any) (Value, error)
- func (i *Instance) Cancel() error
- func (i *Instance) Clone(ctx context.Context) (*Instance, error)
- func (i *Instance) Close() error
- func (i *Instance) DefineFunction(ctx context.Context, name string, fn HostFunc) error
- func (i *Instance) Err() error
- func (i *Instance) Eval(ctx context.Context, expr string) (Value, error)
- func (i *Instance) Exec(ctx context.Context, src string) error
- func (i *Instance) Get(ctx context.Context, name string) (Value, error)
- func (i *Instance) Release(ctx context.Context, vals ...Value) error
- func (i *Instance) Resolve(ctx context.Context, v Value) (Value, error)
- func (i *Instance) Set(ctx context.Context, name string, v any) error
- type Item
- type Iterator
- type MkdirFS
- type Object
- type OpenFileFS
- type Option
- func WithDNSResolver(r *net.Resolver) Option
- func WithEnv(name, value string) Option
- func WithFS(filesystem fs.FS) Option
- func WithGlobals(g Globals) Option
- func WithHeapSize(bytes int) Option
- func WithHostFunc(name string, fn HostFunc) Option
- func WithSource(src string) Option
- func WithStdout(w io.Writer) Option
- func WithTCPAccess(address string, port int) Option
- func WithUDPAccess(address string, port int) Option
- type Program
- type ProgramOption
- type PythonError
- type RenameFS
- type RmdirFS
- type UnlinkFS
- type Value
- func BigInt(n *big.Int) Value
- func Bool(b bool) Value
- func Bytes(b []byte) Value
- func Dict(entries ...Item) Value
- func Exception(typ, msg string) Value
- func Float(f float64) Value
- func FrozenSet(items ...Value) Value
- func Int(n int64) Value
- func List(items ...Value) Value
- func None() Value
- func Of(v any) Value
- func Set(items ...Value) Value
- func Str(s string) Value
- func Tuple(items ...Value) Value
- func (v Value) AsBigInt() (*big.Int, error)
- func (v Value) AsBool() (bool, error)
- func (v Value) AsBytes() ([]byte, error)
- func (v Value) AsDict() ([]Item, error)
- func (v Value) AsFloat() (float64, error)
- func (v Value) AsFrozenSet() ([]Value, error)
- func (v Value) AsInt() (int64, error)
- func (v Value) AsList() ([]Value, error)
- func (v Value) AsObject() (Object, error)
- func (v Value) AsSet() ([]Value, error)
- func (v Value) AsString() (string, error)
- func (v Value) AsTuple() ([]Value, error)
- func (v Value) Export() any
- func (v Value) IsCallable() bool
- func (v Value) IsIterator() bool
- func (v Value) IsNone() bool
- func (v Value) String() string
- func (v Value) Type() string
Examples ¶
Constants ¶
const AnyAddress = network.AnyAddress
AnyAddress matches all supported destination addresses, including loopback and private networks.
Variables ¶
var ( // ErrClosed reports a closed interpreter or pool. ErrClosed = api.ErrClosed // ErrInterrupted identifies an interrupted call. ErrInterrupted = api.ErrInterrupted // ErrInstanceNotInitialised reports an Instance that was not initialized. ErrInstanceNotInitialised = errors.New("cannot perform operation on Instance that has not been initialised") )
var ErrRunReturned = errors.New("micropython: BorrowedInstance used after Run returned")
ErrRunReturned is reported by a BorrowedInstance used after its Program.Run callback returned.
Functions ¶
Types ¶
type BorrowedInstance ¶
type BorrowedInstance struct {
// contains filtered or unexported fields
}
BorrowedInstance provides interpreter operations during Program.Run. It must not be copied or used after the callback returns. All goroutines using it must finish before the callback returns.
func (*BorrowedInstance) Call ¶
Call invokes a Python global function; see Instance.Call.
func (*BorrowedInstance) Eval ¶
Eval evaluates a Python expression; see Instance.Eval.
func (*BorrowedInstance) Exec ¶
func (o *BorrowedInstance) Exec(ctx context.Context, src string) error
Exec runs Python statements; see Instance.Exec.
func (*BorrowedInstance) Get ¶
Get reads a Python global; see Instance.Get.
func (*BorrowedInstance) Set ¶
Set binds a Python global; see Instance.Set.
type Func ¶
type Func struct {
// contains filtered or unexported fields
}
Func is a Python callable bound by Instance.AsCallable. It can be invoked in Go or passed back to the same interpreter.
func (Func) Call ¶
Call invokes the bound function with Instance.Call argument conversions. It must not be called from a HostFunc running on the same Instance.
type Globals ¶
Globals maps Python global names to initial Go values for WithGlobals.
type HostFunc ¶
HostFunc is a Go function callable from Python through WithHostFunc or Instance.DefineFunction. Errors and panics become Python exceptions; use Raise to choose the exception class. A callback must not synchronously call or close its own Instance.
type Instance ¶
type Instance struct {
// contains filtered or unexported fields
}
Instance is a MicroPython interpreter whose state persists between calls. It is safe for concurrent use, but executes one operation at a time. Use Program or Instance.Clone for parallel execution, and call Close when done.
func NewInstance ¶
NewInstance creates an interpreter and applies its initialization options. The caller must close it when done.
Example (ReadOnlyFiles) ¶
package main
import (
"bytes"
"context"
"fmt"
"log"
"testing/fstest"
micropython "github.com/gregfurman/micropython-go"
)
func main() {
ctx := context.Background()
files := fstest.MapFS{
"message.txt": &fstest.MapFile{Data: []byte("hello")},
}
var output bytes.Buffer
in, err := micropython.NewInstance(ctx,
micropython.WithFS(micropython.ReadOnly(files)),
micropython.WithEnv("STAGE", "sandbox"),
micropython.WithStdout(&output),
micropython.WithHeapSize(256*1024),
)
if err != nil {
log.Fatal(err)
}
defer in.Close()
if err := in.Exec(ctx, `
import os
with open('message.txt') as f:
print(os.getenv('STAGE'), f.read())
`); err != nil {
log.Fatal(err)
}
fmt.Print(output.String())
}
Output: sandbox hello
Example (Sandbox) ¶
package main
import (
"context"
"fmt"
"log"
"time"
micropython "github.com/gregfurman/micropython-go"
)
func main() {
ctx := context.Background()
deadline, cancel := context.WithTimeout(ctx, time.Second)
defer cancel()
in, err := micropython.NewInstance(deadline,
micropython.WithEnv("APP_MODE", "agent"),
micropython.WithHeapSize(256*1024),
)
if err != nil {
log.Fatal(err)
}
defer in.Close()
result, err := in.Eval(deadline, "sum(range(101))")
if err != nil {
log.Fatal(err)
}
n, err := result.AsInt()
if err != nil {
log.Fatal(err)
}
fmt.Println(n)
}
Output: 5050
func (*Instance) AsCallable ¶
AsCallable binds a callable Value to this Instance for invocation through Func.Call. The value must belong to this interpreter and remain live when called.
func (*Instance) AsIterator ¶
AsIterator binds a guest iterator value to this Instance for lazy iteration.
func (*Instance) Call ¶
Call invokes a Python global function. Arguments may be Go values or Value builders; the result is a Value. Python state changes persist after the call.
func (*Instance) Cancel ¶
Cancel requests a KeyboardInterrupt in the current Python execution. It is safe from any goroutine and does not affect the next operation. Interruption is best effort: long C operations and blocking host I/O may delay it.
func (*Instance) Clone ¶
Clone copies the current Python state into a new, caller-owned Instance. It locks the source while copying. Go callbacks, output writers, and filesystem backends are shared; guest handles cannot be transferred between instances. Close Python sockets, files, and directory iterators before cloning.
func (*Instance) Close ¶
Close interrupts active execution and closes the interpreter. Later execution attempts return ErrClosed.
func (*Instance) DefineFunction ¶
DefineFunction binds fn to a Python global, replacing any existing binding. The binding persists across calls and is inherited by clones. See HostFunc for callback behavior.
Example ¶
Raise picks the exception class the guest catches.
package main
import (
"context"
"errors"
"fmt"
"log"
micropython "github.com/gregfurman/micropython-go"
)
func main() {
ctx := context.Background()
in, err := micropython.NewInstance(ctx)
if err != nil {
log.Fatal(err)
}
defer in.Close()
rates := map[string]float64{"EUR": 1.09, "GBP": 1.27} // Example rates.
err = in.DefineFunction(ctx, "usd", func(_ context.Context, args []micropython.Value) (micropython.Value, error) {
if len(args) != 1 {
return micropython.Value{}, micropython.Raise("TypeError", "usd expects one currency code")
}
code, err := args[0].AsString()
if err != nil {
return micropython.Value{}, err
}
rate, ok := rates[code]
if !ok {
return micropython.Value{}, micropython.Raise("KeyError", code)
}
return micropython.Float(rate), nil
})
if err != nil {
log.Fatal(err)
}
got, err := in.Eval(ctx, `usd("EUR")`)
if err != nil {
log.Fatal(err)
}
fmt.Println(got)
var exc *micropython.PythonError
if _, err := in.Eval(ctx, `usd("JPY")`); errors.As(err, &exc) {
fmt.Println(exc.Type(), "/", exc.Message())
}
}
Output: 1.09 KeyError / JPY
func (*Instance) Eval ¶
Eval evaluates a Python expression and returns its Value. Use Instance.Exec for statements and assignments.
func (*Instance) Exec ¶
Exec runs Python statements, preserving their state changes. Output goes to WithStdout, or is discarded by default.
func (*Instance) Get ¶
Get reads a Python global without evaluating an expression. It returns a Python NameError if the name is unbound.
func (*Instance) Release ¶
Release unpins guest objects, including handles nested in containers. It invalidates all handles to each object, even separately acquired ones. Non-handles, already-released handles, and foreign handles are ignored.
Release does not run GC or remove Python-owned references. It is optional: Go cleanup also queues releases, applied by subsequent interpreter operations.
type Iterator ¶
type Iterator struct {
// contains filtered or unexported fields
}
Iterator is a guest iterator bound to an Instance by Instance.AsIterator.
type Object ¶
type Object struct {
// contains filtered or unexported fields
}
Object is an opaque guest handle with cached type and capability information. Passing it back to its interpreter refers to the original Python object.
func (Object) IsCallable ¶
IsCallable reports whether the guest object can be called.
func (Object) IsIterable ¶
IsIterable reports whether the guest object is an iterator.
type OpenFileFS ¶
type OpenFileFS = vfs.OpenFileFS
OpenFileFS optionally enables writable open calls for WithFS.
type Option ¶
type Option interface {
ProgramOption
// contains filtered or unexported methods
}
Option configures an Instance or a Program. Access is opt-in: use WithFS, WithEnv, WithTCPAccess, WithUDPAccess, WithDNSResolver, WithStdout, and WithHostFunc to expose host resources. WithSource, WithGlobals, and WithHeapSize configure execution.
func WithDNSResolver ¶
WithDNSResolver supplies and enables name resolution for socket.getaddrinfo. Resolution is denied by default. Nil fails at construction; use net.DefaultResolver explicitly to use the host resolver. Last call wins.
WithTCPAccess(AnyAddress, 443) WithDNSResolver(net.DefaultResolver)
Lookups are independent of TCP/UDP grants and can contact nameservers outside those grants. Resolved destinations still need connection permission. Programs and clones share r; do not modify it while they are in use.
func WithEnv ¶
WithEnv sets a variable for Python's os.getenv. The environment starts empty. Calls are additive; the last value for a name wins.
The Go process environment is never inherited. Python's os.putenv and os.unsetenv affect only this instance. Clones copy the current variables; Program.Run restores the variables captured after initialization.
Names must be nonempty, at most 1024 bytes, and contain neither "=" nor NUL. Values must be at most 65536 bytes and contain no NUL. Invalid pairs fail construction. Guest writes use the same limits and cannot add a new name when 256 variables already exist. This host memory is outside WithHeapSize.
func WithFS ¶
WithFS exposes filesystem at Python's root for files and imports. Access is denied by default or with nil. Repeated use replaces the filesystem. Open files are closed on rewind or instance close, but the caller owns the filesystem. Programs and clones share it; filesystem changes are not rewound.
The fs.FS interface provides read access. Backends can grant writes with OpenFileFS, MkdirFS, UnlinkFS, RmdirFS, and RenameFS. Use ReadOnly to hide those write capabilities.
The backend must confine symlinks and support concurrent use by independent instances. os.DirFS alone does not prevent symlinks escaping its directory.
func WithGlobals ¶
WithGlobals sets initial Python globals using Instance.Set conversion rules. No caller-supplied globals are set by default. Repeated use replaces the map.
Example ¶
Globals reach the source without being spliced into its text, so nothing has to be quoted or escaped.
package main
import (
"context"
"fmt"
"log"
micropython "github.com/gregfurman/micropython-go"
)
func main() {
ctx := context.Background()
p, err := micropython.NewProgram(ctx, micropython.WithSource(`
def describe():
return "%s allows %d retries" % (NAME, LIMITS["retries"])
`), micropython.WithGlobals(micropython.Globals{
"NAME": micropython.Str("service"),
"LIMITS": micropython.Dict(micropython.Item{Key: micropython.Str("retries"), Val: micropython.Int(3)}),
}))
if err != nil {
log.Fatal(err)
}
defer p.Close()
var got micropython.Value
if err := p.Run(ctx, func(in *micropython.BorrowedInstance) error {
v, err := in.Call(ctx, "describe")
got = v
return err
}); err != nil {
log.Fatal(err)
}
fmt.Println(got)
}
Output: service allows 3 retries
func WithHeapSize ¶
WithHeapSize sets the Python heap size in bytes. The default and zero use 128 KiB. This is not a limit on total interpreter or host memory. Invalid sizes fail at construction. Exhausting the heap raises MemoryError.
func WithHostFunc ¶
WithHostFunc binds fn to a Python global before source execution. No Go callbacks are registered by default. The callback controls what host resources Python can access through it. Repeated names use the last binding. Programs and clones share the Go closure, which must support concurrent calls; its state is not rewound. See HostFunc.
func WithSource ¶
WithSource runs src after binding globals and host functions at initialization. By default, no initialization script runs. Repeated use replaces the script. For a Program, the resulting Python state is the starting point for each run.
func WithStdout ¶
WithStdout sends Python's print output to w. By default, or with nil, it is discarded. Repeated use replaces the writer. The caller owns w. Programs and clones share it without synchronization, so it must support concurrent writes when used concurrently.
func WithTCPAccess ¶
WithTCPAccess permits outbound TCP to an IPv4 address, CIDR block, or AnyAddress, on port 1-65535. Hostnames and IPv6 are not supported. Connections are denied by default. Grants are additive and order-independent.
WithTCPAccess("192.0.2.10", 443)
WithTCPAccess("10.0.0.0/8", 5432)
WithTCPAccess(AnyAddress, 443)
DNS requires WithDNSResolver. Invalid grants fail at construction. This opens no sockets; port 443 permits TCP traffic, not just HTTPS.
func WithUDPAccess ¶
WithUDPAccess permits outbound UDP on the same terms as WithTCPAccess. Connections are denied by default. Repeated use adds grants. Python must connect the socket first. sendto may only name the connected peer; recvfrom returns that peer. Unconnected datagrams are unsupported.
type Program ¶
type Program struct {
// contains filtered or unexported fields
}
Program pools interpreters initialized from a common Python state. Runs are safe to execute concurrently and do not retain each other's Python state changes. Call Program.Close when done.
func NewProgram ¶
func NewProgram(ctx context.Context, opts ...ProgramOption) (*Program, error)
NewProgram initializes Python using opts and saves the state for later runs. Initialization must close files, directory iterators, and sockets before the state is saved. The caller must close the Program when done.
func (*Program) Close ¶
Close closes idle interpreters and rejects new work with ErrClosed. Active runs finish normally; their interpreters are closed on return.
func (*Program) Instance ¶
Instance creates a standalone interpreter from the Program's initialized state. It keeps state between calls. The caller must close it separately.
func (*Program) Run ¶
Run calls fn with a borrowed interpreter, then resets or closes it. It returns callback and cleanup errors. External effects are not undone.
Canceling ctx requests interruption of the current Python operation; see Instance.Cancel. Pass ctx to borrowed methods so later operations also observe cancellation. The callback must handle cancellation of its own Go work. The BorrowedInstance is valid only until fn returns.
Example ¶
package main
import (
"context"
"fmt"
"log"
micropython "github.com/gregfurman/micropython-go"
)
func main() {
ctx := context.Background()
p, err := micropython.NewProgram(ctx, micropython.WithSource(`
def score(row):
return {"id": row["id"], "total": row["a"] * 2 + row["b"]}
`))
if err != nil {
log.Fatal(err)
}
defer p.Close()
var out map[string]any
err = p.Run(ctx, func(in *micropython.BorrowedInstance) error {
got, err := in.Call(ctx, "score", map[string]any{"id": "r-1", "a": 4, "b": 5})
if err != nil {
return err
}
out = got.Export().(map[string]any)
return nil
})
if err != nil {
log.Fatal(err)
}
fmt.Println(out["id"], out["total"])
}
Output: r-1 13
type ProgramOption ¶
type ProgramOption interface {
// contains filtered or unexported methods
}
ProgramOption configures a Program. Every Option is also a ProgramOption. WithMaxIdle controls the pool; the other options also apply to instances.
func WithMaxIdle ¶
func WithMaxIdle(n int) ProgramOption
WithMaxIdle limits idle interpreters retained by a Program, not active runs. The default and zero use runtime.NumCPU; negative values fail at construction.
type PythonError ¶
PythonError describes a guest exception. Use errors.As with *PythonError to inspect its Type, Message, and Raw traceback.
Example ¶
A guest that raises comes back as an ordinary Go error and leaves the interpreter usable.
package main
import (
"context"
"errors"
"fmt"
"log"
micropython "github.com/gregfurman/micropython-go"
)
func main() {
ctx := context.Background()
p, err := micropython.NewProgram(ctx, micropython.WithSource("def lookup(key):\n return {\"a\": 1}[key]\n"))
if err != nil {
log.Fatal(err)
}
defer p.Close()
var exc *micropython.PythonError
err = p.Run(ctx, func(in *micropython.BorrowedInstance) error {
_, err := in.Call(ctx, "lookup", "missing")
return err
})
if errors.As(err, &exc) {
fmt.Println(exc.Type(), "/", exc.Message())
}
var got micropython.Value
if err := p.Run(ctx, func(in *micropython.BorrowedInstance) error {
v, err := in.Call(ctx, "lookup", "a")
got = v
return err
}); err != nil {
log.Fatal(err)
}
fmt.Println(got)
}
Output: KeyError / missing 1
type RmdirFS ¶
RmdirFS optionally enables removal of an empty directory for WithFS. It must atomically reject files and symlinks, and must not remove recursively.
type UnlinkFS ¶
UnlinkFS optionally enables removal of a file or symlink for WithFS. It must not follow the final symlink and must atomically reject directories. Go's os.Remove does not satisfy this contract.
type Value ¶
type Value struct {
// contains filtered or unexported fields
}
Value represents copied Python data or a handle owned by an interpreter. Use Export for Go data or the As methods for checked, type-specific access. The zero Value is invalid; use None for Python None. Data copied from a Program.Run survives the run; handles returned by that run, including those nested in collections, do not.
Example ¶
A Go slice could be a list, a tuple or a set, so the builders say which.
package main
import (
"context"
"fmt"
"log"
micropython "github.com/gregfurman/micropython-go"
)
func main() {
ctx := context.Background()
p, err := micropython.NewProgram(ctx, micropython.WithSource("def kind(v):\n return type(v).__name__\n"))
if err != nil {
log.Fatal(err)
}
defer p.Close()
for _, v := range []any{
[]any{1, 2},
micropython.Tuple(micropython.Int(1), micropython.Int(2)),
} {
var got micropython.Value
if err := p.Run(ctx, func(in *micropython.BorrowedInstance) error {
v, err := in.Call(ctx, "kind", v)
got = v
return err
}); err != nil {
log.Fatal(err)
}
fmt.Println(got)
}
}
Output: list tuple
func Exception ¶
Exception builds an exception Value. Returning it from a HostFunc raises it; use Raise to return an exception through the error result instead.
func Of ¶
Of converts Go data to a Value. Nil becomes None; []byte becomes bytes. Scalars and collections use native conversions; other types use JSON. Unsigned integers must fit in int64; use BigInt for larger integers. Use builders such as Tuple when the Python type matters. Conversion failures produce an invalid Value, reported when passed to Python.
func (Value) AsBigInt ¶
AsBigInt returns a Python integer, or an error for other types. The result may share storage with v; copy it before modifying it.
func (Value) AsBytes ¶
AsBytes copies Python bytes into a Go slice, or returns an error for other types.
func (Value) AsDict ¶
AsDict returns a new slice of dictionary entries without converting keys. It preserves received order and returns an error for other types.
func (Value) AsFloat ¶
AsFloat returns a Python float as a float64, or an error for other types. It does not convert integers to floats.
func (Value) AsFrozenSet ¶
AsFrozenSet returns a new slice of a Python frozenset's elements. It returns an error for other types. Element order is unspecified.
func (Value) AsInt ¶
AsInt returns an int64, reporting type mismatch or overflow. Use Value.AsBigInt for larger integers.
func (Value) AsList ¶
AsList returns a new slice of a Python list's elements, or an error for other types.
func (Value) AsSet ¶
AsSet returns a new slice of a Python set's elements, or an error for other types. Element order is unspecified.
func (Value) AsTuple ¶
AsTuple returns a new slice of a Python tuple's elements, or an error for other types.
func (Value) Export ¶
Export converts data to Go scalars, slices, and maps. Handles remain Values, including inside containers. None and the zero Value export as nil. Container kinds are flattened and non-comparable dictionary keys stringified; use the As methods when those distinctions matter.
func (Value) IsCallable ¶
IsCallable reports whether v holds a Python callable.
func (Value) IsIterator ¶
IsIterator reports whether v holds a guest iterator, not a copied collection.
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
basic
command
Run a script in a stateful interpreter, then read values back out.
|
Run a script in a stateful interpreter, then read values back out. |
|
callable
command
Hold a Python function in Go, call it, and pass it back to Python.
|
Hold a Python function in Go, call it, and pass it back to Python. |
|
channel
command
Back a host function with a Go channel.
|
Back a host function with a Go channel. |
|
errors
command
Handle a guest that raises, and stop one that will not finish.
|
Handle a guest that raises, and stop one that will not finish. |
|
filesystem
command
Give the guest files to read.
|
Give the guest files to read. |
|
hostfunc
command
Let Python call back into Go, and control which exception the guest sees when the Go side fails.
|
Let Python call back into Go, and control which exception the guest sees when the Go side fails. |
|
iterator
command
Pull values from a Python generator one at a time, without materialising the whole sequence.
|
Pull values from a Python generator one at a time, without materialising the whole sequence. |
|
memory
command
Size the Python heap to what a script allocates.
|
Size the Python heap to what a script allocates. |
|
network
command
Let the guest make outbound connections.
|
Let the guest make outbound connections. |
|
program
command
Compile a script once and serve concurrent calls from a pool of interpreters, each rewound to the compiled state before it is reused.
|
Compile a script once and serve concurrent calls from a pool of interpreters, each rewound to the compiled state before it is reused. |
|
stdout
command
Read what the guest prints, either collected afterwards or streamed as it runs.
|
Read what the guest prints, either collected afterwards or streamed as it runs. |
|
values
command
Choose the Python type an argument arrives as, and read a result back without guessing what it is.
|
Choose the Python type an argument arrives as, and read a result back without guessing what it is. |
|
internal
|
|
|
host/codec
Package codec translates between the host's value model and the records MicroPython reads and writes.
|
Package codec translates between the host's value model and the records MicroPython reads and writes. |
|
host/env
Package env implements the guest's os environment imports.
|
Package env implements the guest's os environment imports. |
|
host/vfs
Package vfs implements the guest's fs imports over an io/fs filesystem.
|
Package vfs implements the guest's fs imports over an io/fs filesystem. |