From 680bd23bd81573469475ffc67f6d6bf0d4cd22db 2009-09-25 17:57:29 From: Brian Granger Date: 2009-09-25 17:57:29 Subject: [PATCH] Changed Component.__init__ so that config is not deepcopy'd. Previously, we were deepcoping the config for each component. This causes overhead and it is not clear at this point that having components share config (by reference) is a bad idea. --- diff --git a/IPython/core/component.py b/IPython/core/component.py index 730af7e..752f227 100644 --- a/IPython/core/component.py +++ b/IPython/core/component.py @@ -234,10 +234,18 @@ class Component(HasTraitlets): self.root = self # This is the default, it is set when parent is set self.parent = parent if config is not None: - self.config = deepcopy(config) + self.config = config + # We used to deepcopy, but for now we are trying to just save + # by reference. This *could* have side effects as all components + # will share config. + # self.config = deepcopy(config) else: if self.parent is not None: - self.config = deepcopy(self.parent.config) + self.config = self.parent.config + # We used to deepcopy, but for now we are trying to just save + # by reference. This *could* have side effects as all components + # will share config. + # self.config = deepcopy(self.parent.config) self.created = datetime.datetime.now() diff --git a/IPython/core/tests/test_component.py b/IPython/core/tests/test_component.py index f03d4a3..9774320 100644 --- a/IPython/core/tests/test_component.py +++ b/IPython/core/tests/test_component.py @@ -147,12 +147,12 @@ class TestComponentConfig(TestCase): self.assertEquals(c1.config, config) self.assertEquals(c2.config, config) self.assertEquals(c3.config, config) - # Test that we always make copies - self.assert_(c1.config is not config) - self.assert_(c2.config is not config) - self.assert_(c3.config is not config) - self.assert_(c1.config is not c2.config) - self.assert_(c2.config is not c3.config) + # Test that copies are not made + self.assert_(c1.config is config) + self.assert_(c2.config is config) + self.assert_(c3.config is config) + self.assert_(c1.config is c2.config) + self.assert_(c2.config is c3.config) def test_inheritance(self): class MyComponent(Component):