-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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: convert for loops into list and dict comprehensions #2493
Conversation
for column in datasets.columns: | ||
new_datasets[column] = datasets[column] | ||
|
||
new_datasets = {column: datasets[column] for column in datasets.columns} |
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.
Regarding this:
Why is this here at all? This causes the flake8 lint to fail
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.
The variable new_datasets
is not being used later on after the if-test
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.
@DidierRLopes Do you know?
I'm inclined towards moving the unused variable. There seems to be no usage of it in the code.
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.
This was done by @JerBouma, probably he can shed some insight here
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.
I think a lot of these will come forward as I open PR's for the different refactors btw. 😅
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.
Thanks a lot @JerBouma!
@DidierRLopes Perhaps, going forward, if a variable is unused, should we just go ahead and remove it? Unless anything else is explicitly mentioned on the code?
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.
@Uzaaft yes, definitely unused variables should not be in the code. I wonder how that one passed the linters.
Would you be up for jumping into a call on Discord or elsewhere to coordinate the contributing efforts? This would make it easier and quicker to merge PRs
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 sure thing @piiq.
After the merging that you did, I saw a few more possibilities of using list-comprehensions, so I am including those as well now.
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.
@Uzaaft can you add me on discord please? pll_llq#8920
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.
I just sent you an request @piiq
@piiq All checks passed , but I need to update the branch once again😂 |
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.
🚀
On to the Next one🤓 |
Description
The aim of this PR is to refactor all possible for-loops where lists and dicts are created into list-comprehensions, to get an easy gain of performance.
How has this been tested?
The list-comprehensions does not add any additional logic, it just required a rewrite of the old logic. If tests passed before, they will(and does locally), pass.
Checklist:
None of these are required since this is just a refactor
Others
pre-commit install
.pytest tests/...
.