
Prototype : Design Patterns In Python
Medium Article : https://medium.com/design-patterns-in-python/prototype-design-pattern-in-python-45f8d3f15583
Documentation : https://sbcode.net/python/prototype/
Sometimes you just want to switch off your computer and read from a book. So, all GoF patterns are discussed in my Design Patterns In Python book
https://www.amazon.com/dp/B08XLJ8Z2J : ASIN B08XLJ8Z2J
The Prototype design pattern is good for when creating new objects requires more resources than you want to use or have available. You can save resources by just creating a copy of any existing object that is already in memory.
E.g., A file you've downloaded from a server may be large, but since it is already in memory, you could just clone it, and work on the new copy independently of the original.
In the Prototype patterns interface, you create a static clone method that should be implemented by all classes that use the interface. How the clone method is implemented in the concrete class is up to you. You will need to decide whether a shallow or deep copy is required.
A shallow copy, copies and creates new references one level deep,
A deep copy, copies and creates new references for all levels.