bitarray 3.8.1__tar.gz → 3.8.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bitarray
3
- Version: 3.8.1
3
+ Version: 3.8.2
4
4
  Summary: efficient arrays of booleans -- C extension
5
5
  Home-page: https://github.com/ilanschnell/bitarray
6
6
  Author: Ilan Schnell
@@ -11,7 +11,6 @@ Classifier: Intended Audience :: Developers
11
11
  Classifier: Operating System :: OS Independent
12
12
  Classifier: Programming Language :: C
13
13
  Classifier: Programming Language :: Python :: 3
14
- Classifier: Programming Language :: Python :: 3.6
15
14
  Classifier: Programming Language :: Python :: 3.7
16
15
  Classifier: Programming Language :: Python :: 3.8
17
16
  Classifier: Programming Language :: Python :: 3.9
@@ -91,7 +90,7 @@ Once you have installed the package, you may want to test it:
91
90
 
92
91
  $ python -c 'import bitarray; bitarray.test()'
93
92
  bitarray is installed in: /Users/ilan/bitarray/bitarray
94
- bitarray version: 3.8.1
93
+ bitarray version: 3.8.2
95
94
  sys.version: 3.13.5 (main, Jun 16 2025) [Clang 18.1.8]
96
95
  sys.prefix: /Users/ilan/miniforge
97
96
  pointer size: 64 bit
@@ -354,7 +353,7 @@ and can therefore be used as a dictionary key:
354
353
  Reference
355
354
  =========
356
355
 
357
- bitarray version: 3.8.1 -- `change log <https://github.com/ilanschnell/bitarray/blob/master/doc/changelog.rst>`__
356
+ bitarray version: 3.8.2 -- `change log <https://github.com/ilanschnell/bitarray/blob/master/doc/changelog.rst>`__
358
357
 
359
358
  In the following, ``item`` and ``value`` are usually a single bit -
360
359
  an integer 0 or 1.
@@ -378,7 +377,7 @@ The bitarray object:
378
377
 
379
378
  ``endian``: Specifies the bit-endianness of the created bitarray object.
380
379
  Allowed values are ``big`` and ``little`` (the default is ``big``).
381
- The bit-endianness effects the buffer representation of the bitarray.
380
+ The bit-endianness affects the buffer representation of the bitarray.
382
381
 
383
382
  ``buffer``: Any object which exposes a buffer. When provided, ``initializer``
384
383
  cannot be present (or has to be ``None``). The imported buffer may be
@@ -473,7 +472,7 @@ bitarray methods:
473
472
 
474
473
 
475
474
  ``extend(iterable, /)``
476
- Append items from to the end of the bitarray.
475
+ Append items from iterable to the end of the bitarray.
477
476
  If ``iterable`` is a (Unicode) string, each ``0`` and ``1`` are appended as
478
477
  bits (ignoring whitespace and underscore).
479
478
 
@@ -504,7 +503,7 @@ bitarray methods:
504
503
 
505
504
  ``fromfile(f, n=-1, /)``
506
505
  Extend bitarray with up to ``n`` bytes read from file object ``f`` (or any
507
- other binary stream what supports a ``.read()`` method, e.g. ``io.BytesIO``).
506
+ other binary stream that supports a ``.read()`` method, e.g. ``io.BytesIO``).
508
507
  Each read byte will add eight bits to the bitarray. When ``n`` is omitted
509
508
  or negative, reads and extends all data until EOF.
510
509
  When ``n`` is non-negative but exceeds the available data, ``EOFError`` is
@@ -524,8 +523,9 @@ bitarray methods:
524
523
 
525
524
 
526
525
  ``invert(index=<all bits>, /)``
527
- Invert all bits in bitarray (in-place).
528
- When the optional ``index`` is given, only invert the single bit at ``index``.
526
+ Invert bits in-place. When ``index`` is omitted, invert all bits.
527
+ When ``index`` is an integer, invert the single bit at index.
528
+ When ``index`` is a slice, invert the selected bits.
529
529
 
530
530
  New in version 1.5.3: optional index argument
531
531
 
@@ -608,7 +608,7 @@ bitarray methods:
608
608
 
609
609
  ``unpack(zero=b'\x00', one=b'\x01')`` -> bytes
610
610
  Return bytes that contain one byte for each bit in the bitarray,
611
- using specified mapping.
611
+ using the specified mapping.
612
612
 
613
613
 
614
614
  bitarray data descriptors:
@@ -683,7 +683,8 @@ This sub-module was added in version 1.2.
683
683
  ``ba2base(n, bitarray, /, group=0, sep=' ')`` -> str
684
684
  Return a string containing the base ``n`` ASCII representation of
685
685
  the bitarray. Allowed values for ``n`` are 2, 4, 8, 16, 32 and 64.
686
- The bitarray has to be multiple of length 1, 2, 3, 4, 5 or 6 respectively.
686
+ The bitarray has to have a length divisible by 1, 2, 3, 4, 5 or 6
687
+ respectively.
687
688
  For ``n=32`` the RFC 4648 Base32 alphabet is used, and for ``n=64`` the
688
689
  standard base 64 alphabet is used.
689
690
  When grouped, the string ``sep`` is inserted between groups
@@ -57,7 +57,7 @@ Once you have installed the package, you may want to test it:
57
57
 
58
58
  $ python -c 'import bitarray; bitarray.test()'
59
59
  bitarray is installed in: /Users/ilan/bitarray/bitarray
60
- bitarray version: 3.8.1
60
+ bitarray version: 3.8.2
61
61
  sys.version: 3.13.5 (main, Jun 16 2025) [Clang 18.1.8]
62
62
  sys.prefix: /Users/ilan/miniforge
63
63
  pointer size: 64 bit
@@ -320,7 +320,7 @@ and can therefore be used as a dictionary key:
320
320
  Reference
321
321
  =========
322
322
 
323
- bitarray version: 3.8.1 -- `change log <https://github.com/ilanschnell/bitarray/blob/master/doc/changelog.rst>`__
323
+ bitarray version: 3.8.2 -- `change log <https://github.com/ilanschnell/bitarray/blob/master/doc/changelog.rst>`__
324
324
 
325
325
  In the following, ``item`` and ``value`` are usually a single bit -
326
326
  an integer 0 or 1.
@@ -344,7 +344,7 @@ The bitarray object:
344
344
 
345
345
  ``endian``: Specifies the bit-endianness of the created bitarray object.
346
346
  Allowed values are ``big`` and ``little`` (the default is ``big``).
347
- The bit-endianness effects the buffer representation of the bitarray.
347
+ The bit-endianness affects the buffer representation of the bitarray.
348
348
 
