You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
DeepHash output is not like conventional hash functions. It is a dictionary of object IDs to their hashes. This happens because DeepHash calculates the hash of the object and any other objects found within the object in a recursive manner. If you only need the hash of the object you are passing, all you need to do is to do:
At first it might seem weird why DeepHash(obj)[obj] but remember that DeepHash(obj) is a dictionary of hashes of all other objects that obj contains too.
199
200
200
-
The result hash is 34150898645750099477987229399128149852. If you prefer to use another hashing algorithm, you can pass it using the hasher parameter.
201
+
If you prefer to use another hashing algorithm, you can pass it using the hasher parameter.
201
202
202
203
If you do a deep copy of the obj, it should still give you the same hash:
You can pass a list of tuples or list of lists if you have various type groups. When t1 and t2 both fall under one of these type groups, the type change will be ignored. DeepDiff already comes with 2 groups: DeepDiff.strings and DeepDiff.numbers . If you want to pass both:
258
259
@@ -305,19 +306,18 @@ ignore_type_subclasses
305
306
>>> obj_b = ClassB(1)
306
307
>>> obj_c = ClassC(1)
307
308
>>>
308
-
>>> # Since these 2 objects are from 2 different classes, the hashes are different by default.
309
-
... # ignore_type_in_groups is set to [(ClassB, )] which means to ignore any type conversion between
310
-
... # objects of classB and itself which does not make sense but it illustrates a better point when
311
-
... # ignore_type_subclasses is set to be True.
309
+
>>> # By default, subclasses are considered part of the type group.
310
+
... # ignore_type_in_groups=[(ClassB, )] matches ClassC too since it's a subclass.
A function that takes the object and its path and returns a Boolean. If True is returned, the object is excluded from the results, otherwise it is included.
335
335
This is to give the user a higher level of control than one can achieve via exclude_paths, exclude_regex_paths or other means.
336
336
337
+
>>> defexclude_obj_callback(obj, path):
338
+
... returnTrueifisinstance(obj, str) and obj in ('x', 'y') elseFalse
0 commit comments