bitarray 3.7.2__tar.gz → 3.8.1__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.
- {bitarray-3.7.2 → bitarray-3.8.1}/LICENSE +1 -1
- {bitarray-3.7.2 → bitarray-3.8.1}/PKG-INFO +7 -6
- {bitarray-3.7.2 → bitarray-3.8.1}/README.rst +5 -5
- {bitarray-3.7.2 → bitarray-3.8.1}/bitarray/__init__.py +2 -3
- {bitarray-3.7.2 → bitarray-3.8.1}/bitarray/__init__.pyi +1 -2
- {bitarray-3.7.2 → bitarray-3.8.1}/bitarray/_bitarray.c +53 -48
- {bitarray-3.7.2 → bitarray-3.8.1}/bitarray/_util.c +17 -6
- {bitarray-3.7.2 → bitarray-3.8.1}/bitarray/bitarray.h +4 -2
- {bitarray-3.7.2 → bitarray-3.8.1}/bitarray/pythoncapi_compat.h +391 -2
- {bitarray-3.7.2 → bitarray-3.8.1}/bitarray/test_bitarray.py +78 -72
- {bitarray-3.7.2 → bitarray-3.8.1}/bitarray/test_util.py +27 -44
- {bitarray-3.7.2 → bitarray-3.8.1}/bitarray/util.py +1 -1
- {bitarray-3.7.2 → bitarray-3.8.1}/bitarray/util.pyi +1 -1
- {bitarray-3.7.2 → bitarray-3.8.1}/bitarray.egg-info/PKG-INFO +7 -6
- {bitarray-3.7.2 → bitarray-3.8.1}/setup.py +1 -0
- {bitarray-3.7.2 → bitarray-3.8.1}/bitarray/py.typed +0 -0
- {bitarray-3.7.2 → bitarray-3.8.1}/bitarray/test_281.pickle +0 -0
- {bitarray-3.7.2 → bitarray-3.8.1}/bitarray.egg-info/SOURCES.txt +0 -0
- {bitarray-3.7.2 → bitarray-3.8.1}/bitarray.egg-info/dependency_links.txt +0 -0
- {bitarray-3.7.2 → bitarray-3.8.1}/bitarray.egg-info/not-zip-safe +0 -0
- {bitarray-3.7.2 → bitarray-3.8.1}/bitarray.egg-info/top_level.txt +0 -0
- {bitarray-3.7.2 → bitarray-3.8.1}/pyproject.toml +0 -0
- {bitarray-3.7.2 → bitarray-3.8.1}/setup.cfg +0 -0
|
@@ -11,7 +11,7 @@ license to reproduce, analyze, test, perform and/or display publicly,
|
|
|
11
11
|
prepare derivative works, distribute, and otherwise use bitarray
|
|
12
12
|
alone or in any derivative version, provided, however, that Ilan Schnell's
|
|
13
13
|
License Agreement and Ilan Schnell's notice of copyright, i.e., "Copyright (c)
|
|
14
|
-
2008 -
|
|
14
|
+
2008 - 2026 Ilan Schnell; All Rights Reserved" are retained in bitarray
|
|
15
15
|
alone or in any derivative version prepared by Licensee.
|
|
16
16
|
|
|
17
17
|
3. In the event Licensee prepares a derivative work that is based on
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: bitarray
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.8.1
|
|
4
4
|
Summary: efficient arrays of booleans -- C extension
|
|
5
5
|
Home-page: https://github.com/ilanschnell/bitarray
|
|
6
6
|
Author: Ilan Schnell
|
|
@@ -20,6 +20,7 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
20
20
|
Classifier: Programming Language :: Python :: 3.12
|
|
21
21
|
Classifier: Programming Language :: Python :: 3.13
|
|
22
22
|
Classifier: Programming Language :: Python :: 3.14
|
|
23
|
+
Classifier: Programming Language :: Python :: Free Threading :: 1 - Unstable
|
|
23
24
|
Classifier: Topic :: Utilities
|
|
24
25
|
License-File: LICENSE
|
|
25
26
|
Dynamic: author
|
|
@@ -90,7 +91,7 @@ Once you have installed the package, you may want to test it:
|
|
|
90
91
|
|
|
91
92
|
$ python -c 'import bitarray; bitarray.test()'
|
|
92
93
|
bitarray is installed in: /Users/ilan/bitarray/bitarray
|
|
93
|
-
bitarray version: 3.
|
|
94
|
+
bitarray version: 3.8.1
|
|
94
95
|
sys.version: 3.13.5 (main, Jun 16 2025) [Clang 18.1.8]
|
|
95
96
|
sys.prefix: /Users/ilan/miniforge
|
|
96
97
|
pointer size: 64 bit
|
|
@@ -99,13 +100,14 @@ Once you have installed the package, you may want to test it:
|
|
|
99
100
|
HAVE_BUILTIN_BSWAP64: 1
|
|
100
101
|
default bit-endianness: big
|
|
101
102
|
machine byte-order: little
|
|
103
|
+
Py_GIL_DISABLED: 0
|
|
102
104
|
Py_DEBUG: 0
|
|
103
105
|
DEBUG: 0
|
|
104
106
|
.........................................................................
|
|
105
107
|
.........................................................................
|
|
106
108
|
................................................................
|
|
107
109
|
----------------------------------------------------------------------
|
|
108
|
-
Ran
|
|
110
|
+
Ran 598 tests in 0.165s
|
|
109
111
|
|
|
110
112
|
OK
|
|
111
113
|
|
|
@@ -352,7 +354,7 @@ and can therefore be used as a dictionary key:
|
|
|
352
354
|
Reference
|
|
353
355
|
=========
|
|
354
356
|
|
|
355
|
-
bitarray version: 3.
|
|
357
|
+
bitarray version: 3.8.1 -- `change log <https://github.com/ilanschnell/bitarray/blob/master/doc/changelog.rst>`__
|
|
356
358
|
|
|
357
359
|
In the following, ``item`` and ``value`` are usually a single bit -
|
|
358
360
|
an integer 0 or 1.
|
|
@@ -588,6 +590,7 @@ bitarray methods:
|
|
|
588
590
|
|
|
589
591
|
``tobytes()`` -> bytes
|
|
590
592
|
Return the bitarray buffer (pad bits are set to zero).
|
|
593
|
+
``a.tobytes()`` is equivalent to ``bytes(a)``
|
|
591
594
|
|
|
592
595
|
|
|
593
596
|
``tofile(f, /)``
|
|
@@ -658,8 +661,6 @@ Functions defined in the `bitarray` module:
|
|
|
658
661
|
|
|
659
662
|
``get_default_endian()`` -> str
|
|
660
663
|
Return the default bit-endianness for new bitarray objects being created.
|
|
661
|
-
Unless ``_set_default_endian('little')`` was called, the default
|
|
662
|
-
bit-endianness is ``big``.
|
|
663
664
|
|
|
664
665
|
New in version 1.3
|
|
665
666
|
|
|
@@ -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.
|
|
60
|
+
bitarray version: 3.8.1
|
|
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
|
|
@@ -66,13 +66,14 @@ Once you have installed the package, you may want to test it:
|
|
|
66
66
|
HAVE_BUILTIN_BSWAP64: 1
|
|
67
67
|
default bit-endianness: big
|
|
68
68
|
machine byte-order: little
|
|
69
|
+
Py_GIL_DISABLED: 0
|
|
69
70
|
Py_DEBUG: 0
|
|
70
71
|
DEBUG: 0
|
|
71
72
|
.........................................................................
|
|
72
73
|
.........................................................................
|
|
73
74
|
................................................................
|
|
74
75
|
----------------------------------------------------------------------
|
|
75
|
-
Ran
|
|
76
|
+
Ran 598 tests in 0.165s
|
|
76
77
|
|
|
77
78
|
OK
|
|
78
79
|
|
|
@@ -319,7 +320,7 @@ and can therefore be used as a dictionary key:
|
|
|
319
320
|
Reference
|
|
320
321
|
=========
|
|
321
322
|
|
|
322
|
-
bitarray version: 3.
|
|
323
|
+
bitarray version: 3.8.1 -- `change log <https://github.com/ilanschnell/bitarray/blob/master/doc/changelog.rst>`__
|
|
323
324
|
|
|
324
325
|
In the following, ``item`` and ``value`` are usually a single bit -
|
|
325
326
|
an integer 0 or 1.
|
|
@@ -555,6 +556,7 @@ bitarray methods:
|
|
|
555
556
|
|
|
556
557
|
``tobytes()`` -> bytes
|
|
557
558
|
Return the bitarray buffer (pad bits are set to zero).
|
|
559
|
+
``a.tobytes()`` is equivalent to ``bytes(a)``
|
|
558
560
|
|
|
559
561
|
|
|
560
562
|
``tofile(f, /)``
|
|
@@ -625,8 +627,6 @@ Functions defined in the `bitarray` module:
|
|
|
625
627
|
|
|
626
628
|
``get_default_endian()`` -> str
|
|
627
629
|
Return the default bit-endianness for new bitarray objects being created.
|
|
628
|
-
Unless ``_set_default_endian('little')`` was called, the default
|
|
629
|
-
bit-endianness is ``big``.
|
|
630
630
|
|
|
631
631
|
New in version 1.3
|
|
632
632
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright (c) 2008 -
|
|
1
|
+
# Copyright (c) 2008 - 2026, Ilan Schnell; All Rights Reserved
|
|
2
2
|
"""
|
|
3
3
|
This package defines an object type which can efficiently represent
|
|
4
4
|
a bitarray. Bitarrays are sequence types and behave very much like lists.
|
|
@@ -13,8 +13,7 @@ from collections import namedtuple
|
|
|
13
13
|
|
|
14
14
|
from bitarray._bitarray import (
|
|
15
15
|
bitarray, decodetree, bits2bytes, _bitarray_reconstructor,
|
|
16
|
-
get_default_endian,
|
|
17
|
-
BITARRAY_VERSION as __version__
|
|
16
|
+
get_default_endian, _sysinfo, BITARRAY_VERSION as __version__
|
|
18
17
|
)
|
|
19
18
|
|
|
20
19
|
__all__ = ['bitarray', 'frozenbitarray', 'decodetree', 'bits2bytes']
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright (c) 2021 -
|
|
1
|
+
# Copyright (c) 2021 - 2026, Ilan Schnell; All Rights Reserved
|
|
2
2
|
#
|
|
3
3
|
# This stub, as well as util.pyi, are tested with Python 3.10 and mypy 1.11.2
|
|
4
4
|
|
|
@@ -162,7 +162,6 @@ __version__: str
|
|
|
162
162
|
def bits2bytes(n: int) -> int: ...
|
|
163
163
|
def get_default_endian() -> str: ...
|
|
164
164
|
def test(verbosity: int = ...) -> TextTestResult: ...
|
|
165
|
-
def _set_default_endian(endian: str) -> None: ...
|
|
166
165
|
def _sysinfo(key: str) -> int: ...
|
|
167
166
|
def _bitarray_reconstructor(cls: type,
|
|
168
167
|
buffer: bytes,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright (c) 2008 -
|
|
2
|
+
Copyright (c) 2008 - 2026, Ilan Schnell; All Rights Reserved
|
|
3
3
|
bitarray is published under the PSF license.
|
|
4
4
|
|
|
5
5
|
This file is the C part of the bitarray package.
|
|
@@ -16,9 +16,6 @@
|
|
|
16
16
|
/* size used when reading / writing blocks from files (in bytes) */
|
|
17
17
|
#define BLOCKSIZE 65536
|
|
18
18
|
|
|
19
|
-
/* default bit-endianness */
|
|
20
|
-
static int default_endian = ENDIAN_BIG;
|
|
21
|
-
|
|
22
19
|
/* translation table - setup during module initialization */
|
|
23
20
|
static char reverse_trans[256];
|
|
24
21
|
|
|
@@ -99,6 +96,9 @@ resize(bitarrayobject *self, Py_ssize_t nbits)
|
|
|
99
96
|
assert(new_allocated >= newsize);
|
|
100
97
|
self->ob_item = PyMem_Realloc(self->ob_item, new_allocated);
|
|
101
98
|
if (self->ob_item == NULL) {
|
|
99
|
+
Py_SET_SIZE(self, 0);
|
|
100
|
+
self->allocated = 0;
|
|
101
|
+
self->nbits = 0;
|
|
102
102
|
PyErr_NoMemory();
|
|
103
103
|
return -1;
|
|
104
104
|
}
|
|
@@ -1031,7 +1031,7 @@ bitarray_buffer_info(bitarrayobject *self)
|
|
|
1031
1031
|
readonly = PyBool_FromLong(self->readonly);
|
|
1032
1032
|
imported = PyBool_FromLong(self->buffer ? 1 : 0);
|
|
1033
1033
|
if (address == NULL || readonly == NULL || imported == NULL)
|
|
1034
|
-
|
|
1034
|
+
goto error;
|
|
1035
1035
|
|
|
1036
1036
|
args = Py_BuildValue("OnsnnOOi",
|
|
1037
1037
|
address,
|
|
@@ -1042,12 +1042,21 @@ bitarray_buffer_info(bitarrayobject *self)
|
|
|
1042
1042
|
readonly,
|
|
1043
1043
|
imported,
|
|
1044
1044
|
self->ob_exports);
|
|
1045
|
+
if (args == NULL)
|
|
1046
|
+
goto error;
|
|
1047
|
+
|
|
1045
1048
|
Py_DECREF(address);
|
|
1046
1049
|
Py_DECREF(readonly);
|
|
1047
1050
|
Py_DECREF(imported);
|
|
1048
1051
|
res = PyObject_CallObject(info, args);
|
|
1049
1052
|
Py_DECREF(args);
|
|
1050
1053
|
return res;
|
|
1054
|
+
|
|
1055
|
+
error:
|
|
1056
|
+
Py_XDECREF(address);
|
|
1057
|
+
Py_XDECREF(readonly);
|
|
1058
|
+
Py_XDECREF(imported);
|
|
1059
|
+
return NULL;
|
|
1051
1060
|
}
|
|
1052
1061
|
|
|
1053
1062
|
PyDoc_STRVAR(buffer_info_doc,
|
|
@@ -1576,7 +1585,8 @@ bitarray_tobytes(bitarrayobject *self)
|
|
|
1576
1585
|
PyDoc_STRVAR(tobytes_doc,
|
|
1577
1586
|
"tobytes() -> bytes\n\
|
|
1578
1587
|
\n\
|
|
1579
|
-
Return the bitarray buffer (pad bits are set to zero)
|
|
1588
|
+
Return the bitarray buffer (pad bits are set to zero).\n\
|
|
1589
|
+
`a.tobytes()` is equivalent to `bytes(a)`");
|
|
1580
1590
|
|
|
1581
1591
|
|
|
1582
1592
|
/* Extend self with bytes from f.read(n). Return number of bytes actually
|
|
@@ -1602,7 +1612,7 @@ extend_fread(bitarrayobject *self, PyObject *f, Py_ssize_t n)
|
|
|
1602
1612
|
ret = bitarray_frombytes(self, bytes);
|
|
1603
1613
|
Py_DECREF(bytes);
|
|
1604
1614
|
if (ret == NULL)
|
|
1605
|
-
|
|
1615
|
+
return -1;
|
|
1606
1616
|
Py_DECREF(ret);
|
|
1607
1617
|
return res;
|
|
1608
1618
|
}
|
|
@@ -2846,8 +2856,9 @@ bitarray_encode(bitarrayobject *self, PyObject *args)
|
|
|
2846
2856
|
|
|
2847
2857
|
/* extend self with the bitarrays from codedict */
|
|
2848
2858
|
while ((symbol = PyIter_Next(iter))) {
|
|
2849
|
-
|
|
2850
|
-
|
|
2859
|
+
if (PyDict_GetItemRef(codedict, symbol, &value) < 0)
|
|
2860
|
+
goto error;
|
|
2861
|
+
|
|
2851
2862
|
if (value == NULL) {
|
|
2852
2863
|
PyErr_Format(PyExc_ValueError,
|
|
2853
2864
|
"symbol not defined in prefix code: %A", symbol);
|
|
@@ -2856,6 +2867,9 @@ bitarray_encode(bitarrayobject *self, PyObject *args)
|
|
|
2856
2867
|
if (check_value(value) < 0 ||
|
|
2857
2868
|
extend_bitarray(self, (bitarrayobject *) value) < 0)
|
|
2858
2869
|
goto error;
|
|
2870
|
+
|
|
2871
|
+
Py_DECREF(symbol);
|
|
2872
|
+
Py_DECREF(value);
|
|
2859
2873
|
}
|
|
2860
2874
|
Py_DECREF(iter);
|
|
2861
2875
|
if (PyErr_Occurred()) /* from PyIter_Next() */
|
|
@@ -2864,6 +2878,8 @@ bitarray_encode(bitarrayobject *self, PyObject *args)
|
|
|
2864
2878
|
|
|
2865
2879
|
error:
|
|
2866
2880
|
Py_DECREF(iter);
|
|
2881
|
+
Py_DECREF(symbol);
|
|
2882
|
+
Py_XDECREF(value);
|
|
2867
2883
|
return NULL;
|
|
2868
2884
|
}
|
|
2869
2885
|
|
|
@@ -3025,8 +3041,10 @@ binode_to_dict(binode *nd, PyObject *dict, bitarrayobject *prefix)
|
|
|
3025
3041
|
|
|
3026
3042
|
if ((t = bitarray_cp(prefix)) == NULL)
|
|
3027
3043
|
return -1;
|
|
3028
|
-
if (resize(t, t->nbits + 1) < 0)
|
|
3044
|
+
if (resize(t, t->nbits + 1) < 0) {
|
|
3045
|
+
Py_DECREF(t);
|
|
3029
3046
|
return -1;
|
|
3047
|
+
}
|
|
3030
3048
|
setbit(t, t->nbits - 1, k);
|
|
3031
3049
|
ret = binode_to_dict(nd->child[k], dict, t);
|
|
3032
3050
|
Py_DECREF(t);
|
|
@@ -3116,7 +3134,7 @@ decodetree_todict(decodetreeobject *self)
|
|
|
3116
3134
|
if ((dict = PyDict_New()) == NULL)
|
|
3117
3135
|
return NULL;
|
|
3118
3136
|
|
|
3119
|
-
prefix = newbitarrayobject(&Bitarray_Type, 0,
|
|
3137
|
+
prefix = newbitarrayobject(&Bitarray_Type, 0, ENDIAN_DEFAULT);
|
|
3120
3138
|
if (prefix == NULL)
|
|
3121
3139
|
goto error;
|
|
3122
3140
|
|
|
@@ -3323,12 +3341,12 @@ decodeiter_next(decodeiterobject *it)
|
|
|
3323
3341
|
static void
|
|
3324
3342
|
decodeiter_dealloc(decodeiterobject *it)
|
|
3325
3343
|
{
|
|
3344
|
+
PyObject_GC_UnTrack(it);
|
|
3326
3345
|
if (it->decodetree)
|
|
3327
3346
|
Py_DECREF(it->decodetree);
|
|
3328
3347
|
else /* when decodeiter was created from dict - free tree */
|
|
3329
3348
|
binode_delete(it->tree);
|
|
3330
3349
|
|
|
3331
|
-
PyObject_GC_UnTrack(it);
|
|
3332
3350
|
Py_DECREF(it->self);
|
|
3333
3351
|
PyObject_GC_Del(it);
|
|
3334
3352
|
}
|
|
@@ -3468,6 +3486,7 @@ static int
|
|
|
3468
3486
|
searchiter_traverse(searchiterobject *it, visitproc visit, void *arg)
|
|
3469
3487
|
{
|
|
3470
3488
|
Py_VISIT(it->self);
|
|
3489
|
+
Py_VISIT(it->sub);
|
|
3471
3490
|
return 0;
|
|
3472
3491
|
}
|
|
3473
3492
|
|
|
@@ -3565,6 +3584,8 @@ static PyMethodDef bitarray_methods[] = {
|
|
|
3565
3584
|
to01_doc},
|
|
3566
3585
|
{"tobytes", (PyCFunction) bitarray_tobytes, METH_NOARGS,
|
|
3567
3586
|
tobytes_doc},
|
|
3587
|
+
{"__bytes__", (PyCFunction) bitarray_tobytes, METH_NOARGS,
|
|
3588
|
+
tobytes_doc},
|
|
3568
3589
|
{"tofile", (PyCFunction) bitarray_tofile, METH_O,
|
|
3569
3590
|
tofile_doc},
|
|
3570
3591
|
{"tolist", (PyCFunction) bitarray_tolist, METH_NOARGS,
|
|
@@ -3600,10 +3621,8 @@ static PyMethodDef bitarray_methods[] = {
|
|
|
3600
3621
|
static int
|
|
3601
3622
|
endian_from_string(const char *str)
|
|
3602
3623
|
{
|
|
3603
|
-
assert(default_endian == ENDIAN_LITTLE || default_endian == ENDIAN_BIG);
|
|
3604
|
-
|
|
3605
3624
|
if (str == NULL)
|
|
3606
|
-
return
|
|
3625
|
+
return ENDIAN_DEFAULT;
|
|
3607
3626
|
|
|
3608
3627
|
if (strcmp(str, "little") == 0)
|
|
3609
3628
|
return ENDIAN_LITTLE;
|
|
@@ -4046,7 +4065,8 @@ bits2bytes(PyObject *module, PyObject *n)
|
|
|
4046
4065
|
return PyErr_Format(PyExc_TypeError, "'int' object expected, "
|
|
4047
4066
|
"got '%s'", Py_TYPE(n)->tp_name);
|
|
4048
4067
|
|
|
4049
|
-
zero = PyLong_FromLong(0)
|
|
4068
|
+
if ((zero = PyLong_FromLong(0)) == NULL)
|
|
4069
|
+
return NULL;
|
|
4050
4070
|
cmp_res = PyObject_RichCompareBool(n, zero, Py_LT);
|
|
4051
4071
|
Py_DECREF(zero);
|
|
4052
4072
|
if (cmp_res < 0)
|
|
@@ -4056,13 +4076,17 @@ bits2bytes(PyObject *module, PyObject *n)
|
|
|
4056
4076
|
return NULL;
|
|
4057
4077
|
}
|
|
4058
4078
|
|
|
4059
|
-
seven = PyLong_FromLong(7)
|
|
4079
|
+
if ((seven = PyLong_FromLong(7)) == NULL)
|
|
4080
|
+
return NULL;
|
|
4060
4081
|
a = PyNumber_Add(n, seven); /* a = n + 7 */
|
|
4061
4082
|
Py_DECREF(seven);
|
|
4062
4083
|
if (a == NULL)
|
|
4063
4084
|
return NULL;
|
|
4064
4085
|
|
|
4065
|
-
eight = PyLong_FromLong(8)
|
|
4086
|
+
if ((eight = PyLong_FromLong(8)) == NULL) {
|
|
4087
|
+
Py_DECREF(a);
|
|
4088
|
+
return NULL;
|
|
4089
|
+
}
|
|
4066
4090
|
b = PyNumber_FloorDivide(a, eight); /* b = a // 8 */
|
|
4067
4091
|
Py_DECREF(eight);
|
|
4068
4092
|
Py_DECREF(a);
|
|
@@ -4126,39 +4150,13 @@ reconstructor(PyObject *module, PyObject *args)
|
|
|
4126
4150
|
static PyObject *
|
|
4127
4151
|
get_default_endian(PyObject *module)
|
|
4128
4152
|
{
|
|
4129
|
-
return PyUnicode_FromString(ENDIAN_STR(
|
|
4153
|
+
return PyUnicode_FromString(ENDIAN_STR(ENDIAN_DEFAULT));
|
|
4130
4154
|
}
|
|
4131
4155
|
|
|
4132
4156
|
PyDoc_STRVAR(get_default_endian_doc,
|
|
4133
4157
|
"get_default_endian() -> str\n\
|
|
4134
4158
|
\n\
|
|
4135
|
-
Return the default bit-endianness for new bitarray objects being created
|
|
4136
|
-
Unless `_set_default_endian('little')` was called, the default\n\
|
|
4137
|
-
bit-endianness is `big`.");
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
static PyObject *
|
|
4141
|
-
set_default_endian(PyObject *module, PyObject *args)
|
|
4142
|
-
{
|
|
4143
|
-
char *endian_str;
|
|
4144
|
-
int t;
|
|
4145
|
-
|
|
4146
|
-
if (!PyArg_ParseTuple(args, "s:_set_default_endian", &endian_str))
|
|
4147
|
-
return NULL;
|
|
4148
|
-
|
|
4149
|
-
/* As endian_from_string() might return -1, we have to store its value
|
|
4150
|
-
in a temporary variable before setting default_endian. */
|
|
4151
|
-
if ((t = endian_from_string(endian_str)) < 0)
|
|
4152
|
-
return NULL;
|
|
4153
|
-
default_endian = t;
|
|
4154
|
-
|
|
4155
|
-
Py_RETURN_NONE;
|
|
4156
|
-
}
|
|
4157
|
-
|
|
4158
|
-
PyDoc_STRVAR(set_default_endian_doc,
|
|
4159
|
-
"_set_default_endian(endian, /)\n\
|
|
4160
|
-
\n\
|
|
4161
|
-
Set the default bit-endianness for new bitarray objects being created.");
|
|
4159
|
+
Return the default bit-endianness for new bitarray objects being created.");
|
|
4162
4160
|
|
|
4163
4161
|
|
|
4164
4162
|
static PyObject *
|
|
@@ -4181,6 +4179,11 @@ sysinfo(PyObject *module, PyObject *args)
|
|
|
4181
4179
|
R("PY_LITTLE_ENDIAN", PY_LITTLE_ENDIAN);
|
|
4182
4180
|
R("PY_BIG_ENDIAN", PY_BIG_ENDIAN);
|
|
4183
4181
|
R("HAVE_BUILTIN_BSWAP64", HAVE_BUILTIN_BSWAP64);
|
|
4182
|
+
#ifdef Py_GIL_DISABLED /* Python configured using --disable-gil */
|
|
4183
|
+
R("Py_GIL_DISABLED", 1);
|
|
4184
|
+
#else
|
|
4185
|
+
R("Py_GIL_DISABLED", 0);
|
|
4186
|
+
#endif
|
|
4184
4187
|
#ifdef Py_DEBUG /* Python configured using --with-pydebug */
|
|
4185
4188
|
R("Py_DEBUG", 1);
|
|
4186
4189
|
#else
|
|
@@ -4211,8 +4214,6 @@ static PyMethodDef module_functions[] = {
|
|
|
4211
4214
|
reduce_doc},
|
|
4212
4215
|
{"get_default_endian", (PyCFunction) get_default_endian, METH_NOARGS,
|
|
4213
4216
|
get_default_endian_doc},
|
|
4214
|
-
{"_set_default_endian", (PyCFunction) set_default_endian, METH_VARARGS,
|
|
4215
|
-
set_default_endian_doc},
|
|
4216
4217
|
{"_sysinfo", (PyCFunction) sysinfo, METH_VARARGS,
|
|
4217
4218
|
sysinfo_doc},
|
|
4218
4219
|
{NULL, NULL} /* sentinel */
|
|
@@ -4260,6 +4261,10 @@ PyInit__bitarray(void)
|
|
|
4260
4261
|
if ((m = PyModule_Create(&moduledef)) == NULL)
|
|
4261
4262
|
return NULL;
|
|
4262
4263
|
|
|
4264
|
+
#ifdef Py_GIL_DISABLED
|
|
4265
|
+
PyUnstable_Module_SetGIL(m, Py_MOD_GIL_NOT_USED);
|
|
4266
|
+
#endif
|
|
4267
|
+
|
|
4263
4268
|
if (PyType_Ready(&Bitarray_Type) < 0)
|
|
4264
4269
|
return NULL;
|
|
4265
4270
|
Py_SET_TYPE(&Bitarray_Type, &PyType_Type);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright (c) 2019 -
|
|
2
|
+
Copyright (c) 2019 - 2026, Ilan Schnell; All Rights Reserved
|
|
3
3
|
bitarray is published under the PSF license.
|
|
4
4
|
|
|
5
5
|
This file contains the C implementation of some useful utility functions.
|
|
@@ -102,6 +102,9 @@ resize_lite(bitarrayobject *self, Py_ssize_t nbits)
|
|
|
102
102
|
|
|
103
103
|
self->ob_item = PyMem_Realloc(self->ob_item, newsize);
|
|
104
104
|
if (self->ob_item == NULL) {
|
|
105
|
+
Py_SET_SIZE(self, 0);
|
|
106
|
+
self->allocated = 0;
|
|
107
|
+
self->nbits = 0;
|
|
105
108
|
PyErr_NoMemory();
|
|
106
109
|
return -1;
|
|
107
110
|
}
|
|
@@ -1154,7 +1157,8 @@ byte_length(Py_ssize_t i)
|
|
|
1154
1157
|
BSI(1) = 32 (BSI = Buffer Size Indexable)
|
|
1155
1158
|
|
|
1156
1159
|
Moving from block type n to n + 1 multiplies the decoded block size
|
|
1157
|
-
by a factor of 256 (as
|
|
1160
|
+
by a factor of 256 (as one extra byte can index 256 times as much
|
|
1161
|
+
address space):
|
|
1158
1162
|
|
|
1159
1163
|
BSI(n + 1) = 256 * BSI(n)
|
|
1160
1164
|
*/
|
|
@@ -1281,7 +1285,8 @@ module_sc_rts(PyObject *module, PyObject *obj)
|
|
|
1281
1285
|
a.count(1, 8 * offset, 8 * offset + (1 << (8 * n)))
|
|
1282
1286
|
|
|
1283
1287
|
The offset must be divisible by SEGSIZE, as this functions makes use of
|
|
1284
|
-
running totals, stored in rts[].
|
|
1288
|
+
running totals, stored in rts[].
|
|
1289
|
+
Here, and in the following, 'offset' is in units of bytes. */
|
|
1285
1290
|
static Py_ssize_t
|
|
1286
1291
|
sc_count(bitarrayobject *a, Py_ssize_t *rts, Py_ssize_t offset, int n)
|
|
1287
1292
|
{
|
|
@@ -1968,8 +1973,10 @@ chdi_new(PyObject *module, PyObject *args)
|
|
|
1968
1973
|
return NULL;
|
|
1969
1974
|
|
|
1970
1975
|
it = PyObject_GC_New(chdi_obj, &CHDI_Type);
|
|
1971
|
-
if (it == NULL)
|
|
1972
|
-
|
|
1976
|
+
if (it == NULL) {
|
|
1977
|
+
Py_DECREF(symbol);
|
|
1978
|
+
return NULL;
|
|
1979
|
+
}
|
|
1973
1980
|
|
|
1974
1981
|
if ((count_sum = set_count(it->count, count)) < 0)
|
|
1975
1982
|
goto error;
|
|
@@ -1990,7 +1997,7 @@ chdi_new(PyObject *module, PyObject *args)
|
|
|
1990
1997
|
|
|
1991
1998
|
error:
|
|
1992
1999
|
it->array = NULL;
|
|
1993
|
-
|
|
2000
|
+
Py_DECREF(symbol);
|
|
1994
2001
|
it->symbol = NULL;
|
|
1995
2002
|
Py_DECREF(it);
|
|
1996
2003
|
return NULL;
|
|
@@ -2249,6 +2256,10 @@ PyInit__util(void)
|
|
|
2249
2256
|
if ((m = PyModule_Create(&moduledef)) == NULL)
|
|
2250
2257
|
return NULL;
|
|
2251
2258
|
|
|
2259
|
+
#ifdef Py_GIL_DISABLED
|
|
2260
|
+
PyUnstable_Module_SetGIL(m, Py_MOD_GIL_NOT_USED);
|
|
2261
|
+
#endif
|
|
2262
|
+
|
|
2252
2263
|
if (PyType_Ready(&CHDI_Type) < 0)
|
|
2253
2264
|
return NULL;
|
|
2254
2265
|
Py_SET_TYPE(&CHDI_Type, &PyType_Type);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright (c) 2008 -
|
|
2
|
+
Copyright (c) 2008 - 2026, Ilan Schnell; All Rights Reserved
|
|
3
3
|
bitarray is published under the PSF license.
|
|
4
4
|
|
|
5
5
|
Author: Ilan Schnell
|
|
6
6
|
*/
|
|
7
|
-
#define BITARRAY_VERSION "3.
|
|
7
|
+
#define BITARRAY_VERSION "3.8.1"
|
|
8
8
|
|
|
9
9
|
#ifdef STDC_HEADERS
|
|
10
10
|
# include <stddef.h>
|
|
@@ -52,6 +52,8 @@ typedef struct {
|
|
|
52
52
|
/* --- bit-endianness --- */
|
|
53
53
|
#define ENDIAN_LITTLE 0
|
|
54
54
|
#define ENDIAN_BIG 1
|
|
55
|
+
/* default bit-endianness */
|
|
56
|
+
#define ENDIAN_DEFAULT ENDIAN_BIG
|
|
55
57
|
|
|
56
58
|
#define IS_LE(self) ((self)->endian == ENDIAN_LITTLE)
|
|
57
59
|
#define IS_BE(self) ((self)->endian == ENDIAN_BIG)
|