Skip to content

Commit

Permalink
[contacts.ContactGroup] Speedup: Use id(top) before anything else to …
Browse files Browse the repository at this point in the history
…check for same topology in all CPs
  • Loading branch information
gph82 committed Jan 30, 2025
1 parent 578d761 commit 9d771b0
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions mdciao/contacts/contacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -3494,6 +3494,11 @@ def _unique_topology_from_ctcs(self):
if all([ictc.top is None for ictc in self.contact_pairs]):
return None

#First try the quickest (and likeliest) which is all CPs point to the same object
top_id = _np.unique([id(ictc.top) for ictc in self.contact_pairs])
if len(top_id)==1:
return self.contact_pairs[0].top
# More than one ID? Still the tops could be the same (but the control is slow)
top = _np.unique([ictc.top.__hash__() for ictc in self.contact_pairs])
if len(top)==1:
return self.contact_pairs[0].top
Expand Down

0 comments on commit 9d771b0

Please sign in to comment.