frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

Open in hackernews

Crimes with Python's Pattern Matching (2022)

https://www.hillelwayne.com/post/python-abc/
64•agluszak•2h ago

Comments

quotemstr•1h ago
I've never understood why Python's pattern-matching isn't more general.

First, "case foo.bar" is a value match, but "case foo" is a name capture. Python could have defined "case .foo" to mean "look up foo as a variable the normal way" with zero ambiguity, but chose not to.

Second, there's no need to special-case some builtin types as matching whole values. You can write "case float(m): print(m)" and print the float that matched, but you can't write "case MyObject(obj): print(obj)" and print your object. Python could allow "..." or "None" or something in __match_args__ to mean "the whole object", but didn't.

Aefiam•47m ago
case .foo is explicitly mentioned in https://peps.python.org/pep-0622/ :

> While potentially useful, it introduces strange-looking new syntax without making the pattern syntax any more expressive. Indeed, named constants can be made to work with the existing rules by converting them to Enum types, or enclosing them in their own namespace (considered by the authors to be one honking great idea)[...] If needed, the leading-dot rule (or a similar variant) could be added back later with no backward-compatibility issues.

second: you can use case MyObject() as obj: print(obj)

zahlman•40m ago
I don't think I've written a match-case yet. Aside from not having a lot of use cases for it personally, I find that it's very strange-feeling syntax. It tries too hard to look right, with the consequence that it's sometimes quite hard to reason about.
rpcope1•38m ago
After doing Erlang and Scala pattern matching, the whole Python implementation just feels really ugly and gross. They should have cribbed a lot more of how Scala does it.
orbisvicis•22m ago
I've given up on matching as I'm tired of running into its limitations.

That said, I don't think OP's antics are a crime. That SyntaxError though, that might be a crime.

And a class-generating callable class would get around Python caching the results of __subclasshook__.

vlade11115•23m ago
While the article is very entertaining, I'm not a fan of the pattern matching in Python. I wish for some linter rule that can forbid the usage of pattern matching.
purplehat_•5m ago
Could someone explain just what's so bad about this?

My best guess is that it adds complexity and makes code harder to read in a goto-style way where you can't reason locally about local things, but it feels like the author has a much more negative view ("crimes", "god no", "dark beating heart", the elmo gif).

CEO pay and stock buybacks have soared at the 100 largest low-wage corporations

https://ips-dc.org/report-executive-excess-2025/
25•hhs•19m ago•0 comments

Crimes with Python's Pattern Matching (2022)

https://www.hillelwayne.com/post/python-abc/
66•agluszak•2h ago•9 comments

How does the US use water?

https://www.construction-physics.com/p/how-does-the-us-use-water
79•juliangamble•10h ago•50 comments

AI tooling must be disclosed for contributions

https://github.com/ghostty-org/ghostty/pull/8289
400•freetonik•3h ago•189 comments

DeepSeek-v3.1 Release

https://api-docs.deepseek.com/news/news250821
183•wertyk•3h ago•36 comments

An interactive guide to SVG paths

https://www.joshwcomeau.com/svg/interactive-guide-to-paths/
143•joshwcomeau•3d ago•14 comments

A Decoder Ring for AI Job Titles

https://www.dbreunig.com/2025/08/21/a-guide-to-ai-titles.html
30•dbreunig•3h ago•26 comments

Beyond sensor data: Foundation models of behavioral data from wearables

https://arxiv.org/abs/2507.00191
182•brandonb•7h ago•37 comments

Text.ai (YC X25) Is Hiring Founding Full-Stack Engineer

https://www.ycombinator.com/companies/text-ai/jobs/OJBr0v2-founding-full-stack-engineer
1•RushiSushi•1h ago

Miles from the ocean, there's diving beneath the streets of Budapest

https://www.cnn.com/2025/08/18/travel/budapest-diving-molnar-janos-cave
75•thm•3d ago•9 comments

My other email client is a daemon

https://feyor.sh/blog/my-other-email-client-is-a-mail-daemon/
60•aebtebeten•13h ago•14 comments

Weaponizing image scaling against production AI systems

https://blog.trailofbits.com/2025/08/21/weaponizing-image-scaling-against-production-ai-systems/
295•tatersolid•10h ago•75 comments

Beyond the Logo: How We're Weaving Full Images Inside QR Codes

https://blog.nitroqr.com/beyond-the-logo-how-were-weaving-full-images-inside-qr-codes
11•bhasinanant•3d ago•5 comments

How well does the money laundering control system work?

https://www.journals.uchicago.edu/doi/10.1086/735665
150•PaulHoule•9h ago•146 comments

D4D4

https://www.nmichaels.org/musings/d4d4/d4d4/
426•csense•4d ago•49 comments

Using Podman, Compose and BuildKit

https://emersion.fr/blog/2025/using-podman-compose-and-buildkit/
229•LaSombra•11h ago•65 comments

Building AI products in the probabilistic era

https://giansegato.com/essays/probabilistic-era
74•sdan•3h ago•43 comments

The power of two random choices (2012)

https://brooker.co.za/blog/2012/01/17/two-random.html
33•signa11•3d ago•3 comments

Show HN: OS X Mavericks Forever

https://mavericksforever.com/
262•Wowfunhappy•3d ago•110 comments

The contrarian physics podcast subculture

https://timothynguyen.org/2025/08/21/physics-grifters-eric-weinstein-sabine-hossenfelder-and-a-crisis-of-credibility/
124•Emerson1•5h ago•151 comments

The Core of Rust

https://jyn.dev/the-core-of-rust/
123•zdw•5h ago•102 comments

Launch HN: Skope (YC S25) – Outcome-based pricing for software products

32•benjsm•7h ago•27 comments

Mark Zuckerberg freezes AI hiring amid bubble fears

https://www.telegraph.co.uk/business/2025/08/21/zuckerberg-freezes-ai-hiring-amid-bubble-fears/
630•pera•11h ago•629 comments

Privately-Owned Rail Cars

https://www.amtrak.com/privately-owned-rail-cars
60•jasoncartwright•9h ago•91 comments

Adding my home electricity uptime to status.href.cat

https://aggressivelyparaphrasing.me/2025/08/21/adding-my-home-electricity-uptime-to-status-href-cat/
34•todsacerdoti•6h ago•29 comments

Uv format: Code Formatting Comes to uv (experimentally)

https://pydevtools.com/blog/uv-format-code-formatting-comes-to-uv-experimentally/
65•tanelpoder•1h ago•65 comments

In the long run, LLMs make us dumber

https://desunit.com/blog/in-the-long-run-llms-make-us-dumber/
59•speckx•3h ago•43 comments

Show HN: ChartDB Cloud – Visualize and Share Database Diagrams

https://app.chartdb.io
77•Jonathanfishner•9h ago•11 comments

Libre-Chip Awarded NLnet Grant to Prototype a CPU Isn't Vulnerable to Spectre

https://www.phoronix.com/news/Libre-Chip-NLnet-Grant
11•Bender•1h ago•0 comments

I forced every engineer to take sales calls and they rewrote our platform

https://old.reddit.com/r/Entrepreneur/comments/1mw5yfg/forced_every_engineer_to_take_sales_calls_they/
200•bilsbie•6h ago•144 comments