thriftpy2
Pure python implementation of Apache Thrift.
What it is and what it does
ThriftPy2 is a pure Python Thrift implementation that eliminates the need to compile or install the official Thrift package. You define your service interface in a .thrift file, then load it dynamically at runtime using thriftpy2.load(), which generates Python classes on the fly. This approach works with both synchronous and asynchronous code paths, supporting multiple protocols (binary, compact, JSON, Apache JSON) and transports (buffered, framed, HTTP).
The package is designed for developers building microservices or distributed systems who want the flexibility of Thrift's language-agnostic RPC without the compilation step. It includes helpers like make_server, make_client, make_aio_server, and make_aio_client to simplify server and client setup. Runtime dependencies are minimal: ply for parsing, ijson for JSON handling, and typing_extensions for type hints.
Use it for:
- Build RPC microservices that communicate with Thrift-based servers written in other languages
- Dynamically load and parse Thrift service definitions at application startup without code generation
- Create async/await-based Thrift servers and clients for high-concurrency applications
- Migrate from the deprecated ThriftPy package by changing imports to thriftpy2
- Implement HTTP-based Thrift transports for services behind load balancers or proxies
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
ThriftPy2 is a pure Python implementation of Apache Thrift that lets you load Thrift IDL files dynamically and build RPC clients and servers without code generation or compilation.
Yes. ThriftPy2 is actively maintained, has no known vulnerabilities, supports current Python versions (3.7+), and is widely used (top 5000 PyPI packages). Install it if you need Thrift RPC without compilation overhead. Medium install friction is acceptable given the broad platform coverage and stability.
Install
thriftpy2 on PyPI
pip
pip install thriftpy2uv
uv add thriftpy2poetry
poetry add thriftpy2Installing thriftpy2
Before you install
Medium install friction due to compiled wheels for multiple Python versions and platforms. The package is actively maintained with a recent release and no known vulnerabilities, making it a stable choice for production use.
License in practice
MIT license permits unrestricted use, modification, and distribution in both open-source and commercial projects, with only attribution and license inclusion required.
Quickstart
pip install thriftpy2
import thriftpy2
from thriftpy2.rpc import make_server
pingpong_thrift = thriftpy2.load("pingpong.thrift", module_name="pingpong_thrift")
class Dispatcher:
def ping(self):
return "pong"
server = make_server(pingpong_thrift.PingPong, Dispatcher(), '127.0.0.1', 6000)
server.serve()
Requires a .thrift file defining your service interface; Python 3.7 or later
Verify before relying
- Performance characteristics compared to official Apache Thrift implementation
- Completeness of Cython optimization coverage across all protocols and transports
Package facts
| License | The MIT License (MIT) Copyright (c) <2014> <Eleme Inc.> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the… (full text in the JSON record) (permissive) |
| Python support | supports the current Python release (>=3.7) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | 3 — ply, ijson, typing_extensions |
| Maintenance | actively maintained — 5 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,677,333/month — #3,662 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: thriftpy2-0.7.0-cp310-cp310-macosx_11_0_arm64.whl; thriftpy2-0.7.0-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; thriftpy2-0.7.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; thriftpy2-0.7.0-cp310-cp310-musllinux_1_2_aarch64.whl; thriftpy2-0.7.0-cp310-cp310-musllinux_1_2_x86_64.whl; thriftpy2-0.7.0-cp310-cp310-win32.whl; thriftpy2-0.7.0-cp310-cp310-win_amd64.whl; thriftpy2-0.7.0-cp310-cp310-win_arm64.whl; thriftpy2-0.7.0-cp311-cp311-macosx_11_0_arm64.whl; thriftpy2-0.7.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; thriftpy2-0.7.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; thriftpy2-0.7.0-cp311-cp311-musllinux_1_2_aarch64.whl; thriftpy2-0.7.0-cp311-cp311-musllinux_1_2_x86_64.whl; thriftpy2-0.7.0-cp311-cp311-win32.whl; thriftpy2-0.7.0-cp311-cp311-win_amd64.whl; thriftpy2-0.7.0-cp311-cp311-win_arm64.whl; thriftpy2-0.7.0-cp312-cp312-macosx_11_0_arm64.whl; thriftpy2-0.7.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; thriftpy2-0.7.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; thriftpy2-0.7.0-cp312-cp312-musllinux_1_2_aarch64.whl
Keywords: thrift, python, thriftpy, thriftpy2
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
thrift-saslImplements SASL authentication transports for…
permissive · top 5,000 on PyPI
thriftThrift is the Python bindings for Apache…
permissive · top 1,000 on PyPI
pure-transportProvides a Thrift transport for PyHive…
permissive · top 15,000 on PyPI
hmsclientA Python client for connecting to and querying…
permissive · top 5,000 on PyPI
ajsonrpcImplements the JSON-RPC 2.0 protocol with an…
permissive · top 5,000 on PyPI
opentelemetry-exporter-jaeger-thriftExports OpenTelemetry tracing data to Jaeger…
permissive · top 15,000 on PyPI
hive-metastore-clientA Python client for connecting to Apache Hive…
unclear · top 15,000 on PyPI
json-rpcImplements JSON-RPC 2.0 and 1.0 protocol…
permissive · top 5,000 on PyPI
python-lsp-jsonrpcImplements a JSON RPC 2.0 server for Python…
permissive · top 5,000 on PyPI
jsonrpcclientGenerates JSON-RPC request objects and parses…
unclear · top 15,000 on PyPI