Skip to main content

Python serializer based on init-args

Project description

Python init-args based Serializer

This package provides improved pickling support. Instead of storing the entire state dict __dict__, the parameters passed to the initializer __init__() are captured. During unpickling, the captured parameters are used to create a new object instance.

This behaviour is implemented using the __reduce__() hook. Thus, it is strongly discouraged to override the __reduce__() method. If you need to pickle variables beyond the constructor parameters, you should use the regular __getstate__() and __setstate__() methods.

Usage:

class MyCustomClass(OptionalBaseClass, Serializable):
    
    def __init__(self, *args, **kwargs):
        # Recommended to call this first
        Serializable._init(self, locals())

Project details


Release history Release notifications | RSS feed

This version

1.1

Download files

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

Source Distribution

init-args-serializer-1.1.tar.gz (4.7 kB view details)

Uploaded Source

File details

Details for the file init-args-serializer-1.1.tar.gz.

File metadata

  • Download URL: init-args-serializer-1.1.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.6.9

File hashes

Hashes for init-args-serializer-1.1.tar.gz
Algorithm Hash digest
SHA256 7defe53f4b20d64ddaf0aa8e360d4b8b3afb9e3b946dd4f6432fb54eb9b145dc
MD5 78a8743ab60fea5d71efe540ca015476
BLAKE2b-256 a60a3aef59897053b83673c7ce41ea78c067f1001f0fb47782f2e40e05aca9ca

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