uqfoundation / dill

serialize all of Python

Home Page:http://dill.rtfd.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

dionhaefner opened this issue · comments

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?