Why is `{*l}` faster than `set(l)` - python sets (not really only for sets, for all sequences)
So here is my timings: >>> import timeit >>> timeit.timeit(lambda: set(l)) 0.7210583936611334 >>> timeit.timeit(lambda: {*l}) 0.5386332845236943 Why is that, my opinion would be equal but it's not. So unpacking is fast from this example, right? For the same reason [] is faster than list() ; the interpreter includes dedicated support for syntax based operations that uses specialized code paths, while constructor calls involve: Loading the constructor from built-in scope (requires a pair of dict lookups, one in global scope, then another in built-in scope when it fails) Requires dispatch through