You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a minor issue that should have no relevant impact in performance (and, for certain, not a negative one). But, IMHO, it is a boost in readability and friendlier to typical Python idioms.
There are a total of 26 places where a list is initialized with the following pattern:
AFAICT, there is no need to initialize object instances in order to populate the list. This is a burden for readability and for the garbage collector. I have not investigated the 26 different usages of that anti-idiom, but in the ones I have looked at, the instantiated object is never used and is simply a placeholder.
I believe that the following is much more readable for Python standards and avoids flooding the GC:
some_blocks= [None] *number_of_blocks
Because None is a singleton object (in Python), the suggested code will be lighter. I expect that to be "the chocolate of the parrot" regarding performance, but again, "Simple is better than complex & Readability counts".
The text was updated successfully, but these errors were encountered:
This is a minor issue that should have no relevant impact in performance (and, for certain, not a negative one). But, IMHO, it is a boost in readability and friendlier to typical Python idioms.
There are a total of 26 places where a list is initialized with the following pattern:
AFAICT, there is no need to initialize
object
instances in order to populate the list. This is a burden for readability and for the garbage collector. I have not investigated the 26 different usages of that anti-idiom, but in the ones I have looked at, the instantiated object is never used and is simply a placeholder.I believe that the following is much more readable for Python standards and avoids flooding the GC:
Because
None
is a singleton object (in Python), the suggested code will be lighter. I expect that to be "the chocolate of the parrot" regarding performance, but again, "Simple is better than complex & Readability counts".The text was updated successfully, but these errors were encountered: