Live data from Hacker News

Making ast.walk 220x Faster

reflex.dev

21–22 of 22 posts

Re: Making ast.walk 220x Faster

#21
post #7

I appreciate that you first tried to optimize the original Python code. Idiomatic Python is unfortunately disappointingly slow and not so interesting to compare to.

I've generally taken the position that if you're considering doing micro optimizations in your python code you should just switch to another language instead. The gains from switching language are going to be so much higher than the gains from trying to get the python interpreter to be a little less slow (and empirically, every time I've seen it tried the code has been rewritten in the end anyway).

Re: Making ast.walk 220x Faster

#22

The second part, where it says that Rust is faster than Python, is so obvious than doesn't deserve any further comments. What I found interesting, is that idiomatic Python, with generators and all, can be so much worse than "C-style" Python, if you will pardon that term. It's a pity many kids are taught Python before C...

I still recommend to use idiomatic Python though. If you like C-style Python, you can use Cython and get a performance boost at the same time.
Post reply on HN