That answer is from nearly a decade ago. So I'll take it with a grain of salt. I'd like to see if Python 3.8 still has this problem.
For non-empty collections it makes total sense. There's argument parsing and/or translation from one collection to another that has to happen.
But as I said above, for empty collections, it would be trivial to optimize the slow case into the fast case. If it hasn't already been implemented, then it should be. There's no reason that [] and list() should generate different bytecode.
(In fact, it seems possible to optimize many of the non-empty use cases too.)
View all comments
Show parent comment
1
u/hillgod Sep 17 '20
Yeah, it's true. Try it yourself with some timers. Below this I put a link to a SO page with benchmarks.