Skip to content

Support optional caching of rotated shapes to disk #27

@tmontes

Description

@tmontes

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.Base class 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 cache shape argument.
    • When given a callable, the implementation above would be used.
    • If given a str of path.Path it could take that as the file to be used for caching, taking care of the dirty work of setting and wiring it up. :)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions