Skip to content

Commit

Permalink
One more minor optimization for when we max out our hashing ability.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamadden committed Sep 8, 2016
1 parent 65c0c31 commit acfbf04
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/nti/schema/eqhash.py
Expand Up @@ -198,6 +198,11 @@ def _hash(values):
except TypeError:
# Snap. Something changed.
for i, value in enumerate(values):
if transformers[i] is _superhash:
# We've reached our limit. Nothing else to do
# for this one.
continue

if transformers[i] is _superhash_force:
try:
_superhash_force(value)
Expand Down
6 changes: 6 additions & 0 deletions src/nti/schema/tests/test_eqhash.py
Expand Up @@ -112,6 +112,12 @@ class AThing(object):
assert_that(hash(thing_superhash2), is_(hash(thing_superhash)))
assert_that(hash(thing_superhash2), is_(hash(thing_superhash)))

# One more mutation for coverage
thing_superhash.a = athing
thing_superhash2.a = athing
assert_that(hash(thing_superhash2), is_(hash(thing_superhash)))
assert_that(hash(thing_superhash2), is_(hash(thing_superhash)))


def test_eq_hash_classes(self):
# Default doesn't include classes
Expand Down

0 comments on commit acfbf04

Please sign in to comment.