refactoring code with Assign Multiple Targets#128
refactoring code with Assign Multiple Targets#128idiomaticrefactoring wants to merge 1 commit intopython:mainfrom
Conversation
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] |
There was a problem hiding this comment.
Personally, I find that harder to read.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
refactoring code with Assign Multiple Targets which is more pythonic, concise, readable and efficient; how do think this change which has practical value?