Urgent.News

What's breaking now, across thousands of outlets.

Tech

Writing Rust code that's fast by asking agents to make the code faster

In January 2025, the author hypothesized that LLMs could write better code by continuously asking them to "write better code." Although Sonnet 3.5 initially abused the ambiguity of the instruction, the author later tested agentic LLMs like Claude Opus 4.5, which could iteratively improve on algorithmic Python code.

The author proposed that modern agentic LLMs could write Rust code faster than existing state-of-the-art libraries by using Rust's speed and memory safety, as well as PyO3 to bridge Rust and Python for ergonomic use. The author's first test case involved reimplementing the UMAP algorithm in Rust, which is a valuable machine learning algorithm but scales poorly to big data.

To measure performance improvements, the author utilized Rust's comprehensive benchmarking tool, criterion. They provided the agent with a detailed prompt, including the creation of benchmarks using different input data sizes and a requirement to iterate on code until no further speed improvements were achievable. The agent was given permission to make autonomous optimizations until it reached the "fast as it can be" threshold.

The author found that Opus 4.5 was somewhat lazy in its optimization efforts, but by refining the prompt to include a clear pass/fail target, it was able to achieve significantly faster code. The benchmarks showed speedups ranging from 2x to 20x, depending on the domain. The author concluded that this experiment demonstrated the potential of agentic LLMs to create faster Rust code for Python integration.

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

This story

This is one outlet's version. Read the fullest account.

Read the original at minimaxir.com →

More in Tech

Building an Embedded Raft SDK for Existing Node.js Services

Sometimes an application needs Raft semantics, but it does not need another general-purpose distributed system. An existing scheduler, control plane, metadata service, or coordination service may…

  • node-raft-rsm SDK provides Node.js services with Raft consensus capabilities.
  • Developers define commands, state machine, storage, transport for integration.
  • SDK focuses on RaftNode creation, proposal, reading, and stopping operations.

More from Tuesday 22 September →