Increase the usage of augmented assignment statements
See original GitHub issue👀 Some source code analysis tools can help to find opportunities for improving software components. 💭 I propose to increase the usage of augmented assignment statements accordingly.
Would you like to integrate anything from a transformation result which can be generated by a command like the following? (👉 Please check also for questionable change suggestions because of an evolving search pattern.)
lokal$ perl -p -i.orig -0777 -e 's/^(?<indentation>\s+)(?<target>\S+)\s*=\s*\k<target>[ \t]*(?<operator>[+\-%&|^@]|\*\*?|\/\/?|<<|>>)/$+{indentation}$+{target} $+{operator}=/gm' $(find ~/Projekte/librosa/lokal -name '*.py')
Issue Analytics
- State:
- Created 2 years ago
- Comments:17 (9 by maintainers)
Top Results From Across the Web
Increase the usage of augmented assignment statements
I propose to increase the usage of augmented assignment statements accordingly. Would you like to integrate anything from a transformation ...
Read more >Increase the usage of augmented assignment statements (#2594 ...
I propose to increase the usage of augmented assignment statements accordingly. diff --git a/pitivi/autoaligner.py b/pitivi/autoaligner.py index ...
Read more >Augmented assignment - Wikipedia
An augmented assignment is generally used to replace a statement where an operator takes a variable as one of its arguments and then...
Read more >Augmented Assignment Operators in Python - GeeksforGeeks
An assignment operator is an operator that is used to assign some value to a variable. Like normally in Python, we write “a...
Read more >Augmented Assignment Operators in Python with Examples
Unlike normal assignment operator, Augmented Assignment Operators are used to replace those statements where binary operator takes two operands says var1 ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes, but you could also have skipped this entire conversation by describing the proposed changes it would identify.
Asking devs to copypaste a baroque perl one-liner, clever as it might be, is pretty unreasonable. In general, I would never ask anyone to run code in a shell that isn’t 100% clear and obvious, if only for security reasons. Anyone asking strangers to paste commands into a shell should be greeted with healthy suspicion, as I’m doing here.
Yes! This way we can at least discuss the merits of individual changes. (Though, really, permalinking to the altered lines would be even better, but I’ll take it.)
Now, going point by point:
beat.py:normalize: definitely not, it would alter the input onset strength signal.
beat.py:dp
audio.py:
constantq:
pitch.py:
spectrum.py:
display.py:
filters.py:
onset.py:
utils.py:
almost everything in tests: nope, modifying fixtures in-place would invalidate different runs of the tests
So of all that diff, there are maybe 6 lines that could be changed as you suggest. The rest would render the code incorrect (eg by modifying input arrays, or unsafely modifying other objects that are multiply referenced locally) or provide no clear benefit (ie relate to scalars instead of arrays).
Except that it isn’t the same. Consider the following two functions:
And now call them as follows:
The first function leaves the input unchanged, the second does not. (This is because ndarrays implement the
+=
operator distinctly from the+
operator.) In functional programming speak, we would say that the second has side-effects and the first is a pure function. We generally try to avoid side effects.Sure, but correctness is always more important than speed.
Yes, actually. The question is not about the syntactic difference, but rather what is to be gained in our specific context.