Code Monkey home page Code Monkey logo

Comments (8)

seperman avatar seperman commented on May 22, 2024 1

This issue is fixed in 1.5.0 release. I will put it on pypi today.

from deepdiff.

seperman avatar seperman commented on May 22, 2024

@inoks Thanks for reporting this. This is caused by pickle caring about dictionary order which I was not aware of:

>>> import pickle
>>> a={'title': 1, 'http://purl.org/rss/1.0/modules/content/:encoded': '1'}
>>> b={'http://purl.org/rss/1.0/modules/content/:encoded': '1', 'title': 1}
>>> a==b
True
>>> pickle.dumps(a)==pickle.dumps(b)
False
>>> pickle.dumps(a)
"(dp0\nS'http://purl.org/rss/1.0/modules/content/:encoded'\np1\nS'1'\np2\nsS'title'\np3\nI1\ns."
>>> pickle.dumps(b)
"(dp0\nS'title'\np1\nI1\nsS'http://purl.org/rss/1.0/modules/content/:encoded'\np2\nS'1'\np3\ns."

I will fix it as soon as I can.

from deepdiff.

seperman avatar seperman commented on May 22, 2024

Testing further, it works correctly 90% of times in python3. I'm gonna be refactoring some code to make this work.

from deepdiff.

ThriceGood avatar ThriceGood commented on May 22, 2024

Hey,

I'm wondering if this is related to the issue I'm having:


d1 = {
    'key1': 'val1',
    'key2': [
        {
            'key3': 'val3',
            'key4': 'val4',
        },
        {
            'key5': 'val5',
            'key6': 'val6',
        },
    ],
}
d2 = {
    'key1': 'val1',
    'key2': [
        {
            'key3': 'val3',
            'key4': 'val4',
        },
        {
            'key5': 'CHANGE',
            'key6': 'val6',
        },
    ],
}
>>> diff = DeepDiff(d1, d2)
{'values_changed': {"root['key2'][1]['key5']": {'newvalue': 'CHANGE', 'oldvalue': 'val5'}}}
"""
    works as expected. What seems to cause a problem it when
    I re-order the list and have a changed value in one of the lists dicts. 
    Using with ignore_order=True.
"""
d1 = {
    'key1': 'val1',
    'key2': [
        {
            'key3': 'val3',
            'key4': 'val4',
        },
        {
            'key5': 'val5',
            'key6': 'val6',
        },
    ],
}
d2 = {
    'key1': 'val1',
    'key2': [
        {
            'key5': 'CHANGE',
            'key6': 'val6',
        },
        {
            'key3': 'val3',
            'key4': 'val4',
        },
    ],
}
>>> diff = DeepDiff(d1, d2, ignore_order=True)
{'iterable_item_removed': {"root['key2'][1]": {'key6': 'val6', 'key5': 'val5'}}, 'iterable_item_added': {"root['key2'][0]": {'key6': 'val6', 'key5': 'CHANGE'}}} 
"""
    it looks like it sees it as a new dict instead of a changed value in a current dict
"""

from deepdiff.

seperman avatar seperman commented on May 22, 2024

@ThriceGood Yep, I need to fork Pickle and make it sort data while serializing. I will do that this weekend.

from deepdiff.

seperman avatar seperman commented on May 22, 2024

@ThriceGood I looked at your notes again and you are correct, that is a whole different issue and it is currently by design. I will open a ticket and add you there so we can discuss.

from deepdiff.

slyapustin avatar slyapustin commented on May 22, 2024

Unfortunately that update does not helps with my case, I will put more complex example later.

from deepdiff.

seperman avatar seperman commented on May 22, 2024

@inoks Yes, please post an example that fails and reopen the ticket then. Thanks!

from deepdiff.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.