memoize alternatives and similar packages
Based on the "Algorithms and Data structures" category.
Alternatively, view memoize alternatives based on common mentions on social networks and blogs.
-
exconstructor
An Elixir library for generating struct constructors that handle external data with ease. -
aja
Extension of the Elixir standard library focused on data stuctures, data manipulation and performance -
remodel
:necktie: An Elixir presenter package used to transform map structures. "ActiveModel::Serializer for Elixir" -
MapDiff
Calculates the difference between two (nested) maps, and returns a map representing the patch of changes. -
the_fuzz
String metrics and phonetic algorithms for Elixir (e.g. Dice/Sorensen, Hamming, Jaccard, Jaro, Jaro-Winkler, Levenshtein, Metaphone, N-Gram, NYSIIS, Overlap, Ratcliff/Obershelp, Refined NYSIIS, Refined Soundex, Soundex, Weighted Levenshtein) -
exmatrix
Elixir library implementing a parallel matrix multiplication algorithm and other utilities for working with matrices. Used for benchmarking computationally intensive concurrent code. -
Closure Table
Closure Table for Elixir - a simple solution for storing and manipulating complex hierarchies. -
bitmap
Bitmap implementation in Elixir using binaries and integers. Fast space efficient data structure for lookups -
paratize
Elixir library providing some handy parallel processing facilities that supports configuring number of workers and timeout.
SaaSHub - Software Alternatives and Reviews
![SaaSHub Logo SaaSHub Logo](https://cdn-b.libhunt.com/assets/partners/saashub-small-09b040e303cf50000aca670e1c77a15c64fc5c073fbdca2665ec2b8b621efc1a.png)
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of memoize or a related project?
Popular Comparisons
README
DefMemo
A memoization macro (defmemo) for Elixir.
Adapted from : (Gustavo Brunoro) https://gist.github.com/brunoro/6159378
I found Gustavo's Gist when looking at memoization and elixir and fixed it to work with version 1.0.x. Since then I've fixed a few of the problems with the original implementation:
will correctly memoize the results of functions with identical signatures but in different modules.
will work with 'when' guard clauses in function definitions. (That was fun!)
Added lots of lovely tests.
Usage
Add defmemo to your mix.exs file:
{:defmemo, "~> 0.1.0"}
And run:
mix deps.get
Before using a defmemo'd function (it's fine to define them), start_link must be called. e.g.
DefMemo.start_link
or you can add :defmemo into the applications section of your mix.exs:
[applications: [:logger, :defmemo]]
Example
defmodule FibMemo do
import DefMemo
defmemo fibs(0), do: 0
defmemo fibs(1), do: 1
defmemo fibs(n), do: fibs(n - 1) + fibs(n - 2)
def fib_10 do
fibs(10)
end
end
Performance
As you would expect for something like fibs, memoization provides dramatic performance improvements:
UNMEMOIZED VS MEMOIZED
***********************
fib (unmemoized)
function -> {result, running time(μs)}
==================================
fibs(30) -> {832040, 31089}
fibs(30) -> {832040, 31833}
FibMemo (memoized)
==================================
fibs(30) -> {832040, 79}
fibs(30) -> {832040, 3}
fibs(50) -> {12586269025, 103}
fibs(50) -> {12586269025, 3}
Note that these have also improved from version 0.1 to 0.1.1. The above numbers are on the low end of the spectrum with access ranging from 2 to 15 μs for me.
TODO
- Add test for supervisor crashing.
- Look at injecting the type of result table used.
- Better documentation.
- More tests (alwaaaays with the testing!)
Test with some biger data (e.g. for something like web crawling)
~~Supervisor ~~
Redis Based ResultTable - I've been playing with this - obviously there are limitations on type and it's slower than gen server but there are of course circumstances where it could be useful but for the most part its not a good "fit".