This question evaluates understanding of Python data structures (lists and dictionaries), including common operations and average time complexity, iteration order guarantees, mutability, memory behavior, list transformation approaches (map versus list comprehensions), and concurrency concepts such as the CPython Global Interpreter Lock, threading versus multiprocessing, and synchronization primitives (Queue, Lock, Event) as they relate to race conditions and deadlocks. It is commonly asked to gauge reasoning about performance and correctness trade-offs in the Data Manipulation (SQL/Python) domain and tests both conceptual understanding and practical application.
Explain the differences between Python lists and dictionaries (maps), including common operations and their average time complexity, iteration order guarantees, mutability, and memory behavior. Demonstrate how you would transform a list using map versus list comprehensions and when each is preferable. Explain the CPython Global Interpreter Lock (GIL) and how it impacts multithreading. When would you choose threading versus multiprocessing, and how would you share data safely (e.g., Queue, Lock, Event) while avoiding pitfalls like race conditions and deadlocks?