Python core
This folder has no README. Everything inside it is listed below.
Folders
Notes
- Is Python interpreted or compiled? 5 Both, and the interviewer is checking whether you know there is a compilation step at all.
- Mutable vs Immutable Types in Python 7 Python's built-in types divide into mutable (changeable after creation) and immutable (unchangeable; "modifications" produce new objects).
- Variable Scope in Python 3 Variable scope refers to the context in which a variable is accessible within a program.
- Introspection in Python 3 Introspection in Python refers to the ability of a program to examine the type or properties of an object at runtime.
- What is the difference between is and ==? 3 In Python, both is and == are used for comparison, but they serve different purposes.
- Difference Between __init__() and __new__() in Python 3 In Python, both __init__() and __new__() are special methods related to object creation, but they serve different purposes in the object lifecycle.
- Imports and the module system 4 import looks like a declaration and is actually a function call that runs code.
- Metaclasses 4 A metaclass is the class of a class. Every class you define is an instance of type, and type is what actually builds it — a metaclass is a subclass of type…
- Difference Between staticmethod and classmethod in Python 3 In Python, both staticmethod and classmethod are used to define methods that are associated with a class rather than an instance of the class, but they have…
- Decorators 5 A decorator is a callable that takes a function and returns a replacement, applied with @.
- args and *kwargs in Python 3 In Python, args and *kwargs are used in function definitions to allow for variable-length arguments.
- Testing in Python 5 The framework question is settled — pytest, for new code, without much argument.
- Fixtures and Patch in pytest 3 A fixture in pytest is a powerful and flexible mechanism used to set up and tear down resources required for testing.
- Lambda Functions and Their Usage with map, filter, and reduce in Python 3 A lambda function in Python is a small, anonymous function defined using the lambda keyword.
- Shallow vs deep copy copy.copy() makes a new outer object referencing the same nested objects. copy.deepcopy() recursively copies everything.
- Hashable Objects in Python 3 In Python, an object is hashable if:
- Argument Passing in Python: By Reference or By Value? 3 In programming, "pass by reference" and "pass by value" refer to how arguments are passed to functions:
- Error handling with try and except 4 In Python, the try and except blocks are used to handle exceptions (errors) gracefully, preventing your program from crashing unexpectedly.
- Iterables and iterators 7 Every for loop in Python is the iterator protocol.
- __eq__ and __hash__ 7 Two methods with a contract between them, and the contract is not a convention — it is what makes dict and set work at all.
- Enum vs StrEnum 6 StrEnum landed in 3.11 and quietly obsoleted the class Foo(str, Enum) idiom that everyone had been writing for a decade.
- Debugging and introspecting async code 5 Async bugs are rarely wrong logic. They are a task nobody awaited, a synchronous call blocking the loop, or an exception that vanished — and none of those…
- Application debugging and introspection 5 The interview question is really "what do you do when you cannot reproduce it".
- Python memory model — allocation, refcounting, GC When is a Python object freed? CPython answers with two mechanisms in tandem: reference counting, which frees almost everything the moment the last…
- __slots__ — when it saves memory and what it breaks __slots__ declares a fixed set of attributes for a class, replacing the per-instance __dict__ with a compact array of slots.
- weakref — References That Don't Prevent GC 8 A weakref references an object without incrementing its refcount.
- String interning and the small-int cache CPython optimizes some immutable values by interning them — keeping a single canonical instance and reusing it.
- dis — inspecting Python bytecode CPython compiles source to bytecode (a sequence of opcodes for a stack-based VM).
- dict internals CPython's dict is a hash table with open addressing.
- list internals CPython's list is a dynamic array of pointers to Python objects, with over-allocation to amortize append cost.
- match/case — structural pattern matching (3.10+) PEP 634/636. More than just a switch statement: it pattern-matches structure.
- What's new in Python 3.12-3.14 5 The version-currency file. Python 3.14 shipped October 2025 and 3.14.x is the baseline for examples; Python 3.15.0 shipped on 2026-10-09 (explicit lazy…
- Generators 6 A generator function is the cheapest way to write an iterator: calling it runs nothing and returns a generator object, and each next() runs the body up to…
- Stack and heap in Python 4 The usual answer, "variables live on the stack and objects on the heap", is half right in CPython and misleading in the half that interviewers probe.
- The allocator: heap, arenas, pools, blocks 3 Garbage collection decides when memory is reclaimed; the allocator decides where objects live and when memory goes back to the operating system.
- Python memory in production 6 The mechanisms are covered one by one in the notes before this: where objects live (34_stack_vs_heap.md), when they are freed (24_memory_model.md), and how…