The Flyweight Pattern
Learn about the Flyweight pattern and how it differs from the Singleton pattern in Python.
We'll cover the following...
Overview
The Flyweight pattern is a memory optimization pattern. Novice Python programmers tend to ignore memory optimization, assuming the built-in garbage collector will take care of it. Relying on built-in memory management is the best way to start. In some cases, for example, very large data science applications, memory constraints can become barriers, and more active measures need to be taken. In very small Internet of Things devices, memory management can also be helpful.
The Flyweight pattern ensures that objects that share a state can use the same memory for their shared state. It is normally implemented only after a program ...