Skip to content

Discussion: cPickle #485

@leogama

Description

@leogama

Hey, I've been working on a prototype of a "portable pickle" feature and started wondering whether it could eventually work with cPickle (or _pickle), the accelerator module written in C. I've also seen some comments in the code referencing the possibility that dill in general could use it.

However, after doing some investigation I noted that, even if the save_<type> functions are updated to use state setters (Py 3.8+) and don't rely on internal Pickler methods like save and save_reduce, there remains a big problem: cPickle will always save types and functions as globals (there isn't an internal dispatch table that we can modify as with the Python implementation).

I thought of creating a C extension module to play with cPickle internals, but all the C functions are private. The only remaining alternative I see is to have a complete clone of Pickler code with some minor tweaks to allow overriding these types' saving.

Have you also wondered about these issues? Do you think it is feasible to have a C extension compatible with multiple Python 3 versions? (I have no ideia how building and distributing these works.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions