A fast bencode implementation in Cython supports both Python2 & Python3 .
pip install bencoder.pyx
from bencoder import bencode, bdecode
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'])
- Support encode large int
- Use OrderedDict instaed of dict
- Support encoding subclasses of dict