Everything old is new again: memory optimization
16 hours ago
- #memory-optimization
- #python-vs-cpp
- #performance
- AI sociopaths have bought all the world's RAM, reducing memory in consumer devices.
- Memory optimization has become important after years of neglect.
- A Python script for word counting consumes 1.3 MB of memory.
- A C++ version of the same task uses only 100 kB (7.7% of Python's usage).
- C++ achieves lower memory usage by avoiding string objects and using string views.
- The C++ runtime itself uses 70 kB, mostly for exception handling.
- Disabling exception support in C++ could reduce memory usage to just 21 kB (98.4% reduction).
- Python's higher memory usage is due to its runtime and built-in functionalities.