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

Refactor and Optimization:: Argument Table Formation:: Constants.py #268

Merged
merged 2 commits into from
Oct 7, 2024

Conversation

IIITM-Jay
Copy link
Member

@IIITM-Jay IIITM-Jay commented Jul 22, 2024

About

This PR deals with refactoring and optimization towards Argument Lookup Table (arg_lut) of constants.py. It focuses on optimizing the code with fewer lines keeping the objective same to provide better readability and concise comprehension.

Added/ Modified Changes

  1. Changed the formation of arg_lut = {}: Used dictionary comprehension to form the required arg_lut
  2. Read the CSV file and processes each row to convert the necessary values and build the dictionary.
  3. Added appropriate comments
  4. Avoided explicit iteration and assignment of values within a loop
  5. Removed redundancy: prior declaration of a dictionary

Approach/ Technique/ Principles Used

  1. Dictionary Comprehension:
    a. Offers syntax with lesser lines of codes: Dict Comprehensions , Reference taken
    {expression(variable): expression(variable) for variable, variable in input_set [predicate][, …]}
    b. Does exactly the same job without having prior declaration of the dictionary variable

@IIITM-Jay IIITM-Jay changed the title Refactor and Optimiation:: Argument Table Formation:: Constants.py Refactor and Optimization:: Argument Table Formation:: Constants.py Jul 22, 2024
@IIITM-Jay
Copy link
Member Author

@aswaterman this is another set of optimization using dictionary comprehension techniques. Let me know your view points on the same. Thanks!

Copy link
Member

@aswaterman aswaterman left a comment

Choose a reason for hiding this comment

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

Definitely a stylistic improvement.

@aswaterman aswaterman merged commit 9653f6a into riscv:master Oct 7, 2024
2 checks passed
Timmmm added a commit to Timmmm/riscv-opcodes that referenced this pull request Oct 8, 2024
This little bit of code from riscv#268 was not formatted in riscv#292 because it was not merged yet. Basically it was a semantic conflict between the PRs, but not a text conflict, so Git can't detect it.

This can be prevented using merge queues, but it probably isn't necessary on a repo of this size.
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.

2 participants