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

Remove quadratic time complexity in Statement.cast() #634

Merged

Conversation

antonblanchard
Copy link
Contributor

Using sum(lst, []) to flatten a list of lists has quadratic time
complexity. Use chain.from_iterable() instead. While not strictly
necessary to improve performance, convert to map().

A test case writing out verilog for a 512k entry FIFO is 120x faster
with this applied.

Using sum(lst, []) to flatten a list of lists has quadratic time
complexity. Use chain.from_iterable() instead. While not strictly
necessary to improve performance, convert to map().

A test case writing out verilog for a 512k entry FIFO is 120x faster
with this applied.
Copy link
Member

@whitequark whitequark left a comment

Choose a reason for hiding this comment

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

LGTM, nice catch!

@codecov
Copy link

codecov bot commented Sep 27, 2021

Codecov Report

Merging #634 (e62ef89) into master (9834b7e) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #634   +/-   ##
=======================================
  Coverage   81.47%   81.47%           
=======================================
  Files          49       49           
  Lines        6450     6451    +1     
  Branches     1287     1286    -1     
=======================================
+ Hits         5255     5256    +1     
  Misses       1008     1008           
  Partials      187      187           
Impacted Files Coverage Δ
nmigen/hdl/ast.py 90.00% <100.00%> (+0.01%) ⬆️

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 9834b7e...e62ef89. Read the comment docs.

@whitequark whitequark merged commit 9f78ac0 into amaranth-lang:master Sep 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants