Describe the mechanics of the __prepare__ method in metaclasses. When in the class lifecycle is it called and what data structure does it return by default?
Python
How is the exception mechanism in Python implemented under the hood? Why is using the except Exception construct considered an antipattern in production and what critical system exceptions can it accidentally catch?
Describe the N+1 query problem in aggregation. How to efficiently count related objects, such as the number of comments on 100 posts, without loading all related entities into Python memory?
How does the .update() method work in Django ORM and SQLAlchemy? Are model signals like pre_save and post_save triggered when it is executed, or do custom save() methods run? Why?
What is Soft Delete at the database level? What architectural problems with indexes, field uniqueness, and ORM performance arise when using the is_deleted = True flag in large tables?
What is the Identity Map in the Data Mapper pattern in SQLAlchemy? How does this mechanism ensure that two different queries to the same database row within a session return a reference to the same object in Python memory?
What is a Task Leak in asynchronous Python? How can an unclosed or hanging coroutine lead to hidden memory leaks and how to track this in a running application?
What happens if an asynchronous code calls a synchronous blocking function, such as time.sleep() or a heavy request via the requests library? How to properly move such calls outside the event loop?
What is the difference between asyncio.create_task() and directly calling a coroutine with await? How does the asyncio scheduler work when a task is created with create_task(), but the current thread is busy with heavy computations?