[Checkins] SVN: zope.interface/trunk/src/zope/interface/interface.py using `__setattr__` instead of `property` speeds up zope start-up time again, since getting the value for `__bases__` through `__dict__` adds up with almost 200.000 calls; of course, there's some overhead, since `__setattr__` gets called for the other attributes as well, but overall start-up is still faster

Jim Fulton jim at zope.com
Sun Jan 6 14:27:38 EST 2008


This change breaks assigning to __class__, which the twisted folks  
depend on.  In general, Im suspicious of using __setattr__.  What  
impact does this change have on startup time?  How did you measure it?

Jim


On Nov 1, 2007, at 2:29 PM, Andreas Zeidler wrote:

> Log message for revision 81363:
>  using `__setattr__` instead of `property` speeds up zope start-up  
> time again, since getting the value for `__bases__` through  
> `__dict__` adds up with almost 200.000 calls;  of course, there's  
> some overhead, since `__setattr__` gets called for the other  
> attributes as well, but overall start-up is still faster
>
> Changed:
>  U   zope.interface/trunk/src/zope/interface/interface.py
>
> -=-
> Modified: zope.interface/trunk/src/zope/interface/interface.py
> ===================================================================
> --- zope.interface/trunk/src/zope/interface/interface.py	2007-11-01  
> 17:59:51 UTC (rev 81362)
> +++ zope.interface/trunk/src/zope/interface/interface.py	2007-11-01  
> 18:29:40 UTC (rev 81363)
> @@ -274,7 +274,7 @@
>
>     def __setBases(self, bases):
>         # Register ourselves as a dependent of our old bases
> -        for b in self.__bases__:
> +        for b in getattr(self, '__bases__', ()):
>             b.unsubscribe(self)
>
>         # Register ourselves as a dependent of our bases
> @@ -284,12 +284,12 @@
>
>         self.changed(self)
>
> -    __bases__ = property(
> +    def __setattr__(self, name, value):
> +        if name == '__bases__':
> +            self.__setBases(value)
> +        else:
> +            self.__dict__[name] = value
>
> -        lambda self: self.__dict__.get('__bases__', ()),
> -        __setBases,
> -        )
> -
>     def changed(self, originally_changed):
>         """We, or something we depend on, have changed
>         """
>
> _______________________________________________
> Checkins mailing list
> Checkins at zope.org
> http://mail.zope.org/mailman/listinfo/checkins

--
Jim Fulton
Zope Corporation




More information about the Checkins mailing list