linkml / linkml-runtime

Runtime support for linkml generated models
https://linkml.io/linkml/
Creative Commons Zero v1.0 Universal
24 stars 23 forks source link

[perf] swap out bool with `is None` in `induced_slot` #331

Closed sneakers-the-rat closed 1 month ago

sneakers-the-rat commented 1 month ago

More free perf!

Since the iteration over all the metaslots happens so many times, it turns out that the time in JsonObj.__bool__ is actually appreciable. A simple swap out with is None gives us a 137% perf boost for free :)

lots more perf to be had in this method in a fuller refactor but wanted to get this one in here since it's so uncontroversial, should be quick review

before (__bool__ in pink):

Screenshot 2024-07-23 at 8 52 20 PM

after (__bool__ not present anymore):

Screenshot 2024-07-23 at 9 06 56 PM