Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimise ImageColor using functools.lru_cache #7657

Merged
merged 1 commit into from Dec 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/PIL/ImageColor.py
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