[blivet][follow-up a v2] Do not create a copy of singleton objects

Brian C. Lane bcl at redhat.com
Thu Oct 8 23:41:15 UTC 2015


On Thu, Oct 08, 2015 at 10:56:09AM +0200, Vratislav Podzimek wrote:
> On Wed, 2015-10-07 at 09:52 -0700, Brian C. Lane wrote:
> > On Wed, Oct 07, 2015 at 09:33:44AM -0400, David Lehman wrote:
> > > On Wed, 2015-10-07 at 12:55 +0200, Vratislav Podzimek wrote:
> > > > They are singletons and thus should only exist in single instances.
> > > 
> > > I like this one much better than follow-up b. ACK.
> > 
> > It is cleaner than the other, but it hides the fact that your copy
> > contains things that aren't copies. Maybe add a sphinx notice to the
> > class documentation to make this somewhat clearer?
> Sounds like a good idea to me. Actually, I was thinking about implementing a 
> '@singleton' class decorator that would:
> a) add the __call__ method returning self
> b) add/override the __deepcopy__ method returning self
> c) add a documentation to the decorated class
> 
> possibly with a 'one_copy=True' parameter that would determine the behavior of
> __deepcopy__. That would help us keep things consistent. 

Sounds good as long as Sphinx can pick up the docs.

-- 
Brian C. Lane | Anaconda Team | IRC: bcl #anaconda | Port Orchard, WA (PST8PDT)


More information about the anaconda-patches mailing list