Urgent.News

What's breaking now, across thousands of outlets.

Tech

66x faster on sorted data: Timsort, 24 years on

66x faster on sorted data: Timsort, 24 years on Tim Peters died on July 15, 2026. Guido van Rossum announced it today, November 11, on the Python discussion forum. The sort Peters wrote in 2002 still sorts a million already-ordered integers in 5.6 milliseconds — 66 times faster than the same million shuffled. I re-ran it this afternoon to check the number holds up, and it does. What happened…

Tim Peters, a key contributor to Python, passed away on July 15, 2026, at the age of 74. Guido van Rossum, Python's creator, announced the news on November 11, 2026, in the Python discussion forum. Timsort, a sorting algorithm created by Peters in 2002, continues to perform exceptionally well on sorted data, according to recent tests.

Timsort, which was designed for Python lists, remains the default sorting algorithm for many mainstream languages, including Java, Android, Swift, Rust, and Go's slices package. This is due to its efficiency in handling sorted data, which is much faster than random data. For instance, sorting a million already-ordered integers takes only 5.6 milliseconds, while sorting a million shuffled integers takes 369.4 milliseconds.

Peters recognized that the textbook sorting algorithm, n log n, is not always the most efficient solution in real-world scenarios. Many datasets are close to being sorted, with only a few elements out of place. Timsort addresses this by detecting sorted runs and merging them, rather than starting from scratch. The result is that sorted input is 66 times faster than random input, while reversed input takes only 8.0 milliseconds, compared to 369.4 milliseconds for random input.

To demonstrate Timsort's efficiency, Peters created a class that counted comparisons during sorting. He found that sorting a million integers using Timsort required only 99,999 comparisons, which is the theoretical minimum. In contrast, random input required 1,529,183 comparisons, close to the n log2 n bound. This highlights the adaptivity of Timsort, which optimizes its performance based on the data's characteristics.

Peters' work on Timsort exemplifies the principle of practicality over purity. He focused on improving Python's performance for common cases, rather than adhering strictly to theoretical best practices. His contributions to Python, including the optimized pymalloc, dict implementation, and cyclic garbage collector, have had a lasting impact on the language. Timsort, in particular, continues to provide a significant performance advantage for sorting operations in Python programs.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Node.js Cron Data Backups: Tenant-Isolated Object Uploads and Presigned Recovery

Object storage for e-commerce app data backups is a tenant-isolation problem before it is a capacity problem. A valid restore must select one tenant, one backup run, and one retention class without…

  • Node.js apps upload e-commerce backups to secure object storage
  • Use dedicated backup bucket with unique key incorporating tenant ID and UTC date
  • Generate short-lived signed URL for tenant-specific data access and recovery

Introduction to ComfyUI: Modular Interface for Diffusion Models

What is ComfyUI ComfyUI is a creation engine with artificial intelligence and a node-based graphical interface. It acts as a backend, API, and local inference engine for diffusion models, allowing the…

  • ComfyUI is an AI creation tool operating as a local inference engine
  • Graph-based node interface allows direct manipulation of models and parameters
  • Optimized for conventional hardware, runs large models with 4GB VRAM/8GB RAM

I Cloned a Repo and It Ran Code Before I Read a Single Line

03:03 in the morning, and a file appeared on my machine that I never asked for. I had typed exactly one command: npm install .

  • Five execution surfaces tested on cloned repository
  • Two surfaces (npm preinstall, Python setup.py) executed on install
  • Two surfaces (Git hook, README) never executed in experiment

More from Thursday 12 November →