maxwelllink.tools.fast_json module

Fast JSON helpers for hot-path serialization.

Encoding and decoding live together so a single place decides whether orjson is used. Aggregate bridges encode one payload per molecule every step, so at tens of thousands of molecules this is a measurable part of the step.

maxwelllink.tools.fast_json.json_dumps(payload)[source]

Encode a mapping into compact, sorted UTF-8 JSON bytes.

Notes

orjson always emits compact UTF-8, so it needs no ensure_ascii or separators argument. It writes null for a non-finite float where stdlib json writes NaN; null is the parseable one, since json_loads() is orjson too.

Parameters:

payload (Mapping) – JSON-serializable mapping to encode.

Returns:

Compact UTF-8 JSON with sorted keys.

Return type:

bytes

maxwelllink.tools.fast_json.json_loads(obj, /)

Deserialize JSON to Python objects.