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

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

Closed
behrm opened this issue Jul 25, 2023 · 1 comment

Comments

@behrm
Copy link

behrm commented Jul 25, 2023

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)

@seperman
Copy link
Owner

Hi @behrm
Thanks for bringing this issue to my attention again. Sometimes I fix the latest bug reports first and some tickets are forgotten.
I will take a look at it asap.

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

2 participants