Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/synodriver/fast-bencode
fast bencode for python, based on cython
https://github.com/synodriver/fast-bencode
bencode cython
Last synced: 18 days ago
JSON representation
fast bencode for python, based on cython
- Host: GitHub
- URL: https://github.com/synodriver/fast-bencode
- Owner: synodriver
- Created: 2021-05-28T18:41:42.000Z (over 3 years ago)
- Default Branch: sds
- Last Pushed: 2024-10-20T16:53:56.000Z (25 days ago)
- Last Synced: 2024-10-20T20:03:47.393Z (25 days ago)
- Topics: bencode, cython
- Language: C
- Homepage:
- Size: 756 KB
- Stars: 8
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.markdown
- Changelog: changename.py
Awesome Lists containing this project
README
✨ fast-bencode ✨
The cython version of bencode
[![pypi](https://img.shields.io/pypi/v/fast-bencode.svg)](https://pypi.org/project/fast-bencode/)
![python](https://img.shields.io/pypi/pyversions/fast-bencode)
![implementation](https://img.shields.io/pypi/implementation/fast-bencode)
![wheel](https://img.shields.io/pypi/wheel/fast-bencode)
![license](https://img.shields.io/github/license/synodriver/fast-bencode.svg)
![action](https://img.shields.io/github/workflow/status/synodriver/fast-bencode/run%20unitest)### forked from [bencode](https://github.com/bittorrent/bencode) to support latest version of python
- extra cython extension to speedup
- ```typing``` with mypy check### Usage
```python
from pprint import pprint
from bencode import bdecode, bencodewith open("test.torrent", "rb") as f:
data = f.read()raw = bdecode(data, decode=False) # do not decode bytes to str, use this to speedup. default is True
pprint(raw)assert bencode(raw, bufsize=1000000) == data # customize buffer size(in bytes) to speedup, this reduces call to realloc
```
- There are alias function ```loads``` for ```bdecode``` and ```dumps``` for ```bencode```
- ```load``` and ```dump``` are useful for file-like object
```python
from pprint import pprint
from bencode import load, dumps, loads, dumpswith open("test.torrent", "rb") as f:
data = load(f, decode=False)pprint(data)
print(dumps(data, bufsize=1000000))
```### build
git clone https://github.com/synodriver/fast-bencode.git
cd fast-bencode
python setup.py build_ext -i
```