simdutf

Nim bindings to simdutf

Pure Nim score 15/100 · tests present · no docs generated

Summary

Latest Version 6.5.12
License Apache-2.0
CI Status Failing
Downloads 0
Last Indexed 2026-07-21 05:26

Authors

  • xTrayambak

Installation

nimble install simdutf
choosenim install simdutf
git clone https://github.com/ferus-web/simdutf

OS Compatibility

Platform Linux macOS Windows FreeBSD OpenBSD NetBSD Android iOS WASM Embedded
simdutf - - - - - - -

Dependencies

Package Version Optional
nim >= 2.0.0 No
results >= 0.5.0 No

Source

Repository https://github.com/ferus-web/simdutf
Homepage https://github.com/ferus-web/simdutf
Registry Source nimble_official

README

WARNING: This package is deprecated, and is known to be have certain performance issues. Do not use it!

High-level wrapper over simdutf

This package provides a nice little interface over simdutf, a fast, cross-architecture SIMD accelerated library for base64 encoding and decoding alongside encoding validation and conversion.

The low level bindings are present in simdutf/bindings, but do not use them unless you know what you're doing. The high level wrapper is memory safe* as it validates all allocations to be of the correct sizes to prevent buffer overflows.

How fast is it?

Here's a benchmark to show that. (Run this for yourselves with nimble benchmark)

Device: Laptop \ CPU: AMD Ryzen 5 5600H @ 4.20Ghz with 12 cores \ RAM: 16 GB of DDR4 @ 3200 MT/s + 24GB of swap (not used in this benchmark)

$ nimble benchmark
> generating sentences ...
> sentences generated; may the most optimized win
   min time    avg time  std dv   runs name
   0.337 ms    0.373 ms  ±0.016  x1000 encode 1000 strings (simdutf)
   2.741 ms    2.825 ms  ±0.039  x1000 encode 1000 strings (std/base64)

Real-World Usage

  • bali, a JavaScript engine written in Nim

This will hopefully soon fully replace std/base64 from the entirity of the Ferus' web engine's stack.

Usage (Base64)

The API is almost the same as std/base64.

import simdutf/base64

for i, name in [
    "Joseph",
    "Andreas",
    "James",
    "Thomas",
    "Monika",
    "Prateek",
    "Ahmad",
    "Anton",
]:
  echo name.encode(urlSafe = (i mod 2) == 0) # We support URL safe encoding too

Usage (Unicode)

The unicode wrapper is still very much a work-in-progress. Most of the functions in the unicode module aren't wrapped yet. Feel free to send PRs, though :)

import simdutf/unicode

assert validateUtf8("Hello simdutf!")
assert validateAscii("This is ascii, isn't it?")
assert validateUtf16("你好,世界")
assert validateUtf32("")