Performance
Post #3197, on Jun 7, 2021 in TG
Chrome hogs 500 MB, Python demolishes 10 GB parsing one XML file
Description
Two - panel Winnie-the-Pooh meme. Top panel shows a casually dressed Pooh leaning back with half-closed eyes; white background text reads: “Chrome: uses 500 MB to open 3 tabs”. Bottom panel shows the same bear in a tuxedo, looking pleased; white background text reads: “Python: uses 10 GB to parse a 50 MB XML file”. The joke contrasts Chrome’s notorious browser memory bloat with an even more extreme case of Python’s run-time overhead when loading large XML documents, poking fun at modern software’s inefficiency and the hidden performance costs of high-level parsing libraries
Use J and K for navigation
Comments
19Comment deleted
Chrome burning 500 MB for three tabs is cute - my Python ETL needs a 10 GB Kubernetes pod to turn a 50 MB XML into the 12 bytes of JSON the SPA actually uses
We'll spend weeks optimizing a database query to save 100ms, then casually load a 2GB pandas DataFrame into memory just to filter 10 rows because 'RAM is cheap' - until production crashes at 3am
The real sophistication here is that both are technically correct: Chrome's 500MB for 3 tabs is just aggressive tab caching and V8 heap allocation, while Python's 10GB for a 50MB XML file is what happens when you accidentally use xml.dom.minidom instead of lxml's iterparse() and load the entire DOM tree into memory. At least Chrome has the decency to blame each tab's renderer process separately - Python just hands you one massive memory spike and a sheepish 'well, you did ask me to parse it' shrug
Python's XML parser: because streaming was too efficient for that 'batteries included' philosophy
We roast Chrome for 500MB, then parse a 50MB XML in Python with xmltodict, materialize a 10GB DOM of Unicode strings and dicts, and wonder why Kubernetes keeps OOM‑killing the pod
Chrome treats 500MB as freemium; Python’s ElementTree says “hold my GIL” - every tag becomes a handful of Unicode objects and dicts, turning 50MB into a 10GB object graph unless you iterparse
Java* Comment deleted
Is it? Comment deleted
F Comment deleted
I have been parsing several 10gb xmls with python. After some time optimizing I have managed to parse these xmls using 8gb of ram and 6gb swap. You can check the code here btw https://github.com/Desantnikov/huge_xmls_parser Comment deleted
What do you store in 10gb xml? Database :D Comment deleted
It was a list of all entrepreneurs in my country. For some reasons our government's IT guys decided to store them in xml Comment deleted
Why don't you use lxml iterative parser? Comment deleted
I have used it Comment deleted
Why does it use 8gb of ram then? (just curious) Comment deleted
There could be really big files for gov purposes👀 Comment deleted
It uses 10GB RAM to keep in memory at what part it is Comment deleted
JS: I want 1 TB of RAM Comment deleted
*Electron Comment deleted