Compute a deterministic hash of the solution content.
(self)
| 328 | object.__setattr__(self, "_hash_cache", self._compute_hash()) |
| 329 | |
| 330 | def _compute_hash(self) -> str: |
| 331 | """Compute a deterministic hash of the solution content.""" |
| 332 | h = hashlib.sha1() |
| 333 | for s in ( |
| 334 | self.name, |
| 335 | self.definition, |
| 336 | *[lang.value for lang in self.spec.languages], |
| 337 | self.spec.entry_point, |
| 338 | self.spec.binding.value if self.spec.binding else "", |
| 339 | *self.spec.dependencies, |
| 340 | *(part for src in self.sources for part in (src.path, src.content)), |
| 341 | ): |
| 342 | h.update(s.encode()) |
| 343 | |
| 344 | return h.hexdigest() |
| 345 | |
| 346 | def hash(self) -> str: |
| 347 | """Return the memoized deterministic hash of the solution content. |