Skip to content

Can't pickle generic types #511

Closed
python/cpython
#6216
@pitrou

Description

@pitrou

Briefly:

>>> import pickle, typing
>>> tp = typing.List[int]
>>> pickle.loads(pickle.dumps(tp))
Traceback (most recent call last):
  File "<ipython-input-5-ae365d48e86d>", line 1, in <module>
    pickle.loads(pickle.dumps(tp))
PicklingError: Can't pickle typing.List[int]: it's not the same object as typing.List

This can be an issue with certain advanced serialization libraries such as dill or cloudpickle, which are often used by distributed computing frameworks.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions