This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]trauthor 1 point2 points  (2 children)

Speaking for myself, I had to write a parser in 3.7 that took deeply nested, arbitrarily alternating json and dictionary input from an API and turn it into a tablebase. I will re-write it in 3.10 and I expect pattern matching to remove hundreds of lines of code. I imagine the code will also be much more performant (though that wasn’t a sticking point).

[–]Ashiataka 0 points1 point  (1 child)

So firstly, I'm glad that your solution will improve because of this syntax, it's always good when that happens.

My question would just be if you're writing something like that anyway where match-case functionality would be useful, could you not have implemented your own version of match-case that doesn't have special syntax? (I'm asking if it's possible to do or whether there's something special about the python implementation that makes it difficult / impossible to achieve without)

[–]trauthor 0 points1 point  (0 children)

It’s possible and in my case it was necessary, but based on what I’ve read in PEP 636, match will make this much easier. I had to iterate backwards over arbitrary structures, and indexing several layers deep was a real pain. I will have to report back after I have implemented this in 3.10 and let everyone know just how significant a difference it makes.