2020-06-26 15:19:34 +00:00
|
|
|
# pyvarint
|
|
|
|
|
2020-06-29 23:40:01 +00:00
|
|
|
[![Build Status](https://drone.autonomic.zone/api/badges/hyperpy/pyvarint/status.svg)](https://drone.autonomic.zone/hyperpy/pyvarint)
|
|
|
|
|
2020-06-29 23:47:23 +00:00
|
|
|
## Varints, a method of serializing integers using one or more bytes
|
2020-06-29 23:40:01 +00:00
|
|
|
|
2020-07-07 13:59:42 +00:00
|
|
|
## Install
|
|
|
|
|
2020-06-29 23:40:01 +00:00
|
|
|
```sh
|
|
|
|
$ pip install pyvarint
|
|
|
|
```
|
2020-07-07 13:59:42 +00:00
|
|
|
|
|
|
|
## Example
|
|
|
|
|
|
|
|
```python
|
|
|
|
from random import sample
|
|
|
|
from pyvarint import decode, encode
|
|
|
|
|
|
|
|
ten_rand_ints = sample(range(100), 10)
|
|
|
|
|
|
|
|
for rand_int in ten_rand_ints:
|
|
|
|
encoded = encode(rand_int)
|
|
|
|
decoded = decode(encoded)
|
|
|
|
assert decoded == rand_int
|
|
|
|
```
|