Best of Confessions of a Code Addict2024

  1. 1
    Article
    Avatar of codeconfessionsConfessions of a Code Addict·1y

    Linux Context Switching Internals: Part 1 - Process State and Memory

    Context switching is essential for managing multiple processes efficiently in the Linux kernel. This post delves into how the Linux kernel represents process state and memory using key structures like task_struct and mm_struct. It discusses various process states, the significance of kernel and user mode stacks, memory segments, and how page tables facilitate virtual memory management. Understanding these fundamentals is crucial for performance optimization in complex systems.

  2. 2
    Article
    Avatar of codeconfessionsConfessions of a Code Addict·2y

    An Unreachable Hidden XKCD Easter Egg inside CPython

    CPython codebase has two hidden Easter eggs related to xkcd comics. One is the well-known 'import antigravity', while the lesser-known one involves error messages inspired by xkcd. In debug builds, control reaching an unreachable state triggers xkcd-related messages. These messages are based on xkcd issue 2200, with a special definition when 'RANDALL_WAS_HERE' is enabled, referencing the comic's creator, Randall Munroe.

  3. 3
    Article
    Avatar of codeconfessionsConfessions of a Code Addict·2y

    The Pythonic Emptiness

    The post discusses why checking for sequence emptiness using truthiness is considered more Pythonic and efficient than using len(). It addresses concerns about readability and ambiguity, attributing such issues to poor coding practices like unclear variable names, lack of docstrings, and insufficient input validation. The Pythonic approach is part of PEP-8 recommendations and emphasizes that the perceived ambiguity often reflects broader code quality issues.

  4. 4
    Article
    Avatar of codeconfessionsConfessions of a Code Addict·2y

    Everything You Wanted to Know About Profilers in Python

    This post provides an introduction to profilers in Python, including the types of profilers and how to use them. It also mentions a live session on building a sampling profiler for Python.