Speed up parsing by caching Stem.petals property

Merged
#160 · Created  · Last updated

Merged pull request

Merged in cached_petals (pull request #160)

00b4d70·Author: ·Closed by: ·2023-11-28

Description

The petal property does an inversion of the key_to_petal_dict, which can be (and often is) expensive. Currently we re-do this inversion a lot because the petal property (or it’s relative the bud property) is accessed many times during update_constants.

This PR greatly speeds up parsing by smartly caching the petals property. Basically, we know that petals will be identical given identical states of key_to_petal_dict, so we re-generate the petals iff key_to_petal_dict has been updated since the last time we accessed petals.

In my rough tests this change speeds up any Parse task by almost a factor of 4 (which makes sense because stem.bud was called 4 times in update_constants). Such speed!

 

Additionally, there was some minor cleanup of old logic flow in ParseDataBase.update_constants. I’ll leave some comments below where necessary.

0 attachments

0 comments

Loading commits...