Skip to content

jameshilliard/bencoder.pyx

 
 

Repository files navigation

Bencoder.pyx

A fast bencode implementation in Cython supports both Python2 & Python3 .

macOS Test Status Windows Test Status Linux Test Status PyPI License Codecov Coverage bencoder-pyx PyPI Downloads

Install

pip install bencoder.pyx

Usage

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

ChangeLog

Version 1.2.1

  • Drop support for Python 2.6
  • Performance boost for bencode method. #7

Version 1.2.0

  • Add bdecode2 method. #6

Version 1.1.3

  • Performance Improvement
  • Fix package metainfo #3

Version 1.1.2

  • Support encode large int

Version 1.1.0

  • Use OrderedDict instaed of dict
  • Support encoding subclasses of dict

About

A fast bencode implementation in Cython

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 89.8%
  • Shell 10.2%