-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Milestone
Description
Facts
- Bitmap shapes support rotation.
- Rotated variations of the source image are computed.
- Such computation is not fast, especially when no 3rd-party libraries are installed.
- They are cached in RAM for the lifetime of the running process.
- New processes have to recompute everything: potentially slow and wasteful.
Thoughts
- Adding support for optional caching of such computed images to disk may be valuable for some use cases.
Implementation idea
- The shape could be given a "cache object factory" callable, defaulting to
dict. - Such factory would create a mutable mapping object that the
shape.Baseclass would use.
This could be enough, I suppose. With this, simple disk-based caching could be achieved by passing one of the classes in the shelve Standard Library, for example.
Extra
- One or more custom mutable mappings and their factories could be included.
- One such custom mapping could even support having everything bundled with the code itself: no external disk-based dependencies.
- An alternative, very easy to use API could be made available too:
- Maybe the above mentioned "cache object factory" would be passed to a
cacheshape argument. - When given a callable, the implementation above would be used.
- If given a
strofpath.Pathit could take that as the file to be used for caching, taking care of the dirty work of setting and wiring it up. :)
- Maybe the above mentioned "cache object factory" would be passed to a