# tensorplay.serialization.save

Source: https://www.tensorplay.cn/docs/generated/tensorplay.serialization.save.html

# tensorplay.serialization.save

tensorplay.serialization.save(obj: [Any](https://docs.python.org/3/library/typing.html#typing.Any), f: [str](https://docs.python.org/3/library/stdtypes.html#str) | [PathLike](https://docs.python.org/3/library/os.html#os.PathLike)[[str](https://docs.python.org/3/library/stdtypes.html#str)], *, metadata: [Mapping](https://docs.python.org/3/library/typing.html#typing.Mapping)[[str](https://docs.python.org/3/library/stdtypes.html#str), [Any](https://docs.python.org/3/library/typing.html#typing.Any)] | [None](https://docs.python.org/3/library/constants.html#None) = None, alignment: [int](https://docs.python.org/3/library/functions.html#int) = 4096, checksum: [str](https://docs.python.org/3/library/stdtypes.html#str) = 'crc32', pickle_protocol: [int](https://docs.python.org/3/library/functions.html#int) = 2) &#x2192; [None](https://docs.python.org/3/library/constants.html#None)[[source]](../_modules/tensorplay/serialization.html#save)

Save obj to disk.

Formats are selected by extension:

- .mega (default): native MEGA artifact. Supports nested tensor containers plus JSON-primitive leaves, shared-storage deduplication, an alignment , per-region checksum ( "crc32" , "sha256" , or "none" ) and free-form metadata (strings, numbers, bools, lists).

- .safetensors : flat name->tensor mapping.

- .pt / .pth : torch-compatible archive; any picklable object graph.

A file-like object (io.BytesIO etc.) receives the torch pickle format,
matching torch.save conventions.
