Skip to content

PickleSerializer default protocol=0 #5

@jayvdb

Description

@jayvdb

PickleSerializer default protocol=0 is quite problematic IMO - it is surprising that on modern Python (3), protocol 0 would be the default.

For me this resulted in copyreg._reduce_ex (protocol 0 and 1) raising

a class that defines slots without defining getstate cannot be pickled

It is possible to override this with serializer='pickle:///?protocol=4'

cloudpickle uses default DEFAULT_PROTOCOL = pickle.HIGHEST_PROTOCOL which is dynamically used if the protocol arg at instantiation is None, allowing the caller to modify module attribute DEFAULT_PROTOCOL if they need to. That probably isnt ideal here where the serializer arg can take sub-args.

Perhaps the default should be serializer='pickle:///?protocol=highest', or at least that should be supported to allow easy access to a sane default for most common purposes where cross-python-version pickling isnt needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions