diff --git a/Lib/tkinter/__init__.py b/Lib/tkinter/__init__.py index d494c0c9687cd1..401ba092deb421 100644 --- a/Lib/tkinter/__init__.py +++ b/Lib/tkinter/__init__.py @@ -32,6 +32,7 @@ import collections import enum +import functools import sys import types @@ -1314,6 +1315,7 @@ def winfo_reqwidth(self): return self.tk.getint( self.tk.call('winfo', 'reqwidth', self._w)) + @functools.lru_cache def winfo_rgb(self, color): """Return a tuple of integer RGB values in range(65536) for color in this widget.""" return self._getints( @@ -1848,6 +1850,15 @@ def __repr__(self): return '<%s.%s object %s>' % ( self.__class__.__module__, self.__class__.__qualname__, self._w) + def __eq__(self, other): + if isinstance(other, Misc): + return self._w == other._w + + return False + + def __hash__(self): + return hash(self._w) + # Pack methods that apply to the master _noarg_ = ['_noarg_'] diff --git a/Misc/NEWS.d/next/Library/2025-01-07-05-25-57.gh-issue-128576.qzDkju.rst b/Misc/NEWS.d/next/Library/2025-01-07-05-25-57.gh-issue-128576.qzDkju.rst new file mode 100644 index 00000000000000..15f6cdca13b8b2 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-01-07-05-25-57.gh-issue-128576.qzDkju.rst @@ -0,0 +1,2 @@ +Add decorator :func:`functools.lru_cache` to the :mod:`tkinter` method +:meth:`!winfo_rgb`.