Comments (8)
This issue is fixed in 1.5.0 release. I will put it on pypi today.
from deepdiff.
@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.
Testing further, it works correctly 90% of times in python3. I'm gonna be refactoring some code to make this work.
from deepdiff.
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.
@ThriceGood Yep, I need to fork Pickle and make it sort data while serializing. I will do that this weekend.
from deepdiff.
@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.
Unfortunately that update does not helps with my case, I will put more complex example later.
from deepdiff.
@inoks Yes, please post an example that fails and reopen the ticket then. Thanks!
from deepdiff.
Related Issues (20)
- DeepDiff fails when dictionary keys are unrepresentable and exclude_regex_paths is not None
- Errors with dictionary_item_removed and dictionary_item_added HOT 3
- Error on Delta With None Key and Removed Item from List
- Need to be able to see full path on all outputs HOT 1
- Error when subtracting Delta from a dictionary HOT 4
- Documentation on how to consume keys HOT 2
- Error after comparing: Can not produce a hash (type datetime.date doesn't define __round__ method) HOT 1
- parse_path() cannot parse a path HOT 4
- Is there a way to systematically cycle through all corresponding attributes that haven't changed? HOT 1
- support compre string as float specify precision HOT 1
- Error when comparing two nested dicts with 2 added fields HOT 5
- why exclude_regex_paths dont work with ignore_order HOT 1
- Change of integer attribute is not detected HOT 3
- DeepDiff include_path param doesn't work with list of dictionaries HOT 1
- Instantiating a Delta with a flat_dict_list unexpectedly mutates the flat_dict_list HOT 1
- DeepDiff result got errors but not raising an exception
- Documentation on how to create an object only containing changed elements. HOT 1
- DeepDiff cannot compare two zero-dimensional `ndarrays` HOT 2
- Deepdiff incompatible with numpy 2.0 HOT 3
- DeepDiff cannot distinguish between datetime timezones HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from deepdiff.