On Mon, 28 Oct 2024 at 15:06, Andrew Nelson wrote:
> Hi all,
> is there a canonical way of serialising Generators
>
Specifically I'm interested in a safe way (i.e. no pickle) of
saving/restoring Generator state via HDF5 file storage.
___
NumPy-Discussi
On Mon, Oct 28, 2024 at 12:11 AM Andrew Nelson via NumPy-Discussion <
numpy-discussion@python.org> wrote:
> Hi all,
> is there a canonical way of serialising Generators (not via pickle).
>
Pickle is the canonical way. In particular, the pickle _machinery_ is going
to be the single source of truth
Hi all,
is there a canonical way of serialising Generators (not via pickle). Would
the following be reasonable for saving and restoring state:
```
def serialize_rng(rng):
klass = rng.bit_generator.state['bit_generator']
entropy = rng.bit_generator.seed_seq.entropy
return klass, entropy