349
349
  ``buffer``: Any object which exposes a buffer. When provided, ``initializer``
350
350
  cannot be present (or has to be ``None``). The imported buffer may be
@@ -439,7 +439,7 @@ bitarray methods:
439
439
 
440
440
 
441
441
  ``extend(iterable, /)``
442
- Append items from to the end of the bitarray.
442
+ Append items from iterable to the end of the bitarray.
443
443
  If ``iterable`` is a (Unicode) string, each ``0`` and ``1`` are appended as
444
444
  bits (ignoring whitespace and underscore).
445
445
 
@@ -470,7 +470,7 @@ bitarray methods:
470
470
 
471
471
  ``fromfile(f, n=-1, /)``
472
472
  Extend bitarray with up to ``n`` bytes read from file object ``f`` (or any
473
- other binary stream what supports a ``.read()`` method, e.g. ``io.BytesIO``).
473
+ other binary stream that supports a ``.read()`` method, e.g. ``io.BytesIO``).
474
474
  Each read byte will add eight bits to the bitarray. When ``n`` is omitted
475
475
  or negative, reads and extends all data until EOF.
476
476
  When ``n`` is non-negative but exceeds the available data, ``EOFError`` is
@@ -490,8 +490,9 @@ bitarray methods:
490
490
 
491
491
 
492
492
  ``invert(index=<all bits>, /)``
493
- Invert all bits in bitarray (in-place).
494
- When the optional ``index`` is given, only invert the single bit at ``index``.
493
+ Invert bits in-place. When ``index`` is omitted, invert all bits.
494
+ When ``index`` is an integer, invert the single bit at index.
495
+ When ``index`` is a slice, invert the selected bits.
495
496
 
496
497
  New in version 1.5.3: optional index argument
497
498
 
@@ -574,7 +575,7 @@ bitarray methods:
574
575
 
575
576
  ``unpack(zero=b'\x00', one=b'\x01')`` -> bytes
576
577
  Return bytes that contain one byte for each bit in the bitarray,
577
- using specified mapping.
578
+ using the specified mapping.
578
579
 
579
580
 
580
581
  bitarray data descriptors:
@@ -649,7 +650,8 @@ This sub-module was added in version 1.2.
649
650
  ``ba2base(n, bitarray, /, group=0, sep=' ')`` -> str
650
651
  Return a string containing the base ``n`` ASCII representation of
651
652
  the bitarray. Allowed values for ``n`` are 2, 4, 8, 16, 32 and 64.
652
- The bitarray has to be multiple of length 1, 2, 3, 4, 5 or 6 respectively.
653
+ The bitarray has to have a length divisible by 1, 2, 3, 4, 5 or 6
654
+ respectively.
653
655
  For ``n=32`` the RFC 4648 Base32 alphabet is used, and for ``n=64`` the
654
656
  standard base 64 alphabet is used.
655
657
  When grouped, the string ``sep`` is inserted between groups
@@ -24,6 +24,34 @@ static PyTypeObject Bitarray_Type;
24
24
  #define bitarray_Check(obj) PyObject_TypeCheck((obj), &Bitarray_Type)
25
25
 
26
26
 
27
+ static size_t
28
+ new_allocation(size_t size, size_t allocated, size_t newsize)
29
+ {
30
+ assert(allocated >= size);
31
+ assert(newsize > 0);
32
+
33
+ if (allocated >= newsize) {
34
+ /* current buffer is large enough to host the requested size */
35
+ if (newsize >= allocated / 2)
36
+ return allocated; /* minor downsize - keep current allocation */
37
+
38
+ return newsize; /* major downsize - shrink to exact size */
39
+ }
40
+ else {
41
+ /* need to grow buffer */
42
+ size_t new_alloc = newsize;
43
+ /* overallocate when previous size isn't zero and when growth
44
+ is moderate */
45
+ if (size != 0 && newsize / 2 <= allocated) {
46
+ /* overallocate proportional to the bitarray size and
47
+ add padding to make the allocated size multiple of 4 */
48
+ new_alloc += (newsize >> 4) + (newsize < 8 ? 3 : 7);
49
+ new_alloc &= ~(size_t) 3;
50
+ }
51
+ return new_alloc;
52
+ }
53
+ }
54
+
27
55
  static int
28
56
  resize(bitarrayobject *self, Py_ssize_t nbits)
29
57
  {
@@ -69,28 +97,13 @@ resize(bitarrayobject *self, Py_ssize_t nbits)
69
97
  return 0;
70
98
  }
71
99
 
