I wonder if when we have many void func that change values of some object inplace (in Python return None) like:
A = []
def foo():
A.append(range(10))
Will there be any benefits of doing list comprehension with these funcs:
funcs = [ foo1, foo2, foo3, ..., foo10]
[
func() for func in funcs
]
Is it similar to C++ brackets?
Or is it equivalent in performance to simple for loop:
for func in funcs:
func()
Which one should I use and why? Mostly Im using Python 3.5 so Im asking about this version :P
EDIT_000:::
I wonder if when we have many func that change values of some object inplace and return some dummy boolean, like:
A = []
dummy = False #edit
def foo():
A.append(range(10))
return dummy #edit, we return dummy not None now
Will there be any benefits of doing list comprehension with these funcs:
funcs = [ foo1, foo2, foo3, ..., foo10]
[
func() for func in funcs
]
Is it equivalent in performance to simple for loop:
for func in funcs:
dummy=func()
Or will there be some performance gain when we create list full of dummy (like we get more heat waste by pressing more gas in car so it will run faster)?