GitHub - daijro/turbobase64: Cython bindings for Turbo Base64

1 min read Original article ↗

Turbo Base64

PyPI AppVeyor

🚀 Lightning fast base64 encoding for Python

✨ Features

  • 20-30x faster than the standard library
  • Benchmarks faster than any other C base64 library
  • Fastest implementation of AVX, AVX2, and AVX512 base64 encoding
  • No other dependencies

⚡ How fast is it?

Graph generated from benchmark.py:


💻 Usage

This will automatically detect the fastest algorithm your CPU is capable of and use it.

Encoding

>>> turbob64.b64encode(b'Hello World!')
b'SGVsbG8gV29ybGQh'

Decoding

>>> turbob64.b64decode(b'SGVsbG8gV29ybGQh')
b'Hello World!'

Other Functions

Directly call CPU-specific algorithms

Memory efficient (small lookup tables) scalar but slower version

turbob64.b64senc(b'Hello World!')
turbob64.b64sdec(b'SGVsbG8gV29ybGQh')

Fast scalar

turbob64.b64xenc(b'Hello World!')
turbo64.b64xdec(b'SGVsbG8gV29ybGQh')

ssse3 SIMD

turbob64.b64v128enc(b'Hello World!')
turbob64.b64v128dec(b'SGVsbG8gV29ybGQh')

avx SIMD

turbob64.b64v128aenc(b'Hello World!')
turbob64.b64v128adec(b'SGVsbG8gV29ybGQh')

avx2 SIMD

turbob64.b64v256enc(b'Hello World!')
turbob64.b64v256dec(b'SGVsbG8gV29ybGQh')

avx2 SIMD (optimized for short strings)

turbob64.b64v256enc_short(b'Hello World!')
turbob64.b64v256dec_short(b'SGVsbG8gV29ybGQh')

avx512_vbmi SIMD

turbob64.b64v512enc(b'Hello World!')
turbob64.b64v512dec(b'SGVsbG8gV29ybGQh')