Damerau Levenshtein implementation with Pyo3

Hi there! I'm in the process of learning Rust, and it is amazing!
In my first project, I try to implement the Damerau Levenshtein as a python package with Pyo3. The first tests are working. However, compared to the C implementation, my Rust code runs 90% slower. Furthermore, I don't know how I can make the arguments generic to all types of objects (Compare the C implementation). Currently, my code only compares Integer lists.

My request: Is there someone who can review my code and may suggest improvements to boost the runtime?
Thank you!

Edit: I know that there are a lot of crates that already implement the dl distance. However, I want to compare list of objects and not only strings.

Commenting without looking at the code yet ..

The two most popular replies to "Why doesn't my Rust code run as fast as X?" are:

  1. Did you build/run a release build? (using the --release flag)
  2. Indexing in Rust causes bounds checks. If you can express an iteration over an array/vector using an actual iterator you may be able to avoid those bound checks.

Thanks mate! Now, the rust implementation is 4 times faster!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.