loqs.internal.encoder.baseencoder¶
Classes¶
Attributes¶
| Name | Type | Value | Doc |
|---|---|---|---|
NUMPY_SCALAR_TYPES |
(np.number, np.bool_) |
The numpy scalar types the encoders tag, so they read back with their dtype. |
Functions¶
copy_cached_reference ¶
copy_cached_reference(reference_obj)
Copy an already-decoded object for a "copy"-type cached reference,
used by both encoders' decode_cached_obj.
For classes confirmed to treat their own nested content as immutable
once constructed -- History and
InstructionStack, each already implementing a cheap
"wrap an existing instance" constructor for exactly this reason --
this uses that constructor instead of a full recursive
copy.deepcopy(), which would otherwise redundantly re-copy content
already safe to share. History's constructor gives the copy shallow
copies of its Frames (whose own _data is only ever replaced via
.update(), never mutated in place), not shared Frames.
InstructionStack shares its nested content.
Instruction and QECCode are shared as they are (immutable after
construction but for idempotent memos). QECCodePatch and
PatchLayout, which builders and codepacks mutate in place, copy only
the mutated parts: a patch its data, a layout its patch dict,
patches and relations. Every other type still gets a full
deepcopy(), since that safety hasn't been confirmed for them (e.g. a
quantum state's own array data is mutated in place).