baml.random.Xoshiro256PlusPlus

A fast, seedable, deterministic PRNG (xoshiro256++). Given the same seed it always reproduces the same stream, which makes it ideal for tests, simulations, and sampling.

Reference version

Signature

class baml.random.Xoshiro256PlusPlus

A fast, seedable, deterministic PRNG (xoshiro256++). Given the same seed it always reproduces the same stream, which makes it ideal for tests, simulations, and sampling.

NOT cryptographically secure: its output is predictable from observed draws. Never use it for keys, tokens, nonces, or any security-sensitive value — use SystemRandom or a well-seeded ChaCha20 instead.

Source:<builtin>/baml/ns_random/random.bamlbytes 2766–4117

Fields

_state

$rust_type

Opaque, mutex-guarded generator state owned by the Rust runtime.

Static methods

function

_new

(seed: uint8array) -> baml.random.Xoshiro256PlusPlus throws never
function

new

(seed: uint8array = …) -> baml.random.Xoshiro256PlusPlus throws never

Creates a new Xoshiro256PlusPlus pseudo-random number generator.

Parameters

  • seed: The seed for the random number generator. If no seed is provided, a random seed is generated using the system random number generator. The seed must be at least 32 bytes long.

Panics

If seed is shorter than 32 bytes.

Implementations

baml.Concrete for T

Source:<builtin>/baml/core.bamlbytes 763–795

baml.random.Rng for baml.random.Xoshiro256PlusPlus

Instance methods

function

random

(self, bytes: int) -> uint8array throws never
function

random_int

(self) -> int throws never

Source:<builtin>/baml/ns_random/random.bamlbytes 3832–4115