Skip to content

Instantly share code, notes, and snippets.

@pythonhacker
Last active March 12, 2026 05:44
Show Gist options
  • Select an option

  • Save pythonhacker/275b7fa8f2516fd075fed8ba5ef89f56 to your computer and use it in GitHub Desktop.

Select an option

Save pythonhacker/275b7fa8f2516fd075fed8ba5ef89f56 to your computer and use it in GitHub Desktop.
Performance of creation various RGB color classes using timeit
import timeit
for klass in (Color, ColorAttr, ColorProp, ColorAttrCustom,
ColorDesc, ColorData, ColorTuple):
print(f"Class: {klass.__name__}")
code = f"{klass.__name__}(128, 128, 128)"
setup = f"from __main__ import {klass.__name__}"
print(timeit.timeit(stmt=code, number=1000_000, setup=setup))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment