Repository navigation
MetaClasses: keep a class' slot initial values of its whole hierarchy - #553
Merged
Merged
Conversation
_wrapInitMethodIfSlotDefaults walked the whole MRO of every class to collect the initial values of slotted fields, also in hierarchies without any. Each class now keeps them in __allSlotDefaults__, merged from its direct base-classes' mappings and its own __slotDefaults__, and returns right away if the mapping is empty. The wrapper's semantics are unchanged. Co-Authored-By: Patrick Lehmann <Paebbels@gmail.com>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
This was referenced Oct 12, 2026
Merged
Merged
Merged
Merged
This was referenced Oct 20, 2026
Merged
Merged
Merged
Merged
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
ExtendedType._wrapInitMethodIfSlotDefaults(MetaClasses: assign a slotted field's initial value in an intermediate __init__ #524, MetaClasses: assign slot initial values without probing each field #544) walked the whole method resolution order of every newclass to collect the initial values of slotted fields, also in hierarchies without any. Each class now keeps them in
the class field
__allSlotDefaults__, merged from its direct base-classes' mappings and its own__slotDefaults__,and returns right away when the mapping is empty.
any
__init__runs, a mixin-class' field in a class without slots goes to__dict__, a derived class wraps thebase-class' original
__init__.__allSlotDefaults__is listed inExtendedType's field list.Measurements
Only the changed step,
PYTHONPATHpinned to each checkout,taskset -c 6:_wrapInitMethodIfSlotDefaults, leaf class with an MRO of 14, no initial valuesDuring pyVHDLModel's import (412 classes, none with initial values; Python 3.13), the step takes 0.57 ms instead of
0.87 ms. That is about 1 % of the time spent in
ExtendedType.__new__, below the run-to-run noise of the whole import.Documentation
doc/News.rst: the unreleased MetaClasses: assign a slotted field's initial value in an intermediate __init__ #524 entry names__allSlotDefaults__.Unit Tests
tests/unit/MetaClasses/ObjectVariable.py:__allSlotDefaults__of a mixin-class, an intermediate class and aclass mixing both; a hierarchy without initial values keeps its own
__init__.tests/unit: 2521 passed, 31 skipped, 3 xfailed.Related Issues and Pull-Requests