wietsedv / dtw-numba

A faster Python DTW library with no precompiled code

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

dtw-numba

Warning

Work in progress. Just copy and inspect code from dtw_numba/__init__.py if you want to use it. Feel free to give feedback by writing an issue.

Another dynamic time warping (DTW) implementation, but this one is actually simple and fast. Unlike the alternatives, this library is written in Python with just Numpy and Numba. No overcomplicated and unreadable compiled C or Rust code in here, but better performance anyway.

In my experience, the best performing Python DTW implementation for high-dimensional data is dtw-python. dtw-numba aims to be compatible with dtw-python, and functionality and performance is tested against it. Please write an issue with your own benchmark results if you disagree.

The current implementation is minimal, but equivalent to dtw-python distance with default arguments. But speed is (depending on dimensionality) 20 to 300 times as fast.

Context

Python is slow, even with Numpy. Everything that needs to be fast is written in C, C++ or Rust, but I dislike that for various performance, debugging, transparancy and development reasons. Mojo should solve these issues, but it is in early development. I will write a Mojo DTW package, but before that I wrote/am writing this Numba version as a baseline.

My idea was that I would write a simple Numba implementation that would probably not be faster than the "optimized" low-level libraries, and then port it to Mojo for better performance. Turns out my implementation is faster than these other libraries. Numba has its own problems, but it does not fail to deliver performance on simple algorithms like DTW.

Benchmarks

Will be added later.

About

A faster Python DTW library with no precompiled code

License:Apache License 2.0


Languages

Language:Python 100.0%