Coding style
- Sometimes use functools.cache.
This commit is contained in:
parent
e54a07d038
commit
93a5cad003
2 changed files with 5 additions and 6 deletions
|
|
@ -163,7 +163,7 @@ def fix_paths(root_path, paths):
|
|||
|
||||
def highlight_str(line, highlight_color, transparency):
|
||||
|
||||
@functools.lru_cache()
|
||||
@functools.lru_cache(maxsize=500)
|
||||
def blend_style(style):
|
||||
fg_color = (style.fg_color if type(style.fg_color) == tuple
|
||||
else termstr.XTERM_COLORS[style.fg_color])
|
||||
|
|
@ -918,13 +918,12 @@ class Screen:
|
|||
_STATUS_BAR = highlight_chars(" *help *quit *t*a*b:focus *turn *log *edit *next *sort"
|
||||
" *refresh *fullscreen *open", Log._GREEN_STYLE)
|
||||
|
||||
@functools.lru_cache()
|
||||
@functools.cache
|
||||
def _get_partial_bar_chars(self, bar_transparency):
|
||||
bar_color = termstr.blend_color(termstr.Color.black, termstr.Color.white, bar_transparency)
|
||||
return [termstr.TermStr(char).fg_color(bar_color).bg_color(termstr.Color.black)
|
||||
for char in fill3.ScrollBar._PARTIAL_CHARS[1]]
|
||||
|
||||
@functools.lru_cache(maxsize=2)
|
||||
def _get_status_bar_appearance(self, width, progress_bar_size):
|
||||
bar_transparency = 0.7
|
||||
bar = self._STATUS_BAR.center(width)[:width]
|
||||
|
|
|
|||
|
|
@ -519,7 +519,7 @@ def dump_pickle_safe(object_, path, protocol=pickle.HIGHEST_PROTOCOL, open=open)
|
|||
os.rename(tmp_path, path)
|
||||
|
||||
|
||||
@functools.lru_cache()
|
||||
@functools.cache
|
||||
def compression_open_func(compression):
|
||||
return open if compression == "none" else importlib.import_module(compression).open
|
||||
|
||||
|
|
@ -619,7 +619,7 @@ for extensions, tool_names in tools_for_extensions:
|
|||
(extensions, [globals()[tool_name] for tool_name in tool_names]))
|
||||
|
||||
|
||||
@functools.lru_cache(maxsize=1)
|
||||
@functools.cache
|
||||
def _tools_for_extension():
|
||||
result = {}
|
||||
for extensions, tools in TOOLS_FOR_EXTENSIONS:
|
||||
|
|
@ -661,7 +661,7 @@ def splitext(path):
|
|||
return root, ext
|
||||
|
||||
|
||||
@functools.lru_cache()
|
||||
@functools.cache
|
||||
def is_tool_available(tool):
|
||||
if (hasattr(tool, "command") and tool.command.startswith(f"{PYTHON_EXECUTABLE} -m ")):
|
||||
try:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue