Browse by Topic

Popular

Latest

Latest Posts

Diagram showing a Python instance attribute being cached by functools.cached_property for repeated fast access.
Python

Using Python functools.cached_property

python functools cached_property: Learn how functools.cached_property caches instance attributes, when to use it, and how it compares to property and lru_cache.

cachingfunctoolspythondecorators
Illustration of a Python cached property caching a computed value on an instance, with a lock and memory icon.
Python

Python cached property: Cache Computed Attributes

python cached property: Learn how to use Python's cached_property to cache expensive attribute computations, when to apply it, and how to handle invalidation and threa...

cached_propertyfunctoolscachingdecorators
Illustration of a Python computed property showing a getter method transforming an attribute.
Python

Python Computed Property: Using @property Correctly

Learn how to implement computed properties in Python with @property: getters, setters, cached_property, and performance tradeoffs.

pythonproperty-decoratoroopcaching
Python property deleter concept illustration showing a property with getter, setter, and deleter methods.
Python

Python Property Deleter: Customizing Attribute Deletion

Use a property's `deleter` method to define custom deletion behavior for Python properties, including cache invalidation, cleanup, and validation.

propertydeleterdescriptorattribute deletion
Illustration of a Python setter property intercepting an attribute assignment with a validation gate before storing the value.
Python

Python Setter Property: Syntax and Use Cases

Learn how a Python setter property controls attribute assignment, adds validation, and keeps derived state consistent in your classes.

python properties@property decoratorattribute validationdata encapsulation
Python getter property concept illustrated with a property decorator and a value being accessed.
Python

Python Getter Property: Using @property Effectively

python getter property: Learn how to implement getter properties in Python with @property, including computed values, validation, and read-only attributes.

pythonpropertiesdecoratorsobject-oriented-programming
Illustration of Python property decorator controlling attribute access with getter and setter methods.
Python

Python Property: Getters, Setters, and Validation

Learn how to use Python's property decorator to control attribute access, add validation, and compute values with clean, readable code.

property decoratorgetters settersdata validationcomputed attributes
Diagram showing how Python's += operator dispatches to __iadd__ for in-place mutation versus creating a new object.
Python

Python __iadd__: How += Mutates or Reassigns

Understand Python's __iadd__ method and how += dispatches to it, with the fallback to __add__, return-value rules, and mutable vs immutable differences.

dunder methodsoperator overloadingin-place operationsmutable objects
Python code snippet showing augmented assignment operators with a visual distinction between mutable and immutable object behavior.
Python

Python In-Place Operators: Syntax and Behavior

python in place operators: Understand how Python's in-place operators like += and *= work, when they mutate objects, and how to implement them in custom classes.

Python operatorsmutabilitydunder methodsmemory efficiency
Diagram showing two objects and the plus operator with a reversed arrow indicating the __radd__ method call
Python

Python __radd__: Reverse Addition Explained

python **radd**: Understand Python's __radd__ method: when it's called, how to implement it, and common pitfalls when overloading addition for custom types.

dunder methodsoperator overloadingPython internalsnumeric types