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

Increase the usage of augmented assignment statements #81

Open
elfring opened this issue Oct 10, 2021 · 8 comments
Open

Increase the usage of augmented assignment statements #81

elfring opened this issue Oct 10, 2021 · 8 comments

Comments

@elfring
Copy link

elfring commented Oct 10, 2021

👀 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?
(:point_right: Please check also for questionable change suggestions because of an evolving search pattern.)

[Markus_Elfring@fedora lokal]$ ./comby -diff ':[[a]] = :[[_]] + :[[b]]' ':[a] += :[b]' $(find ~/Projekte/SLY/lokal -name '*.py')
…
+++ /home/Markus_Elfring/Projekte/SLY/lokal/sly/yacc.py
@@ -1231,7 +1231,7 @@
                 lr_index = p.lr_index
                 j = state
                 while lr_index < p.len - 1:
-                    lr_index = lr_index + 1
+                    lr_index += 1
                     t = p.prod[lr_index]
 
                     # Check to see if this symbol and state are a non-terminal transition
…
@elfring
Copy link
Author

elfring commented Oct 16, 2021

💭 Would you like to apply a source code transformation result which can be generated also by a command like the following?
(:point_right: Update candidates in 12 lines)

[Markus_Elfring@fedora lokal]$ perl -p -i.orig -0777 -e 's/^(?<indentation>\s+)(?<target>\S+)\s*=\s*\k<target>\s*(?<operator>[+\-%&|^@]|\*\*?|\/\/?|<<|>>)/$+{indentation}$+{target} $+{operator}=/gm' $(find ~/Projekte/SLY/lokal -name '*.py')

@dabeaz
Copy link
Owner

dabeaz commented Oct 16, 2021

Does this make any different at all in SLY performance?

@elfring
Copy link
Author

elfring commented Oct 16, 2021

I guess that a corresponding run time difference would be measurable.
Can you find further software fine-tuning desirable then? 🤔

@dabeaz
Copy link
Owner

dabeaz commented Oct 16, 2021

Why do these changes matter?

@elfring
Copy link
Author

elfring commented Oct 16, 2021

💭 I suggest to reconsider your development concerns also according to information from the Python enhancement proposal 577 (from 2018-05-14).

@dabeaz
Copy link
Owner

dabeaz commented Oct 16, 2021

Why does this matter?

@elfring
Copy link
Author

elfring commented Oct 16, 2021

Can you accept the explanation from the Python documentation (which you probably know already)?

“…
In the augmented version, x is only evaluated once. Also, when possible, the actual operation is performed in-place, meaning that rather than creating a new object and assigning that to the target, the old object is modified instead.
…”

💭 Do you accordingly expect positive effects for the software run time characteristics?

@hadware
Copy link

hadware commented Oct 25, 2021

@jpsnyder : 💭 Would you confirm that a synthetic version of the human mind can produce suggestions that are valid in the context of software development?

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

No branches or pull requests

3 participants