Hello community, here is the log from the commit of package python-bitarray for openSUSE:Factory checked in at 2020-09-30 19:54:21 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-bitarray (Old) and /work/SRC/openSUSE:Factory/.python-bitarray.new.4249 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-bitarray" Wed Sep 30 19:54:21 2020 rev:5 rq:838633 version:1.5.3 Changes: -------- --- /work/SRC/openSUSE:Factory/python-bitarray/python-bitarray.changes 2020-08-31 16:51:12.696382388 +0200 +++ /work/SRC/openSUSE:Factory/.python-bitarray.new.4249/python-bitarray.changes 2020-09-30 19:54:40.516799937 +0200 @@ -1,0 +2,7 @@ +Wed Sep 30 04:35:36 UTC 2020 - Steve Kowalik <steven.kowa...@suse.com> + +- Update to 1.5.3: + * add optional index parameter to `.index()` to invert single bit + * fix `sys.getsizeof(bitarray)` by adding `.__sizeof__()`, see issue #100 + +------------------------------------------------------------------- Old: ---- bitarray-1.5.2.tar.gz New: ---- bitarray-1.5.3.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-bitarray.spec ++++++ --- /var/tmp/diff_new_pack.byfWWI/_old 2020-09-30 19:54:41.096800456 +0200 +++ /var/tmp/diff_new_pack.byfWWI/_new 2020-09-30 19:54:41.100800459 +0200 @@ -18,7 +18,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-bitarray -Version: 1.5.2 +Version: 1.5.3 Release: 0 Summary: Efficient Arrays of Booleans License: Python-2.0 ++++++ bitarray-1.5.2.tar.gz -> bitarray-1.5.3.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bitarray-1.5.2/CHANGE_LOG new/bitarray-1.5.3/CHANGE_LOG --- old/bitarray-1.5.2/CHANGE_LOG 2020-08-16 23:16:22.000000000 +0200 +++ new/bitarray-1.5.3/CHANGE_LOG 2020-08-24 21:14:16.000000000 +0200 @@ -1,3 +1,9 @@ +2020-08-24 1.5.3: +------------------- + * add optional index parameter to `.index()` to invert single bit + * fix `sys.getsizeof(bitarray)` by adding `.__sizeof__()`, see issue #100 + + 2020-08-16 1.5.2: ------------------- * add PyType_Ready usage, issue #66 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bitarray-1.5.2/README.md new/bitarray-1.5.3/README.md --- old/bitarray-1.5.2/README.md 2020-08-16 23:16:22.000000000 +0200 +++ new/bitarray-1.5.3/README.md 2020-08-24 21:14:16.000000000 +0200 @@ -35,23 +35,33 @@ Bitarray can be installed from source: - $ tar xzf bitarray-1.5.2.tar.gz - $ cd bitarray-1.5.2 + $ tar xzf bitarray-1.5.3.tar.gz + $ cd bitarray-1.5.3 $ python setup.py install On Unix systems, the latter command may have to be executed with root -privileges. You can also pip install bitarray. +privileges. You can also pip install bitarray. Please note that you need +a working C compiler to run the `python setup.py install` command. +If you rather want to use precompiled binaries, you can: + +* `pip install bitarray-hardbyte` (this PyPI package contains Python + wheels for Linux, MaxOSX and Windows and all common Python versions) +* `conda install bitarray` (both the default Anaconda repository as well + as conda-forge support bitarray) +* download Windows wheels from + [Chris Gohlke](https://www.lfd.uci.edu/~gohlke/pythonlibs/#bitarray) + Once you have installed the package, you may want to test it: $ python -c 'import bitarray; bitarray.test()' bitarray is installed in: /usr/local/lib/python2.7/site-packages/bitarray - bitarray version: 1.5.2 + bitarray version: 1.5.3 3.7.4 (r271:86832, Dec 29 2018) [GCC 4.2.1 (SUSE Linux)] ......................................................................... ......................................................................... .............................. ---------------------------------------------------------------------- - Ran 230 tests in 0.889s + Ran 250 tests in 0.921s OK @@ -420,10 +430,10 @@ Insert `bool(value)` into the bitarray before index. -`invert()` +`invert(index=<all bits>)` -Invert all bits in the array (in-place), -i.e. convert each 1-bit into a 0-bit and vice versa. +Invert all bits in the array (in-place). +When the optional `index` is given, only invert the single bit at index. `iterdecode(code, /)` -> iterator @@ -674,6 +684,12 @@ Change log ---------- +*1.5.3* (2020-08-24): + + * add optional index parameter to `.index()` to invert single bit + * fix `sys.getsizeof(bitarray)` by adding `.__sizeof__()`, see issue #100 + + *1.5.2* (2020-08-16): * add PyType_Ready usage, issue #66 @@ -705,44 +721,4 @@ in 2013). We do NOT plan to stop support for Python 2.7 anytime soon. -*1.4.2* (2020-07-15): - - * add more tests - * C-level: - - simplify pack/unpack code - - fix memory leak in `~` operation (bitarray_cpinvert) - - -*1.4.1* (2020-07-14): - - * add official Python 3.9 support - * improve many docstrings - * add DeprecationWarning for `bitdiff()` - * add DeprecationWarning when trying to extend bitarrays - from bytes on Python 3 (`bitarrays(b'011')` and `.extend(b'110')`) - * C-level: - - Rewrote `.fromfile()` and `.tofile()` implementation, - such that now the same code is used for Python 2 and 3. - The new implementation is more memoery efficient on - Python 3. - - use memcmp() in richcompare to shortcut EQ/NE, when - comparing two very large bitarrays for equality the - speedup can easily be 100x - - simplify how unpacking is handled - * add more tests - - -*1.4.0* (2020-07-11): - - * add `.clear()` method (Python 3.3 added this method to lists) - * avoid overallocation when bitarray objects are initially created - * raise BufferError when resizing bitarrays which is exporting buffers - * add example to study the resize() function - * improve some error messages - * add more tests - * raise `NotImplementedError` with (useful message) when trying to call - the `.fromstring()` or `.tostring()` methods, which have been removed - in the last release - - Please find the complete change log [here](https://github.com/ilanschnell/bitarray/blob/master/CHANGE_LOG). diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bitarray-1.5.2/bitarray/_bitarray.c new/bitarray-1.5.3/bitarray/_bitarray.c --- old/bitarray-1.5.2/bitarray/_bitarray.c 2020-08-16 23:16:22.000000000 +0200 +++ new/bitarray-1.5.3/bitarray/_bitarray.c 2020-08-24 21:14:16.000000000 +0200 @@ -7,7 +7,7 @@ Author: Ilan Schnell */ -#define BITARRAY_VERSION "1.5.2" +#define BITARRAY_VERSION "1.5.3" #define PY_SSIZE_T_CLEAN #include "Python.h" @@ -727,7 +727,7 @@ PyLong_Check(x)) #endif -/* given an PyLong (which must be 0 or 1), or a PyBool, return 0 or 1, +/* given a PyLong (which must be 0 or 1) or a PyBool, return 0 or 1, or -1 on error */ static int IntBool_AsInt(PyObject *v) @@ -784,7 +784,7 @@ "use len(self) instead", 1) < 0) return NULL; - return PyLong_FromLongLong(self->nbits); + return PyLong_FromSsize_t(self->nbits); } PyDoc_STRVAR(length_doc, @@ -831,7 +831,7 @@ normalize_index(self->nbits, &start); normalize_index(self->nbits, &stop); - return PyLong_FromLongLong(count(self, vi, start, stop)); + return PyLong_FromSsize_t(count(self, vi, start, stop)); } PyDoc_STRVAR(count_doc, @@ -862,7 +862,7 @@ PyErr_Format(PyExc_ValueError, "%d is not in bitarray", vi); return NULL; } - return PyLong_FromLongLong(i); + return PyLong_FromSsize_t(i); } PyDoc_STRVAR(index_doc, @@ -920,7 +920,7 @@ p = search(self, xa, p); if (p < 0) break; - item = PyLong_FromLongLong(p); + item = PyLong_FromSsize_t(p); p++; if (item == NULL || PyList_Append(list, item) < 0) { Py_XDECREF(item); @@ -1109,17 +1109,34 @@ static PyObject * -bitarray_invert(bitarrayobject *self) +bitarray_invert(bitarrayobject *self, PyObject *args) { - invert(self); + Py_ssize_t i = PY_SSIZE_T_MAX; + + if (!PyArg_ParseTuple(args, "|n:invert", &i)) + return NULL; + + if (i == PY_SSIZE_T_MAX) { /* default - invert all bits */ + invert(self); + Py_RETURN_NONE; + } + + if (i < 0) + i += self->nbits; + + if (i < 0 || i >= self->nbits) { + PyErr_SetString(PyExc_IndexError, "index out of range"); + return NULL; + } + setbit(self, i, 1 - GETBIT(self, i)); Py_RETURN_NONE; } PyDoc_STRVAR(invert_doc, -"invert()\n\ +"invert(index=<all bits>)\n\ \n\ -Invert all bits in the array (in-place),\n\ -i.e. convert each 1-bit into a 0-bit and vice versa."); +Invert all bits in the array (in-place).\n\ +When the optional `index` is given, only invert the single bit at index."); static PyObject * @@ -1578,6 +1595,19 @@ Remove all items from the bitarray."); +static PyObject * +bitarray_sizeof(bitarrayobject *self) +{ + Py_ssize_t res; + + res = sizeof(bitarrayobject) + self->allocated; + return PyLong_FromSsize_t(res); +} + +PyDoc_STRVAR(sizeof_doc, +"Return the size of the bitarray in memory, in bytes."); + + /* ----------------------- bitarray_as_sequence ------------------------ */ static Py_ssize_t @@ -2447,7 +2477,7 @@ if (p < 0) /* no more positions -- stop iteration */ return NULL; it->p = p + 1; /* next search position */ - return PyLong_FromLongLong(p); + return PyLong_FromSsize_t(p); } static void @@ -2542,7 +2572,7 @@ index_doc}, {"insert", (PyCFunction) bitarray_insert, METH_VARARGS, insert_doc}, - {"invert", (PyCFunction) bitarray_invert, METH_NOARGS, + {"invert", (PyCFunction) bitarray_invert, METH_VARARGS, invert_doc}, {"length", (PyCFunction) bitarray_length, METH_NOARGS, length_doc}, @@ -2582,6 +2612,8 @@ copy_doc}, {"__reduce__", (PyCFunction) bitarray_reduce, METH_NOARGS, reduce_doc}, + {"__sizeof__", (PyCFunction) bitarray_sizeof, METH_NOARGS, + sizeof_doc}, {NULL, NULL} /* sentinel */ }; @@ -3084,7 +3116,7 @@ } #undef aa #undef bb - return PyLong_FromLongLong(res); + return PyLong_FromSsize_t(res); } PyDoc_STRVAR(bitdiff_doc, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bitarray-1.5.2/bitarray/_util.c new/bitarray-1.5.3/bitarray/_util.c --- old/bitarray-1.5.2/bitarray/_util.c 2020-08-16 23:16:22.000000000 +0200 +++ new/bitarray-1.5.3/bitarray/_util.c 2020-08-24 21:14:16.000000000 +0200 @@ -232,7 +232,7 @@ PyErr_SetString(PyExc_ValueError, "n exceeds total count"); return NULL; } - return PyLong_FromLongLong(i); + return PyLong_FromSsize_t(i); } PyDoc_STRVAR(count_n_doc, @@ -264,7 +264,7 @@ PyErr_Format(PyExc_ValueError, "%d not in bitarray", vi); return NULL; } - return PyLong_FromLongLong(i); + return PyLong_FromSsize_t(i); } PyDoc_STRVAR(rindex_doc, @@ -335,7 +335,7 @@ } #undef aa #undef bb - return PyLong_FromLongLong(res); + return PyLong_FromSsize_t(res); } #define COUNT_FUNC(oper, ochar) \ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bitarray-1.5.2/bitarray/test_bitarray.py new/bitarray-1.5.3/bitarray/test_bitarray.py --- old/bitarray-1.5.2/bitarray/test_bitarray.py 2020-08-16 23:16:22.000000000 +0200 +++ new/bitarray-1.5.3/bitarray/test_bitarray.py 2020-08-24 21:14:16.000000000 +0200 @@ -869,7 +869,6 @@ self.assertEqual(any(a), a.any()) self.assertEqual(any(a.tolist()), a.any()) - def test_repr(self): r = repr(bitarray()) self.assertEqual(r, "bitarray()") @@ -885,7 +884,6 @@ self.assertEqual(a, b) self.check_obj(b) - def test_copy(self): for a in self.randombitarrays(): b = a.copy() @@ -900,7 +898,6 @@ self.assertFalse(b is a) self.assertEQUAL(a, b) - def assertReallyEqual(self, a, b): # assertEqual first, because it will have a good message if the # assertion fails. @@ -942,9 +939,19 @@ b = a.copy() self.assertReallyEqual(a, b) n = len(a) - b[n - 1] = not b[n - 1] # flip the last bit + b.invert(n - 1) # flip last bit self.assertReallyNotEqual(a, b) + def test_sizeof(self): + a = bitarray() + size = sys.getsizeof(a) + self.assertEqual(size, a.__sizeof__()) + self.assertIsInstance(size, int if is_py3k else (int, long)) + self.assertTrue(size < 200) + a = bitarray(8000) + self.assertTrue(sys.getsizeof(a) > 1000) + + tests.append(SpecialMethodTests) # --------------------------------------------------------------------------- @@ -1170,14 +1177,6 @@ self.assertEQUAL(a, bitarray('010100101')) def test_invert(self): - a = bitarray() - a.invert() - self.assertEQUAL(a, bitarray()) - - a = bitarray('11011') - a.invert() - self.assertEQUAL(a, bitarray('00100')) - a = bitarray('11011') b = ~a self.assertEQUAL(b, bitarray('00100')) @@ -1338,7 +1337,7 @@ class MethodTests(unittest.TestCase, Util): - def test_append(self): + def test_append_simple(self): a = bitarray() a.append(True) a.append(False) @@ -1352,6 +1351,7 @@ a.append('a') self.assertEQUAL(a, bitarray('100011001')) + def test_append_random(self): for a in self.randombitarrays(): aa = a.tolist() b = a @@ -1362,7 +1362,6 @@ b.append('') self.assertEQUAL(b, bitarray(aa + [1, 0], endian=a.endian())) - def test_insert(self): a = bitarray() b = a @@ -1382,7 +1381,6 @@ self.assertEqual(a.tolist(), aa) self.check_obj(a) - def test_index1(self): a = bitarray() for i in (True, False, 1, 0): @@ -1547,7 +1545,6 @@ self.assertEqual(a.count(1, i, j), s[i:j].count('1')) self.assertEqual(a.count(0, i, j), s[i:j].count('0')) - def test_search(self): a = bitarray('') self.assertEqual(a.search(bitarray('0')), []) @@ -1645,8 +1642,36 @@ self.assertEqual(b[len(a):], (len(b) - len(a)) * bitarray('0')) + def test_invert_simple(self): + a = bitarray() + a.invert() + self.assertEQUAL(a, bitarray()) + + a = bitarray('11011') + a.invert() + self.assertEQUAL(a, bitarray('00100')) + a.invert(2) + self.assertEQUAL(a, bitarray('00000')) + a.invert(-1) + self.assertEQUAL(a, bitarray('00001')) + + def test_invert_errors(self): + a = bitarray(5) + self.assertRaises(IndexError, a.invert, 5) + self.assertRaises(IndexError, a.invert, -6) + self.assertRaises(TypeError, a.invert, "A") + self.assertRaises(TypeError, a.invert, 0, 1) + + def test_invert_random(self): + for a in self.randombitarrays(start=1): + b = a.copy() + c = a.copy() + i = randint(0, len(a) - 1) + b.invert(i) + c[i] = not c[i] + self.assertEQUAL(b, c) - def test_sort(self): + def test_sort_simple(self): a = bitarray('1101000') a.sort() self.assertEqual(a, bitarray('0000111')) @@ -1663,26 +1688,14 @@ self.assertRaises(TypeError, a.sort, 'A') - N = 100000 - a = bitarray(randint(N, N + 100)) - for dum in range(100): - a[randint(0, N - 1)] = randint(0, 1) - b = a.tolist() - a.sort() - self.assertEqual(a, bitarray(sorted(b))) - - for a in self.randombitarrays(): - b = a.tolist() - ida = id(a) - rev = randint(0, 1) - a.sort(rev) - self.assertEqual(a, bitarray(sorted(b, reverse=rev))) - self.assertEqual(id(a), ida) - - - def test_reverse(self): - self.assertRaises(TypeError, bitarray().reverse, 42) + def test_sort_random(self): + for rev in 0, 1: + for a in self.randombitarrays(): + b = a.tolist() + a.sort(rev) + self.assertEqual(a, bitarray(sorted(b, reverse=rev))) + def test_reverse_simple(self): for x, y in [('', ''), ('1', '1'), ('10', '01'), ('001', '100'), ('1110', '0111'), ('11100', '00111'), ('011000', '000110'), ('1101100', '0011011'), @@ -1694,15 +1707,14 @@ a.reverse() self.assertEQUAL(a, bitarray(y)) + self.assertRaises(TypeError, bitarray().reverse, 42) + + def test_reverse_random(self): for a in self.randombitarrays(): - aa = a.tolist() - b = bitarray(a) - ida = id(a) + b = a.copy() a.reverse() - self.assertEqual(ida, id(a)) - self.assertEQUAL(a, bitarray(aa[::-1], endian=a.endian())) - self.assertEqual(a, b[::-1]) - + self.assertEQUAL(a, bitarray(b.tolist()[::-1], endian=a.endian())) + self.assertEQUAL(a, b[::-1]) def test_tolist(self): a = bitarray() @@ -1715,18 +1727,7 @@ a = bitarray(lst) self.assertEqual(a.tolist(), lst) - def test_remove(self): - a = bitarray() - for i in (True, False, 1, 0): - self.assertRaises(ValueError, a.remove, i) - - a = bitarray(21) - a.setall(0) - self.assertRaises(ValueError, a.remove, 1) - a.setall(1) - self.assertRaises(ValueError, a.remove, 0) - a = bitarray('1010110') for val, res in [(False, '110110'), (True, '10110'), (1, '0110'), (1, '010'), (0, '10'), @@ -1740,8 +1741,18 @@ self.assertTrue(b is a) self.assertEQUAL(b, bitarray('000011')) + def test_remove_errors(self): + a = bitarray() + for i in (True, False, 1, 0): + self.assertRaises(ValueError, a.remove, i) - def test_pop(self): + a = bitarray(21) + a.setall(0) + self.assertRaises(ValueError, a.remove, 1) + a.setall(1) + self.assertRaises(ValueError, a.remove, 0) + + def test_pop_simple(self): for x, n, r, y in [('1', 0, True, ''), ('0', -1, False, ''), ('0011100', 3, True, '001100')]: @@ -1754,6 +1765,7 @@ self.assertEqual(a.pop(), False) self.assertRaises(IndexError, a.pop) + def test_pop_random(self): for a in self.randombitarrays(): self.assertRaises(IndexError, a.pop, len(a)) self.assertRaises(IndexError, a.pop, -len(a) - 1) @@ -1773,7 +1785,6 @@ self.assertEqual(a, bitarray(aa)) self.check_obj(a) - def test_clear(self): for a in self.randombitarrays(): ida = id(a) @@ -1806,8 +1817,7 @@ self.assertTrue(a is b) self.check_obj(b) - - def test_bytereverse(self): + def test_bytereverse_explicit(self): for x, y in [('', ''), ('1', '0'), ('1011', '0000'), @@ -1820,14 +1830,13 @@ a.bytereverse() self.assertEqual(a, bitarray(y)) + def test_bytereverse_byte(self): for i in range(256): a = bitarray() a.frombytes(bytes(bytearray([i]))) - aa = a.tolist() - b = a + b = a.copy() b.bytereverse() - self.assertEqual(b, bitarray(aa[::-1])) - self.assertTrue(a is b) + self.assertEqual(b, a[::-1]) self.check_obj(b) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bitarray-1.5.2/bitarray/test_util.py new/bitarray-1.5.3/bitarray/test_util.py --- old/bitarray-1.5.2/bitarray/test_util.py 2020-08-16 23:16:22.000000000 +0200 +++ new/bitarray-1.5.3/bitarray/test_util.py 2020-08-24 21:14:16.000000000 +0200 @@ -219,6 +219,16 @@ class TestsCount_N(unittest.TestCase, Util): + @staticmethod + def count_n(a, n): + "return the index i for which a[:i].count() == n" + i, j = n, a.count(1, 0, n) + while j < n: + if a[i]: + j += 1 + i += 1 + return i + def check_result(self, a, n, i): self.assertEqual(a.count(1, 0, i), n) if i: @@ -244,6 +254,7 @@ i = count_n(a, n) self.check_result(a, n, i) self.assertEqual(a[:i].count(), n) + self.assertEqual(i, self.count_n(a, n)) self.assertEQUAL(a, b) def test_frozen(self): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bitarray-1.5.2/examples/README new/bitarray-1.5.3/examples/README --- old/bitarray-1.5.2/examples/README 2020-08-16 23:16:22.000000000 +0200 +++ new/bitarray-1.5.3/examples/README 2020-08-24 21:14:16.000000000 +0200 @@ -13,11 +13,6 @@ current implementation. -helpers.py: - some useful helper function which people have requested, but which are - not common enough to add to the library itself. - - huffman/ Directory containing a library and examples for working with Huffman trees and codes. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bitarray-1.5.2/examples/helpers.py new/bitarray-1.5.3/examples/helpers.py --- old/bitarray-1.5.2/examples/helpers.py 2020-08-16 23:16:22.000000000 +0200 +++ new/bitarray-1.5.3/examples/helpers.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,19 +0,0 @@ -from bitarray import bitarray - - -# an optimized C version of this function can be found in bitarray.util -def count_n(a, n): - "return the index i for which a[:i].count() == n" - i, j = n, a.count(1, 0, n) - while j < n: - if a[i]: - j += 1 - i += 1 - return i - -if __name__ == '__main__': - # count_n - a = bitarray('11111011111011111011111001111011111011111011111010111010111') - for n in range(0, 48): - i = count_n(a, n) - assert a[:i].count() == n diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bitarray-1.5.2/update_readme.py new/bitarray-1.5.3/update_readme.py --- old/bitarray-1.5.2/update_readme.py 2020-08-16 23:16:22.000000000 +0200 +++ new/bitarray-1.5.3/update_readme.py 2020-08-24 21:14:16.000000000 +0200 @@ -21,7 +21,7 @@ for line in open('CHANGE_LOG'): m = ver_pat.match(line) if m: - if count == 6: + if count == 4: break count += 1 fo.write(m.expand(r'*\2* (\1):\n'))