mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 18:06:18 +03:00
Optimise ImageColor using functools.lru_cache
This commit is contained in:
parent
aaf99d18ae
commit
9158c9aec0
|
@ -19,10 +19,12 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
from functools import lru_cache
|
||||||
|
|
||||||
from . import Image
|
from . import Image
|
||||||
|
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def getrgb(color):
|
def getrgb(color):
|
||||||
"""
|
"""
|
||||||
Convert a color string to an RGB or RGBA tuple. If the string cannot be
|
Convert a color string to an RGB or RGBA tuple. If the string cannot be
|
||||||
|
@ -121,6 +123,7 @@ def getrgb(color):
|
||||||
raise ValueError(msg)
|
raise ValueError(msg)
|
||||||
|
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def getcolor(color, mode):
|
def getcolor(color, mode):
|
||||||
"""
|
"""
|
||||||
Same as :py:func:`~PIL.ImageColor.getrgb` for most modes. However, if
|
Same as :py:func:`~PIL.ImageColor.getrgb` for most modes. However, if
|
||||||
|
|
Loading…
Reference in New Issue
Block a user