in #c
One thing that I find easier in C compared to Python is that loops are not as expensive. And sometimes, things are easier to implement when you can think of them individually.
For example, to render characters with different styles, we can do this in C:
for (index = 0; index < SIZE; index++) { render_character(characters[index], styles[index]); }
This is cheap in C. But in Python, it is expensive. So to make this fast in Python, we might want to do something like this:
for (substring, style) in split_parts(text): render_text(substring, style)
Assuming we can write split_parts without looping over all characters, this will perform better in Python because of fewer loop iterations.
What is Rickard working on and thinking about right now?
Every month I write a newsletter about just that. You will get updates about my current projects and thoughts about programming, and also get a chance to hit reply and interact with me. Subscribe to it below.