This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import functools | |
| import inspect | |
| import time | |
| import cProfile | |
| import time | |
| from contextlib import contextmanager | |
| import pstats | |
| import sys | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Singleton(type): | |
| """ | |
| Metaclass. | |
| Only allows the creation of one instance, all other tries return | |
| the same instance of the first creation. | |
| Use: | |
| class Test(metaclass=Singleton): | |
| ... | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import weakref | |
| class Cached(type): | |
| """ | |
| Metaclass. | |
| Only allows the creation of one type of instance, all other instances | |
| with the same initialization variables return the same instance of the | |
| first creation. | |
OlderNewer