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 hashes)

Uploaded Source

Supported by

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