diff options
| author | Jason Madden <jamadden@gmail.com> | 2020-01-22 09:32:06 -0600 |
|---|---|---|
| committer | Jason Madden <jamadden@gmail.com> | 2020-01-22 09:32:06 -0600 |
| commit | 3cc593ed15c08e09f47cd9a186bd1cd33c1cc148 (patch) | |
| tree | 2fff330a718986fa6795de52aee6d0b854fa4dfa /src/zope/interface/interface.py | |
| parent | b928f8a53cb299f72ff60fc8e622b8e41cabad12 (diff) | |
| download | zope-interface-c-opts-members.tar.gz | |
Use tp_members in SpecificationBase and ClassProvidesBase.c-opts-members
Instead of storing 1 and 2 attributes, respectively, in __dict__. This lets us eliminate inst_attr and its use of an undocumented API.
It also helps reign in the size of these objects. Before, on CPython 8, a ClassProvides object that subclasses both SpecificationBase and ClassProvidesBase required 408 bytes: 48 for the object, 360 for the dict.
Now it requires 72 + 232 = 304.
With a bit of work on defining __slots__ in Python, that can be brought much lower still, I think.
zope.security tests pass with this installed.
Diffstat (limited to 'src/zope/interface/interface.py')
| -rw-r--r-- | src/zope/interface/interface.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/zope/interface/interface.py b/src/zope/interface/interface.py index 05f5594..e72c2bd 100644 --- a/src/zope/interface/interface.py +++ b/src/zope/interface/interface.py @@ -97,6 +97,10 @@ class Element(object): @_use_c_impl class SpecificationBase(object): + __slots__ = ( + '_implied', + ) + def providedBy(self, ob): """Is the interface implemented by an object """ @@ -192,7 +196,7 @@ class Specification(SpecificationBase): raise KeyError(dependent) def __setBases(self, bases): - # Register ourselves as a dependent of our old bases + # Remove ourselves as a dependent of our old bases for b in self.__bases__: b.unsubscribe(self) |
