Skip to content

yggdrasil.pickle.ser._scratch

_scratch

Minimal byte-buffer for pickle-module internal use.

The yggdrasil :class:~yggdrasil.io.BytesIO is a full IO object with singleton dispatch, URL routing, format detection, stat tracking, and spill-to-disk support — all entirely unnecessary for the scratch buffers the serializer creates and immediately consumes. :class:_ScratchBuf wraps :class:io.BytesIO (stdlib) and exposes exactly the surface that header.py / serialized.py / collections.py / serde.py use. This cuts per-object allocation overhead by ~10× compared with the full :class:~yggdrasil.io.IO.

The interface is intentionally kept identical to the yggdrasil IO subset used in the pickle module — no new abstractions, no leaking outside this package.