Code Monkey home page Code Monkey logo

extmap-on-mac's Introduction

License: GPL 3 CI

extmap

extmap is a very simple package that lets you build a read-only, constant database that maps Elisp symbols to almost arbitrary Elisp objects. The idea is to avoid preloading all data to memory and only retrieve it when needed.

This package doesn’t use any external programs, making it a suitable dependency for smaller libraries.

Typical workflow

Normally, map file should be created by package maintainer. On end-user machine, necessary values from this pregenerated file are retrieved. If only relatively few values are required, a lot of memory (and probably also CPU time) can be saved by not loading the whole available database into memory on the user machine.

For a usage example, refer to package datetime.

Creating a map

Creating disk maps doesn’t involve any additional tools and can be done from Elisp. Here is a trivial example:

(extmap-from-alist "mycool.extmap"
                   '((foo . 42)
                     (bar . (we (can (store [almost "anything"]))))))

By default, function refuses to work if the output file already exists. However, you can tell it to overwrite it instead:

(extmap-from-alist ... :overwrite t)

Using a map

Using a map is also easy. First, you need to initialize it:

(extmap-init "mycool.extmap")

Keep in mind that the file must exist for as long as you use the map: the whole point is that it loads missing data on-demand.

Now that you have map object, you can retrieve values from it:

(let ((extmap (extmap-init "mycool.extmap")))
  (extmap-get extmap 'bar))

You don’t need to care if a value is already in memory or not: the map will load it for you when necessary.

Other functions

All the functions in the package are documented within Emacs (the three demonstrated above also have more information). Here is just a full list:

  • Using maps:

    • extmap-init
    • extmap-get
    • extmap-contains-key
    • extmap-value-loaded
    • extmap-keys
    • extmap-mapc
    • extmap-mapcar
    • extmap-statistics
  • Creating maps:

    • extmap-from-alist
    • extmap-from-iterator

extmap-on-mac's People

Contributors

doublep avatar twlz0ne avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.