A fast bencode implementation in Cython supports both Python2 & Python3 .
pip install bencoder.pyx
from bencoder import bencode, bdecode, bdecode2
assert bencode("WWWWWW") == b'6:WWWWWW'
assert bencode(233) == b'i233e'
with open("debian-8.3.0-amd64-netinst.iso.torrent", "rb") as f:
torrent = bdecode(f.read())
print(torrent['announce'])
decoded, length = bdecode2(b'6:WWWWWWi233e')
assert decoded == b'WWWWWW'
assert length == 8
- Add support for Python 3.11
- Add support for Python 3.9 & 3.10
- Drop support for Python 2
- Build wheels for musl & aarch64
- Add support for Python 3.8
- Drop support for Python 3.4
- Use built-in dict instead of OrderedDict on Python >= 3.7
- Drop support for Python 3.3
- Fix bytes parsing when used with python-future #41
- Drop support for Python 2.6
- Performance boost for bencode method. #7
- Add bdecode2 method. #6
- Performance Improvement
- Fix package metainfo #3
- Support encode large int
- Use OrderedDict instaed of dict
- Support encoding subclasses of dict