/Python

Predicting Solar Eclipses With Python

- Erik Bernhardsson tl;dr: “As I am en route to see my first total solar eclipse, I was curious how hard it would be to compute eclipses in Python. It turns out, ignoring some minor coordinate system head-banging, I was able to get something half-decent working in a couple of hours.”

featured in #504


A Search Engine In 80 Lines Of Python

- Alex Molas tl;dr: “Ever heard of the “Small Website Discoverability Crisis”? The problem it’s basically that small websites, ones like this one, are impossible to be found using Google or any other search engine. My mission? Making those tiny websites great again. In this post I will walk you through the journey of buliding a search engine from scratch using Python. This implementation doesn’t pretend to be a production-ready search engine, just a usable toy example showing how a search engine works under the hood.”

featured in #487


Pytest Daemon: 10X Local Test Iteration Speed

- Ruby Feinstein tl;dr: Discord utilizes a Python monolith to power its API, from sending messages to managing subscriptions. To support this, they use pytest to write and run unit tests. Over the last 8 years, the time it takes to run a single test has continuously grown until it reached a point where it takes 13 seconds to run a single test. even if the test ends up doing absolutely nothing. This post discusses how tests were sped up.

featured in #472


Rust std fs Slower Than Python!? No, It's Hardware!

- Xuan Wo tl;dr: "I'm about to share a lengthy tale that begins with opendal op.read() and concludes with an unexpected twist. This journey was quite enlightening for me, and I hope it will be for you too. I'll do my best to recreate the experience, complete with the lessons I've learned along the way. Let's dive in!"

featured in #469


How We Organise Our Very Large Python Monolith

tl;dr: "I work on Kraken: a Python application which has, at last count, 27,637 modules. Yes, you read that right: nearly 28k separate Python files - not including tests. I do this along with 400 other developers worldwide, constantly merging in code. And all anyone needs to make a change - and kick start a deployment of the software that runs 17 different energy and utility companies, with many millions of customers - is one single approval from a colleague on Github." The author shares how this is an effective way of working and the monolith’s structure. 

featured in #466


Analyzing Data 170,000x Faster With Python

- Sidney Radcliffe tl;dr: The article elaborates on the process of optimizing a function in Python. Sydney begins by explaining the initial challenges faced, such as slow performance and high memory usage. To address these issues, the article suggests using libraries like NumPy and Cython. Throughout the piece, the author provides code snippets to showcase the optimization steps. By the end, performance comparisons are presented, highlighting the significant improvements achieved through the optimization process.

featured in #461


Why Does Python Code Run Faster In A Function?

- Scott Robinson tl;dr: “Python is not necessarily known for its speed, but there are certain things that can help you squeeze out a bit more performance from your code. Surprisingly, one of these practices is running code in a function rather than in the global scope. In this article, we'll see why Python code runs faster in a function and how Python code execution works.”

featured in #455


CLI Tools Hidden In The Python Standard Library

- Simon Willison tl;dr: “This is a neat Python feature: modules with a if \_\_name\_\_ == "\_\_main\_\_": block that are available on Python's standard import path can be executed from the terminal using python -m name\_of\_module.” This made Simon: what other little tools are lurking in the Python standard library, available on any computer with a working Python installation? 

featured in #427


Making Python 100x Faster With Less Than 100 Lines Of Rust

- Ohad Ravid tl;dr: “Our system also has to work on-prem with limited CPU resources, and while at first it performed well, as the number of concurrent physical users grew we started running into problems and our system struggled to keep up with the load. We came to the conclusion that we had to make our system at least 50 times faster to handle the increased workload, and we figured that Rust could help us achieve that.”

featured in #426


The Best Tools For Python SDK Creation

tl;dr: Some of the most popular OSS options available for creating Python SDKs go head to head with Speakeasy's managed pipeline. Find out what the pros and cons of each approach are.

featured in #420