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

How to ensure the same functions serialize to the same bytes? #622

Open
dionhaefner opened this issue Oct 5, 2023 · 0 comments
Open

How to ensure the same functions serialize to the same bytes? #622

dionhaefner opened this issue Oct 5, 2023 · 0 comments

Comments

@dionhaefner
Copy link

I'm trying to use dill to detect whether a function has changed between sessions. I want functions with identical bodies, signatures, and globals to produce the same serialization. But even the simplest experiment fails:

import dill

def foo():
    pass

foo_pickled = dill.dumps(foo, byref=False, recurse=False)

def foo():
    pass

foo_pickled_again = dill.dumps(foo, byref=False, recurse=False)
assert foo_pickled == foo_pickled_again

Is there a shortlist of attributes I need to override to achieve this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant