[Checkins] [zopefoundation/zope.interface] ddf670: Use tp_members in SpecificationBase and ClassProvi...
Jason Madden
noreply at github.com
Thu Jan 23 13:39:55 CET 2020
Branch: refs/heads/c-opts-members
Home: https://github.com/zopefoundation/zope.interface
Commit: ddf670afb792b7f7849d6383f31cac3273811edf
https://github.com/zopefoundation/zope.interface/commit/ddf670afb792b7f7849d6383f31cac3273811edf
Author: Jason Madden <jamadden at gmail.com>
Date: 2020-01-23 (Thu, 23 Jan 2020)
Changed paths:
M CHANGES.rst
M src/zope/interface/_zope_interface_coptimizations.c
M src/zope/interface/declarations.py
M src/zope/interface/interface.py
M src/zope/interface/tests/test_declarations.py
Log Message:
-----------
Use tp_members in SpecificationBase and ClassProvidesBase.
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.
More information about the checkins
mailing list