A software example

The Exaile music player [j.mp/exaile] uses Flyweight to reuse objects (in this case, music tracks) that are identified by the same URL. There's no point in creating a new object if it has the same URL as an existing object, so the same object is reused to save resources [j.mp/exailefly].

Peppy, an XEmacs-like editor implemented in Python [j.mp/peppyp], uses the Flyweight pattern to store the state of a major mode status bar. That's because unless modified by the user, all status bars share the same properties [j.mp/peepyfly].

Get Python: Master the Art of Design Patterns now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.