File: README.md

package info (click to toggle)
python-rencode 1.0.6-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 220 kB
  • sloc: python: 777; makefile: 4
file content (192 lines) | stat: -rw-r--r-- 4,268 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# 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
* Andrew Resch <andrewresch@gmail.com>
* Website: https://github.com/aresch/rencode

## License
See [COPYING](https://github.com/aresch/rencode/blob/master/COPYING)  for license information.