Python
#7

Memory-Efficient Data Streaming with Generators in Python

MediumAmazon
Interview Question #7
Asked at Amazon

Explain how to read a 20GB log file in Python on a machine with only 4GB of RAM without crashing. Write a generator function that yields parsed JSON logs one by one.

Input Table: massive_file
1 rows preview
file_sizeavailable_ram
20 GB4 GB
Expected Output Structure1 rows
memory_behavior
Constant ~10MB RAM usage
Interview Context

Asked frequently in data analyst and business analyst technical rounds. Focus on clean filtering, optimal indexing usage, and unambiguous column selection.

Python 3.10 (Pandas)
Environment Ready

Click "Run & Test" to execute your Pandas code against the test assertions.

Chat with us