Cache results in poezio.theming.to_curses_attr.

This increases performances a *lot* compared to the previous uncached
version.
This commit is contained in:
Emmanuel Gil Peyrot 2016-07-06 04:13:02 +01:00
parent 0276f2adf7
commit a47e18e873

View file

@ -69,6 +69,7 @@ log = logging.getLogger(__name__)
from poezio.config import config
import curses
import functools
import os
from os import path
@ -403,6 +404,7 @@ def read_tuple(_str):
char = attrs[2] if len(attrs) > 2 else '\0'
return (int(attrs[0]), int(attrs[1])), char
@functools.lru_cache(maxsize=128)
def to_curses_attr(color_tuple):
"""
Takes a color tuple (as defined at the top of this file) and