I came across a blog post with the following function call:
intersection_cardinality = len(set.intersection(*[x, y]))
Is there any benefit in passing parameters as an unpacked array created just for that, instead of simply calling set.intersection(x, y)?
The blog post was written in python2, but the question goes for 3 as well.
In the example you provided, there is no real point in using this syntax.
There are cases though where creating an array or tuple to unpack it can be useful.
# Python3
def print_n_times(n, string):
# Instead of doing a loop we unpack an array of length n
print(*n*(string,), sep='\n')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With