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

Jason Madden noreply at github.com
Thu Jan 23 14:06:36 CET 2020


  Branch: refs/heads/master
  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.


  Commit: 5a6989c006f598ad61aa092c0bf2af1fc1dd3fc0
      https://github.com/zopefoundation/zope.interface/commit/5a6989c006f598ad61aa092c0bf2af1fc1dd3fc0
  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:
  -----------
  Merge pull request #154 from zopefoundation/c-opts-members

Use tp_members in SpecificationBase and ClassProvidesBase; stop using private undoc API


Compare: https://github.com/zopefoundation/zope.interface/compare/540401cee8cb...5a6989c006f5


More information about the checkins mailing list