[Checkins] [zopefoundation/zope.interface] ca9a0f: Use a descriptor for __module__

Jason Madden noreply at github.com
Wed Mar 11 19:43:04 CET 2020


  Branch: refs/heads/faster-eq-hash-comparison
  Home:   https://github.com/zopefoundation/zope.interface
  Commit: ca9a0f894b669e549a244de4f3cb8c9f8ab3be1b
      https://github.com/zopefoundation/zope.interface/commit/ca9a0f894b669e549a244de4f3cb8c9f8ab3be1b
  Author: Jason Madden <jamadden at gmail.com>
  Date:   2020-03-11 (Wed, 11 Mar 2020)

  Changed paths:
    M src/zope/interface/_compat.py
    M src/zope/interface/_zope_interface_coptimizations.c
    M src/zope/interface/interface.py
    M src/zope/interface/tests/test_registry.py

  Log Message:
  -----------
  Use a descriptor for __module__

This makes the rest of the attribute access fast again, but slows down
__module__.

+-------------------------------------------+------------+-------------------------------+
| Benchmark                                 | 38-master3 | 38-faster-descr               |
+===========================================+============+===============================+
| read __module__                           | 41.1 ns    | 123 ns: 2.99x slower (+199%)  |
+-------------------------------------------+------------+-------------------------------+
| read __name__                             | 41.3 ns    | 39.9 ns: 1.04x faster (-3%)   |
+-------------------------------------------+------------+-------------------------------+
| read __doc__                              | 41.8 ns    | 42.4 ns: 1.01x slower (+1%)   |
+-------------------------------------------+------------+-------------------------------+
| query adapter (no registrations)          | 3.85 ms    | 2.95 ms: 1.30x faster (-23%)  |
+-------------------------------------------+------------+-------------------------------+
| query adapter (all trivial registrations) | 4.59 ms    | 3.67 ms: 1.25x faster (-20%)  |
+-------------------------------------------+------------+-------------------------------+
| contains (empty dict)                     | 136 ns     | 54.8 ns: 2.48x faster (-60%)  |
+-------------------------------------------+------------+-------------------------------+
| contains (populated dict)                 | 137 ns     | 55.7 ns: 2.46x faster (-59%)  |
+-------------------------------------------+------------+-------------------------------+
| contains (populated list)                 | 40.2 us    | 2.86 us: 14.03x faster (-93%) |
+-------------------------------------------+------------+-------------------------------+

Not significant (1): read providedBy




More information about the checkins mailing list