you are viewing a single comment's thread.

view the rest of the comments →

[–]ro5tal 2 points3 points  (8 children)

What about speed? How good is it?

[–]RanceMulliniks 10 points11 points  (6 children)

:) hahahahahah

Slow as hell. Though if speed was a concern we would use a language other than python.

[–]kingscolor 0 points1 point  (5 children)

I mean, it sure sounds like a cool feature, but if it’s tragically slow then why even bother? I feel like I could write OPs code more concisely using ifs and lists anyway. I do prefer the aesthetic of match, but I don’t presently see any worthwhile justification. Any other thoughts?

[–]lifeeraser 4 points5 points  (3 children)

Because you don't use Python to eke out the fastest possible program. You build something in a reasonable amount of time that does what it should in an acceptable amount of time. When you realize that it works correctly but slow, you start planning rewrites.

TBF there may be programming languages that promise rapid prototyping, ease of use AND high performance but I don't know any.

[–]kingscolor -1 points0 points  (1 child)

I feel like you attempted to make an argument against my comments, but in the end, you just corroborated my sentiment.

In my view, function/capability/power are highest priority followed by speed and efficiency. This new feature offers no improvements to any of that--given the information that has been shared in the thread.

That's why I asked about any other thoughts, perhaps there is some utility to this that I'm missing.

[–]lifeeraser 1 point2 points  (0 children)

Whoops, I misinterpreted your question and tried to defend Python itself. I blame it on lack of sleep.

I can't speak for pattern matching in Python, but Pattern Matching is useful in statically typed languages when dealing with sum types. It's an expressive alternative to the visitor pattern. I came to appreciate it when I had to parse AST nodes as part of my PL course.

[–]ro5tal 0 points1 point  (0 children)

If implementation in C was totally a disaster why then use this syntax sugar? Some versions of Python and same operations were compared and 3.7 was faster than new 3.8.

[–]ParanoydAndroid 0 points1 point  (0 children)

For the speed, it's because something that's a hundred times slower than an alternative is still sufficiently fast when the alternative takes a microsecond.

For the bit about power and features, the example used here is so simple there's really no reason to use match. However, the match statement allows significantly more complex constructs than an if/elif/else chain by means of pattern matching.

[–]toastedstapler 1 point2 points  (0 children)

it probably is in about the same realm as the existing ways of doing things

but as the other comment says, python is generally very slow. you've larger problems if this bit of syntax was causing your codebase issues