MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _whats_different

Method _whats_different

lib/sqlalchemy/sql/cache_key.py:485–513  ·  view source on GitHub ↗
(self, other: CacheKey)

Source from the content-addressed store, hash-verified

483 return ck1._diff(ck2)
484
485 def _whats_different(self, other: CacheKey) -> Iterator[str]:
486 k1 = self.key
487 k2 = other.key
488
489 stack: List[int] = []
490 pickup_index = 0
491 while True:
492 s1, s2 = k1, k2
493 for idx in stack:
494 s1 = s1[idx]
495 s2 = s2[idx]
496
497 for idx, (e1, e2) in enumerate(zip_longest(s1, s2)):
498 if idx < pickup_index:
499 continue
500 if e1 != e2:
501 if isinstance(e1, tuple) and isinstance(e2, tuple):
502 stack.append(idx)
503 break
504 else:
505 yield "key%s[%d]: %s != %s" % (
506 "".join("[%d]" % id_ for id_ in stack),
507 idx,
508 e1,
509 e2,
510 )
511 else:
512 stack.pop(-1)
513 break
514
515 def _diff(self, other: CacheKey) -> str:
516 return ", ".join(self._whats_different(other))

Calls 3

appendMethod · 0.45
joinMethod · 0.45
popMethod · 0.45