Repository navigation
perf: the value key holds its datatype's URI, so the garbage collector stops tracking a plain value's key - #704
Merged
Merged
Conversation
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 4 |
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.
…set of a plain value hold only atomic objects and the garbage collector stops tracking them (spec 5, 4.3) Every key held the datatype's QualifiedName in slot 0, which kept three tuples and three dicts per record tracked (13 GC-tracked objects per record against 3.2.3's 7). The hand-written rows of _value_key now return the URI string, read once into four constants, an int's through int_datatype, which holds the size rule canonical_xsd_datatype also uses, and Literal._key reads its datatype's URI. A name compares and hashes by its URI, so keys stay equal for equal values; a parametrised table pins each plain type against its Literal twin, the non-twins and the identifier and fallback rows.
…ws, with #670 left open (spec 5, 4.3) PR 28 built #690 with #670's derived table and then the hand-written rows with four URI constants; on a quiet machine the two forms measured the same, inside a 2.7-point noise floor, with 7.0 GC-tracked objects per record each, and the derived table cost more readability than it bought, so the maintainer chose #690 alone. Section 4.3 describes the chosen form, F14 records the measurement, and #670 moves to Out of scope.
…t the key holds and why the hand-written rows stayed (spec 5, 4.3) The pre-PR review found the spec's GC claim overstated for subclasses of plain types, F14's amended cell missing the reason the derived table lost, a docstring still naming the datatype where the key holds its URI, and twin-table assertions that hold for every row confined to the twin rows.
… the spec's #670 entry points at F14, and the twin test reuses its record (spec 5, 4.3) The pre-PR maintainability pass found the int32 and int64 bounds spelled in the bounds table and again as constants below it, section 10 restating F14's ruling, and the twin test building one record twice; each now has one home.
trungdong
force-pushed
the
perf/3.3.0-value-key
branch
from
October 29, 2026 11:08
e716818 to
cf3419c
Compare
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.
Makes every attribute value key hold its datatype's URI string instead of the datatype's
QualifiedName, so a record of plain values leaves the garbage collector as little to track as it did in 3.2.3. Closes #690.The value key is what attribute equality, record hashing and the per-attribute value set compare. Its slot 0 held the datatype's
QualifiedName, which kept three tuples and three dicts per record tracked by the garbage collector, 13 tracked objects per record against 3.2.3's 7._value_keykeeps its hand-written rows, and each plain row now returns the URI string, read once into four module constants; an int's row returnsint_datatype(value).uri, whereint_datatypeholds the size rule (xsd:int,xsd:longorxsd:integer) thatcanonical_xsd_datatypealso uses.Literal._keyreads its datatype's URI. For a value of an exact plain type the key and the value set then hold only atomic objects and CPython stops tracking them, which brings the count back to 7.0 per record.A name compares and hashes by its URI, so keys stay equal for equal values, and equality, hashing, the value set and unpickling are unchanged; a value set pickled by 3.2.3 rebuilds its keys on load as before.
test_a_plain_value_keys_as_its_twinpins each plain type against itsLiteraltwin, the non-twins of #235, #34 and #663, the subclass rows, and the identifier and fallback rows.One edge changes. A
Literalbuilt outside a record with a datatype that is not a qualified name, such as a bare string, now raisesAttributeErrorwhen hashed or compared, where 3.2.3 returned. Asserting such a literal on a record already raised in both, and the constructor's annotation admits only aQualifiedNameorNone. #705 proposes a clear error at construction.#670 proposed deriving the plain rows from the writers' table as well. That form was built and measured against this one. The two ran the same, and the derivation added a lookup map, a walk of a subclass's bases and an int fix-up to
_value_key, so spec 5's F14 is amended and #670 stays open.ab.py main --python 3.12 --passes 3on CPython 3.12.8, garbage collection off, on a quietened machine (load average 2.3; the head against itself moved no row by more than 3.4%):With
--gc, construction is −3.9%, the PROV-JSON read −2.7% and equality −3.6%. The benchmark document has one integer per block, so documents of one plain type were timed separately (3,000 entities of three attributes): integers −2.3%, strings −1.2%, floats −1.5%.There is no HISTORY entry, because the key of every value a record can hold is unchanged (spec 5, section 7).