tools-python
tools-python copied to clipboard
Fix several accidentally quadratic functions
Fixes https://github.com/spdx/tools-python/issues/790
I am by no means a python expert, please let me know if there are more idiomatic ways to solve this.
After this change:
$ time pyspdxtools -i sbom.spdx.json
pyspdxtools -i sbom.spdx.json 1.57s user 0.06s system 95% cpu 1.708 total
Note that this document previously took almost 9 minutes to validate, so this is ~300x faster for that particular document.
cc @meretp
This patch grew out of the use of ntia-conformance-checker
. Thanks, @meretp, for helping with the transition to the new tools-python
version for ntia-conformance-checker
a few months back.
I've update the PR with changes from @paulgibert that seem better than what I came up with :)
@maxhbr or @meretp -- Any thoughts on this other approach?
Hey, maybe it would be worth to connect in a video call?
How would you feel about something like this instead? https://github.com/spdx/tools-python/pull/800
I suspect just changing those function signatures is probably not what we want to do (I assume it's a breaking change), but what if we kept the same signatures and introduced a parallel set of functions that takes a set instead of a list (list variant can just call set variant).