skillfed

thriftpy2

Pure python implementation of Apache Thrift.

thriftpy2 v0.7.0 1.7M downloads/30d#3,662 on PyPI588
Permissive 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) Active released

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 thriftpy2

uv

uv add thriftpy2

poetry

poetry add thriftpy2

Installing 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

Development Status :: 4 - BetaIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Software Development

Tags

thrift rpc client serverapache thrift pythonthrift idl loaderrpc protocol implementationthrift without code generationasync thrift serverthrift binary protocol
rpc-frameworkthrift-protocolasync-support

More Software Development packages