Habr AI→ original

Python in AI: why the language is 70 times slower than C and losing ground on edge

The artificial intelligence industry — the most resource-intensive in history — primarily runs on Python: it is approximately 70 times slower than C and ranks 26th out of 27 in the energy efficiency ranking of programming languages. On on-device and edge inference, it is already being displaced by compiled languages, primarily Swift.

AI-processed from Habr AI; edited by Hamidun News
Python in AI: why the language is 70 times slower than C and losing ground on edge
Source: Habr AI. Collage: Hamidun News.
◐ Listen to article

The artificial intelligence industry — the most computationally hungry industry in history — primarily computes in Python programming language, which is approximately 70 times slower than C and ranks 26th out of 27 in the programming language energy efficiency ranking.

The cost of Python's crown

The author of the article on Habr breaks down the cost of this choice in three dimensions: in microseconds of computation, in gigawatt-hours of data center energy, and in doubled labor of engineers who must compensate for the language's slowness with additional optimization and wrapping over faster libraries. The material is built on figures and links to primary sources, and also considers honest counterarguments in favor of Python — that is, it does not reduce to one-sided accusations of the language in all industry problems.

Why the industry still chose Python

Python's dominance in machine learning developed historically: a huge ecosystem of libraries grew around the language, and the "slow" part of the code in practice is almost always delegated to fast C and CUDA implementations under the hood. But as the load shifts from training large models in the cloud to running them on the user's side, this architectural decision begins to work against the industry.

While training and inference occurred primarily in data centers on powerful GPU clusters, Python's overhead was invisible against the background of the overall cost of computation. The situation changes when a model needs to run on a smartphone, laptop, or embedded device with limited energy budget: there the difference between interpreted and compiled code execution becomes critical for response time and battery life, not just a line item in data center energy consumption reports.

Where Python is already being squeezed out

As AI model inference shifts to user devices — on-device and edge scenarios, local inference without cloud access — Python's positions weaken. These new territories are already being claimed by compiled languages, and first and foremost Swift, which in such scenarios has the advantage of execution speed and energy consumption.

  • Python is approximately 70 times slower than the C language
  • In the programming language energy efficiency ranking, Python ranks 26th out of 27
  • The cost of Python's dominance is measured in microseconds, gigawatt-hours, and engineer labor
  • On on-device and edge inference, Python is being displaced by compiled languages, first and foremost Swift

What this cost means for data centers

Gigawatt-hours in this comparison is not an abstraction, but a direct consequence of the fact that interpreted Python requires more computational cycles for the same task than compiled code, and therefore more electricity for cooling and powering servers. The doubled labor of engineers is the cost of constant overhead: wrapping Python code over faster C and CUDA libraries, profiling bottlenecks and rewriting critical sections at a lower level to compensate for the language's slowness.

What this means

Python remains the default language for training and prototyping AI models, but as inference moves to local devices and edge scenarios, where every milliwatt and millisecond counts, its cost becomes increasingly noticeable — and it is there that compiled languages get a chance to displace the long-standing leader. This is not about a complete replacement of Python in the coming years, but about a gradual division of application areas: cloud and prototyping remain with it, edge and on-device increasingly move to compiled alternatives like Swift.

ZK
Hamidun News
AI news without noise. Daily editorial selection from 50+ sources. A product by Zhemal Khamidun, Head of AI at Alpina Digital.

Need AI working inside your business — not just in your newsfeed?

I build production AI for companies — custom CRM, internal tools, autonomous agents, workflow automation. Owned by you, shaped to your process, no per-seat tax. Built by Zhemal Khamidun, CPO of AlpinaGPT (AI platform, 6,000+ users).

What do you think?
Loading comments…