summaryrefslogtreecommitdiff
path: root/python-cbitstruct.spec
blob: d5e18d376fadf425d74bcba5bf4d58bf53c689b5 (plain)
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
%global _empty_manifest_terminate_build 0
Name:		python-cbitstruct
Version:	1.0.9
Release:	1
Summary:	Faster C implementation of bitstruct
License:	MPL-2.0
URL:		https://github.com/qchateau/cbitstruct
Source0:	https://mirrors.nju.edu.cn/pypi/web/packages/b9/e5/5562adfa22b709a6201e5e7b69d6b60439b009503bf556f9bbe110f1ddc8/cbitstruct-1.0.9.tar.gz
BuildArch:	noarch


%description
![License](https://img.shields.io/badge/license-MPL--2.0-brightgreen)  [![Build Status](https://travis-ci.com/qchateau/cbitstruct.svg?branch=master)](https://travis-ci.com/qchateau/cbitstruct)

# About

`cbitstruct` is a C implementation of the `bitstruct` library. Credits to Erik Moqvist for the original `bitstruct` library available on [Github](https://github.com/eerimoq/bitstruct) and [pip](https://pypi.org/project/bitstruct/).

The goal is to provide the same API an idealy to be able to interchange `import bitstruct` and `import cbitstruct as bitstruct`.

Obvious increased performance comes with limitations described below.

# Installation

```bash
pip3 install cbitstruct
```

# Documentation

Please refer to the [`bitstruct` documentation](https://bitstruct.readthedocs.io/en/latest/) as the aim of this library is to provide the same API with increased performance.

If you are not used to `bitstruct`, you should seriously consider using it first, before migrating to this library if you require higher performance.

# Limitations

| Limitation | Will it be lifted ? |
|------------|---------------------|
| All types except padding are limited to 64 bits | Maybe for 'raw' and 'text' types |
| May not work on big-endian architectures | Maybe |
| Exceptions differ from `bitstruct` | Probably not |
| CPython only | Probably not |
| Error messages are unclear | Will never be as clear as `bitstruct` |
| Python >= 3.5 | No |

Some limitations are there because I did not get the time or motivation to lift them up. Some other are deeply rooted into this library and may never be lifted.

# Performance

## Comparing to `bitstruct`

The script available in `tests/test_perf.py` measures performance comparing to the `bitstruct` library.

Here are the result "on my machine" (Ubuntu in Virtualbox on a laptop):
```
byteswap list of int      | x  8.779 (   8.638us ->   0.984us)
byteswap str              | x 17.466 (   9.158us ->   0.524us)
calcsize                  | x139.330 (  61.060us ->   0.438us)
compiled pack             | x 47.389 (  35.968us ->   0.759us)
compiled pack_dict        | x 27.184 (  34.588us ->   1.272us)
compiled pack_into        | x 32.037 (  38.650us ->   1.206us)
compiled pack_into_dict   | x 27.343 (  37.718us ->   1.379us)
compiled unpack           | x 33.928 (  31.278us ->   0.922us)
compiled unpack_dict      | x 21.627 (  31.597us ->   1.461us)
compiled unpack_from      | x 30.622 (  29.977us ->   0.979us)
compiled unpack_from_dict | x 20.479 (  30.936us ->   1.511us)
pack                      | x 77.003 ( 103.030us ->   1.338us)
pack_dict                 | x 53.254 ( 103.255us ->   1.939us)
pack_into                 | x 82.829 ( 119.373us ->   1.441us)
pack_into_dict            | x 52.173 ( 108.135us ->   2.073us)
unpack                    | x 78.459 (  91.896us ->   1.171us)
unpack_dict               | x 40.287 (  89.300us ->   2.217us)
unpack_from               | x 77.027 (  91.202us ->   1.184us)
unpack_from_dict          | x 39.467 (  88.043us ->   2.231us)
```

*Disclaimer:* these results may and will vary largely depending on the number of elements and types you pack/unpack. This script is provided as-is, and I will gladly accept an improved script providing more reliable results.


## The dict API
The `dict` API is marginally slower than the traditional one. As the packing/unpacking performance is quite high, the overhead of performing dictionary lookups and hashing significantly increas pack and unpacking duration.


%package -n python3-cbitstruct
Summary:	Faster C implementation of bitstruct
Provides:	python-cbitstruct
BuildRequires:	python3-devel
BuildRequires:	python3-setuptools
BuildRequires:	python3-pip
%description -n python3-cbitstruct
![License](https://img.shields.io/badge/license-MPL--2.0-brightgreen)  [![Build Status](https://travis-ci.com/qchateau/cbitstruct.svg?branch=master)](https://travis-ci.com/qchateau/cbitstruct)

# About

`cbitstruct` is a C implementation of the `bitstruct` library. Credits to Erik Moqvist for the original `bitstruct` library available on [Github](https://github.com/eerimoq/bitstruct) and [pip](https://pypi.org/project/bitstruct/).

The goal is to provide the same API an idealy to be able to interchange `import bitstruct` and `import cbitstruct as bitstruct`.

Obvious increased performance comes with limitations described below.

# Installation

```bash
pip3 install cbitstruct
```

# Documentation

Please refer to the [`bitstruct` documentation](https://bitstruct.readthedocs.io/en/latest/) as the aim of this library is to provide the same API with increased performance.

If you are not used to `bitstruct`, you should seriously consider using it first, before migrating to this library if you require higher performance.

# Limitations

| Limitation | Will it be lifted ? |
|------------|---------------------|
| All types except padding are limited to 64 bits | Maybe for 'raw' and 'text' types |
| May not work on big-endian architectures | Maybe |
| Exceptions differ from `bitstruct` | Probably not |
| CPython only | Probably not |
| Error messages are unclear | Will never be as clear as `bitstruct` |
| Python >= 3.5 | No |

Some limitations are there because I did not get the time or motivation to lift them up. Some other are deeply rooted into this library and may never be lifted.

# Performance

## Comparing to `bitstruct`

The script available in `tests/test_perf.py` measures performance comparing to the `bitstruct` library.

Here are the result "on my machine" (Ubuntu in Virtualbox on a laptop):
```
byteswap list of int      | x  8.779 (   8.638us ->   0.984us)
byteswap str              | x 17.466 (   9.158us ->   0.524us)
calcsize                  | x139.330 (  61.060us ->   0.438us)
compiled pack             | x 47.389 (  35.968us ->   0.759us)
compiled pack_dict        | x 27.184 (  34.588us ->   1.272us)
compiled pack_into        | x 32.037 (  38.650us ->   1.206us)
compiled pack_into_dict   | x 27.343 (  37.718us ->   1.379us)
compiled unpack           | x 33.928 (  31.278us ->   0.922us)
compiled unpack_dict      | x 21.627 (  31.597us ->   1.461us)
compiled unpack_from      | x 30.622 (  29.977us ->   0.979us)
compiled unpack_from_dict | x 20.479 (  30.936us ->   1.511us)
pack                      | x 77.003 ( 103.030us ->   1.338us)
pack_dict                 | x 53.254 ( 103.255us ->   1.939us)
pack_into                 | x 82.829 ( 119.373us ->   1.441us)
pack_into_dict            | x 52.173 ( 108.135us ->   2.073us)
unpack                    | x 78.459 (  91.896us ->   1.171us)
unpack_dict               | x 40.287 (  89.300us ->   2.217us)
unpack_from               | x 77.027 (  91.202us ->   1.184us)
unpack_from_dict          | x 39.467 (  88.043us ->   2.231us)
```

*Disclaimer:* these results may and will vary largely depending on the number of elements and types you pack/unpack. This script is provided as-is, and I will gladly accept an improved script providing more reliable results.


## The dict API
The `dict` API is marginally slower than the traditional one. As the packing/unpacking performance is quite high, the overhead of performing dictionary lookups and hashing significantly increas pack and unpacking duration.


%package help
Summary:	Development documents and examples for cbitstruct
Provides:	python3-cbitstruct-doc
%description help
![License](https://img.shields.io/badge/license-MPL--2.0-brightgreen)  [![Build Status](https://travis-ci.com/qchateau/cbitstruct.svg?branch=master)](https://travis-ci.com/qchateau/cbitstruct)

# About

`cbitstruct` is a C implementation of the `bitstruct` library. Credits to Erik Moqvist for the original `bitstruct` library available on [Github](https://github.com/eerimoq/bitstruct) and [pip](https://pypi.org/project/bitstruct/).

The goal is to provide the same API an idealy to be able to interchange `import bitstruct` and `import cbitstruct as bitstruct`.

Obvious increased performance comes with limitations described below.

# Installation

```bash
pip3 install cbitstruct
```

# Documentation

Please refer to the [`bitstruct` documentation](https://bitstruct.readthedocs.io/en/latest/) as the aim of this library is to provide the same API with increased performance.

If you are not used to `bitstruct`, you should seriously consider using it first, before migrating to this library if you require higher performance.

# Limitations

| Limitation | Will it be lifted ? |
|------------|---------------------|
| All types except padding are limited to 64 bits | Maybe for 'raw' and 'text' types |
| May not work on big-endian architectures | Maybe |
| Exceptions differ from `bitstruct` | Probably not |
| CPython only | Probably not |
| Error messages are unclear | Will never be as clear as `bitstruct` |
| Python >= 3.5 | No |

Some limitations are there because I did not get the time or motivation to lift them up. Some other are deeply rooted into this library and may never be lifted.

# Performance

## Comparing to `bitstruct`

The script available in `tests/test_perf.py` measures performance comparing to the `bitstruct` library.

Here are the result "on my machine" (Ubuntu in Virtualbox on a laptop):
```
byteswap list of int      | x  8.779 (   8.638us ->   0.984us)
byteswap str              | x 17.466 (   9.158us ->   0.524us)
calcsize                  | x139.330 (  61.060us ->   0.438us)
compiled pack             | x 47.389 (  35.968us ->   0.759us)
compiled pack_dict        | x 27.184 (  34.588us ->   1.272us)
compiled pack_into        | x 32.037 (  38.650us ->   1.206us)
compiled pack_into_dict   | x 27.343 (  37.718us ->   1.379us)
compiled unpack           | x 33.928 (  31.278us ->   0.922us)
compiled unpack_dict      | x 21.627 (  31.597us ->   1.461us)
compiled unpack_from      | x 30.622 (  29.977us ->   0.979us)
compiled unpack_from_dict | x 20.479 (  30.936us ->   1.511us)
pack                      | x 77.003 ( 103.030us ->   1.338us)
pack_dict                 | x 53.254 ( 103.255us ->   1.939us)
pack_into                 | x 82.829 ( 119.373us ->   1.441us)
pack_into_dict            | x 52.173 ( 108.135us ->   2.073us)
unpack                    | x 78.459 (  91.896us ->   1.171us)
unpack_dict               | x 40.287 (  89.300us ->   2.217us)
unpack_from               | x 77.027 (  91.202us ->   1.184us)
unpack_from_dict          | x 39.467 (  88.043us ->   2.231us)
```

*Disclaimer:* these results may and will vary largely depending on the number of elements and types you pack/unpack. This script is provided as-is, and I will gladly accept an improved script providing more reliable results.


## The dict API
The `dict` API is marginally slower than the traditional one. As the packing/unpacking performance is quite high, the overhead of performing dictionary lookups and hashing significantly increas pack and unpacking duration.


%prep
%autosetup -n cbitstruct-1.0.9

%build
%py3_build

%install
%py3_install
install -d -m755 %{buildroot}/%{_pkgdocdir}
if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
pushd %{buildroot}
if [ -d usr/lib ]; then
	find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/lib64 ]; then
	find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/bin ]; then
	find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/sbin ]; then
	find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
fi
touch doclist.lst
if [ -d usr/share/man ]; then
	find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
fi
popd
mv %{buildroot}/filelist.lst .
mv %{buildroot}/doclist.lst .

%files -n python3-cbitstruct -f filelist.lst
%dir %{python3_sitelib}/*

%files help -f doclist.lst
%{_docdir}/*

%changelog
* Sun Apr 23 2023 Python_Bot <Python_Bot@openeuler.org> - 1.0.9-1
- Package Spec generated