Am 06.03.2015 um 23:12 schrieb Aaron Meurer:
> Hmm, I didn't notice that the only reason this class is constructed at
> import time is that it uses the Singleton metaclass.
Singleton actually explicitly documents that it's running the instance
constructor during class declaration:
> The class is instantiated immediately at the point where it is
> defined by calling cls.__new__(cls). This instance is cached and
> cls.__new__ is rebound to return it directly.
As I understand things, the behaviour that we want is the exact
opposite, namely that a singleton class defers constructing the
singleton until the first time it is explicitly requested.
So I'm changing that behaviour, and removing that section from the
docstring.
There's one funny thing I noticed: Singleton caches the original
constructor, under the name of _new_instance, so that subclasses can
still call it to construct their own instances.
However, _new_instance is never ever called in all of SymPy. There's not
even a unit test for that behaviour.
Should I remove that feature? It would simplify the code, not in terms
of lines of code but conceptually (because finding the constructor
involves looking in the MRO chain so anybody trying to understand the
code has to understand both the lookup and the caching at the same time).