Rust-backed PyJWT-compatible JWT library for Python
Project description
pyjwt-rs
jwt_rs는 PyJWT 호환을 목표로 하는 Rust 기반 Python 확장 모듈입니다.
핵심 목표는 두 가지입니다.
- 같은 코드에
import jwt_rs as jwt만 바꿔서 동작할 것 - Rust 코어로 주요 공개키 JWT workload에서
PyJWT보다 더 빠를 것
Current Status
현재 공개 표면은 PyJWT 스타일을 유지합니다.
encode(payload, key, algorithm="HS256", headers=None)decode(token, key, algorithms=None, options=None, audience=None, issuer=None, leeway=0)decode_complete(...)get_unverified_header(token)PyJWS,PyJWK, algorithm registry
현재 지원 알고리즘:
- HMAC:
HS256,HS384,HS512 - RSA:
RS256,RS384,RS512,PS256,PS384,PS512 - EC:
ES256,ES384,ES512,ES256K EdDSA
테스트 상태:
324 passed
품질 정책:
- 테스트는 hidden warning 없이 통과해야 합니다. CI는
-W error기반 게이트를 사용합니다. - 의도된 skip은
.quality/pytest-allowlist.json에 명시되어야 합니다. - 릴리스/호환성 작업은 공개 GitHub issue와 milestone으로 추적합니다.
- 자세한 운영 정책은 CONTRIBUTING.md, 호환성 갭은 COMPATIBILITY_CHECKLIST.md 에서 관리합니다.
Usage
import jwt_rs as jwt
token = jwt.encode({"sub": "alice"}, "secret", algorithm="HS256")
claims = jwt.decode(token, "secret", algorithms=["HS256"])
header = jwt.get_unverified_header(token)
Performance
성능 목표는 모든 경로 일괄 2배가 아니라, 먼저 실사용 공개키 경로에서 PyJWT를 확실히 추월하는 것입니다.
아래 블록은 benchmark 스크립트로 자동 생성됩니다. 수동으로 적지 않습니다.
Auto-generated from scripts/benchmark_same_api.py on 2026-04-21T07:14:04+00:00 using --iterations 150 --warmup 20.
현재 same-API benchmark 기준:
| Case | encode | decode | decode_complete |
|---|---|---|---|
hs256 |
1.43x |
2.10x |
2.04x |
rs256 |
59.10x |
2.15x |
2.13x |
es256 |
3.12x |
1.76x |
1.81x |
eddsa |
1.59x |
1.06x |
1.06x |
좋은 구간:
rs256.encode:jwt_rs가PyJWT대비59.10xes256.encode:jwt_rs가PyJWT대비3.12xes256.decode:jwt_rs가PyJWT대비1.76xeddsa.encode:jwt_rs가PyJWT대비1.59x
아직 미달인 구간:
- 현재 주요 추적 경로는 모두
PyJWT이상입니다.
해석:
1.00x초과면jwt_rs가 빠릅니다.2.00x이상이면 README 목표인PyJWT 대비 2배를 넘긴 것입니다.- 현재 목표는 특히 공개키 경로에서 이 값을 끌어올리는 것입니다.
벤치 재현 명령:
uv run --with pyjwt python scripts/benchmark_same_api.py --iterations 150 --warmup 20
README 자동 갱신 명령:
uv run python scripts/update_readme_bench.py
Development
source "$HOME/.cargo/env"
cd pyjwt-rs
uv venv
source .venv/bin/activate
uv pip install -e ".[dev]"
uv run --with maturin maturin develop
uv run pytest -q
Notes
- Python은 호환 인터페이스를 담당하고, 코어 sign/verify hot path는 Rust가 담당합니다.
- 현재 공개키 알고리즘 경로는 Rust 내부 OpenSSL backend를 사용합니다.
options={"verify_signature": False}경로는 별도 insecure decode 흐름을 사용합니다.- 완전한
PyJWTparity를 목표로 하지만, 성능 최적화를 위해 내부 구현은PyJWT와 다릅니다. - 배포 버전과
PyJWT호환 버전 구분은 VERSIONING.md 에 정리했습니다.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyjwt_rs-1.2.0.tar.gz.
File metadata
- Download URL: pyjwt_rs-1.2.0.tar.gz
- Upload date:
- Size: 179.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
37dc964086ae08c5bc506ef4f6016e2d315f7b8b28fffb0fac17a9139c7e5601
|
|
| MD5 |
b25c49a1a4aa58518cf60c57cd1b3d7e
|
|
| BLAKE2b-256 |
da1b84df72008fb1d9b835a766ce14f269c4e674f0e7d555513c700efd1b4b13
|
File details
Details for the file pyjwt_rs-1.2.0-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: pyjwt_rs-1.2.0-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 2.7 MB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
69d3802986d62c01ca5d3bd7a9b1c7a7a0829ed883987e40bc5e3236895d4bb1
|
|
| MD5 |
3cf55a550440fc082f0a7193e18ac797
|
|
| BLAKE2b-256 |
479fa7c4049f5880e82b990c16eda6062ab479d070c835aa5af52b81686fb8c0
|
File details
Details for the file pyjwt_rs-1.2.0-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: pyjwt_rs-1.2.0-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 2.4 MB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03c02a840aa6851ddb9ecf7baf48aa9397faef6e383299e31ed8471db71411b5
|
|
| MD5 |
a49c53b5d52611a5dfe80e672382b38a
|
|
| BLAKE2b-256 |
f788c261b59773b08dfde78818fafa122d9e7bc3ecc94bfd39b9b7d9d2185116
|
File details
Details for the file pyjwt_rs-1.2.0-cp312-cp312-macosx_10_12_x86_64.whl.
File metadata
- Download URL: pyjwt_rs-1.2.0-cp312-cp312-macosx_10_12_x86_64.whl
- Upload date:
- Size: 2.1 MB
- Tags: CPython 3.12, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
801e76837d895de9be164e4aef830f371e2aa86429997902956ab5c3c29edc37
|
|
| MD5 |
c451d0ef8bf50a6c350ea6e1e943e980
|
|
| BLAKE2b-256 |
f33a6f358fd9bd33d3b68b0ca5d4634b17a01754efa300c289638bfb0942bec6
|
File details
Details for the file pyjwt_rs-1.2.0-cp310-cp310-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pyjwt_rs-1.2.0-cp310-cp310-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 2.3 MB
- Tags: CPython 3.10, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aad91cd66427b1244da8d8ab551a8fb86ee2f99a2fc590ebf4c5064996ac49da
|
|
| MD5 |
74305b32aeef5d3c67ad0ea400a33814
|
|
| BLAKE2b-256 |
e5f3439b9f12d5a0a719224eff9025a71369421615f34233069fe93e790dcd38
|
File details
Details for the file pyjwt_rs-1.2.0-cp310-cp310-manylinux_2_28_aarch64.whl.
File metadata
- Download URL: pyjwt_rs-1.2.0-cp310-cp310-manylinux_2_28_aarch64.whl
- Upload date:
- Size: 2.5 MB
- Tags: CPython 3.10, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
707434b612460eac5ee150d84428a8e41d149e2ec051ac8300a3c9b20d6eae21
|
|
| MD5 |
3a2703b36e86fab2f7a3012a428de244
|
|
| BLAKE2b-256 |
142c10d233b78ebd5b130f1cf0f3bb0e57d2ce2c9de5a997b18338d8794b5d52
|