File: README.md

package info (click to toggle)
sabctools 8.2.6-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 16,000 kB
  • sloc: cpp: 13,977; sh: 1,112; python: 950; ansic: 191; makefile: 13
file content (63 lines) | stat: -rw-r--r-- 2,348 bytes parent folder | download | duplicates (5)
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

SABCTools - C implementations of functions for use within SABnzbd  
===============================  
  
This module implements three main sets of C implementations that are used within SABnzbd:   
* yEnc decoding and encoding using SIMD routines  
* CRC32 calculations  
* Non-blocking SSL-socket reading  
* Marking files as sparse

Of course, they can also be used in any other application.

## yEnc decoding and encoding using SIMD routines
yEnc decoding and encoding performed by using [yencode](https://github.com/animetosho/node-yencode) from animetosho,   
which utilizes x86/ARM SIMD optimised routines if such CPU features are available.  
  
## CRC32 calculations
We used the `crcutil` library for very fast CRC calculations.

## Non-blocking SSL-socket reading  
When Python reads data from a non-blocking SSL socket, it is limited to receiving 16K data at once. This module implements a patched version that can read as much data is available at once.
For more details, see the [cpython pull request](https://github.com/python/cpython/pull/31492).

## Marking files as sparse
Uses Windows specific system calls to mark files as sparse and set the desired size.
On other platforms the same is achieved by calling `truncate`.

## Utility functions
Use `sabctools.bytearray_malloc(size)` to get an `bytearray` that is uninitialized (not set to `0`'s). 
This is much faster than the built-in `bytearray(size)` because the data inside the new `bytearray` will be whatever is present in the memory block.
  
# Installing  
  
As simple as running:  
```  
pip install sabctools --upgrade  
```  
When you want to compile from sources, you can run in the `sabctools` directory:  
```  
pip install .  
```  

## SIMD detection  

To see which SIMD set was detected on your system, run:  
```  
python -c "import sabctools; print(sabctools.simd);"  
```  
  
## OpenSSL detection  

To see if we could link to OpenSSL library on your system, run:  
```  
python -c "import sabctools; print(sabctools.openssl_linked);"  
```  

# Testing  
  
For testing we use `pytest` (install via `pip install -r tests/requirements.txt`) and test can simply be executed by browsing to the `sabctools` directory and running:  
```  
pytest  
```  
Note that tests can fail if `git` modified the line endings of data files when checking out the repository!