/Python

Where Exactly Does Python 3.11 Get Its ~25% Speedup?

- Beshr Kayali tl;dr: "Python 3.11 was released a few days ago and as usual, it comes with more than a few new features that make it ever more interesting, from exception groups and fine-grained error locations and tracebacks to TOML parsing support in the standard library and of course the much awaited speedup as part of the faster CPython project. CPython 3.11 is 25% faster than CPython 3.10 on average according to benchmarks with pyperformance."

featured in #367


Python CLI Tricks That Don't Require Any Code Whatsoever

- Martin Heinz tl;dr: "Out-of-the-box, Python standard library ships with many great libraries allowing us to do many cool things directly from terminal without needing to even open a .py file. This includes things like starting a webserver, opening a browser, parsing JSON files, benchmarking programs and many more, all of which we will explore in this article."

featured in #362


Hello World Under The Microscope

tl;dr: "We will trace the execution path of the "Hello World" micro-program written in Python and run on Windows, starting from a single call to the high-level print function, through the subsequent levels of abstraction of the interpreter, operating system and graphics drivers, and ending with the display of the corresponding pixels on the screen. As it turns out, this path in itself is neither simple nor short, but definitely fascinating."

featured in #359


Accelerate Python Code 100x By Import Taichi As Ti

- Yuanming Hu tl;dr: If your program takes forever to run a massive for loop, has a bottleneck, or needs to process lots of images hen you might want to learn more about Taichi. "A DSL embedded in Python but has its own compiler to take over the code decorated with @ti.kernel, achieving high-performance execution on all kinds of hardware, including CPU and GPU. One of the most notable advantages it delivers is speeding up Python code."

featured in #352


You Should Be Using Python's Walrus Operator - Here's Why

- Martin Heinz tl;dr: "The assignment operator - or walrus operator as we all know it - is a feature that's been in Python for a while now (since 3.8), yet it's still somewhat controversial and many people have unfounded hate for it. In this article I will try to convince you that the walrus operator really is a good addition to the language and that if you use it properly, then it can help you make your code more concise and readable."

featured in #349


Crimes With Python's Pattern Matching

- Hillel Wayne tl;dr: "The pattern matching feature is, on the whole, pretty reasonably designed, and people will expect it to behave in reasonable ways. Whereas \_\_subclasshook\_\_ is extremely dark magic. This kind of chicanery might have a place in the dark beating heart of a complex library, certainly not for any code your coworkers will have to deal with." Hillel guides us though pattern matching and \_subclasshook\_\_. 

featured in #340


Python 3.11 Is Up To 10 - 60% Faster Than Python 3.10

tl;dr: "CPython 3.11 is on average 25% faster than CPython 3.10 when measured with the pyperformance benchmark suite, and compiled with GCC on Ubuntu Linux. Depending on your workload, the speedup could be up to 10-60% faster. This project focuses on two major areas in Python: faster startup and faster runtime."

featured in #332


Multiprocessing In Python: The Complete Guide

- Jason Brownlee tl;dr: "This guide provides a detailed and comprehensive guide to multiprocessing in Python, including how processes work, how to use processes in multiprocessor programming, concurrency primitives used with processes, common questions, and best practices."

featured in #331


Don't Let Dicts Spoil Your Code

- Roman Imankulov tl;dr: "The simplicity of organic code growth has a flip side: it becomes too hard to maintain. The proliferation of dicts as primary data structures is a clear signal of tech debt in your code. Fortunately, modern Python provides many viable alternatives to plain dicts."

featured in #329


The Overengineered Solution To My Pigeon Problem

- Max Nagy tl;dr: "The brains of the operation is a python script using openCV. It compares the current image to the normal background. If the average amount of change of all pixels is above some threshold, we fire the gun."

featured in #328