__new__() does not return anything, on singletong pattern

Steven D'Aprano steve+comp.lang.python at pearwood.info
Thu Mar 12 07:04:30 EDT 2015


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.

2MB is not that big.

3-4 seconds to instantiate is a bit worrying, but you should look at
improving the efficiency of loading a map rather than insisting that there
should be only one map instance. Particularly in the map editor, what if
the user wants to copy parts of one map into a second map? I've often
wanted to do that with games. Every other editor, from music editors to
text editors, allows you to have multiple documents open. Why should game
level editors be stuck in the 1980s?

While Map is a singleton, editing multiple maps at once is impossible (or at
least tiresomely difficult).


-- 
Steven




More information about the Python-list mailing list