72
- if (allocated >= newsize) {
73
- /* current buffer is large enough to host the requested size */
74
- if (newsize >= allocated / 2) {
75
- /* minor downsize, bypass reallocation */
76
- Py_SET_SIZE(self, newsize);
77
- self->nbits = nbits;
78
- return 0;
79
- }
80
- /* major downsize, resize down to exact size */
81
- new_allocated = newsize;
82
- }
83
- else {
84
- /* need to grow buffer */
85
- new_allocated = newsize;
86
- /* overallocate when previous size isn't zero and when growth
87
- is moderate */
88
- if (size != 0 && newsize / 2 <= allocated) {
89
- /* overallocate proportional to the bitarray size and
90
- add padding to make the allocated size multiple of 4 */
91
- new_allocated += (newsize >> 4) + (newsize < 8 ? 3 : 7);
92
- new_allocated &= ~(size_t) 3;
93
- }
100
+ new_allocated = new_allocation(size, allocated, newsize);
101
+
102
+ if (new_allocated == allocated) {
103
+ /* bypass reallocation */
104
+ Py_SET_SIZE(self, newsize);
105
+ self->nbits = nbits;
106
+ return 0;
94
107
  }
95
108
 
96
109
  assert(new_allocated >= newsize);
@@ -203,7 +216,7 @@ bytereverse(char *p, Py_ssize_t n)
203
216
  /* The following two functions operate on first n bytes in buffer.
204
217
  Within this region, they shift all bits by k positions to right,
205
218
  i.e. towards higher addresses.
206
- They operate on little-endian and bit-endian bitarrays respectively.
219
+ They operate on little-endian and big-endian bitarrays respectively.
207
220
  As we shift right, we need to start with the highest address and loop
208
221
  downwards such that lower bytes are still unaltered.
209
222
  See also devel/shift_r8.c
@@ -1194,7 +1207,7 @@ bitarray_extend(bitarrayobject *self, PyObject *obj)
1194
1207
  PyDoc_STRVAR(extend_doc,
1195
1208
  "extend(iterable, /)\n\
1196
1209
  \n\
1197
- Append items from to the end of the bitarray.\n\
1210
+ Append items from iterable to the end of the bitarray.\n\
1198
1211
  If `iterable` is a (Unicode) string, each `0` and `1` are appended as\n\
1199
1212
  bits (ignoring whitespace and underscore).");
1200
1213
 
@@ -1346,7 +1359,8 @@ bitarray_invert(bitarrayobject *self, PyObject *args)
1346
1359
  invert_span(self, 0, self->nbits);
1347
1360
  }
1348
1361
  else {
1349
- return PyErr_Format(PyExc_TypeError, "index expect, not '%s' object",
1362
+ return PyErr_Format(PyExc_TypeError,
1363
+ "index expected, not '%s' object",
1350
1364
  Py_TYPE(arg)->tp_name);
1351
1365
  }
1352
1366
  Py_RETURN_NONE;
@@ -1355,8 +1369,9 @@ bitarray_invert(bitarrayobject *self, PyObject *args)
1355
1369
  PyDoc_STRVAR(invert_doc,
1356
1370
  "invert(index=<all bits>, /)\n\
1357
1371
  \n\
1358
- Invert all bits in bitarray (in-place).\n\
1359
- When the optional `index` is given, only invert the single bit at `index`.");
1372
+ Invert bits in-place. When `index` is omitted, invert all bits.\n\
1373
+ When `index` is an integer, invert the single bit at index.\n\
1374
+ When `index` is a slice, invert the selected bits.");
1360
1375
 
1361
1376
 
1362
1377
  static PyObject *
@@ -1557,7 +1572,7 @@ bitarray_frombytes(bitarrayobject *self, PyObject *buffer)
1557
1572
  assert(Py_SIZE(self) == n + view.len);
1558
1573
  memcpy(self->ob_item + n, (char *) view.buf, (size_t) view.len);
1559
1574
 
1560
- /* remove pad bits staring at previous bit length (8 * n - p) */
1575
+ /* remove pad bits starting at previous bit length (8 * n - p) */
1561
1576
  if (delete_n(self, 8 * n - p, p) < 0)
1562
1577
  goto error;
1563
1578
 
@@ -1654,7 +1669,7 @@ PyDoc_STRVAR(fromfile_doc,
1654
1669
  "fromfile(f, n=-1, /)\n\
1655
1670
  \n\
1656
1671
  Extend bitarray with up to `n` bytes read from file object `f` (or any\n\
1657
- other binary stream what supports a `.read()` method, e.g. `io.BytesIO`).\n\
1672
+ other binary stream that supports a `.read()` method, e.g. `io.BytesIO`).\n\
1658
1673
  Each read byte will add eight bits to the bitarray. When `n` is omitted\n\
1659
1674
  or negative, reads and extends all data until EOF.\n\
1660
1675
  When `n` is non-negative but exceeds the available data, `EOFError` is\n\
@@ -1673,7 +1688,7 @@ bitarray_tofile(bitarrayobject *self, PyObject *f)
1673
1688
  Py_ssize_t size = Py_MIN(nbytes - offset, BLOCKSIZE);
1674
1689
 
1675
1690
  assert(size >= 0 && offset + size <= nbytes);
1676
- /* basically: f.write(memoryview(self)[offset:offset + size] */
1691
+ /* basically: f.write(memoryview(self)[offset:offset + size]) */
1677
1692
  ret = PyObject_CallMethod(f, "write", "y#",
1678
1693
  self->ob_item + offset, size);
1679
1694
  if (ret == NULL)
@@ -1763,7 +1778,7 @@ PyDoc_STRVAR(unpack_doc,
1763
1778
  "unpack(zero=b'\\x00', one=b'\\x01') -> bytes\n\
1764
1779
  \n\
1765
1780
  Return bytes that contain one byte for each bit in the bitarray,\n\
1766
- using specified mapping.");
1781
+ using the specified mapping.");
1767
1782
 
1768
1783
 
1769
1784
  static PyObject *
@@ -3167,7 +3182,7 @@ PyDoc_STRVAR(complete_doc,
3167
3182
  "complete() -> bool\n\
3168
3183
  \n\
3169
3184
  Return whether tree is complete. That is, whether or not all\n\
3170
- nodes have both children (unless they are symbols nodes).");
3185
+ nodes have both children (unless they are symbol nodes).");
3171
3186
 
3172
3187
 
3173
3188
  static PyObject *
@@ -3332,7 +3347,7 @@ decodeiter_next(decodeiterobject *it)
3332
3347
  PyObject *symbol;
3333
3348
 
3334
3349
  symbol = binode_traverse(it->tree, it->self, &(it->index));
3335
- if (symbol == NULL) /* stop iteration OR error occured */
3350
+ if (symbol == NULL) /* stop iteration OR error occurred */
3336
3351
  return NULL;
3337
3352
  Py_INCREF(symbol);
3338
3353
  return symbol;
@@ -3723,9 +3738,9 @@ newbitarray_from_bytes(PyTypeObject *type, PyObject *buffer, int endian)
3723
3738
  }
3724
3739
 
3725
3740
  /* As of bitarray version 2.9.0, "bitarray(nbits)" will initialize all items
3726
- to 0 (previously, the buffer was be uninitialized).
3741
+ to 0 (previously, the buffer was uninitialized).
3727
3742
  However, for speed, one might want to create an uninitialized bitarray.
3728
- In 2.9.1, we added the ability to created uninitialized bitarrays again,
3743
+ In 2.9.1, we added the ability to create uninitialized bitarrays again,
3729
3744
  using "bitarray(nbits, endian, Ellipsis)".
3730
3745
  */
3731
3746
  static PyObject *
@@ -4003,7 +4018,7 @@ Optional keyword arguments:\n\
4003
4018
  \n\
4004
4019
  `endian`: Specifies the bit-endianness of the created bitarray object.\n\
4005
4020
  Allowed values are `big` and `little` (the default is `big`).\n\
4006
- The bit-endianness effects the buffer representation of the bitarray.\n\
4021
+ The bit-endianness affects the buffer representation of the bitarray.\n\
4007
4022
  \n\
4008
4023
  `buffer`: Any object which exposes a buffer. When provided, `initializer`\n\
4009
4024
  cannot be present (or has to be `None`). The imported buffer may be\n\
@@ -4203,7 +4218,7 @@ sysinfo(PyObject *module, PyObject *args)
4203
4218
  PyDoc_STRVAR(sysinfo_doc,
4204
4219
  "_sysinfo(key) -> int\n\
4205
4220
  \n\
4206
- Return system and compile specific information given a key.");
4221
+ Return system- and compile-specific information given a key.");
4207
4222
 
4208
4223
 
4209
4224
  static PyMethodDef module_functions[] = {
@@ -31,7 +31,7 @@ ensure_bitarray(PyObject *obj)
31
31
 
32
32
  /* Return new bitarray of length 'nbits', endianness given by the PyObject
33
33
  'endian' (which may be Py_None).
34
- Unless -1, 'c' is placed into all characters of buffer. */
34
+ Unless -1, 'c' is written to all bytes of the buffer. */
35
35
  static bitarrayobject *
36
36
  new_bitarray(Py_ssize_t nbits, PyObject *endian, int c)
37
37
  {
@@ -494,7 +494,7 @@ correspond_all(PyObject *module, PyObject *args)
494
494
  v = zlw(b);
495
495
  not_u = ~u;
496
496
  not_v = ~v;
497
- /* for nff we need to substract the number of unused 1 bits */
497
+ /* for nff we need to subtract the number of unused 1 bits */
498
498
  nff += popcnt_64(not_u & not_v) - (64 - rbits);
499
499
  nft += popcnt_64(not_u & v);
500
500
  ntf += popcnt_64(u & not_v);
@@ -552,7 +552,7 @@ byteswap(PyObject *module, PyObject *args)
552
552
 
553
553
  if (n < 0)
554
554
  return PyErr_Format(PyExc_ValueError,
555
- "positive int expect, got %zd", n);
555
+ "positive int expected, got %zd", n);
556
556
 
557
557
  if (PyObject_GetBuffer(buffer, &view, PyBUF_SIMPLE | PyBUF_WRITABLE) < 0)
558
558
  return NULL;
@@ -839,7 +839,7 @@ static const char base64_alphabet[] =
839
839
  "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
840
840
 
841
841
  /* Given the length of the base m in [1..6] and a character c, return
842
- its index in the base 2**m alphabet , or -1 if when c is not included.
842
+ its index in the base 2**m alphabet, or -1 if c is not included.
843
843
  Note: i >> m is true when i is not in range(0, 2**m) */
844
844
  static int
845
845
  digit_to_int(int m, char c)
@@ -981,7 +981,8 @@ PyDoc_STRVAR(ba2base_doc,
981
981
  \n\
982
982
  Return a string containing the base `n` ASCII representation of\n\
983
983
  the bitarray. Allowed values for `n` are 2, 4, 8, 16, 32 and 64.\n\
984
- The bitarray has to be multiple of length 1, 2, 3, 4, 5 or 6 respectively.\n\
984
+ The bitarray has to have a length divisible by 1, 2, 3, 4, 5 or 6\n\
985
+ respectively.\n\
985
986
  For `n=32` the RFC 4648 Base32 alphabet is used, and for `n=64` the\n\
986
987
  standard base 64 alphabet is used.\n\
987
988
  When grouped, the string `sep` is inserted between groups\n\
@@ -1200,7 +1201,7 @@ byte_length(Py_ssize_t i)
1200
1201
  * The last element rts[NSEG(self)] is always the total count.
1201
1202
  Here: rts[NSEG(self)] = rts[4] = 12
1202
1203
 
1203
- * The last segment may be partial. In that case, its size it given
1204
+ * The last segment may be partial. In that case, its size is given
1204
1205
  by nbits % 256. Here: nbits % 256 = 987 % 256 = 219
1205
1206
 
1206
1207
  As each segment (at large) covers 256 bits (32 bytes), and each element
@@ -1284,7 +1285,7 @@ module_sc_rts(PyObject *module, PyObject *obj)
1284
1285
 
1285
1286
  a.count(1, 8 * offset, 8 * offset + (1 << (8 * n)))
1286
1287
 
1287
- The offset must be divisible by SEGSIZE, as this functions makes use of
1288
+ The offset must be divisible by SEGSIZE, as this function makes use of
1288
1289
  running totals, stored in rts[].
1289
1290
  Here, and in the following, 'offset' is in units of bytes. */
1290
1291
  static Py_ssize_t
@@ -1301,7 +1302,7 @@ sc_count(bitarrayobject *a, Py_ssize_t *rts, Py_ssize_t offset, int n)
1301
1302
  /* Write a raw block, and return number of bytes copied.
1302
1303
  Note that the encoded block size is the return value + 1 (the head byte).
1303
1304
 
1304
- The header byte is in range(0x01, 0xa0).
1305
+ The head byte is in range(0x01, 0xa0).
1305
1306
  * range(0x01, 0x20) number of raw bytes
1306
1307
  * range(0x20, 0xa0) number of 32-byte segments */
1307
1308
  static int
@@ -1341,7 +1342,6 @@ static void
1341
1342
  sc_write_indices(char *str, bitarrayobject *a, Py_ssize_t *rts,
1342
1343
  Py_ssize_t offset, int n, int k)
1343
1344
  {
1344
- const char *str_stop = str + n * k; /* stop position in buffer 'str' */
1345
1345
  const char *buff = a->ob_item + offset;
1346
1346
  Py_ssize_t m;
1347
1347
 
@@ -1370,12 +1370,13 @@ sc_write_indices(char *str, bitarrayobject *a, Py_ssize_t *rts,
1370
1370
  if (buff[i] & BITMASK(a, j)) {
1371
1371
  write_n(str, n, 8 * i + j);
1372
1372
  str += n;
1373
- if (--ni == 0) {
1373
+ if (--k == 0)
1374
+ /* we have encountered all indices in this block */
1375
+ return;
1376
+
1377
+ if (--ni == 0)
1374
1378
  /* we have encountered all indices in this segment */
1375
- if (str == str_stop)
1376
- return;
1377
1379
  goto next_segment;
1378
- }
1379
1380
  }
1380
1381
  }
1381
1382
  }
@@ -1407,7 +1408,7 @@ sc_write_sparse(char *str, bitarrayobject *a, Py_ssize_t *rts,
1407
1408
  str[len++] = (char) (0xc0 + n); /* block type */
1408
1409
  str[len++] = (char) k; /* index count */
1409
1410
  }
1410
- if (k == 0) /* no index bytes - sc_write_sparse() does not allow k = 0 */
1411
+ if (k == 0) /* no index bytes to write */
1411
1412
  return len;
1412
1413
 
1413
1414
  /* write block data - k indices, n bytes per index */
@@ -1423,7 +1424,7 @@ sc_write_sparse(char *str, bitarrayobject *a, Py_ssize_t *rts,
1423
1424
 
1424
1425
  - 32 index bytes take up as much space as a raw buffer of 32 bytes.
1425
1426
  Hence, if the bit count of the first 32 bytes of the bitarray buffer
1426
- is greater or equal to 32, we choose a raw block (type 0).
1427
+ is greater than or equal to 32, we choose a raw block (type 0).
1427
1428
 
1428
1429
  - Arguably, n index bytes always take up as much space as n raw bytes.
1429
1430
  So what makes 32 special here? A bitarray with a 32 byte buffer has
@@ -1459,7 +1460,7 @@ sc_write_sparse(char *str, bitarrayobject *a, Py_ssize_t *rts,
1459
1460
 
1460
1461
  header_size + (n + 1) * population
1461
1462
 
1462
- As n >= 1, the header_size will is always 2 bytes here.
1463
+ As n >= 1, the header_size is always 2 bytes here.
1463
1464
 
1464
1465
  - As we only need to know which of these sizes is bigger, we can
1465
1466
  subtract (n * population) from both sizes. Hence, the costs are:
@@ -1480,7 +1481,7 @@ sc_encode_block(char *str, Py_ssize_t *len,
1480
1481
  assert(nbytes > 0);
1481
1482
 
1482
1483
  count = (int) sc_count(a, rts, offset, 1);
1483
- /* the number of index bytes exceeds the number of raw bytes */
1484
+ /* the number of index bytes is no smaller than the number of raw bytes */
1484
1485
  if (count >= Py_MIN(32, nbytes)) { /* type 0 - raw bytes */
1485
1486
  int k = sc_write_raw(str + *len, a, rts, offset);
1486
1487
  *len += 1 + k;
@@ -1515,7 +1516,7 @@ sc_encode_block(char *str, Py_ssize_t *len,
1515
1516
  return BSI(n);
1516
1517
  }
1517
1518
 
1518
- /* write header and return number or bytes written to buffer 'str' */
1519
+ /* write header and return number of bytes written to buffer 'str' */
1519
1520
  static int
1520
1521
  sc_encode_header(char *str, bitarrayobject *a)
1521
1522
  {
@@ -1565,7 +1566,7 @@ sc_encode(PyObject *module, PyObject *obj)
1565
1566
 
1566
1567
  /* Make sure we have enough memory in output buffer for next block.
1567
1568
  The largest block possible is a type 0 block with 128 segments.
1568
- Its size is: 1 head bytes + 128 * 32 raw bytes.
1569
+ Its size is: 1 head byte + 128 * 32 raw bytes.
1569
1570
  Plus, we also may have the stop byte. */
1570
1571
  if (allocated < len + 1 + 128 * 32 + 1) {
1571
1572
  if (_PyBytes_Resize(&out, allocated + ALLOC_SIZE) < 0)
@@ -1597,7 +1598,7 @@ Use `sc_decode()` for decompressing (decoding).");
1597
1598
 
1598
1599
 
1599
1600
  /* read header from 'iter' and set 'endian' and 'nbits', return 0 on success
1600
- and -1 of failure (after setting exception) */
1601
+ and -1 on failure (after setting exception) */
1601
1602
  static int
1602
1603
  sc_decode_header(PyObject *iter, int *endian, Py_ssize_t *nbits)
1603
1604
  {
@@ -1759,12 +1760,12 @@ untouched. Use `sc_encode()` for compressing (encoding).");
1759
1760
  'padding' refers to the pad bits within the variable length format.
1760
1761
  This is not the same as the pad bits of the actual bitarray.
1761
1762
  For example, b'\x10' has padding = 1, and decodes to bitarray('000'),
1762
- which has 5 pad bits. 'padding' can take values to up 6.
1763
+ which has 5 pad bits. 'padding' can take values up to 6.
1763
1764
  */
1764
1765
  #define LEN_PAD_BITS 3
1765
1766
 
1766
1767
  /* initial number of bits we allocate in vl_decode(), and amount by which
1767
- we increase our allocation by in vl_decode_core() if we run out */
1768
+ we increase the allocation in vl_decode_core() */
1768
1769
  #define ALLOC_BITS 1024
1769
1770
 
1770
1771
  /* Consume 'iter' while extending bitarray 'a'.
@@ -4,7 +4,7 @@
4
4
 
5
5
  Author: Ilan Schnell
6
6
  */
7
- #define BITARRAY_VERSION "3.8.1"
7
+ #define BITARRAY_VERSION "3.8.2"
8
8
 
9
9
  #ifdef STDC_HEADERS
10
10
  # include <stddef.h>
@@ -64,7 +64,7 @@ typedef struct {
64
64
  /* number of pad bits */
65
65
  #define PADBITS(self) ((8 - (self)->nbits % 8) % 8)
66
66
 
67
- /* number of bytes necessary to store given nunmber of bits */
67
+ /* number of bytes necessary to store given number of bits */
68
68
  #define BYTES(bits) (((bits) + 7) >> 3)
69
69
 
70
70
  /* we're not using bitmask_table here, as it is actually slower */
@@ -268,7 +268,7 @@ to_aligned(void *p)
268
268
  return (4 - r) % 4;
269
269
  }
270
270
 
271
- /* population count of n words starting from at uint64_t pointer w */
271
+ /* population count of n words starting at uint64_t pointer w */
272
272
  static inline Py_ssize_t
273
273
  popcnt_words(uint64_t *w, Py_ssize_t n)
274
274
  {
@@ -301,7 +301,7 @@ adjust_step_positive(Py_ssize_t slicelength,
301
301
  assert(*step != 1 || slicelength == 0 || *stop - *start == slicelength);
302
302
  }
303
303
 
304
- /* convert Python object to C int and set value at address -
304
+ /* convert Python object to C int at address *vi -
305
305
  return 1 on success, 0 on failure (and set exception) */
306
306
  static inline int
307
307
  conv_pybit(PyObject *value, int *vi)
@@ -25,9 +25,6 @@ extern "C" {
25
25
  #if PY_VERSION_HEX < 0x030b00B4 && !defined(PYPY_VERSION)
26
26
  # include "frameobject.h" // PyFrameObject, PyFrame_GetBack()
27
27
  #endif
28
- #if PY_VERSION_HEX < 0x030C00A3
29
- # include <structmember.h> // T_SHORT, READONLY
30
- #endif
31
28
 
32
29
 
33
30
  #ifndef _Py_CAST
@@ -1428,6 +1425,11 @@ PyUnicodeWriter_WriteStr(PyUnicodeWriter *writer, PyObject *obj)
1428
1425
  static inline int
1429
1426
  PyUnicodeWriter_WriteRepr(PyUnicodeWriter *writer, PyObject *obj)
1430
1427
  {
1428
+ if (obj == NULL) {
1429
+ return _PyUnicodeWriter_WriteASCIIString((_PyUnicodeWriter*)writer,
1430
+ "<NULL>", 6);
1431
+ }
1432
+
1431
1433
  PyObject *str = PyObject_Repr(obj);
1432
1434
  if (str == NULL) {
1433
1435
  return -1;
@@ -1572,6 +1574,11 @@ static inline int PyLong_IsZero(PyObject *obj)
1572
1574
 
1573
1575
  // gh-124502 added PyUnicode_Equal() to Python 3.14.0a0
1574
1576
  #if PY_VERSION_HEX < 0x030E00A0
1577
+
1578
+ #if PY_VERSION_HEX >= 0x030d0000 && !defined(PYPY_VERSION)
1579
+ PyAPI_FUNC(int) _PyUnicode_Equal(PyObject *str1, PyObject *str2);
1580
+ #endif
1581
+
1575
1582
  static inline int PyUnicode_Equal(PyObject *str1, PyObject *str2)
1576
1583
  {
1577
1584
  if (!PyUnicode_Check(str1)) {
@@ -1586,8 +1593,6 @@ static inline int PyUnicode_Equal(PyObject *str1, PyObject *str2)
1586
1593
  }
1587
1594
 
1588
1595
  #if PY_VERSION_HEX >= 0x030d0000 && !defined(PYPY_VERSION)
1589
- PyAPI_FUNC(int) _PyUnicode_Equal(PyObject *str1, PyObject *str2);
1590
-
1591
1596
  return _PyUnicode_Equal(str1, str2);
1592
1597
  #elif PY_VERSION_HEX >= 0x03060000 && !defined(PYPY_VERSION)
1593
1598
  return _PyUnicode_EQ(str1, str2);
@@ -1610,11 +1615,14 @@ static inline PyObject* PyBytes_Join(PyObject *sep, PyObject *iterable)
1610
1615
 
1611
1616
 
1612
1617
  #if PY_VERSION_HEX < 0x030E00A0
1618
+
1619
+ #if PY_VERSION_HEX >= 0x03000000 && !defined(PYPY_VERSION)
1620
+ PyAPI_FUNC(Py_hash_t) _Py_HashBytes(const void *src, Py_ssize_t len);
1621
+ #endif
1622
+
1613
1623
  static inline Py_hash_t Py_HashBuffer(const void *ptr, Py_ssize_t len)
1614
1624
  {
1615
1625
  #if PY_VERSION_HEX >= 0x03000000 && !defined(PYPY_VERSION)
1616
- PyAPI_FUNC(Py_hash_t) _Py_HashBytes(const void *src, Py_ssize_t len);
1617
-
1618
1626
  return _Py_HashBytes(ptr, len);
1619
1627
  #else
1620
1628
  Py_hash_t hash;
@@ -1919,43 +1927,46 @@ PyLongWriter_Finish(PyLongWriter *writer)
1919
1927
 
1920
1928
 
1921
1929
  #if PY_VERSION_HEX < 0x030C00A3
1922
- # define Py_T_SHORT T_SHORT
1923
- # define Py_T_INT T_INT
1924
- # define Py_T_LONG T_LONG
1925
- # define Py_T_FLOAT T_FLOAT
1926
- # define Py_T_DOUBLE T_DOUBLE
1927
- # define Py_T_STRING T_STRING
1928
- # define _Py_T_OBJECT T_OBJECT
1929
- # define Py_T_CHAR T_CHAR
1930
- # define Py_T_BYTE T_BYTE
1931
- # define Py_T_UBYTE T_UBYTE
1932
- # define Py_T_USHORT T_USHORT
1933
- # define Py_T_UINT T_UINT
1934
- # define Py_T_ULONG T_ULONG
1935
- # define Py_T_STRING_INPLACE T_STRING_INPLACE
1936
- # define Py_T_BOOL T_BOOL
1937
- # define Py_T_OBJECT_EX T_OBJECT_EX
1938
- # define Py_T_LONGLONG T_LONGLONG
1939
- # define Py_T_ULONGLONG T_ULONGLONG
1940
- # define Py_T_PYSSIZET T_PYSSIZET
1930
+ # define Py_T_SHORT 0
1931
+ # define Py_T_INT 1
1932
+ # define Py_T_LONG 2
1933
+ # define Py_T_FLOAT 3
1934
+ # define Py_T_DOUBLE 4
1935
+ # define Py_T_STRING 5
1936
+ # define _Py_T_OBJECT 6
1937
+ # define Py_T_CHAR 7
1938
+ # define Py_T_BYTE 8
1939
+ # define Py_T_UBYTE 9
1940
+ # define Py_T_USHORT 10
1941
+ # define Py_T_UINT 11
1942
+ # define Py_T_ULONG 12
1943
+ # define Py_T_STRING_INPLACE 13
1944
+ # define Py_T_BOOL 14
1945
+ # define Py_T_OBJECT_EX 16
1946
+ # define Py_T_LONGLONG 17
1947
+ # define Py_T_ULONGLONG 18
1948
+ # define Py_T_PYSSIZET 19
1941
1949
 
1942
1950
  # if PY_VERSION_HEX >= 0x03000000 && !defined(PYPY_VERSION)
1943
- # define _Py_T_NONE T_NONE
1951
+ # define _Py_T_NONE 20
1944
1952
  # endif
1945
1953
 
1946
- # define Py_READONLY READONLY
1947
- # define Py_AUDIT_READ READ_RESTRICTED
1948
- # define _Py_WRITE_RESTRICTED PY_WRITE_RESTRICTED
1954
+ # define Py_READONLY 1
1955
+ # define Py_AUDIT_READ 2
1956
+ # define _Py_WRITE_RESTRICTED 4
1949
1957
  #endif
1950
1958
 
1951
1959
 
1952
1960
  // gh-127350 added Py_fopen() and Py_fclose() to Python 3.14a4
1953
1961
  #if PY_VERSION_HEX < 0x030E00A4
1962
+
1963
+ #if 0x030400A2 <= PY_VERSION_HEX && !defined(PYPY_VERSION)
1964
+ PyAPI_FUNC(FILE*) _Py_fopen_obj(PyObject *path, const char *mode);
1965
+ #endif
1966
+
1954
1967
  static inline FILE* Py_fopen(PyObject *path, const char *mode)
1955
1968
  {
1956
1969
  #if 0x030400A2 <= PY_VERSION_HEX && !defined(PYPY_VERSION)
1957
- PyAPI_FUNC(FILE*) _Py_fopen_obj(PyObject *path, const char *mode);
1958
-
1959
1970
  return _Py_fopen_obj(path, mode);
1960
1971
  #else
1961
1972
  FILE *f;
@@ -1992,6 +2003,8 @@ static inline int Py_fclose(FILE *file)
1992
2003
 
1993
2004
 
1994
2005
  #if 0x03080000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x030E0000 && !defined(PYPY_VERSION)
2006
+ PyAPI_FUNC(const PyConfig*) _Py_GetConfig(void);
2007
+
1995
2008
  static inline PyObject*
1996
2009
  PyConfig_Get(const char *name)
1997
2010
  {
@@ -2127,8 +2140,6 @@ PyConfig_Get(const char *name)
2127
2140
  return Py_NewRef(value);
2128
2141
  }
2129
2142
 
2130
- PyAPI_FUNC(const PyConfig*) _Py_GetConfig(void);
2131
-
2132
2143
  const PyConfig *config = _Py_GetConfig();
2133
2144
  void *member = (char *)config + spec->offset;
2134
2145
  switch (spec->type) {
@@ -2231,6 +2242,81 @@ static inline int PyUnstable_Object_IsUniquelyReferenced(PyObject *obj)
2231
2242
  }
2232
2243
  #endif
2233
2244
 
2245
+ // gh-128926 added PyUnstable_TryIncRef() and PyUnstable_EnableTryIncRef() to
2246
+ // Python 3.14.0a5. Adapted from _Py_TryIncref() and _PyObject_SetMaybeWeakref().
2247
+ #if PY_VERSION_HEX < 0x030E00A5
2248
+ static inline int PyUnstable_TryIncRef(PyObject *op)
2249
+ {
2250
+ #ifndef Py_GIL_DISABLED
2251
+ if (Py_REFCNT(op) > 0) {
2252
+ Py_INCREF(op);
2253
+ return 1;
2254
+ }
2255
+ return 0;
2256
+ #else
2257
+ // _Py_TryIncrefFast()
2258
+ uint32_t local = _Py_atomic_load_uint32_relaxed(&op->ob_ref_local);
2259
+ local += 1;
2260
+ if (local == 0) {
2261
+ // immortal
2262
+ return 1;
2263
+ }
2264
+ if (_Py_IsOwnedByCurrentThread(op)) {
2265
+ _Py_INCREF_STAT_INC();
2266
+ _Py_atomic_store_uint32_relaxed(&op->ob_ref_local, local);
2267
+ #ifdef Py_REF_DEBUG
2268
+ _Py_INCREF_IncRefTotal();
2269
+ #endif
2270
+ return 1;
2271
+ }
2272
+
2273
+ // _Py_TryIncRefShared()
2274
+ Py_ssize_t shared = _Py_atomic_load_ssize_relaxed(&op->ob_ref_shared);
2275
+ for (;;) {
2276
+ // If the shared refcount is zero and the object is either merged
2277
+ // or may not have weak references, then we cannot incref it.
2278
+ if (shared == 0 || shared == _Py_REF_MERGED) {
2279
+ return 0;
2280
+ }
2281
+
2282
+ if (_Py_atomic_compare_exchange_ssize(
2283
+ &op->ob_ref_shared,
2284
+ &shared,
2285
+ shared + (1 << _Py_REF_SHARED_SHIFT))) {
2286
+ #ifdef Py_REF_DEBUG
2287
+ _Py_INCREF_IncRefTotal();
2288
+ #endif
2289
+ _Py_INCREF_STAT_INC();
2290
+ return 1;
2291
+ }
2292
+ }
2293
+ #endif
2294
+ }
2295
+
2296
+ static inline void PyUnstable_EnableTryIncRef(PyObject *op)
2297
+ {
2298
+ #ifdef Py_GIL_DISABLED
2299
+ // _PyObject_SetMaybeWeakref()
2300
+ if (_Py_IsImmortal(op)) {
2301
+ return;
2302
+ }
2303
+ for (;;) {
2304
+ Py_ssize_t shared = _Py_atomic_load_ssize_relaxed(&op->ob_ref_shared);
2305
+ if ((shared & _Py_REF_SHARED_FLAG_MASK) != 0) {
2306
+ // Nothing to do if it's in WEAKREFS, QUEUED, or MERGED states.
2307
+ return;
2308
+ }
2309
+ if (_Py_atomic_compare_exchange_ssize(
2310
+ &op->ob_ref_shared, &shared, shared | _Py_REF_MAYBE_WEAKREF)) {
2311
+ return;
2312
+ }
2313
+ }
2314
+ #else
2315
+ (void)op; // unused argument
2316
+ #endif
2317
+ }
2318
+ #endif
2319
+
2234
2320
 
2235
2321
  #if PY_VERSION_HEX < 0x030F0000
2236
2322
  static inline PyObject*
@@ -2587,6 +2673,40 @@ PyUnstable_Unicode_GET_CACHED_HASH(PyObject *op)
2587
2673
  }
2588
2674
  #endif
2589
2675
 
2676
+ #if 0x030D0000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x030F00A7 && !defined(PYPY_VERSION)
2677
+ // Immortal objects were implemented in Python 3.12, however there is no easy API
2678
+ // to make objects immortal until 3.14 which has _Py_SetImmortal(). Since
2679
+ // immortal objects are primarily needed for free-threading, this API is implemented
2680
+ // for 3.14 using _Py_SetImmortal() and uses private macros on 3.13.
2681
+ #if 0x030E0000 <= PY_VERSION_HEX
2682
+ PyAPI_FUNC(void) _Py_SetImmortal(PyObject *op);
2683
+ #endif
2684
+
2685
+ static inline int
2686
+ PyUnstable_SetImmortal(PyObject *op)
2687
+ {
2688
+ assert(op != NULL);
2689
+ if (!PyUnstable_Object_IsUniquelyReferenced(op) || PyUnicode_Check(op)) {
2690
+ return 0;
2691
+ }
2692
+ #if 0x030E0000 <= PY_VERSION_HEX
2693
+ _Py_SetImmortal(op);
2694
+ #else
2695
+ // Python 3.13 doesn't export _Py_SetImmortal() function
2696
+ if (PyObject_GC_IsTracked(op)) {
2697
+ PyObject_GC_UnTrack(op);
2698
+ }
2699
+ #ifdef Py_GIL_DISABLED
2700
+ op->ob_tid = _Py_UNOWNED_TID;
2701
+ op->ob_ref_local = _Py_IMMORTAL_REFCNT_LOCAL;
2702
+ op->ob_ref_shared = 0;
2703
+ #else
2704
+ op->ob_refcnt = _Py_IMMORTAL_REFCNT;
2705
+ #endif
2706
+ #endif
2707
+ return 1;
2708
+ }
2709
+ #endif
2590
2710
 
2591
2711
  #ifdef __cplusplus
2592
2712
  }
@@ -179,13 +179,13 @@ class _Random:
179
179
  diff = a.count() - k
180
180
 
181
181
  randrange = random.randrange
182
- if diff < 0: # not enough bits 1 - increase count
182
+ if diff < 0: # not enough 1 bits - increase count
183
183
  for _ in range(-diff):
184
184
  i = randrange(n)
185
185
  while a[i]:
186
186
  i = randrange(n)
187
187
  a[i] = 1
188
- elif diff > 0: # too many bits 1 - decrease count
188
+ elif diff > 0: # too many 1 bits - decrease count
189
189
  for _ in range(diff):
190
190
  i = randrange(n)
191
191
  while not a[i]:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bitarray
3
- Version: 3.8.1
3
+ Version: 3.8.2
4
4
  Summary: efficient arrays of booleans -- C extension
5
5
  Home-page: https://github.com/ilanschnell/bitarray
6
6
  Author: Ilan Schnell
@@ -11,7 +11,6 @@ Classifier: Intended Audience :: Developers
11
11
  Classifier: Operating System :: OS Independent
12
12
  Classifier: Programming Language :: C
13
13
  Classifier: Programming Language :: Python :: 3
14
- Classifier: Programming Language :: Python :: 3.6
15
14
  Classifier: Programming Language :: Python :: 3.7
16
15
  Classifier: Programming Language :: Python :: 3.8
17
16
  Classifier: Programming Language :: Python :: 3.9
@@ -91,7 +90,7 @@ Once you have installed the package, you may want to test it:
91
90
 
92
91
  $ python -c 'import bitarray; bitarray.test()'
93
92
  bitarray is installed in: /Users/ilan/bitarray/bitarray
94
- bitarray version: 3.8.1
93
+ bitarray version: 3.8.2
95
94
  sys.version: 3.13.5 (main, Jun 16 2025) [Clang 18.1.8]
96
95
  sys.prefix: /Users/ilan/miniforge
97
96
  pointer size: 64 bit
@@ -354,7 +353,7 @@ and can therefore be used as a dictionary key:
354
353
  Reference
355
354
  =========
356
355
 
357
- bitarray version: 3.8.1 -- `change log <https://github.com/ilanschnell/bitarray/blob/master/doc/changelog.rst>`__
356
+ bitarray version: 3.8.2 -- `change log <https://github.com/ilanschnell/bitarray/blob/master/doc/changelog.rst>`__
358
357
 
359
358
  In the following, ``item`` and ``value`` are usually a single bit -
360
359
  an integer 0 or 1.
@@ -378,7 +377,7 @@ The bitarray object:
378
377
 
379
378
  ``endian``: Specifies the bit-endianness of the created bitarray object.
380
379
  Allowed values are ``big`` and ``little`` (the default is ``big``).
381
- The bit-endianness effects the buffer representation of the bitarray.
380
+ The bit-endianness affects the buffer representation of the bitarray.
382
381
 
383
382
  ``buffer``: Any object which exposes a buffer. When provided, ``initializer``
384
383
  cannot be present (or has to be ``None``). The imported buffer may be
@@ -473,7 +472,7 @@ bitarray methods:
473
472
 
474
473
 
475
474
  ``extend(iterable, /)``
476
- Append items from to the end of the bitarray.
475
+ Append items from iterable to the end of the bitarray.
477
476
  If ``iterable`` is a (Unicode) string, each ``0`` and ``1`` are appended as
478
477
  bits (ignoring whitespace and underscore).
479
478
 
@@ -504,7 +503,7 @@ bitarray methods:
504
503
 
505
504
  ``fromfile(f, n=-1, /)``
506
505
  Extend bitarray with up to ``n`` bytes read from file object ``f`` (or any
507
- other binary stream what supports a ``.read()`` method, e.g. ``io.BytesIO``).
506
+ other binary stream that supports a ``.read()`` method, e.g. ``io.BytesIO``).
508
507
  Each read byte will add eight bits to the bitarray. When ``n`` is omitted
509
508
  or negative, reads and extends all data until EOF.
510
509
  When ``n`` is non-negative but exceeds the available data, ``EOFError`` is
@@ -524,8 +523,9 @@ bitarray methods:
524
523
 
525
524
 
526
525
  ``invert(index=<all bits>, /)``
527
- Invert all bits in bitarray (in-place).
528
- When the optional ``index`` is given, only invert the single bit at ``index``.
526
+ Invert bits in-place. When ``index`` is omitted, invert all bits.
527
+ When ``index`` is an integer, invert the single bit at index.
528
+ When ``index`` is a slice, invert the selected bits.
529
529
 
530
530
  New in version 1.5.3: optional index argument
531
531
 
@@ -608,7 +608,7 @@ bitarray methods:
608
608
 
609
609
  ``unpack(zero=b'\x00', one=b'\x01')`` -> bytes
610
610
  Return bytes that contain one byte for each bit in the bitarray,
611
- using specified mapping.
611
+ using the specified mapping.
612
612
 
613
613
 
614
614
  bitarray data descriptors:
@@ -683,7 +683,8 @@ This sub-module was added in version 1.2.
683
683
  ``ba2base(n, bitarray, /, group=0, sep=' ')`` -> str
684
684
  Return a string containing the base ``n`` ASCII representation of
685
685
  the bitarray. Allowed values for ``n`` are 2, 4, 8, 16, 32 and 64.
686
- The bitarray has to be multiple of length 1, 2, 3, 4, 5 or 6 respectively.
686
+ The bitarray has to have a length divisible by 1, 2, 3, 4, 5 or 6
687
+ respectively.
687
688
  For ``n=32`` the RFC 4648 Base32 alphabet is used, and for ``n=64`` the
688
689
  standard base 64 alphabet is used.
689
690
  When grouped, the string ``sep`` is inserted between groups
@@ -3,10 +3,10 @@ import sys
3
3
  import platform
4
4
 
5
5
 
6
- if sys.version_info[:3] < (3, 6, 1):
6
+ if sys.version_info[:3] < (3, 7):
7
7
  sys.exit("""\
8
8
  ****************************************************************************
9
- * bitarray requires Python 3.6.1 or later.
9
+ * bitarray requires Python 3.7 or later.
10
10
  * The last bitarray version supporting Python 2.7 is bitarray 2.9.3.
11
11
  ****************************************************************************
12
12
  """)
@@ -47,7 +47,6 @@ setup(
47
47
  "Operating System :: OS Independent",
48
48
  "Programming Language :: C",
49
49
  "Programming Language :: Python :: 3",
50
- "Programming Language :: Python :: 3.6",
51
50
  "Programming Language :: Python :: 3.7",
52
51
  "Programming Language :: Python :: 3.8",
53
52
  "Programming Language :: Python :: 3.9",
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes