Skip to main content

Base class with serialization helpers for user-defined Python objects

Project description

Tests PyPI PyPI downloads

serializable

Base class with serialization methods for user-defined Python objects

Usage

Classes which inherit from Serializable are enabled with default implementations of to_json, from_json, __reduce__ (for pickling), and other serialization helpers.

A derived class must either:

  • have a member data matching the name of each argument to __init__
  • provide a user-defined to_dict() method which returns a dictionary whose keys match the arguments to __init__

If you change the keyword arguments to a class which derives from Serializable but would like to be able to deserialize older JSON representations then you can define a class-level dictionary called _KEYWORD_ALIASES which maps old keywords to new names (or None if a keyword was removed).

Limitations

  • Serializable objects must inherit from Serializable, be tuples or namedtuples, be serializble primitive types such as dict, list, int, float, or str.

  • The serialized representation of objects relies on reserved keywords (such as "__name__", and "__class__"), so dictionaries are expected to not contain any keys which begin with two underscores.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

serializable-1.0.0.tar.gz (19.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

serializable-1.0.0-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

Details for the file serializable-1.0.0.tar.gz.

File metadata

  • Download URL: serializable-1.0.0.tar.gz
  • Upload date:
  • Size: 19.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.6

File hashes

Hashes for serializable-1.0.0.tar.gz
Algorithm Hash digest
SHA256 d1d23b312b25e67996573f3d7471a701811a89f000dd3b8c13e21aee89cbcff0
MD5 0868ece92079aefde64e15ad26df1e41
BLAKE2b-256 b0281a65d58fbad2556f70c1386c9210113e9d82805118ad021474040d1b195f

See more details on using hashes here.

File details

Details for the file serializable-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: serializable-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 17.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.6

File hashes

Hashes for serializable-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 eb42ead0c8cab5bb5d5e47f64ee370fcec837ce101df1573b5d2ad1dff2d27ea
MD5 14cb5d666bf3a70a4ba2f5699df0b0c4
BLAKE2b-256 c8188aad9163e9d72210838bf4563d75acd84da3fbe8cc2a38d1d559e8785444

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page