From 5a4adc43fe726634bf6cbd7cd95fd4110b7d189d Mon Sep 17 00:00:00 2001 From: Andras Schmelczer Date: Mon, 4 Jul 2022 09:28:35 +0200 Subject: [PATCH] Cache get --- src/great_ai/large_file/large_file/large_file.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/great_ai/large_file/large_file/large_file.py b/src/great_ai/large_file/large_file/large_file.py index 0172ef9..9ae0564 100644 --- a/src/great_ai/large_file/large_file/large_file.py +++ b/src/great_ai/large_file/large_file/large_file.py @@ -2,6 +2,7 @@ import os import shutil import tempfile from abc import ABC, abstractmethod +from functools import lru_cache from pathlib import Path from types import TracebackType from typing import IO, Any, List, Optional, Type, Union, cast @@ -141,6 +142,7 @@ class LargeFile(ABC): def version(self) -> int: return cast(int, self._version) + @lru_cache(1) def get(self, hide_progress: bool = False) -> Path: remote_path = next( i.remote_path for i in self._instances if i.version == self._version