[Checkins] [zopefoundation/zope.interface] 3cc593: Use tp_members in SpecificationBase and ClassProvi...

Jason Madden noreply at github.com
Wed Jan 22 16:32:20 CET 2020

  Branch: refs/heads/c-opts-members
  Home:   https://github.com/zopefoundation/zope.interface
  Commit: 3cc593ed15c08e09f47cd9a186bd1cd33c1cc148
  Author: Jason Madden <jamadden at gmail.com>
  Date:   2020-01-22 (Wed, 22 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