Skip to content
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

Fixed Style hash #2346

Merged
merged 7 commits into from Jun 17, 2022
Merged

Fixed Style hash #2346

merged 7 commits into from Jun 17, 2022

Conversation

willmcgugan
Copy link
Collaborator

Fixes a performance bug in the Style class.

Essentially the hash calculation was inconsistent. Things that were equal would sometimes have different hashes. I noticed this when adding lru_cache to Style.__add__. What should have been an easy win caused dramatically reduced performance, because it broken the mechanics of storing Styles in a dict.

The hashing is now in once place. It is also lazy, so the hash is stored the first time it is used.

@willmcgugan willmcgugan changed the title fix hash Fixed Style hash Jun 15, 2022
@codecov-commenter
Copy link

codecov-commenter commented Jun 15, 2022

Codecov Report

Merging #2346 (3bc9b28) into master (14d47c9) will decrease coverage by 0.17%.
The diff coverage is 96.61%.

@@            Coverage Diff             @@
##           master    #2346      +/-   ##
==========================================
- Coverage   98.88%   98.71%   -0.18%     
==========================================
  Files          73       73              
  Lines        7629     7761     +132     
==========================================
+ Hits         7544     7661     +117     
- Misses         85      100      +15     
Flag Coverage Δ
unittests 98.71% <96.61%> (-0.18%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
rich/_export_format.py 100.00% <ø> (ø)
rich/live.py 97.90% <40.00%> (-2.10%) ⬇️
rich/_win32_console.py 89.94% <92.30%> (-1.54%) ⬇️
rich/console.py 98.29% <96.03%> (-0.49%) ⬇️
rich/style.py 99.76% <96.15%> (-0.24%) ⬇️
rich/_inspect.py 100.00% <100.00%> (ø)
rich/_lru_cache.py 100.00% <100.00%> (ø)
rich/_wrap.py 100.00% <100.00%> (ø)
rich/box.py 100.00% <100.00%> (ø)
rich/cells.py 100.00% <100.00%> (ø)
... and 9 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 761cc8d...3bc9b28. Read the comment docs.

@willmcgugan willmcgugan marked this pull request as draft June 15, 2022 20:13
@willmcgugan willmcgugan requested review from darrenburns and olivierphi and removed request for olivierphi and darrenburns June 15, 2022 20:13
@willmcgugan willmcgugan marked this pull request as ready for review June 15, 2022 20:14
@willmcgugan willmcgugan marked this pull request as draft June 15, 2022 20:57
Copy link
Contributor

@olivierphi olivierphi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🙂

@willmcgugan willmcgugan marked this pull request as ready for review June 17, 2022 09:49
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.

None yet

3 participants