Skip to content

fix(color): cleanup equality operator#641

Open
slook wants to merge 1 commit into
ceccopierangiolieugenio:mainfrom
slook:colors-equal-optimize
Open

fix(color): cleanup equality operator#641
slook wants to merge 1 commit into
ceccopierangiolieugenio:mainfrom
slook:colors-equal-optimize

Conversation

@slook

@slook slook commented May 29, 2026

Copy link
Copy Markdown
Contributor

Fixed performance regression of the buffer painting since #638 ...

  • Removed: isinstance() call in __eq__()... This is used for ==, != and in operators so it is too expensive to use here.
  • Changed: Check if any(colors is None...) which avoids doing equality tests of the values in list in paintCanvas().
  • Removed: Old methods in scrollbar which always raised AttributeError since only classStyle is used there.

The changes in this PR are the only instances I can find in the codebase where the other argument could have been None. As such, the slow checking of the other type with isinstance() shall no longer be required any more.

If there are other callers which call this equality operator with something other than a TTkColor object, then that calling code ought to be caught and fixed instead of silently catching wrong types here.

isinstance() it is way too slow while painting the canvas buffers.
@slook slook changed the title chore(color): cleanup equality operator fix(color): cleanup equality operator May 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant