pyphi.serialize.save#

pyphi.serialize.save(obj, target, *, format=None)[source]#

Serialize obj to target.

Parameters:
  • obj (Any) – A PyPhi domain object with a registered serializer (see pyphi.serialize.convert for the supported types).

  • target (str or os.PathLike or file object) – Destination path, or an open binary file object to write to.

  • format ({"json", "msgpack"}, optional) – Wire format. If None (the default), it is inferred from a path’s extension: .json gives "json"; .msgpack or .mpk give "msgpack"; any other extension, or a non-path target, gives "json".

Return type:

None

Notes

A path ending in .gz is gzip-compressed, with the wire format taken from the inner suffix (result.json.gz yields gzip-compressed JSON). Compression is applied only to path targets, not to file objects.