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

refactoring code with Assign Multiple Targets #128

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

idiomaticrefactoring
Copy link

refactoring code with Assign Multiple Targets which is more pythonic, concise, readable and efficient; how do think this change which has practical value?

refactoring code with Assign Multiple Targets which is more pythonic, concise, readable and efficient; how do think this change which has practical value?
data[ii + 1] = data[jj + 1]
data[jj] = tmp_real
data[jj + 1] = tmp_imag
data[ii] , data[ii + 1] , data[jj] , data[jj + 1] = data[jj], data[jj + 1], data[ii], data[ii + 1]
Copy link
Member

Choose a reason for hiding this comment

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

Personally, I find that harder to read.

Copy link
Author

@idiomaticrefactoring idiomaticrefactoring Feb 8, 2022

Choose a reason for hiding this comment

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

How about adding a comment? it maybe more readable.
#swap two imaginary numbers with real part and imaginary part (data[ii],data[ii+1]) <->(data[jj],data[jj+1]) .

Yes, it maybe more longer making it seems harder read. How about if we first look at data[ii] to the left of “=”, then look at data[jj] to the right of “=”, then loop the operation? Sometimes, I find the original code have more statements making me a little scared and confused to read the code.

Copy link
Contributor

Choose a reason for hiding this comment

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

It is indeed harder to read and we should avoid changing benchmarks unless necessary, BTW the bytecode will now use unpack sequence rather than store name so will have an effect on its specialization.

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.

3 participants