-
Notifications
You must be signed in to change notification settings - Fork 360
WIP: Implement ColorFloat #1772
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
Closed
Closed
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
8d09106
Implement ColorFloat as a first polished draft
pushfoo a878d5a
Fix doc build by using more specific ref targeting
pushfoo a9fdd9f
Resolve forward / circular reference issue in Color
pushfoo 96d9cc9
Correct docstrings of ColorFloat.from_uint24
pushfoo 6d05154
Replace ColorNorm in docstrings with ColorFloat
pushfoo 9247431
Use future annotations per @cspotcode's advice
pushfoo 944690e
Add ColorFloat to Color.normalized docstring examples
pushfoo 559b775
Phrasing improvements to top-level ColorFloat docstring
pushfoo b38e521
Correct example in ColorFloat.from_color255 docstring
pushfoo a963873
Docstring fixes
pushfoo a5f0dba
Fix ValueError string in ColorFloat.from_color255
pushfoo 9d4f025
Touch-up docstring for ColorFloat.from_color255
pushfoo 2d2dc66
Correct an error in a ColorFloat docstring
pushfoo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a good candidate for
NamedTuple? I think it gives us the@propertys, the deepcopy, and the defaultavalue for free.I used this snippet to test, I may have missed corner cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tl;dr
NamedTuplesubclassing made validation harder forColor, and is much slower according to einarf.I don't know if the latter is still true on more recent Python versions, and it may be worth rebenchmarking periodically. I agree that your proposal could be cleaner if future minimum Python versions lose its current disadvantages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I see einarf saying NamedTuple is slow, but not saying that what you have written is faster. That makes me think that both might be equally slow. Did anyone benchmark at the time of that conversation?
There's good precedent for this question, since one of my first benchmarks found that shapely was slower even though the shapely code was meant to be faster.