-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cache filtering by font #64
Comments
This should probably be done in all of the filtering functions that operate of immutable properties (i.e., fonts, text, pages). Also, maybe using https://docs.python.org/3/library/functools.html#functools.lru_cache would be a good idea. |
@pauloAmaral Hmm, the problem with e.g. caching by text is that there are so many possible inputs. The reason I was thinking about fonts was that there is a very limited set of fonts for each document. I don't think it'd be as simple as using I was thinking of having an I think the set operation should be quite quick. Obviously it does mean that in some cases you'd be considering all the elements in the document even when your element list is tiny, but I do this it's probably a lot quicker than checking all the elements manually in each case. What do you think? Perhaps I'm overcomplicating it somehow, but I don't see how it would really work for text etc. How do you envisage it working for e.g. text? Additionally, I think it doesn't make sense for |
I think I agree with both your points:
|
Filtering by font occurs frequently, and involves checking the font of each element.
It could be worth caching the filtered elements for each font somewhere on the document. This shouldn't be done at load, only when the function for each font is called.
The text was updated successfully, but these errors were encountered: