Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

refactoring code with Assign Multiple Targets#128

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
idiomaticrefactoring wants to merge1 commit intopython:main
base:main
Choose a base branch
Loading
fromidiomaticrefactoring:patch-1

Conversation

idiomaticrefactoring

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]

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

@idiomaticrefactoringidiomaticrefactoringFeb 8, 2022
edited
Loading

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 atdata[ii] to the left of “=”, then look atdata[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 freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@ericsnowcurrentlyericsnowcurrentlyericsnowcurrently left review comments

@kumaraditya303kumaraditya303kumaraditya303 left review comments

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@idiomaticrefactoring@ericsnowcurrently@kumaraditya303

[8]ページ先頭

©2009-2025 Movatter.jp