Thumbtack · CS Fundamentals
Compare list/dict; parse JSON/CSV at scale
TrueInterview
October 7, 2026 · 1 min read
Give a precise comparison of Python lists and dictionaries: for append, insert, lookup, update, and delete, specify the average and worst-case time complexity, memory impact, and ordering guarantees under CPython 3. How would you store and retrieve values in each, and show concise code for appending to a list and updating a dict? Define JSON and CSV, and explain when JSON is preferable to CSV, taking into account nesting, schema evolution, interoperability, and compression. Provide exact Python code for streaming reads of both formats: (a) a JSON Lines file by iterating line by line and calling json.loads; (b) a CSV file using csv.DictReader; and (c) pandas read_csv with chunksize to sum the numeric column value in data.csv without exceeding available memory. Explain how you would deal with malformed rows, missing or NaN values, bad encodings, and numeric overflow; suggest chunk-size heuristics for a 10 GB file on a machine with 16 GB of RAM; and give a non-pandas alternative that still streams safely.
Overview: This question tests knowledge of Python data structures (list versus dict), algorithmic time and memory complexity, CPython ordering guarantees, large-scale JSON/CSV parsing and streaming, and robust data-cleaning and error-handling approaches.