Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

Web safe object pickling/unpickling

Project description

rencode

The rencode module is similar to bencode from the BitTorrent project. For complex, heterogeneous data structures with many small elements, r-encodings take up significantly less space than b-encodings:

>>> len(rencode.dumps({'a':0, 'b':[1,2], 'c':99}))
13

>>> len(bencode.bencode({'a':0, 'b':[1,2], 'c':99}))
26

This version of rencode is a complete rewrite in Cython to attempt to increase the performance over the pure Python module written by Petru Paler, Connelly Barnes et al.

Performance Comparison

The test program used for these results is included in the repository: https://github.com/aresch/rencode/blob/master/tests/timetest.py

Encode functions

test_encode_fixed_pos_int:
	rencode.pyx: 0.003s (+0.013s) 589.17%
	rencode.py:  0.016s

test_encode_int_int_size:
	rencode.pyx: 0.006s (+0.032s) 625.99%
	rencode.py:  0.038s

test_encode_int_long_long_size:
	rencode.pyx: 0.014s (+0.026s) 279.96%
	rencode.py:  0.040s

test_encode_int_short_size:
	rencode.pyx: 0.006s (+0.030s) 629.80%
	rencode.py:  0.036s

test_encode_str:
	rencode.pyx: 0.006s (+0.010s) 263.96%
	rencode.py:  0.017s

test_encode_dict:
	rencode.pyx: 0.135s (+0.302s) 324.68%
	rencode.py:  0.437s

test_encode_fixed_list:
	rencode.pyx: 0.012s (+0.025s) 307.78%
	rencode.py:  0.037s

test_encode_fixed_neg_int:
	rencode.pyx: 0.003s (+0.012s) 536.97%
	rencode.py:  0.015s

test_encode_fixed_dict:
	rencode.pyx: 0.046s (+0.105s) 331.07%
	rencode.py:  0.151s

test_encode_int_char_size:
	rencode.pyx: 0.005s (+0.029s) 687.64%
	rencode.py:  0.034s

test_encode_fixed_str:
	rencode.pyx: 0.003s (+0.011s) 438.07%
	rencode.py:  0.015s

test_encode_list:
	rencode.pyx: 0.148s (+0.228s) 253.68%
	rencode.py:  0.376s

test_encode_none:
	rencode.pyx: 0.004s (+0.011s) 386.06%
	rencode.py:  0.014s

test_encode_int_big_number:
	rencode.pyx: 0.011s (+0.019s) 264.32%
	rencode.py:  0.030s

test_encode_float_64bit:
	rencode.pyx: 0.003s (+0.011s) 416.19%
	rencode.py:  0.014s

test_encode_bool:
	rencode.pyx: 0.004s (+0.014s) 447.57%
	rencode.py:  0.018s

test_encode_float_32bit:
	rencode.pyx: 0.003s (+0.010s) 417.86%
	rencode.py:  0.014s

Encode functions totals:
	rencode.pyx: 0.412s (+0.888s) 315.49%
	rencode.py:  1.301s

Decode functions

test_decode_fixed_list:
	rencode.pyx: 0.003s (+0.020s) 848.67%
	rencode.py:  0.022s

test_decode_int_long_long_size:
	rencode.pyx: 0.003s (+0.013s) 484.80%
	rencode.py:  0.016s

test_decode_dict:
	rencode.pyx: 0.267s (+0.406s) 251.81%
	rencode.py:  0.673s

test_decode_fixed_dict:
	rencode.pyx: 0.087s (+0.123s) 241.32%
	rencode.py:  0.211s

test_decode_float_32bit:
	rencode.pyx: 0.002s (+0.007s) 536.88%
	rencode.py:  0.009s

test_decode_int_big_number:
	rencode.pyx: 0.007s (+0.010s) 256.05%
	rencode.py:  0.017s

test_decode_int_char_size:
	rencode.pyx: 0.002s (+0.014s) 754.12%
	rencode.py:  0.016s

test_decode_fixed_neg_int:
	rencode.pyx: 0.001s (+0.004s) 389.03%
	rencode.py:  0.006s

test_decode_fixed_str:
	rencode.pyx: 0.009s (+0.009s) 199.78%
	rencode.py:  0.019s

test_decode_float_64bit:
	rencode.pyx: 0.002s (+0.007s) 540.17%
	rencode.py:  0.009s

test_decode_bool:
	rencode.pyx: 0.002s (+0.004s) 369.49%
	rencode.py:  0.006s

test_decode_fixed_pos_int:
	rencode.pyx: 0.002s (+0.004s) 368.96%
	rencode.py:  0.006s

test_decode_list:
	rencode.pyx: 0.019s (+0.247s) 1403.77%
	rencode.py:  0.266s

test_decode_none:
	rencode.pyx: 0.002s (+0.004s) 367.05%
	rencode.py:  0.006s

test_decode_int_short_size:
	rencode.pyx: 0.002s (+0.014s) 716.47%
	rencode.py:  0.016s

test_decode_str:
	rencode.pyx: 0.010s (+0.026s) 364.51%
	rencode.py:  0.036s

test_decode_int_int_size:
	rencode.pyx: 0.002s (+0.014s) 705.92%
	rencode.py:  0.016s

Decode functions totals:
	rencode.pyx: 0.421s (+0.926s) 319.79%
	rencode.py:  1.348s

Overall functions

test_overall_encode:
	rencode.pyx: 0.069s (+0.120s) 274.42%
	rencode.py:  0.189s

test_overall_decode:
	rencode.pyx: 0.051s (+0.153s) 400.57%
	rencode.py:  0.204s

Overall functions totals:
	rencode.pyx: 0.120s (+0.273s) 327.98%
	rencode.py:  0.393s

Author

License

See COPYING for license information.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for rencode, version 1.0.6
Filename, size File type Python version Upload date Hashes
Filename, size rencode-1.0.6-cp27-cp27m-macosx_10_6_intel.whl (80.6 kB) File type Wheel Python version cp27 Upload date Hashes View hashes
Filename, size rencode-1.0.6-cp27-cp27m-manylinux1_i686.whl (126.7 kB) File type Wheel Python version cp27 Upload date Hashes View hashes
Filename, size rencode-1.0.6-cp27-cp27m-manylinux1_x86_64.whl (132.2 kB) File type Wheel Python version cp27 Upload date Hashes View hashes
Filename, size rencode-1.0.6-cp27-cp27mu-manylinux1_i686.whl (126.7 kB) File type Wheel Python version cp27 Upload date Hashes View hashes
Filename, size rencode-1.0.6-cp27-cp27mu-manylinux1_x86_64.whl (132.2 kB) File type Wheel Python version cp27 Upload date Hashes View hashes
Filename, size rencode-1.0.6-cp34-cp34m-macosx_10_6_intel.whl (79.5 kB) File type Wheel Python version cp34 Upload date Hashes View hashes
Filename, size rencode-1.0.6-cp34-cp34m-manylinux1_i686.whl (138.7 kB) File type Wheel Python version cp34 Upload date Hashes View hashes
Filename, size rencode-1.0.6-cp34-cp34m-manylinux1_x86_64.whl (143.1 kB) File type Wheel Python version cp34 Upload date Hashes View hashes
Filename, size rencode-1.0.6-cp35-cp35m-macosx_10_6_intel.whl (82.1 kB) File type Wheel Python version cp35 Upload date Hashes View hashes
Filename, size rencode-1.0.6-cp35-cp35m-manylinux1_i686.whl (139.2 kB) File type Wheel Python version cp35 Upload date Hashes View hashes
Filename, size rencode-1.0.6-cp35-cp35m-manylinux1_x86_64.whl (146.2 kB) File type Wheel Python version cp35 Upload date Hashes View hashes
Filename, size rencode-1.0.6-cp36-cp36m-macosx_10_6_intel.whl (84.7 kB) File type Wheel Python version cp36 Upload date Hashes View hashes
Filename, size rencode-1.0.6-cp36-cp36m-manylinux1_i686.whl (140.7 kB) File type Wheel Python version cp36 Upload date Hashes View hashes
Filename, size rencode-1.0.6-cp36-cp36m-manylinux1_x86_64.whl (146.8 kB) File type Wheel Python version cp36 Upload date Hashes View hashes
Filename, size rencode-1.0.6-cp37-cp37m-macosx_10_6_intel.whl (82.4 kB) File type Wheel Python version cp37 Upload date Hashes View hashes
Filename, size rencode-1.0.6-cp37-cp37m-manylinux1_i686.whl (141.1 kB) File type Wheel Python version cp37 Upload date Hashes View hashes
Filename, size rencode-1.0.6-cp37-cp37m-manylinux1_x86_64.whl (147.4 kB) File type Wheel Python version cp37 Upload date Hashes View hashes
Filename, size rencode-1.0.6.tar.gz (74.7 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page