Conversation
3ed561e to
005f5ad
Compare
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||||||||||||||||||||
005f5ad to
d689fe5
Compare
bact
requested changes
Feb 25, 2026
Reworks the way that SHACLObjects are constructed to use native python object properties to store the values instead of an array of IRIs. This allows the properties to be listed in `__slots__`, which improves the storage space required when there are a lot of these objects present. In order for this to work, the way that classes are defined is completely reworked. Now, instead of using the `@register` function, a custom metaclass is implemented for SHACLObject and the parameters for the class are dealt with in the `__new__()` constructor (instead of arguments to `@register`). Set the documented properties of SHACLObject for the parameters that a class can set. In real world testing with the SPDX 3 model, using slots for the objects resulted in a 24% reduction in both memory usage and load time for large documents. Usage of slots means that multiple inheritance is not supported; by default shacl2code will check if the model uses multiple inheritance and if not, slots will be enabled. This can be overridden with the --use-slots=(yes,no,auto) command line option.
d689fe5 to
754173d
Compare
bact
previously approved these changes
Feb 25, 2026
Collaborator
bact
left a comment
There was a problem hiding this comment.
LGTM. Two optional change suggestions to save few lookups.
Co-authored-by: Arthit Suriyawongkul <arthit@gmail.com>
Co-authored-by: Arthit Suriyawongkul <arthit@gmail.com>
bact
approved these changes
Feb 25, 2026
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.
Reworks the way that SHACLObjects are constructed to use native python object properties to store the values instead of an array of IRIs. This allows the properties to be listed in
__slots__, which improves the storage space required when there are a lot of these objects present.In order for this to work, the way that classes are defined is completely reworked. Now, instead of using the
@registerfunction, a custom metaclass is implemented for SHACLObject and the parameters for the class are dealt with in the__new__()constructor (instead of arguments to@register). Set the documented properties of SHACLObject for the parameters that a class can set.In real world testing with the SPDX 3 model, using slots for the objects resulted in a 24% reduction in both memory usage and load time for large documents.
Usage of slots means that multiple inheritance is not supported; by default shacl2code will check if the model uses multiple inheritance and if not, slots will be enabled. This can be overridden with the --use-slots=(yes,no,auto) command line option.