Last active
March 12, 2026 05:44
-
-
Save pythonhacker/275b7fa8f2516fd075fed8ba5ef89f56 to your computer and use it in GitHub Desktop.
Performance of creation various RGB color classes using timeit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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