Skip to content

Commit

Permalink
Merge pull request #907 from koordinates/dont-lru-cache-methods
Browse files Browse the repository at this point in the history
Don't use lru_cache for method memoization
  • Loading branch information
craigds committed Sep 20, 2023
2 parents 0d9d50d + fb4f3f7 commit f974601
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions kart/repo.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import logging
import os
import re
import struct
import sys
from enum import Enum
from functools import lru_cache
from functools import cached_property
from pathlib import Path

import click
Expand Down Expand Up @@ -411,8 +410,7 @@ def _clone_with_git_command(
else:
raise

@property
@lru_cache(maxsize=1)
@cached_property
def diff_annotations(self):
# DiffAnnotations is slow to import - don't move this to the top of this file.
from .annotations import DiffAnnotations
Expand Down Expand Up @@ -563,8 +561,7 @@ def REPOSTRUCTURE_VERSION_KEY(self):
def WORKINGCOPY_LOCATION_KEY(self):
return KartConfigKeys.BRANDED_WORKINGCOPY_LOCATION_KEYS[self.branding]

@property
@lru_cache(maxsize=1)
@cached_property
def table_dataset_version(self):
"""Returns the Kart repository version - eg 2 for 'Datasets V2' See DATASETS_v2.md"""
return get_repo_wide_version(self)
Expand Down Expand Up @@ -665,8 +662,7 @@ def head_tree(self):
"""
return None if self.head_is_unborn else self.head.peel(pygit2.Tree)

@property
@lru_cache(maxsize=1)
@cached_property
def empty_tree(self):
f"""Returns the empty tree, with SHA {EMPTY_TREE_SHA}."""
return self[EMPTY_TREE_SHA]
Expand Down

0 comments on commit f974601

Please sign in to comment.