Implementing the Flyweight Pattern for Efficient Object Sharing
Flyweight Pattern Concept
The Flyweight pattern addresses memory efficiency by sharing common data across multiple objects rather then storing duplicate information. This approach is particularly valuable when dealing with systems that require numerous fine-grained objects with significant overlapping attributes.
Consider an e-commerce shipping ...
Posted on Fri, 19 Jun 2026 18:25:42 +0000 by bulldorc
Mastering Python Iteration Protocols: Iterators and Generators
The Python Iteration Protocol
In Python, iteration protocols define how sequences are traversed. There is a distinct difference between an iterable object and an iterator object.
Iterable: An object that can return an iterator via its __iter__ method. Examples include lists, tuples, and dictionaries.
Iterator: An object that represents a strea ...
Posted on Mon, 15 Jun 2026 16:32:18 +0000 by l_evans
Understanding Generators and Iterators in Python
What Are Generators?
Generators in Python are a simple way to create iterators. Instead of building a list and storing all elements in memory at once, generators calculate each item on the fly, which saves memory and improves performance when dealing with large datasets.
Creating Generators
One of the simplest ways to create a generator is by u ...
Posted on Wed, 13 May 2026 11:15:32 +0000 by phpnewbie911