Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pickling lambda: "TypeError: cannot pickle '_struct.Struct' object" #688

Closed
jackshi0912 opened this issue Oct 26, 2024 · 0 comments
Closed
Labels
Milestone

Comments

@jackshi0912
Copy link

jackshi0912 commented Oct 26, 2024

When I try to pickle a simple lambda:
dill.dumps(lambda x, y: Foo(args=(x, y.mutations)))
where

class Foo(NamedTuple):
    args: Sequence = ()
    kwargs: Mapping[str, Any] = {}

I get the following error:

  File "/usr/local/lib/python3.10/dist-packages/dill/_dill.py", line 422, in save
    StockPickler.save(self, obj, save_persistent_id)
  File "/usr/lib/python3.10/pickle.py", line 578, in save
    rv = reduce(self.proto)
TypeError: cannot pickle '_struct.Struct' object

cloudpickle has no such issue. I assume that this is a bug since I couldn't find any resources related to it on stackoverflow, the usecase seems quite generic and cloudpickle handles it correctly.

@mmckerns mmckerns added this to the dill-0.4.0 milestone Oct 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants