Script 'mail_helper' called by obssrc
Hello community,
here is the log from the commit of package python-bitarray for openSUSE:Factory
checked in at 2023-06-12 15:25:58
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-bitarray (Old)
and /work/SRC/openSUSE:Factory/.python-bitarray.new.15902 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-bitarray"
Mon Jun 12 15:25:58 2023 rev:18 rq:1092275 version:2.7.5
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-bitarray/python-bitarray.changes
2023-03-07 16:50:42.485702589 +0100
+++
/work/SRC/openSUSE:Factory/.python-bitarray.new.15902/python-bitarray.changes
2023-06-12 15:26:51.051193781 +0200
@@ -1,0 +2,9 @@
+Sun Jun 11 11:51:40 UTC 2023 - Dirk Müller <[email protected]>
+
+- update to 2.7.5:
+ * fix for pypy3.9-v7.3.11
+ * register ``bitarray`` as ``abc.MutableSequence``
+ * improve documentation regarding type when indexing single
+ * bitarray items
+
+-------------------------------------------------------------------
Old:
----
bitarray-2.7.3.tar.gz
New:
----
bitarray-2.7.5.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-bitarray.spec ++++++
--- /var/tmp/diff_new_pack.krW5sz/_old 2023-06-12 15:26:52.027199555 +0200
+++ /var/tmp/diff_new_pack.krW5sz/_new 2023-06-12 15:26:52.035199602 +0200
@@ -18,7 +18,7 @@
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
Name: python-bitarray
-Version: 2.7.3
+Version: 2.7.5
Release: 0
Summary: Efficient Arrays of Booleans
License: Python-2.0
++++++ bitarray-2.7.3.tar.gz -> bitarray-2.7.5.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/bitarray-2.7.3/.github/workflows/build_wheels.yml
new/bitarray-2.7.5/.github/workflows/build_wheels.yml
--- old/bitarray-2.7.3/.github/workflows/build_wheels.yml 2023-02-21
00:10:29.000000000 +0100
+++ new/bitarray-2.7.5/.github/workflows/build_wheels.yml 2023-06-10
21:56:55.000000000 +0200
@@ -8,7 +8,7 @@
runs-on: ${{ matrix.os }}
strategy:
matrix:
- os: [ubuntu-20.04, windows-2019, macos-10.15]
+ os: [ubuntu-20.04, windows-2019, macos-11]
steps:
- uses: actions/checkout@v2
@@ -25,7 +25,6 @@
env:
# configure cibuildwheel to build native archs ('auto'), and some
# emulated ones
- CIBW_SKIP: pp*
CIBW_ARCHS_LINUX: auto aarch64 ppc64le s390x
CIBW_ARCHS_MACOS: x86_64 universal2 arm64
CIBW_TEST_COMMAND: python -c "import bitarray; assert
bitarray.test().wasSuccessful()"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/bitarray-2.7.3/CHANGE_LOG
new/bitarray-2.7.5/CHANGE_LOG
--- old/bitarray-2.7.3/CHANGE_LOG 2023-02-21 00:10:29.000000000 +0100
+++ new/bitarray-2.7.5/CHANGE_LOG 2023-06-10 21:56:55.000000000 +0200
@@ -1,3 +1,18 @@
+2023-06-10 2.7.5:
+-------------------
+ * fix for pypy3.9-v7.3.11, #198 (fixes #188)
+ * enable building wheels for PyPy
+
+
+2023-05-29 2.7.4:
+-------------------
+ * register `bitarray` as `abc.MutableSequence`, see #196
+ * cibuildwheel: update macOS version to 11 from unsupported 10.15, see
+ https://github.com/actions/runner-images/issues/5583
+ * improve documentation regarding type when indexing single
+ bitarray items, #192
+
+
2023-02-20 2.7.3:
-------------------
* fix popcount64 name conflict on NetBSD, #189
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/bitarray-2.7.3/README.rst
new/bitarray-2.7.5/README.rst
--- old/bitarray-2.7.3/README.rst 2023-02-21 00:10:29.000000000 +0100
+++ new/bitarray-2.7.5/README.rst 2023-06-10 21:56:55.000000000 +0200
@@ -63,7 +63,7 @@
$ python -c 'import bitarray; bitarray.test()'
bitarray is installed in: /Users/ilan/bitarray/bitarray
- bitarray version: 2.7.3
+ bitarray version: 2.7.5
sys.version: 3.11.0 (main, Oct 25 2022) [Clang 14.0.4]
sys.prefix: /Users/ilan/Mini3/envs/py311
pointer size: 64 bit
@@ -76,7 +76,7 @@
.........................................................................
................................................................
----------------------------------------------------------------------
- Ran 467 tests in 0.460s
+ Ran 468 tests in 0.460s
OK
@@ -118,6 +118,12 @@
>>> a = bitarray(lst) # initialize from iterable
>>> a
bitarray('10011')
+ >>> a[2] # indexing a single item will always return an integer
+ 0
+ >>> a[2:4] # whereas indexing a slice will always return a bitarray
+ bitarray('01')
+ >>> a[2:3] # even when the slice length is just one
+ bitarray('0')
>>> a.count(1)
3
>>> a.remove(0) # removes first occurrence of 0
@@ -401,7 +407,7 @@
Reference
=========
-bitarray version: 2.7.3 -- `change log
<https://github.com/ilanschnell/bitarray/blob/master/doc/changelog.rst>`__
+bitarray version: 2.7.5 -- `change log
<https://github.com/ilanschnell/bitarray/blob/master/doc/changelog.rst>`__
In the following, ``item`` and ``value`` are usually a single bit -
an integer 0 or 1.
@@ -535,10 +541,12 @@
``fromfile(f, n=-1, /)``
- Extend bitarray with up to n bytes read from the file object f.
- When n is omitted or negative, reads all data until EOF.
- When n is provided and positive but exceeds the data available,
- ``EOFError`` is raised (but the available data is still read and appended.
+ Extend bitarray with up to ``n`` bytes read from file object ``f`` (or any
+ other binary stream what supports a ``.read()`` method, e.g.
``io.BytesIO``).
+ Each read byte will add eight bits to the bitarray. When ``n`` is omitted
or
+ negative, all bytes until EOF are read. When ``n`` is non-negative but
+ exceeds the data available, ``EOFError`` is raised (but the available data
+ is still read and appended).
``index(sub_bitarray, start=0, stop=<end of array>, /)`` -> int
@@ -582,7 +590,7 @@
``pop(index=-1, /)`` -> item
- Return the i-th (default last) element and delete it from the bitarray.
+ Remove and return item at ``index`` (default last).
Raises ``IndexError`` if index is out of range.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/bitarray-2.7.3/bitarray/_bitarray.c
new/bitarray-2.7.5/bitarray/_bitarray.c
--- old/bitarray-2.7.3/bitarray/_bitarray.c 2023-02-21 00:10:29.000000000
+0100
+++ new/bitarray-2.7.5/bitarray/_bitarray.c 2023-06-10 21:56:55.000000000
+0200
@@ -1540,10 +1540,12 @@
PyDoc_STRVAR(fromfile_doc,
"fromfile(f, n=-1, /)\n\
\n\
-Extend bitarray with up to n bytes read from the file object f.\n\
-When n is omitted or negative, reads all data until EOF.\n\
-When n is provided and positive but exceeds the data available,\n\
-`EOFError` is raised (but the available data is still read and appended.");
+Extend bitarray with up to `n` bytes read from file object `f` (or any\n\
+other binary stream what supports a `.read()` method, e.g. `io.BytesIO`).\n\
+Each read byte will add eight bits to the bitarray. When `n` is omitted or\n\
+negative, all bytes until EOF are read. When `n` is non-negative but\n\
+exceeds the data available, `EOFError` is raised (but the available data\n\
+is still read and appended).");
static PyObject *
@@ -1688,7 +1690,7 @@
PyDoc_STRVAR(pop_doc,
"pop(index=-1, /) -> item\n\
\n\
-Return the i-th (default last) element and delete it from the bitarray.\n\
+Remove and return item at `index` (default last).\n\
Raises `IndexError` if index is out of range.");
@@ -1987,7 +1989,7 @@
functionality inside bitarray_ass_subscr() would make the function
incomprehensibly long. */
-/* set elements in self, specified by slice, to other bitarray */
+/* set items in self, specified by slice, to other bitarray */
static int
setslice_bitarray(bitarrayobject *self, PyObject *slice,
bitarrayobject *other)
@@ -2046,7 +2048,7 @@
return res;
}
-/* set elements in self, specified by slice, to value */
+/* set items in self, specified by slice, to value */
static int
setslice_bool(bitarrayobject *self, PyObject *slice, PyObject *value)
{
@@ -2082,7 +2084,7 @@
return 0;
}
-/* delete elements in self, specified by slice */
+/* delete items in self, specified by slice */
static int
delslice(bitarrayobject *self, PyObject *slice)
{
@@ -3852,6 +3854,30 @@
/******************************* Install Module ***************************/
#if IS_PY3K
+/* register bitarray as collections.abc.MutableSequence */
+static int
+register_abc(void)
+{
+ PyObject *abc_module, *mutablesequence, *res;
+
+ if ((abc_module = PyImport_ImportModule("collections.abc")) == NULL)
+ return -1;
+
+ mutablesequence = PyObject_GetAttrString(abc_module, "MutableSequence");
+ Py_DECREF(abc_module);
+ if (mutablesequence == NULL)
+ return -1;
+
+ res = PyObject_CallMethod(mutablesequence, "register", "O",
+ (PyObject *) &Bitarray_Type);
+ Py_DECREF(mutablesequence);
+ if (res == NULL)
+ return -1;
+
+ Py_DECREF(res);
+ return 0;
+}
+
static PyModuleDef moduledef = {
PyModuleDef_HEAD_INIT, "_bitarray", 0, -1, module_functions,
};
@@ -3882,6 +3908,11 @@
Py_INCREF((PyObject *) &Bitarray_Type);
PyModule_AddObject(m, "bitarray", (PyObject *) &Bitarray_Type);
+#if IS_PY3K
+ if (register_abc() < 0)
+ goto error;
+#endif
+
if (PyType_Ready(&DecodeTree_Type) < 0)
goto error;
Py_SET_TYPE(&DecodeTree_Type, &PyType_Type);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/bitarray-2.7.3/bitarray/_util.c
new/bitarray-2.7.5/bitarray/_util.c
--- old/bitarray-2.7.3/bitarray/_util.c 2023-02-21 00:10:29.000000000 +0100
+++ new/bitarray-2.7.5/bitarray/_util.c 2023-06-10 21:56:55.000000000 +0200
@@ -33,7 +33,7 @@
}
/* return new bitarray of length `nbits` (with uninitialized buffer) and
- endianness given by the PyObject 'endian' */
+ endianness given by the PyObject 'endian' (which may be Py_None) */
static bitarrayobject *
new_bitarray(Py_ssize_t nbits, PyObject *endian)
{
@@ -43,7 +43,7 @@
if ((args = PyTuple_New(2)) == NULL)
return NULL;
- /* PyTuple_SET_ITEM âstealsâ a reference to item */
+ /* PyTuple_SET_ITEM "steals" a reference to item */
PyTuple_SET_ITEM(args, 0, PyLong_FromSsize_t(nbits));
Py_INCREF(endian);
PyTuple_SET_ITEM(args, 1, endian);
@@ -2001,7 +2001,7 @@
(PyCFunction) chdi_new, METH_VARARGS, chdi_doc},
#ifndef NDEBUG
/* functionality exposed in debug mode for testing */
- {"_sc_rts", (PyCFunction) sc_rts, METH_O, 0},
+ {"_sc_rts", (PyCFunction) sc_rts, METH_O, 0},
#endif
{NULL, NULL} /* sentinel */
};
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/bitarray-2.7.3/bitarray/bitarray.h
new/bitarray-2.7.5/bitarray/bitarray.h
--- old/bitarray-2.7.3/bitarray/bitarray.h 2023-02-21 00:10:29.000000000
+0100
+++ new/bitarray-2.7.5/bitarray/bitarray.h 2023-06-10 21:56:55.000000000
+0200
@@ -4,7 +4,7 @@
Author: Ilan Schnell
*/
-#define BITARRAY_VERSION "2.7.3"
+#define BITARRAY_VERSION "2.7.5"
#ifdef STDC_HEADERS
#include <stddef.h>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/bitarray-2.7.3/bitarray/pythoncapi_compat.h
new/bitarray-2.7.5/bitarray/pythoncapi_compat.h
--- old/bitarray-2.7.3/bitarray/pythoncapi_compat.h 2023-02-21
00:10:29.000000000 +0100
+++ new/bitarray-2.7.5/bitarray/pythoncapi_compat.h 2023-06-10
21:56:55.000000000 +0200
@@ -390,7 +390,8 @@
// bpo-37194 added PyObject_CallNoArgs() to Python 3.9.0a1
-#if PY_VERSION_HEX < 0x030900A1 || defined(PYPY_VERSION)
+// PyObject_CallNoArgs() added to PyPy 3.9.16-v7.3.11
+#if !defined(PyObject_CallNoArgs) && PY_VERSION_HEX < 0x030900A1
PYCAPI_COMPAT_STATIC_INLINE(PyObject*)
PyObject_CallNoArgs(PyObject *func)
{
@@ -401,7 +402,8 @@
// bpo-39245 made PyObject_CallOneArg() public (previously called
// _PyObject_CallOneArg) in Python 3.9.0a4
-#if PY_VERSION_HEX < 0x030900A4 || defined(PYPY_VERSION)
+// PyObject_CallOneArg() added to PyPy 3.9.16-v7.3.11
+#if !defined(PyObject_CallOneArg) && PY_VERSION_HEX < 0x030900A4
PYCAPI_COMPAT_STATIC_INLINE(PyObject*)
PyObject_CallOneArg(PyObject *func, PyObject *arg)
{
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/bitarray-2.7.3/bitarray/test_bitarray.py
new/bitarray-2.7.5/bitarray/test_bitarray.py
--- old/bitarray-2.7.3/bitarray/test_bitarray.py 2023-02-21
00:10:29.000000000 +0100
+++ new/bitarray-2.7.5/bitarray/test_bitarray.py 2023-06-10
21:56:55.000000000 +0200
@@ -1580,6 +1580,17 @@
self.assertRaises(TypeError, hash, a)
self.assertRaises(TypeError, dict, [(a, 'foo')])
+ @skipIf(sys.version_info[0] == 2)
+ def test_abc(self):
+ from collections import abc
+
+ a = bitarray('001')
+ self.assertIsInstance(a, abc.Sequence)
+ self.assertIsInstance(a, abc.MutableSequence)
+ if sys.platform != "win32":
+ self.assertFalse(isinstance(a, abc.Hashable))
+
+
tests.append(MiscTests)
# ---------------------------------------------------------------------------
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/bitarray-2.7.3/bitarray/test_util.py
new/bitarray-2.7.5/bitarray/test_util.py
--- old/bitarray-2.7.3/bitarray/test_util.py 2023-02-21 00:10:29.000000000
+0100
+++ new/bitarray-2.7.5/bitarray/test_util.py 2023-06-10 21:56:55.000000000
+0200
@@ -1429,8 +1429,9 @@
@skipIf(not DEBUG)
def test_rts_empty(self):
- a = bitarray()
- self.assertEqual(_sc_rts(a), [0])
+ rts = _sc_rts(bitarray())
+ self.assertEqual(len(rts), 1)
+ self.assertEqual(rts, [0])
@skipIf(_SEGSIZE != 32)
def test_rts_example(self):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/bitarray-2.7.3/doc/changelog.rst
new/bitarray-2.7.5/doc/changelog.rst
--- old/bitarray-2.7.3/doc/changelog.rst 2023-02-21 00:10:29.000000000
+0100
+++ new/bitarray-2.7.5/doc/changelog.rst 2023-06-10 21:56:55.000000000
+0200
@@ -1,6 +1,21 @@
Change log
==========
+**2.7.5** (2023-06-10):
+
+* fix for pypy3.9-v7.3.11, `#198
<https://github.com/ilanschnell/bitarray/issues/198>`__ (fixes `#188
<https://github.com/ilanschnell/bitarray/issues/188>`__)
+* enable building wheels for PyPy
+
+
+**2.7.4** (2023-05-29):
+
+* register ``bitarray`` as ``abc.MutableSequence``, see `#196
<https://github.com/ilanschnell/bitarray/issues/196>`__
+* cibuildwheel: update macOS version to 11 from unsupported 10.15, see
+ https://github.com/actions/runner-images/issues/5583
+* improve documentation regarding type when indexing single
+ bitarray items, `#192 <https://github.com/ilanschnell/bitarray/issues/192>`__
+
+
**2.7.3** (2023-02-20):
* fix popcount64 name conflict on NetBSD, `#189
<https://github.com/ilanschnell/bitarray/issues/189>`__
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/bitarray-2.7.3/doc/reference.rst
new/bitarray-2.7.5/doc/reference.rst
--- old/bitarray-2.7.3/doc/reference.rst 2023-02-21 00:10:29.000000000
+0100
+++ new/bitarray-2.7.5/doc/reference.rst 2023-06-10 21:56:55.000000000
+0200
@@ -1,7 +1,7 @@
Reference
=========
-bitarray version: 2.7.3 -- `change log
<https://github.com/ilanschnell/bitarray/blob/master/doc/changelog.rst>`__
+bitarray version: 2.7.5 -- `change log
<https://github.com/ilanschnell/bitarray/blob/master/doc/changelog.rst>`__
In the following, ``item`` and ``value`` are usually a single bit -
an integer 0 or 1.
@@ -135,10 +135,12 @@
``fromfile(f, n=-1, /)``
- Extend bitarray with up to n bytes read from the file object f.
- When n is omitted or negative, reads all data until EOF.
- When n is provided and positive but exceeds the data available,
- ``EOFError`` is raised (but the available data is still read and appended.
+ Extend bitarray with up to ``n`` bytes read from file object ``f`` (or any
+ other binary stream what supports a ``.read()`` method, e.g.
``io.BytesIO``).
+ Each read byte will add eight bits to the bitarray. When ``n`` is omitted
or
+ negative, all bytes until EOF are read. When ``n`` is non-negative but
+ exceeds the data available, ``EOFError`` is raised (but the available data
+ is still read and appended).
``index(sub_bitarray, start=0, stop=<end of array>, /)`` -> int
@@ -182,7 +184,7 @@
``pop(index=-1, /)`` -> item
- Return the i-th (default last) element and delete it from the bitarray.
+ Remove and return item at ``index`` (default last).
Raises ``IndexError`` if index is out of range.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/bitarray-2.7.3/examples/distance.py
new/bitarray-2.7.5/examples/distance.py
--- old/bitarray-2.7.3/examples/distance.py 2023-02-21 00:10:29.000000000
+0100
+++ new/bitarray-2.7.5/examples/distance.py 2023-06-10 21:56:55.000000000
+0200
@@ -3,7 +3,7 @@
corresponding functions in the scipy.spatial.distance module.
The functions in this module are typically around 10 to 50 times faster.
"""
-from time import time
+from time import perf_counter
from bitarray.util import _correspond_all, count_and, count_xor, urandom
@@ -59,18 +59,19 @@
for name in ['dice', 'hamming', 'jaccard', 'kulczynski1',
'rogerstanimoto', 'russellrao', 'sokalmichener',
'sokalsneath', 'yule']:
- f1 = eval(name)
- t0 = time()
+
+ f1 = eval(name) # function defined above
+ t0 = perf_counter()
x1 = f1(a, b)
- t1 = time() - t0
- print('%.14f %9.6f sec %s' % (x1, t1, name))
+ t1 = perf_counter() - t0
+ print('%.14f %6.3f ms %s' % (x1, 1000.0 * t1, name))
- f2 = getattr(distance, name)
- t0 = time()
+ f2 = getattr(distance, name) # scipy.spatial.distance function
+ t0 = perf_counter()
x2 = f2(aa, bb)
- t2 = time() - t0
- print('%.14f %9.6f sec %9.2f' % (x2, t2, t2 / t1))
+ t2 = perf_counter() - t0
+ print('%.14f %6.3f ms %9.2f' % (x2, 1000.0 * t2, t2 / t1))
assert abs(x1 - x2) < 1E-14
-test(2 ** 25 + 67)
+test(2 ** 20 + 67)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/bitarray-2.7.3/examples/hexadecimal.py
new/bitarray-2.7.5/examples/hexadecimal.py
--- old/bitarray-2.7.3/examples/hexadecimal.py 2023-02-21 00:10:29.000000000
+0100
+++ new/bitarray-2.7.5/examples/hexadecimal.py 2023-06-10 21:56:55.000000000
+0200
@@ -1,4 +1,4 @@
-from time import time
+from time import perf_counter
from bitarray import bitarray, get_default_endian
from bitarray.util import urandom, ba2hex, hex2ba, ba2base, base2ba
@@ -42,16 +42,16 @@
# g: function which takes hexstr and returns bitarray
# n: size of random bitarray
a = urandom(n, endian)
- t0 = time()
+ t0 = perf_counter()
s = f(a)
- print('%s: %9.6f sec' % (f.__name__, time() - t0))
- t0 = time()
+ print('%s: %6.3f ms' % (f.__name__, 1000.0 * (perf_counter() - t0)))
+ t0 = perf_counter()
b = g(s, endian)
- print('%s: %9.6f sec' % (g.__name__, time() - t0))
+ print('%s: %6.3f ms' % (g.__name__, 1000.0 * (perf_counter() - t0)))
assert b == a
if __name__ == '__main__':
- n = 100 * 1000 * 1000 + 4
+ n = 1000 * 1000 + 4
for endian in 'little', 'big':
print('%s-endian:' % endian)
for f in ba2hex, ba2_base16, prefix_ba2hex:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/bitarray-2.7.3/examples/huffman/decodetree.py
new/bitarray-2.7.5/examples/huffman/decodetree.py
--- old/bitarray-2.7.3/examples/huffman/decodetree.py 2023-02-21
00:10:29.000000000 +0100
+++ new/bitarray-2.7.5/examples/huffman/decodetree.py 2023-06-10
21:56:55.000000000 +0200
@@ -1,20 +1,20 @@
from random import random, randint
-from time import time
+from time import perf_counter
from bitarray import bitarray, decodetree
from bitarray.util import huffman_code
-N = 1000 * 1000
+N = 100_000
# create Huffman code for N symbols
code = huffman_code({i: random() for i in range(N)})
print(len(code))
# create the decodetree object
-t0 = time()
+t0 = perf_counter()
tree = decodetree(code)
-print('decodetree(code): %9.6f sec' % (time() - t0))
+print('decodetree(code): %9.6f ms' % (1000.0 * (perf_counter() - t0)))
print(tree.nodes())
plain = [randint(0, N - 1) for _ in range(100)]
@@ -23,14 +23,14 @@
a.encode(code, plain)
# decode using the code dictionary
-t0 = time()
+t0 = perf_counter()
res = a.decode(code)
-print('decode(code): %9.6f sec' % (time() - t0))
+print('decode(code): %9.6f ms' % (1000.0 * (perf_counter() - t0)))
assert res == plain
# decode using the decodetree
-t0 = time()
+t0 = perf_counter()
res = a.decode(tree)
-print('decode(tree): %9.6f sec' % (time() - t0))
+print('decode(tree): %9.6f ms' % (1000.0 * (perf_counter() - t0)))
assert res == plain
assert tree.todict() == code
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/bitarray-2.7.3/examples/huffman/decoding.py
new/bitarray-2.7.5/examples/huffman/decoding.py
--- old/bitarray-2.7.3/examples/huffman/decoding.py 2023-02-21
00:10:29.000000000 +0100
+++ new/bitarray-2.7.5/examples/huffman/decoding.py 2023-06-10
21:56:55.000000000 +0200
@@ -1,5 +1,5 @@
from optparse import OptionParser
-from time import time
+from time import perf_counter
from collections import Counter
from bitarray import bitarray
@@ -31,13 +31,13 @@
with open(filename, 'rb') as fi:
plain = bytearray(fi.read())
- t0 = time()
+ t0 = perf_counter()
freq = Counter(plain)
- print('count: %9.6f sec' % (time() - t0))
+ print('count: %9.3f ms' % (1000.0 * (perf_counter() - t0)))
- t0 = time()
+ t0 = perf_counter()
tree = _huffman_tree(freq)
- print('tree: %9.6f sec' % (time() - t0))
+ print('tree: %9.3f ms' % (1000.0 * (perf_counter() - t0)))
if opts.tree:
write_dot(tree, 'tree.dot', 0 in plain)
@@ -50,22 +50,22 @@
a = bitarray()
- t0 = time()
+ t0 = perf_counter()
a.encode(code, plain)
- print('C encode: %9.6f sec' % (time() - t0))
+ print('C encode: %9.3f ms' % (1000.0 * (perf_counter() - t0)))
# Time the decode function above
- t0 = time()
+ t0 = perf_counter()
res = bytearray(iterdecode(tree, a))
- Py_time = time() - t0
- print('Py decode: %9.6f sec' % Py_time)
+ Py_time = perf_counter() - t0
+ print('Py decode: %9.3f ms' % (1000.0 * Py_time))
assert res == plain
# Time the decode method which is implemented in C
- t0 = time()
+ t0 = perf_counter()
res = bytearray(a.iterdecode(code))
- C_time = time() - t0
- print('C decode: %9.6f sec' % C_time)
+ C_time = perf_counter() - t0
+ print('C decode: %9.3f ms' % (1000.0 * C_time))
assert res == plain
print('Ratio: %f' % (Py_time / C_time))
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/bitarray-2.7.3/examples/puff/gunzip.py
new/bitarray-2.7.5/examples/puff/gunzip.py
--- old/bitarray-2.7.3/examples/puff/gunzip.py 2023-02-21 00:10:29.000000000
+0100
+++ new/bitarray-2.7.5/examples/puff/gunzip.py 2023-06-10 21:56:55.000000000
+0200
@@ -17,7 +17,7 @@
12: "QDOS", 13: "Acorn RISCOS", 255: "Unknown",
}
- def read_null_terminated_string(self) -> str:
+ def read_nul_terminated_string(self) -> str:
a = bytearray()
while True:
b: int = self.read_uint(8)
@@ -25,7 +25,12 @@
return a.decode("UTF-8")
a.append(b)
- def read_header(self) -> None:
+ def read_header(self, verbose=False) -> None:
+
+ def vprint(txt):
+ if verbose:
+ print(txt)
+
if self.read_uint(16) != 0x8b1f:
raise ValueError("Invalid GZIP magic number")
@@ -36,44 +41,44 @@
# reserved flags
flags: int = self.read_uint(8)
if flags & 0xe0 != 0:
- print("Reserved flags are set")
+ vprint("Reserved flags are set")
# modification time
mtime = self.read_uint(32)
if mtime != 0:
dt = datetime.datetime.fromtimestamp(mtime, datetime.timezone.utc)
- print(f"Last modified: {dt}")
+ vprint(f"Last modified: {dt}")
else:
- print("Last modified: N/A")
+ vprint("Last modified: N/A")
# extra flags
extraflags = self.read_uint(8)
if extraflags == 2:
- print("Extra flags: Maximum compression")
+ vprint("Extra flags: Maximum compression")
elif extraflags == 4:
- print("Extra flags: Fastest compression")
+ vprint("Extra flags: Fastest compression")
else:
- print(f"Extra flags: Unknown ({extraflags})")
+ vprint(f"Extra flags: Unknown ({extraflags})")
osbyte = self.read_uint(8)
osstr: str = self.operating_system.get(osbyte, "Really unknown")
- print(f"Operating system: {osstr}")
+ vprint(f"Operating system: {osstr}")
# handle assorted flags
if flags & 0x01:
- print("Flag: Text")
+ vprint("Flag: Text")
if flags & 0x04:
- print("Flag: Extra")
+ vprint("Flag: Extra")
count: int = self.read_uint(16)
while count > 0: # Skip extra data
self.read_uint(8)
count -= 1
if flags & 0x08:
- print(f"File name: {self.read_null_terminated_string()}")
+ vprint(f"File name: {self.read_nul_terminated_string()}")
if flags & 0x02:
- print(f"Header CRC-16: {self.read_uint(16):04X}")
+ vprint(f"Header CRC-16: {self.read_uint(16):04X}")
if flags & 0x10:
- print(f"Comment: {self.read_null_terminated_string()}")
+ vprint(f"Comment: {self.read_nul_terminated_string()}")
def check_footer(self, decomp):
self.align_byte_boundary()
@@ -104,7 +109,7 @@
# gunzip: the output is accumulated in a bytearray
output = bytearray()
d = GunZip(input_bits, output)
- d.read_header()
+ d.read_header(verbose=opts.verbose)
stats = d.process_blocks(print_dot if opts.progress else None)
d.check_footer(output)
@@ -119,26 +124,35 @@
def main():
- from optparse import OptionParser
+ from argparse import ArgumentParser
+
+ p = ArgumentParser()
- p = OptionParser(usage="usage: %prog [options] IN_FILE.gz [OUT_FILE]")
+ p.add_argument('-p', '--progress', action="store_true",
+ help="show progress while decoding")
- p.add_option('-p', '--progress',
- action="store_true",
- help="show progress while decoding")
+ p.add_argument('-s', '--stats', action="store_true",
+ help="show block statistics")
- p.add_option('-s', '--stats',
- action="store_true",
- help="show block statistics")
+ p.add_argument('-v', '--verbose', action="store_true")
- opts, args = p.parse_args()
+ p.add_argument('-o', '--out', action="store", dest='dst',
+ help='output filename')
- if len(args) not in (1, 2):
- p.error("incorrect number of arguments")
+ p.add_argument(dest='src', metavar='SRC')
- out_file = args[1] if len(args) == 2 else 'out'
+ args = p.parse_args()
+
+ if args.dst is None:
+ if args.src.endswith('.gz'):
+ args.dst = args.src[:-3]
+ elif args.src.endswith('.tgz'):
+ args.dst = '%s.tar' % args.src[:-4]
+ else:
+ p.error('cannot guess uncompressed filename from %r, '
+ 'please provide -o/-out option' % args.src)
- decompress_file(args[0], out_file, opts)
+ decompress_file(args.src, args.dst, args)
if __name__ == "__main__":
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/bitarray-2.7.3/examples/puff/setup.py
new/bitarray-2.7.5/examples/puff/setup.py
--- old/bitarray-2.7.3/examples/puff/setup.py 2023-02-21 00:10:29.000000000
+0100
+++ new/bitarray-2.7.5/examples/puff/setup.py 2023-06-10 21:56:55.000000000
+0200
@@ -1,4 +1,5 @@
import sys
+from os.path import dirname
if sys.version_info[:2] < (3, 6):
sys.exit("This example requires Python 3.6 or higher")
@@ -8,12 +9,14 @@
except ImportError:
from distutils.core import setup, Extension
+import bitarray
+
setup(
name = "puff",
ext_modules = [Extension(
name = "_puff",
sources = ["_puff.c"],
- include_dirs = ["../../bitarray"],
+ include_dirs = [dirname(bitarray.__file__)],
)],
)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/bitarray-2.7.3/examples/sparse/Makefile
new/bitarray-2.7.5/examples/sparse/Makefile
--- old/bitarray-2.7.3/examples/sparse/Makefile 1970-01-01 01:00:00.000000000
+0100
+++ new/bitarray-2.7.5/examples/sparse/Makefile 2023-06-10 21:56:55.000000000
+0200
@@ -0,0 +1,9 @@
+test:
+ python tests.py -
+ python tests.py flips
+ python tests.py ones
+
+
+clean:
+ rm -f *.pyc *~
+ rm -rf __pycache__
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/bitarray-2.7.3/examples/sparse/compress.py
new/bitarray-2.7.5/examples/sparse/compress.py
--- old/bitarray-2.7.3/examples/sparse/compress.py 2023-02-21
00:10:29.000000000 +0100
+++ new/bitarray-2.7.5/examples/sparse/compress.py 2023-06-10
21:56:55.000000000 +0200
@@ -5,7 +5,7 @@
import bz2
import gzip
import sys
-from time import time
+from time import perf_counter
from collections import Counter
from itertools import islice
from random import random, randint
@@ -177,11 +177,11 @@
('gzip', gzip.compress, gzip.decompress),
('bz2', bz2.compress, bz2.decompress)]:
x = a if name in ('serialize', 'vl', 'sc') else raw
- t0 = time()
+ t0 = perf_counter()
b = f_e(x) # compression
- t1 = time()
+ t1 = perf_counter()
c = f_d(b) # decompression
- t2 = time()
+ t2 = perf_counter()
print(" %-11s %16.3f %16.3f %16.4f" %
(name, 1000 * (t1 - t0), 1000 * (t2 - t1), len(b) / len(raw)))
assert c == x
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/bitarray-2.7.3/examples/utf-8.py
new/bitarray-2.7.5/examples/utf-8.py
--- old/bitarray-2.7.3/examples/utf-8.py 1970-01-01 01:00:00.000000000
+0100
+++ new/bitarray-2.7.5/examples/utf-8.py 2023-06-10 21:56:55.000000000
+0200
@@ -0,0 +1,40 @@
+from bitarray import bitarray
+from bitarray.util import ba2int, pprint
+
+
+# See: https://en.wikipedia.org/wiki/UTF-8
+
+def code_point(u):
+ print('character:', u)
+ b = u.encode('utf-8')
+ print('hexadecimal:', ' '.join('%02x' % i for i in bytearray(b)))
+ a = bitarray(endian='big')
+ a.frombytes(b)
+ pprint(a)
+
+ # calculate binary code point from binary UTF-8 representation
+ if a[0:1] == bitarray('0'):
+ c = a[1:8]
+ assert len(a) == 8
+ elif a[0:3] == bitarray('110'):
+ c = a[3:8] + a[10:16]
+ assert a[8:10] == bitarray('10')
+ assert len(a) == 16
+ elif a[0:4] == bitarray('1110'):
+ c = a[4:8] + a[10:16] + a[18:24]
+ assert a[8:10] == a[16:18] == bitarray('10')
+ assert len(a) == 24
+ elif a[0:5] == bitarray('11110'):
+ c = a[5:8] + a[10:16] + a[18:24] + a[26:32]
+ assert a[8:10] == a[16:18] == a[24:26] == bitarray('10')
+ assert len(a) == 32
+ else:
+ raise
+ code_point = ba2int(c)
+
+ print('code point:', hex(code_point))
+ print()
+
+
+for u in u'\u0024 \u00a2 \u20ac \ud55c \U00010348 \U0010ffff'.split():
+ code_point(u)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/bitarray-2.7.3/examples/utf8.py
new/bitarray-2.7.5/examples/utf8.py
--- old/bitarray-2.7.3/examples/utf8.py 2023-02-21 00:10:29.000000000 +0100
+++ new/bitarray-2.7.5/examples/utf8.py 1970-01-01 01:00:00.000000000 +0100
@@ -1,41 +0,0 @@
-from __future__ import print_function
-from bitarray import bitarray
-from bitarray.util import ba2int, pprint
-
-
-# See: https://en.wikipedia.org/wiki/UTF-8
-
-def code_point(u):
- print('character:', u)
- b = u.encode('utf-8')
- print('hexadecimal:', ' '.join('%02x' % i for i in bytearray(b)))
- a = bitarray(endian='big')
- a.frombytes(b)
- pprint(a)
-
- # calculate binary code point from binary UTF-8 representation
- if a[0:1] == bitarray('0'):
- c = a[1:8]
- assert len(a) == 8
- elif a[0:3] == bitarray('110'):
- c = a[3:8] + a[10:16]
- assert a[8:10] == bitarray('10')
- assert len(a) == 16
- elif a[0:4] == bitarray('1110'):
- c = a[4:8] + a[10:16] + a[18:24]
- assert a[8:10] == a[16:18] == bitarray('10')
- assert len(a) == 24
- elif a[0:5] == bitarray('11110'):
- c = a[5:8] + a[10:16] + a[18:24] + a[26:32]
- assert a[8:10] == a[16:18] == a[24:26] == bitarray('10')
- assert len(a) == 32
- else:
- raise
- code_point = ba2int(c)
-
- print('code point:', hex(code_point))
- print()
-
-
-for u in u'\u0024 \u00a2 \u20ac \ud55c \U00010348 \U0010ffff'.split():
- code_point(u)