Senior Data Engineer at Orbio, working on methane predictions. Previously computational physics: ocean models at the Max Planck Institute for Meteorology and a PhD on high-order CFD at Technion. More about me.
Open Source in the age of AI
If I go through the halls of X, I would probably come back with a very confused opinion on the state of open source today. On the one hand there are examples like opencode with tons and tons of open PRs with seemingly no moderation mechanism. On the other hand there is ghostty which has introduced a Vouch system meaning only approved contributors can submit PRs. But overall the feeling I get is that maintainers on popular open source projects are overwhelmed with PRs. And the worst offenders among these PRs are usually purely agent-written code. ...
A Backend Engineer's Guide to Understanding React and Next.js
I am not completely new to React. A couple of years ago I spent a few weeks struggling with frontend tools to create 49travel. I learnt a lot about tooling, especially Vercel, a little bit about React but I can hardly say I really understood it. Now it is part of my job, so I do want to understand it better. And what better way to understand it than by trying to write a blog post about it. ...
Introduction to Formal Methods (Part 2): From Spec to Code
In Part 1, we talked about the “Why”. Why write a spec? Because English is ambiguous, and debugging design flaws in code is expensive. We looked at Quint and modeled a simple TCP Handshake. We verified that our logic was sound (no safety violations). But as I hinted at the end of Part 1: a spec is just a file. If I go off and write code and ignore the spec, I haven’t really gained anything. In fact, I’ve just wasted time writing a spec. ...
Introduction to Formal Methods (Part 1): Why Spec First?
Formal methods, sounds very… formal! But I have been trying to explore what they are and so I decided to write down my learnings. Hopefully this proves a good starting point for someone else who is curious about the idea but doesn’t have a good starting point. This post is part 1 of 2. In part 1, I will try to give a more conceptual understanding, while also introducing tooling using Quint. In part 2, I will try to show how it can be wired up so that we make sure software implementations actually benefit from formal methods. ...
Decorators in Python make composability easier
The last couple of posts have been about 49travel and the way I built it. This week I am going to be talking about decorators for a bit. It seems very disconnected from the last posts, but I started reflecting on this while writing some Python for 49travel. So there’s still a connection! Python requests As a reminder, to build 49travel, I had to use the amazing Transport Rest API. However, this is obviously not built for production and so does rate limiting. Which is fine since we can just add a rate limit on our side by introducing time.sleep. For eg., this would be one way to do this. ...
Comparing GPT with Open Source LLM's
Last week I talked about how I created 49travel. I went over broadly on the ingredients and often glossed over many details. This week I want to talk about one particular aspect which was pretty interesting for me. It was a nice introduction to the various projects going on in the LLM world that are being furiously worked on since the entry of ChatGPT. The problem As I mentioned in the last post, the reason I wanted to use an LLM was to produce a short summary of the WikiVoyage page so that a visitor to the page could get a nice overview. I originally tried to do this by simply trying to extract the list of places to see and things to do using some ill-formed Regex, but it was soon obvious that this would require a lot of effort. Not all Wikivoyage pages follow the same format and some listings can have really strange formatting. I then thought that an LLM could be a good candidate to solve this problem. What if we simply give it the page, and it summarizes the page for us? But how do I go about doing this? ...
49travel - Travel across Germany with your 49 Euro ticket
49travel This post will be very different than the last few. Over the last couple of weeks, I have been working on an idea for a webapp. In May, Germany launched the Deutschland Ticket. This is an amazing new offer where we can buy a ticket for 49 Euros a month, and access any public transport across Germany. Its all included! So, I made a website to find out all places you could go with this ticket, how long it takes and why that city is worth visiting. To start with, it only shows all places you can get to from Hamburg, but other cities are coming soon. Stay tuned. ...
Using arguments in a Pandas UDF for PySpark
In our last couple of posts we looked at how we could optimize pandas functions. This post will be different. We still want to address issues that we face in the PySpark world, but today we will not look at performance at all. Parameters in a Pandas UDF In PySpark, when we want to use a Pandas UDF, we actually have 2 options. We can use the regular Pandas UDF, or we can use the Pandas Function API. While both of them address the UDF question, the actual function implemented still operates on a Pandas DataFrame, so that simplifies what we want to address in this post. ...
Sometimes Numba can be slower than even Pandas... or why you should always benchmark
In our last post we saw that we can get much more performance by rewriting Pandas GroupBy - Apply in NumPy. I also mentioned that I could not get Numba working with this code to see if it helps. In this blog, I want to talk about how I got Numba working and what the results were, but first, what’s Numba? Numba Numba is a just-in-time (JIT) compiler for Python that specializes in optimizing the performance of numerical computations. Well, that’s all well and good, but what is a JIT compiler? Most people are aware of compiled languages like C++, Rust or Java. For these languages, the development flow is to write code, then compile the code to a binary and then run the binary. But for an interpreted language like Python, the second step is missing. Python is dynamic so the type of variables can be anything. This often means that Python functions spend a lot of time checking variable attributes to then do the correct function call on them. The final function call usually involves a C function call which is fast, but the overhead of type checking and edge cases are huge. ...
Using NumPy to replace Pandas GroupBy-Apply pattern for performance
If you use PySpark a lot you would know that the DataFrame API is great. However there are times when it is not sufficient because it does not cover every single piece of functionality we may want. This is where the Pandas UDF functionality comes in. The nice thing about the Pandas UDF functionality is that it uses Arrow for data transfer between Spark and Pandas which minimizes serialization-deserialization costs. I have a slight preference for Pandas Function API over Pandas UDF but now let’s get to the meat of the post which is about speeding up the Pandas GroupBy-Apply pattern by using NumPy instead. ...