Week 8 — Python Functions & Transactions

intermediate python dbms dsa

Goal: Level up Python with functional patterns and generators, then understand how databases keep your data safe with transactions and locking.

Topics

DayFocusTopics
MonPython FunctionsFunctions and Arguments · Lambda Functions · Map, Filter, Reduce, Zip
TuePython Advanced FunctionsClosures and Nonlocal · Decorators · Generators and Iterators
WedDBMS TransactionsTransactions Deep Dive · Isolation Levels · Locking Mechanisms
ThuDBMS ConcurrencyDeadlocks · Optimistic vs Pessimistic Locking
FriDSA TreesBinary Trees · Binary Search Trees · Binary Search

Key Concepts

  • *args/**kwargs and how Python resolves argument order
  • The decorator pattern — wrapping functions to add behavior without modifying them
  • Generator lazy evaluation with yield — why it’s memory-efficient for large datasets
  • Isolation level tradeoffs — read committed vs serializable, and the phantom read problem
  • Deadlock prevention strategies — lock ordering, timeouts, deadlock detection
  • The binary search template — getting the boundary conditions right every time

Practice

  • Write a @timer decorator that logs how long any function takes to execute
  • Implement a generator for the Fibonacci sequence — verify it’s lazy with next()
  • Explain why READ COMMITTED is the default in PostgreSQL (hint: it’s about the throughput vs safety tradeoff)
  • Implement binary search with both iterative and recursive approaches

~14 topics · ~1.5-2 hrs/day · Focus: read the linked notes, then code each concept