twine
is a simple data serialization format that allows you to share data across different systems.
Click here for documentation
In many cases such as storing large arrays, singleton values, etc. twine takes less space than other serialization formats like JSON and pickle.
Here’s how many bytes each format takes to encode some data:
 | JSON | pickle | twine |
---|---|---|---|
None |
4 | 4 | 1 |
False |
5 | 4 | 1 |
1 |
1 | 5 | 2 |
2 ** 128 - 1 |
39 | 31 | 17 |
-(2 ** 127) |
40 | 30 | 17 |
1.0 |
3 | 21 | 5 |
0.1 |
3 | 21 | 5 |
1 + 10e-15 |
16 | 21 | 9 |
+Infinity |
8 | 21 | 1 |
[] |
2 | 5 | 3 |
range(100) |
390 | 216 | 203 |
range(2**16 - 1) |
447635 | 196513 | 196353 |
"" |
2 | 15 | 3 |
"Hello, World!" |
15 | 28 | 16 |
"\uffff" * 1000 |
6002 | 3018 | 3004 |
twine consumes less space than both JSON and pickle in most of the test cases. However, when the data is short, twine may require more space than JSON.
twine is still a relatively new project, and does not yet have any contributing guidelines. If you want to report a bug or suggest a feature, feel free to create an issue.
twine is licensed under the MIT License.