Hashing a function object in Python

def get_function_hash(fn):
    return hash((
        inspect.getsource(fn),
        get_function_closures(fn),
        get_function_globals(fn),
    ))

See related content for get_function_closures and get_function_globals implementations.

Requirements:

import inspect

Related: