3 ms·
See my other comment with some quick benchmarks: https://news.ycombinator.com/item?id=28601862 https://news.ycombinator.com/item?id=28601862 Yeah, the match is
by benhoyt 5y ago
See my other comment with some quick benchmarks: https://news.ycombinator.com/item?id=28601862 https://news.ycombinator.com/item?id=28601862
Yeah, the match is slower than if-else in that case because they're not grouped. However, the PEP points out that faster implementations are possible -- it would not have to check the type each time if it already knows it can't match. I guess some of those optimizations are left for later.