Key Concepts

+ Add Concept
Python Argument Passing

Python Argument Passing

Python passes object references to functions. A function can mutate a passed mutable object, but rebinding its local parameter does not change the caller’s variable binding.

Python Copy Semantics

Python Copy Semantics

Assignment binds a new name to an existing object. A shallow copy creates a new outer container but retains references to nested objects, while a deep copy recursively copies reachable objects where appropriate.

Python Dataclasses

Python Dataclasses

The dataclasses module generates common methods such as __init__, __repr__, and optionally equality and ordering for classes primarily used to hold data. Field defaults need the same mutable-default care as function parameters.

Python Decorators

Python Decorators

A decorator receives a function or class and returns a replacement, often a wrapper that adds behavior such as logging, authorization, caching, or registration.

Python Equality and Hashing

Python Equality and Hashing

Python distinguishes identity (is) from value equality (==). Objects used as dictionary keys or set members must have a stable hash consistent with equality for as long as they are stored in those collections.

Python Exception Handling

Python Exception Handling

Python uses exceptions to signal exceptional conditions. try, except, else, and finally allow programs to handle expected failures, preserve useful context, and reliably clean up resources.

Python Generators

Python Generators

Generators produce values lazily and retain their execution state between yields. They are useful for processing streams or large collections without materializing every value in memory.

Python Global Interpreter Lock

Python Global Interpreter Lock

In CPython, the Global Interpreter Lock (GIL) allows only one thread at a time to execute Python bytecode in a process. It simplifies memory management but affects how CPU-bound threaded programs scale.

Python Imports and Modules

Python Imports and Modules

An import locates and executes a module the first time it is loaded, then caches the resulting module object in sys.modules. Later imports normally reuse that object rather than re-executing its top-level code.

Python Method Resolution Order

Python Method Resolution Order

Python uses the method resolution order (MRO) to decide which class supplies an attribute. In multiple inheritance, its C3 linearization provides a predictable ordering and enables cooperative calls to super().

Python Mutable Default Arguments

Python Mutable Default Arguments

Python evaluates default argument expressions once, at function definition time. A mutable default such as a list or dictionary is therefore shared by calls that omit that argument.

Python Type Hints

Python Type Hints

Python type hints annotate intended values without normally enforcing them at runtime. Static checkers and editors can use annotations to detect errors, improve completions, and document interfaces.

Questions (12)