Skip to content

Commit

Permalink
Merge pull request #7657 from hugovk/optimise-imagecolor
Browse files Browse the repository at this point in the history
Optimise `ImageColor` using `functools.lru_cache`
  • Loading branch information
radarhere committed Dec 31, 2023
2 parents aaf99d1 + 9158c9a commit 0988703
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/PIL/ImageColor.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@
from __future__ import annotations

import re
from functools import lru_cache

from . import Image


@lru_cache
def getrgb(color):
"""
Convert a color string to an RGB or RGBA tuple. If the string cannot be
Expand Down Expand Up @@ -121,6 +123,7 @@ def getrgb(color):
raise ValueError(msg)


@lru_cache
def getcolor(color, mode):
"""
Same as :py:func:`~PIL.ImageColor.getrgb` for most modes. However, if
Expand Down

0 comments on commit 0988703

Please sign in to comment.