Urgent.News

What's breaking now, across thousands of outlets.

Tech

Why a Single Emoji Quadruples Python String Memory

TL;DR: CPython stores strings using PEP 393 (Flexible String Representation) rather than UTF-8. It selects a fixed width of 1, 2, or 4 bytes per character based on the widest character present. If an ASCII string contains just one 4-byte emoji, Python instantly upgrades every single character in that string to 4 bytes, quadrupling its memory footprint. Imagine loading a massive log file into…

Python strings employ PEP 393, known as Flexible String Representation, instead of variable-length UTF-8 encoding. The interpreter selects a uniform byte width of 1, 2, or 4 bytes per character for the entire string based on the widest single character. This fixed-width strategy ensures constant-time character indexing, optimizing performance while maintaining memory layout consistency.

When an ASCII string contains merely one 4-byte emoji, Python upgrades every single character in the string to 4 bytes, quadrupling its memory footprint. For instance, a massive log file loaded into memory could expand from 100 MB to 400 MB upon processing a line with just one thumbs-up emoji. This behavior is deliberate, not a memory leak, and is a design choice in CPython to maintain efficient indexing performance.

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

Testing a Zabbix Agent on Disposable VMs: 10 Silent Failures Found for a Few Cents

An agent install script that prints "Installation completed successfully" proves very little. The agent can be running, connected to the server, and reporting wrong values or nothing at all on some…

  • Ten issues discovered with Zabbix agent on disposable VMs
  • Issues affect any Zabbix installation, most related to Zabbix implementations
  • Testing method used disposable VMs, deletion after two hours for clean environment

Food complaint root cause vs a formal 8D: what changes in FMCG and where the discipline still helps

Free 21-item 8D checklist (PDF): https://8d-gate.vercel.app/free-8d-checklist?utm_source=devto&utm_medium=article&utm_campaign=food-complaint_checklist (enter your email to download) If your…

  • FMCG food complaint handling differs from formal 8D, prioritizing containment over root cause
  • Traceability via lot codes, production dates, lines, shifts, ingredient batches crucial
  • 8D thinking valuable for separating containment from cause, guiding corrective actions

OpenRouter's February 2026 Outages: How a Cold Cache Overwhelmed the Database

The database was struggling. The API said the user didn't exist. That is the part of OpenRouter's February outages worth looking at closely.

  • OpenRouter suffered two outages in February 2026 due to a cold cache overwhelming the database
  • Users reported as non-existent, causing 401 errors instead of authentication failures
  • Circuit breakers and controlled cache repopulation needed to prevent future issues

More from Sunday 25 October →