Last photo of nineteens. Saying hi to twenties! 💝 Alaçatı, Çeşme/ IZMIR.
seen from Canada

seen from United States
seen from Macao SAR China

seen from Russia

seen from Chile
seen from Singapore
seen from Russia

seen from United States
seen from Canada
seen from Russia
seen from Türkiye
seen from United States

seen from Malaysia
seen from Türkiye
seen from China
seen from Australia

seen from Romania

seen from Türkiye

seen from United Kingdom

seen from Australia
Last photo of nineteens. Saying hi to twenties! 💝 Alaçatı, Çeşme/ IZMIR.
write Python that’s faster than C by optimizing your code, adding standard type annotations, and using Mypyc.
The progression from “idiomatic Python” to “optimized Python” to “C” is a one-way process that gradually loses the advantages that brought us to Python in the first place.
The difficult-to-reverse nature of each step means that once you have prototyped out a reasonably optimized data structure or algorithm, you need to quasi-permanently commit to it in order to squeeze out more straight-line performance of the implementation.
Plus, the process of optimizing Python often destroys its readability, for a few reasons:
1. Optimized Python relies on knowledge of unusual tricks. Things like “use the array module instead of lists”, and “use % instead of .format”.
2. Optimized Python requires you to avoid the things that make Python code nicely organized:
--- method lookups are slow so you should use functions.
--- object attribute accesses are slow so you should use tuples with hard-coded numeric offsets.
--- function calls are slow so you should copy/paste and inline your logic
3. Optimized Python requires very specific knowledge of where it’s going to be running, so you lose the flexibility of how to run it: making your code fast on CPython might make it much slower on PyPy, for example. Native extension modules can make your code faster, but might also make it fail to run inside a browser, or add a ton of work to get it set up on a new operating system.
Maintaining good performance is part of your software’s development lifecycle, not just a thing you do once and stop. So by moving into this increasingly arcane dialect of “fast” python, and then into another programming language entirely with a C rewrite, you end up having to maintain C code anyway. Not to mention the fact that rewriting large amounts of code in C is both ludicrously difficult (particularly if your team primarily knows Python) and also catastrophically dangerous. In recent years, safer tools such as PyO3 have become available, but they still involve switching programming languages and rewriting all your code as soon as you care about speed.
So, for Python to be a truly general-purpose language, we need some way to just write Python, and have it be fast.
[...]
Mypyc takes the annotations meant for Mypy and generates C with them, potentially turning your code into a much more efficient extension module. As part of Mypy itself, it does this with your existing Python type-hints, the kind you’d already use Mypy with to check for correctness, so it doesn’t entail much in the way of additional work.
I’d been curious about this since it was initially released, but I still haven’t had a hard real-world performance problem to really put it through its paces.
So when I learned about the High Throughput Fizzbuzz Challenge via its impressive assembler implementation that achieves 56GiB/s, and I saw even heavily-optimized Python implementations sitting well below the performance of a totally naïve C reference implementation, I thought this would be an interesting miniature experiment to use to at least approximate practical usage.
(28 April 2022)
Dear vosvos,
I love you so so so soooooooooooo much.
Love,
Rain.