summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* Fix interface definitions of IAdapterRegistry.subscribe, subscribers and ↵issue208Jason Madden2020-04-234-79/+122
| | | | | | | | subscriptions. They were defined to accept a name argument, but the actual implementation doesn't. Add tests for this. Fixes #208. Also in test_adapter.py modernize idioms from assertTrue(x in y) and assertTrue(x is y) to assertIn and assertIs.
* Back to development: 5.1.1Jason Madden2020-04-082-1/+7
|
* Preparing release 5.1.05.1.0Jason Madden2020-04-082-2/+2
|
* Merge pull request #203 from zopefoundation/issue199Jason Madden2020-04-086-155/+265
|\ | | | | Make @implementer and classImplements not add redundant interfaces
| * Fix implementerOnly when duplicating something inherited from the parent.issue199Jason Madden2020-04-072-79/+89
| | | | | | | | | | | | Seen in plone.app.testing as a problem in Products.GenericSetup. Added tests for that.
| * Special case the base Interface in @implementer/classImplements to skip the ↵Jason Madden2020-04-074-11/+44
| | | | | | | | redundancy detection for the sake of plone.app.caching.
| * Make @implementer and classImplements not re-declare redundant interfaces.Jason Madden2020-04-074-97/+164
| | | | | | | | classImplementsOnly and @implementer_only can still be used to do that.
* | Merge pull request #205 from zopefoundation/issue204Jason Madden2020-04-073-6/+45
|\ \ | | | | | | The ImmutableDeclaration also has immutable _v_attrs.
| * | The ImmutableDeclaration also has immutable _v_attrs.issue204Jason Madden2020-04-073-6/+45
| |/ | | | | | | Fixes #204
* | Merge pull request #206 from zopefoundation/issue3_minor_cleanupJason Madden2020-04-071-2/+11
|\ \ | |/ |/| Minor cleanup of #202.
| * Minor cleanup of #202.issue3_minor_cleanupJason Madden2020-04-071-2/+11
|/ | | | See https://github.com/zopefoundation/zope.interface/pull/202#pullrequestreview-389126705
* Merge pull request #202 from zopefoundation/issue3Jason Madden2020-04-0712-111/+626
|\ | | | | Let interfaces override __adapt__
| * Feedback from review: whitespace, doc clarification, and a unit test showing ↵Jason Madden2020-04-075-24/+86
| | | | | | | | the precedence of __conform__ vs __adapt__.
| * Let interface 'subclasses' override __adapt__.issue3Jason Madden2020-04-0611-65/+373
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Cooperate with InterfaceClass to ensure there is no performance penalty for this. Fixes #3 +-------------------------------------------------------------+----------------+------------------------------+------------------------------+ | Benchmark | bench_master38 | bench_issue3 | bench_issue3_opt | +=============================================================+================+==============================+==============================+ | call interface (provides; deep) | 369 ns | 454 ns: 1.23x slower (+23%) | not significant | +-------------------------------------------------------------+----------------+------------------------------+------------------------------+ | call interface (provides; wide) | 373 ns | 457 ns: 1.22x slower (+22%) | 365 ns: 1.02x faster (-2%) | +-------------------------------------------------------------+----------------+------------------------------+------------------------------+ | call interface (no alternate, no conform, not provided) | 671 ns | 760 ns: 1.13x slower (+13%) | 636 ns: 1.06x faster (-5%) | +-------------------------------------------------------------+----------------+------------------------------+------------------------------+ | call interface (alternate, no conform, not provided) | 395 ns | 494 ns: 1.25x slower (+25%) | not significant | +-------------------------------------------------------------+----------------+------------------------------+------------------------------+ | call interface (no alternate, valid conform, not provided) | 250 ns | not significant | 227 ns: 1.10x faster (-9%) | +-------------------------------------------------------------+----------------+------------------------------+------------------------------+ | call interface (alternate, invalid conform, not provided) | 348 ns | 424 ns: 1.22x slower (+22%) | not significant | +-------------------------------------------------------------+----------------+------------------------------+------------------------------+
| * Add documentation for taggedValue and invariant.Jason Madden2020-04-063-0/+74
| |
| * Add more cross refs to documentation and fix a couple sphinx warnings about ↵Jason Madden2020-04-063-44/+115
|/ | | | duplicates in the index.
* Merge pull request #201 from zopefoundation/issue200Jason Madden2020-04-069-200/+525
|\ | | | | Remove the bare except: statements.
| * More micro benchmarks.issue200Jason Madden2020-04-021-2/+116
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Comparing to current master, there is no substantial difference. +-------------------------------------------------------------+----------------+------------------------------+ | Benchmark | bench_master38 | bench_issue200 | +=============================================================+================+==============================+ | call interface (alternate, no conform, not provided) | 395 ns | 414 ns: 1.05x slower (+5%) | +-------------------------------------------------------------+----------------+------------------------------+ | call interface (no alternate, valid conform, not provided) | 250 ns | 240 ns: 1.04x faster (-4%) | +-------------------------------------------------------------+----------------+------------------------------+ | read __module__ | 45.3 ns | 43.4 ns: 1.04x faster (-4%) | +-------------------------------------------------------------+----------------+------------------------------+ | query adapter (no registrations) | 3.23 ms | 3.31 ms: 1.02x slower (+2%) | +-------------------------------------------------------------+----------------+------------------------------+ | query adapter (all trivial registrations) | 3.93 ms | 4.40 ms: 1.12x slower (+12%) | +-------------------------------------------------------------+----------------+------------------------------+ | query adapter (all trivial registrations, wide inheritance) | 43.3 us | 45.5 us: 1.05x slower (+5%) | +-------------------------------------------------------------+----------------+------------------------------+ | query adapter (all trivial registrations, deep inheritance) | 43.2 us | 46.9 us: 1.09x slower (+9%) | +-------------------------------------------------------------+----------------+------------------------------+ | sort mixed | 361 us | 354 us: 1.02x faster (-2%) | +-------------------------------------------------------------+----------------+------------------------------+ | contains (populated dict: interfaces) | 61.3 ns | 59.7 ns: 1.03x faster (-3%) | +-------------------------------------------------------------+----------------+------------------------------+ Not significant (13): call interface (provides; deep); call interface (provides; wide); call interface (no alternate, no conform, not provided); call interface (alternate, invalid conform, not provided); read __name__; read __doc__; read providedBy; sort interfaces; sort implementedBy; contains (empty dict); contains (populated list: interfaces); contains (populated dict: implementedBy); contains (populated list: implementedBy)
| * MS VS stuck on c89 strikes again.Jason Madden2020-04-021-1/+1
| |
| * Remove the bare except: statements.Jason Madden2020-04-028-197/+408
|/ | | | | | | | Only catch AttributeError instead of everything. Fixes #200 Note that this does break a doctest in five.intid (it's expecting a TypeError but it now gets Acquisition's RuntimeError).
* Back to development: 5.0.3Jason Madden2020-03-302-1/+7
|
* Preparing release 5.0.25.0.2Jason Madden2020-03-302-2/+2
|
* Merge pull request #198 from zopefoundation/issue197Jason Madden2020-03-304-13/+60
|\ | | | | Ensure that objects that implement no interfaces still have Interface in iro and sro
| * Ensure that objects that implement no interfaces still have Interface in ↵Jason Madden2020-03-304-13/+60
|/ | | | | | their iro and sro. Fixes #197.
* Back to development: 5.0.2Jason Madden2020-03-212-1/+7
|
* Preparing release 5.0.15.0.1Jason Madden2020-03-212-2/+2
|
* Merge pull request #195 from zopefoundation/issue192-issue194Jason Madden2020-03-219-27/+94
|\ | | | | Make the RO for InterfaceClass consistent and fix handling of the STRICT_IRO
| * Make the RO for InterfaceClass consistent and fix handling of the STRICT_IRO ↵issue192-issue194Jason Madden2020-03-209-27/+94
|/ | | | | | | | env variable. Fixes #192 and fixes #194. Also fix the IRO for OrderedDict on CPython 2
* Back to development: 5.0.1Jason Madden2020-03-192-1/+7
|
* Preparing release 5.0.05.0.0Jason Madden2020-03-192-2/+2
|
* Merge branch 'faster-eq-hash-comparison'Jason Madden2020-03-1917-292/+1169
|\
| * Another comment update, referencing #163Jason Madden2020-03-191-2/+7
| |
| * Update comments and add a test for more coverage.Jason Madden2020-03-196-54/+108
| |
| * Remove untested except in the metaclass __new__.faster-eq-hash-comparisonJason Madden2020-03-181-7/+5
| | | | | | | | Reviewers weren't sure how it could be raised.
| * Add additional tests for assigning to Interface.__module__.Jason Madden2020-03-182-6/+7
| |
| * Add tests for comparing InterfaceClass/Implements objects to things without ↵Jason Madden2020-03-185-14/+159
| | | | | | | | | | | | the required attributes. And fix the C handling of this case.
| * Several small tweaks to GC and deletion handling.Jason Madden2020-03-181-5/+11
| | | | | | | | Several places needed to, essentially, call super.
| * Move to a metaclass for handling __module__.Jason Madden2020-03-182-71/+203
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This offers the absolute best performance at what seems like reasonable complexity. +-------------------------------------------------------------+----------------+-------------------------------+ | Benchmark | 38-master-full | 38-faster-meta | +=============================================================+================+===============================+ | read __module__ | 41.8 ns | 40.9 ns: 1.02x faster (-2%) | +-------------------------------------------------------------+----------------+-------------------------------+ | read __name__ | 41.8 ns | 39.9 ns: 1.05x faster (-5%) | +-------------------------------------------------------------+----------------+-------------------------------+ | read providedBy | 56.9 ns | 58.4 ns: 1.03x slower (+3%) | +-------------------------------------------------------------+----------------+-------------------------------+ | query adapter (no registrations) | 3.85 ms | 2.95 ms: 1.31x faster (-24%) | +-------------------------------------------------------------+----------------+-------------------------------+ | query adapter (all trivial registrations) | 4.62 ms | 3.63 ms: 1.27x faster (-21%) | +-------------------------------------------------------------+----------------+-------------------------------+ | query adapter (all trivial registrations, wide inheritance) | 51.8 us | 42.2 us: 1.23x faster (-19%) | +-------------------------------------------------------------+----------------+-------------------------------+ | query adapter (all trivial registrations, deep inheritance) | 52.0 us | 41.7 us: 1.25x faster (-20%) | +-------------------------------------------------------------+----------------+-------------------------------+ | sort interfaces | 234 us | 29.9 us: 7.84x faster (-87%) | +-------------------------------------------------------------+----------------+-------------------------------+ | sort mixed | 569 us | 340 us: 1.67x faster (-40%) | +-------------------------------------------------------------+----------------+-------------------------------+ | contains (empty dict) | 135 ns | 55.2 ns: 2.44x faster (-59%) | +-------------------------------------------------------------+----------------+-------------------------------+ | contains (populated dict: interfaces) | 137 ns | 56.1 ns: 2.45x faster (-59%) | +-------------------------------------------------------------+----------------+-------------------------------+ | contains (populated list: interfaces) | 39.7 us | 2.96 us: 13.42x faster (-93%) | +-------------------------------------------------------------+----------------+-------------------------------+ | contains (populated dict: implementedBy) | 137 ns | 55.2 ns: 2.48x faster (-60%) | +-------------------------------------------------------------+----------------+-------------------------------+ | contains (populated list: implementedBy) | 40.6 us | 24.1 us: 1.68x faster (-41%) | +-------------------------------------------------------------+----------------+-------------------------------+ Not significant (2): read __doc__; sort implementedBy
| * Use a descriptor for __module__Jason Madden2020-03-184-48/+83
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * Avoid use of a metaclass by implementeng __getattribute__.Jason Madden2020-03-185-213/+270
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is pretty, but it slows down all attribute access to interfaces. By up to 25%. I'm not sure that's acceptable for things like Interface.providedBy. +-------------------------------------------+------------+-------------------------------+ | Benchmark | 38-master3 | 38-faster3 | +===========================================+============+===============================+ | read __module__ | 41.1 ns | 44.3 ns: 1.08x slower (+8%) | +-------------------------------------------+------------+-------------------------------+ | read __name__ | 41.3 ns | 51.6 ns: 1.25x slower (+25%) | +-------------------------------------------+------------+-------------------------------+ | read __doc__ | 41.8 ns | 53.3 ns: 1.28x slower (+28%) | +-------------------------------------------+------------+-------------------------------+ | read providedBy | 56.7 ns | 71.6 ns: 1.26x slower (+26%) | +-------------------------------------------+------------+-------------------------------+ | query adapter (no registrations) | 3.85 ms | 2.95 ms: 1.31x faster (-23%) | +-------------------------------------------+------------+-------------------------------+ | query adapter (all trivial registrations) | 4.59 ms | 3.65 ms: 1.26x faster (-20%) | +-------------------------------------------+------------+-------------------------------+ | contains (empty dict) | 136 ns | 55.4 ns: 2.45x faster (-59%) | +-------------------------------------------+------------+-------------------------------+ | contains (populated dict) | 137 ns | 55.0 ns: 2.49x faster (-60%) | +-------------------------------------------+------------+-------------------------------+ | contains (populated list) | 40.2 us | 2.95 us: 13.62x faster (-93%) | +-------------------------------------------+------------+-------------------------------+
| * Fix tests when zope.component is also importable.Jason Madden2020-03-182-1/+24
| |
| * Clean up linter errors in test_interface.py so new/real problems are more ↵Jason Madden2020-03-181-41/+52
| | | | | | | | obvious.
| * Benchmarks looking up adapters from components.Jason Madden2020-03-181-2/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Current results (this branch vs master, 354faccebd5b612a2ac8e081a7e5d2f7fb1089c1): | Benchmark | 38-master | 38-faster | |-------------------------------------------|-----------|-------------------------------| | query adapter (no registrations) | 3.81 ms | 3.03 ms: 1.26x faster (-20%) | | query adapter (all trivial registrations) | 4.65 ms | 3.90 ms: 1.19x faster (-16%) | | contains (empty dict) | 163 ns | 76.1 ns: 2.14x faster (-53%) | | contains (populated dict) | 162 ns | 76.9 ns: 2.11x faster (-53%) | | contains (populated list) | 40.3 us | 3.09 us: 13.04x faster (-92%) | Also need benchmarks using inheritance. The 'implied' data structures are also hash/equality based.
| * Fix doctest by making sure the default type repr can be used.Jason Madden2020-03-181-2/+16
| |
| * Move Interface hashing and comparison to C; 2.5 to 15x speedup in micro ↵Jason Madden2020-03-186-74/+361
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | benchmarks Included benchmark numbers: Current master, Python 3.8: ..................... contains (empty dict): Mean +- std dev: 198 ns +- 5 ns ..................... contains (populated dict): Mean +- std dev: 197 ns +- 6 ns ..................... contains (populated list): Mean +- std dev: 53.1 us +- 1.2 us This code: ..................... contains (empty dict): Mean +- std dev: 77.9 ns +- 2.3 ns ..................... contains (populated dict): Mean +- std dev: 78.4 ns +- 3.1 ns ..................... contains (populated list): Mean +- std dev: 3.69 us +- 0.08 us So anywhere from 2.5 to 15x faster. Not sure how that will translate to larger benchmarks, but I'm hopeful. It turns out that messing with ``__module__`` is nasty, tricky business, especially when you do it from C. Everytime you define a new subclass, the descriptors that you set get overridden by the type machinery (PyType_Ready). I'm using a data descriptor and a meta class right now to avoid that but I'm not super happy with that and would like to find a better way. (At least, maybe the data part of the descriptor isn't necessary?) It may be needed to move more code into C, I don't want a slowdown accessing ``__module__`` either; copying around the standard PyGetSet or PyMember descriptors isn't enough because they don't work on the class object (so ``classImplements(InterfaceClass, IInterface)`` fails).
| * Merge pull request #188 from zopefoundation/issue8Jason Madden2020-03-187-44/+224
| |\ | | | | | | Ensure Interface is the last item in the __sro__.
| | * Move the one-base optimization down a level, and enable using pre-calculated ↵Jason Madden2020-03-183-33/+84
| |/ |/| | | | | | | | | | | | | __sro__ for caching. In my local 'load the world' test, this went from ~7800 full C3 merges to about ~1100. Also take steps to avoid triggering false positive warnings about changed ROs when it's *just* Interface that moved.
* | Ensure Interface is the last item in the __sro__.Jason Madden2020-03-185-25/+154
|/ | | | | | None of the elegant solutions mentioned in the issue worked out, so I had to brute force it. Fixes #8
* Merge pull request #189 from zopefoundation/issue136-issue134Jason Madden2020-03-182-141/+151
|\ | | | | Documentation clarifications.
| * Documentation clarifications.issue136-issue134Jason Madden2020-03-172-141/+151
| | | | | | | | | | | | | | | | | | - docs/adapter.rst Subscriptions are returned from least to most specific, not the other way around; the docs were incorrect. Add additional examples, and use more verbose names in current examples, to clarify this. Fixes #136. - interfaces.py names() and namesAndDescriptions() just return a collection, not a sequence. Fixes #134.