Skip to content

Code example for: "Can't pickle local object 'DeepDiff.__init__.<locals>.<lambda>'" #408

@behrm

Description

@behrm

hi Sep,
here is some Code to reproduce the problem:

from concurrent.futures.process import ProcessPoolExecutor
from concurrent.futures._base import as_completed

from deepdiff.diff import DeepDiff


def main():
    
    t1 = [[1, 2, 3, 9], [9, 8, 5, 9]]
    t2 = [[1, 2, 4, 10], [4, 2, 5]]

    diff = DeepDiff(t1, t2)
    print(diff)
    
    futures = []
    with ProcessPoolExecutor(max_workers = 1) as executor:

        futures.append(executor.submit(DeepDiff, t1, t2))
        
        for future in as_completed(futures):
            if future._exception is None and future._result is not None:
                # DeepDiff 5.5.0
                print(future._result)
            else:
                # DeepDiff 6.3.1
                print(future._exception)
    pass


if __name__ == '__main__':
    main()

With DeepDiff 5.5.0 its output is:

{'values_changed': {'root[0][2]': {'new_value': 4, 'old_value': 3}, 'root[0][3]': {'new_value': 10, 'old_value': 9}, 'root[1][0]': {'new_value': 4, 'old_value': 9}, 'root[1][1]': {'new_value': 2, 'old_value': 8}}, 'iterable_item_removed': {'root[1][3]': 9}}
{'values_changed': {'root[0][2]': {'new_value': 4, 'old_value': 3}, 'root[0][3]': {'new_value': 10, 'old_value': 9}, 'root[1][0]': {'new_value': 4, 'old_value': 9}, 'root[1][1]': {'new_value': 2, 'old_value': 8}}, 'iterable_item_removed': {'root[1][3]': 9}}

With DeepDiff 6.3.1 its output is:

{'values_changed': {'root[0][2]': {'new_value': 4, 'old_value': 3}, 'root[0][3]': {'new_value': 10, 'old_value': 9}, 'root[1][0]': {'new_value': 4, 'old_value': 9}, 'root[1][1]': {'new_value': 2, 'old_value': 8}}, 'iterable_item_removed': {'root[1][3]': 9}}
Can't pickle local object 'DeepDiff.__init__.<locals>.<lambda>'

Originally posted by @behrm in #298 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions