All Projects → mayeut → pybase64

mayeut / pybase64

Licence: BSD-2-Clause license
Fast Base64 encoding/decoding in Python

Programming Languages

python
139335 projects - #7 most used programming language
c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to pybase64

Base64 Avx512
Code for paper "Base64 encoding and decoding at almost the speed of a memory copy"
Stars: ✭ 158 (+88.1%)
Mutual labels:  base64, simd
Base64simd
Base64 coding and decoding with SIMD instructions (SSE/AVX2/AVX512F/AVX512BW/AVX512VBMI/ARM Neon)
Stars: ✭ 115 (+36.9%)
Mutual labels:  base64, simd
fast-base64
Fastest base64 on the web, with Wasm + SIMD
Stars: ✭ 23 (-72.62%)
Mutual labels:  base64, simd
Base64
Base64 encoding / decoding with SIMD-support, also base64Url
Stars: ✭ 44 (-47.62%)
Mutual labels:  base64, simd
dcurl
Hardware-accelerated Multi-threaded IOTA PoW, drop-in replacement for ccurl
Stars: ✭ 39 (-53.57%)
Mutual labels:  simd
simdutf8
SIMD-accelerated UTF-8 validation for Rust.
Stars: ✭ 426 (+407.14%)
Mutual labels:  simd
cpuwhat
Nim utilities for advanced CPU operations: CPU identification, ISA extension detection, bindings to assorted intrinsics
Stars: ✭ 25 (-70.24%)
Mutual labels:  simd
simdjson-rust
Rust bindings for the simdjson project.
Stars: ✭ 59 (-29.76%)
Mutual labels:  simd
frp
FRP: Fast Random Projections
Stars: ✭ 40 (-52.38%)
Mutual labels:  simd
FFmpegPlayer
Simple FFmpeg video player
Stars: ✭ 72 (-14.29%)
Mutual labels:  simd
data-encoding
Efficient and customizable data-encoding functions in Rust
Stars: ✭ 92 (+9.52%)
Mutual labels:  base64
go-checksum
Simple tool to calc Golang module checksum of go.mod and module dir.
Stars: ✭ 45 (-46.43%)
Mutual labels:  base64
vue-base64-file-upload
Upload files as base64 data-uris
Stars: ✭ 77 (-8.33%)
Mutual labels:  base64
parcel-plugin-url-loader
📦url loader for parcel, use base64 encode file
Stars: ✭ 24 (-71.43%)
Mutual labels:  base64
heyoka
C++ library for ODE integration via Taylor's method and LLVM
Stars: ✭ 151 (+79.76%)
Mutual labels:  simd
fecpp
Forward error correction with SIMD optimizations
Stars: ✭ 79 (-5.95%)
Mutual labels:  simd
zig-gamedev
Building game development ecosystem for @ziglang!
Stars: ✭ 1,059 (+1160.71%)
Mutual labels:  simd
ImageSms
Image SMS uses long text SMS to send a very small picture.
Stars: ✭ 24 (-71.43%)
Mutual labels:  base64
react-file-input-previews-base64
This package provides an easy to use, ready to go and customizable wrapper around file input, with option for image previews and returning file as base64 string.
Stars: ✭ 15 (-82.14%)
Mutual labels:  base64
glm
OpenGL Mathematics (GLM)
Stars: ✭ 6,667 (+7836.9%)
Mutual labels:  simd

Fast Base64 implementation

license-status pypi-status python-versions Documentation Status gha-status codecov-status

This project is a wrapper on libbase64.

It aims to provide a fast base64 implementation for base64 encoding/decoding.

Installation

pip install pybase64

Usage

pybase64 uses the same API as Python base64 "modern interface" (introduced in Python 2.4) for an easy integration.

To get the fastest decoding, it is recommended to use the pybase64.b64decode and validate=True when possible.

import pybase64

print(pybase64.b64encode(b'>>>foo???', altchars='_:'))
# b'Pj4_Zm9vPz8:'
print(pybase64.b64decode(b'Pj4_Zm9vPz8:', altchars='_:', validate=True))
# b'>>>foo???'

# Standard encoding helpers
print(pybase64.standard_b64encode(b'>>>foo???'))
# b'Pj4+Zm9vPz8/'
print(pybase64.standard_b64decode(b'Pj4+Zm9vPz8/'))
# b'>>>foo???'

# URL safe encoding helpers
print(pybase64.urlsafe_b64encode(b'>>>foo???'))
# b'Pj4-Zm9vPz8_'
print(pybase64.urlsafe_b64decode(b'Pj4-Zm9vPz8_'))
# b'>>>foo???'

A command-line tool is also provided. It has encode, decode and benchmark subcommands.

usage: pybase64 [-h] [-V] {benchmark,encode,decode} ...

pybase64 command-line tool.

positional arguments:
  {benchmark,encode,decode}
                        tool help
    benchmark           -h for usage
    encode              -h for usage
    decode              -h for usage

optional arguments:
  -h, --help            show this help message and exit
  -V, --version         show program's version number and exit

Full documentation on Read the Docs.

Benchmark

Running Python 3.7.2, Apple LLVM version 10.0.0 (clang-1000.11.45.5), Mac OS X 10.14.2 on an Intel Core i7-4870HQ @ 2.50GHz

pybase64 0.5.0 (C extension active - AVX2)
bench: altchars=None, validate=False
pybase64._pybase64.encodebytes:   1734.776 MB/s (13,271,472 bytes -> 17,928,129 bytes)
pybase64._pybase64.b64encode:     4039.539 MB/s (13,271,472 bytes -> 17,695,296 bytes)
pybase64._pybase64.b64decode:     1854.423 MB/s (17,695,296 bytes -> 13,271,472 bytes)
base64.encodebytes:                 78.352 MB/s (13,271,472 bytes -> 17,928,129 bytes)
base64.b64encode:                  539.840 MB/s (13,271,472 bytes -> 17,695,296 bytes)
base64.b64decode:                  287.826 MB/s (17,695,296 bytes -> 13,271,472 bytes)
bench: altchars=None, validate=True
pybase64._pybase64.b64encode:     4156.607 MB/s (13,271,472 bytes -> 17,695,296 bytes)
pybase64._pybase64.b64decode:     4107.997 MB/s (17,695,296 bytes -> 13,271,472 bytes)
base64.b64encode:                  559.342 MB/s (13,271,472 bytes -> 17,695,296 bytes)
base64.b64decode:                  143.674 MB/s (17,695,296 bytes -> 13,271,472 bytes)
bench: altchars=b'-_', validate=False
pybase64._pybase64.b64encode:     2786.776 MB/s (13,271,472 bytes -> 17,695,296 bytes)
pybase64._pybase64.b64decode:     1124.136 MB/s (17,695,296 bytes -> 13,271,472 bytes)
base64.b64encode:                  322.427 MB/s (13,271,472 bytes -> 17,695,296 bytes)
base64.b64decode:                  205.195 MB/s (17,695,296 bytes -> 13,271,472 bytes)
bench: altchars=b'-_', validate=True
pybase64._pybase64.b64encode:     2806.271 MB/s (13,271,472 bytes -> 17,695,296 bytes)
pybase64._pybase64.b64decode:     2740.456 MB/s (17,695,296 bytes -> 13,271,472 bytes)
base64.b64encode:                  314.709 MB/s (13,271,472 bytes -> 17,695,296 bytes)
base64.b64decode:                  121.803 MB/s (17,695,296 bytes -> 13,271,472 bytes)

Changelog

1.2.2

  • Fix C extension build on musl distros
  • Publish musllinux wheels

1.2.1

  • Publish PyPy 3.8 (pypy38_pp73) wheels

1.2.0

  • Release the GIL
  • Publish CPython 3.10 wheels
  • Drop python 3.5 support

1.1.4

  • Add macOS arm64 wheel

1.1.3

  • GitHub Actions: fix build on tag

1.1.2

  • Add PyPy wheels
  • Add aarch64, ppc64le & s390x manylinux wheels

1.1.1

  • Move CI from TravisCI/AppVeyor to GitHub Actions
  • Fix publication of Linux/macOS wheels

1.1.0

  • Add b64encode_as_string, same as b64encode but returns a str object instead of a bytes object
  • Add b64decode_as_bytearray, same as b64decode but returns a bytarray object instead of a bytes object
  • Speed-Up decoding from UCS1 strings

1.0.2

  • Update base64 library
  • Publish python 3.9 wheels

1.0.1

  • Publish python 3.8 wheels

1.0.0

  • Drop python 3.4 support
  • Drop python 2.7 support

0.5.0

  • Publish python 3.7 wheels
  • Drop python 3.3 support

0.4.0

  • Speed-up decoding when validate==False

0.3.1

  • Fix deployment issues

0.3.0

  • Add encodebytes function

0.2.1

  • Fixed invalid results on Windows

0.2.0

  • Added documentation

  • Added subcommands to the main script:

    • help
    • version
    • encode
    • decode
    • benchmark

0.1.2

  • Updated base64 native library

0.1.1

  • Fixed deployment issues

0.1.0

  • First public release
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].