Mario Figueiredo wrote:
It's just a cheap global, since is ubiquitous throughout the entire application, does behave like a singleton, and is a bit too expensive to create. A full map in the main application takes 3 or 4 seconds to instantiate and occupies around 2 Mb of memory.
There's nothing wrong with having only one instance. The quesion is whether it's a good idea to make calling Map() be the way to get hold of that instance. I would say it's counterproductive. The implementation is convoluted, and it makes code that calls Map() confusing, because it looks like it's creating a new instance when it really isn't. I would just provide a function: _map = None def get_map(): global _map if _map is None: _map = Map() return _map and document the fact that you shouldn't call Map() directly. -- Greg -- https://mail.python.org/mailman/listinfo/python-list