bitarray 3.10.0__tar.gz → 3.10.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.10.0 → bitarray-3.10.1}/PKG-INFO +8 -8
- {bitarray-3.10.0 → bitarray-3.10.1}/README.rst +7 -7
- {bitarray-3.10.0 → bitarray-3.10.1}/bitarray/_bitarray.c +123 -37
- {bitarray-3.10.0 → bitarray-3.10.1}/bitarray/bitarray.h +1 -1
- {bitarray-3.10.0 → bitarray-3.10.1}/bitarray/test_bitarray.py +142 -121
- {bitarray-3.10.0 → bitarray-3.10.1}/bitarray/test_util.py +66 -103
- {bitarray-3.10.0 → bitarray-3.10.1}/bitarray/util.py +57 -70
- {bitarray-3.10.0 → bitarray-3.10.1}/bitarray.egg-info/PKG-INFO +8 -8
- {bitarray-3.10.0 → bitarray-3.10.1}/LICENSE +0 -0
- {bitarray-3.10.0 → bitarray-3.10.1}/bitarray/__init__.py +0 -0
- {bitarray-3.10.0 → bitarray-3.10.1}/bitarray/__init__.pyi +0 -0
- {bitarray-3.10.0 → bitarray-3.10.1}/bitarray/_util.c +0 -0
- {bitarray-3.10.0 → bitarray-3.10.1}/bitarray/py.typed +0 -0
- {bitarray-3.10.0 → bitarray-3.10.1}/bitarray/pythoncapi_compat.h +0 -0
- {bitarray-3.10.0 → bitarray-3.10.1}/bitarray/test_281.pickle +0 -0
- {bitarray-3.10.0 → bitarray-3.10.1}/bitarray/test_free_threading.py +0 -0
- {bitarray-3.10.0 → bitarray-3.10.1}/bitarray/util.pyi +0 -0
- {bitarray-3.10.0 → bitarray-3.10.1}/bitarray.egg-info/SOURCES.txt +0 -0
- {bitarray-3.10.0 → bitarray-3.10.1}/bitarray.egg-info/dependency_links.txt +0 -0
- {bitarray-3.10.0 → bitarray-3.10.1}/bitarray.egg-info/not-zip-safe +0 -0
- {bitarray-3.10.0 → bitarray-3.10.1}/bitarray.egg-info/top_level.txt +0 -0
- {bitarray-3.10.0 → bitarray-3.10.1}/pyproject.toml +0 -0
- {bitarray-3.10.0 → bitarray-3.10.1}/setup.cfg +0 -0
- {bitarray-3.10.0 → bitarray-3.10.1}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: bitarray
|
|
3
|
-
Version: 3.10.
|
|
3
|
+
Version: 3.10.1
|
|
4
4
|
Summary: efficient arrays of booleans -- C extension
|
|
5
5
|
Home-page: https://github.com/ilanschnell/bitarray
|
|
6
6
|
Author: Ilan Schnell
|
|
@@ -94,7 +94,7 @@ Once you have installed the package, you may want to test it:
|
|
|
94
94
|
$ python -c 'import bitarray; bitarray.test()'
|
|
95
95
|
bitarray is installed in: /Users/ilan/bitarray/bitarray
|
|
96
96
|
sys.prefix: /Users/ilan/miniforge
|
|
97
|
-
bitarray version: 3.10.
|
|
97
|
+
bitarray version: 3.10.1
|
|
98
98
|
sys.version: 3.14.5 (main, May 20 2026) [Clang 20.1.8]
|
|
99
99
|
sys.abiflags: ''
|
|
100
100
|
sys._is_gil_enabled(): True
|
|
@@ -111,7 +111,7 @@ Once you have installed the package, you may want to test it:
|
|
|
111
111
|
..........s.....................................s........................
|
|
112
112
|
......s.........................................................
|
|
113
113
|
----------------------------------------------------------------------
|
|
114
|
-
Ran
|
|
114
|
+
Ran 640 tests in 0.192s
|
|
115
115
|
|
|
116
116
|
OK (skipped=4)
|
|
117
117
|
|
|
@@ -358,7 +358,7 @@ and can therefore be used as a dictionary key:
|
|
|
358
358
|
Reference
|
|
359
359
|
=========
|
|
360
360
|
|
|
361
|
-
bitarray version: 3.10.
|
|
361
|
+
bitarray version: 3.10.1 -- `change log <https://github.com/ilanschnell/bitarray/blob/master/doc/changelog.rst>`__
|
|
362
362
|
|
|
363
363
|
In the following, ``item`` and ``value`` are usually a single bit -
|
|
364
364
|
an integer 0 or 1.
|
|
@@ -937,7 +937,7 @@ This sub-module was added in version 1.2.
|
|
|
937
937
|
|
|
938
938
|
|
|
939
939
|
``pprint(bitarray, /, stream=None, group=8, indent=4, width=80)``
|
|
940
|
-
Pretty-print bitarray object to ``stream``, defaults
|
|
940
|
+
Pretty-print bitarray object to ``stream``, defaults to ``sys.stdout``.
|
|
941
941
|
By default, bits are grouped in bytes (8 bits), and 64 bits per line.
|
|
942
942
|
Non-bitarray objects are printed using ``pprint.pprint()``.
|
|
943
943
|
|
|
@@ -948,8 +948,8 @@ This sub-module was added in version 1.2.
|
|
|
948
948
|
Return (pseudo-) random bitarray of length ``n`` with ``k`` elements
|
|
949
949
|
set to one. Mathematically equivalent to setting (in a bitarray of
|
|
950
950
|
length ``n``) all bits at indices ``random.sample(range(n), k)`` to one.
|
|
951
|
-
The random bitarrays are reproducible when
|
|
952
|
-
a specific seed value.
|
|
951
|
+
The random bitarrays are reproducible when calling Python's ``random.seed()``
|
|
952
|
+
with a specific seed value.
|
|
953
953
|
|
|
954
954
|
New in version 3.6
|
|
955
955
|
|
|
@@ -958,7 +958,7 @@ This sub-module was added in version 1.2.
|
|
|
958
958
|
Return (pseudo-) random bitarray of length ``n``, where each bit has
|
|
959
959
|
probability ``p`` of being one (independent of any other bits). Mathematically
|
|
960
960
|
equivalent to ``bitarray((random() < p for _ in range(n)), endian)``, but much
|
|
961
|
-
faster for large ``n``. The random bitarrays are reproducible when
|
|
961
|
+
faster for large ``n``. The random bitarrays are reproducible when calling
|
|
962
962
|
Python's ``random.seed()`` with a specific seed value.
|
|
963
963
|
|
|
964
964
|
This function requires Python 3.12 or higher, as it depends on the standard
|
|
@@ -59,7 +59,7 @@ Once you have installed the package, you may want to test it:
|
|
|
59
59
|
$ python -c 'import bitarray; bitarray.test()'
|
|
60
60
|
bitarray is installed in: /Users/ilan/bitarray/bitarray
|
|
61
61
|
sys.prefix: /Users/ilan/miniforge
|
|
62
|
-
bitarray version: 3.10.
|
|
62
|
+
bitarray version: 3.10.1
|
|
63
63
|
sys.version: 3.14.5 (main, May 20 2026) [Clang 20.1.8]
|
|
64
64
|
sys.abiflags: ''
|
|
65
65
|
sys._is_gil_enabled(): True
|
|
@@ -76,7 +76,7 @@ Once you have installed the package, you may want to test it:
|
|
|
76
76
|
..........s.....................................s........................
|
|
77
77
|
......s.........................................................
|
|
78
78
|
----------------------------------------------------------------------
|
|
79
|
-
Ran
|
|
79
|
+
Ran 640 tests in 0.192s
|
|
80
80
|
|
|
81
81
|
OK (skipped=4)
|
|
82
82
|
|
|
@@ -323,7 +323,7 @@ and can therefore be used as a dictionary key:
|
|
|
323
323
|
Reference
|
|
324
324
|
=========
|
|
325
325
|
|
|
326
|
-
bitarray version: 3.10.
|
|
326
|
+
bitarray version: 3.10.1 -- `change log <https://github.com/ilanschnell/bitarray/blob/master/doc/changelog.rst>`__
|
|
327
327
|
|
|
328
328
|
In the following, ``item`` and ``value`` are usually a single bit -
|
|
329
329
|
an integer 0 or 1.
|
|
@@ -902,7 +902,7 @@ This sub-module was added in version 1.2.
|
|
|
902
902
|
|
|
903
903
|
|
|
904
904
|
``pprint(bitarray, /, stream=None, group=8, indent=4, width=80)``
|
|
905
|
-
Pretty-print bitarray object to ``stream``, defaults
|
|
905
|
+
Pretty-print bitarray object to ``stream``, defaults to ``sys.stdout``.
|
|
906
906
|
By default, bits are grouped in bytes (8 bits), and 64 bits per line.
|
|
907
907
|
Non-bitarray objects are printed using ``pprint.pprint()``.
|
|
908
908
|
|
|
@@ -913,8 +913,8 @@ This sub-module was added in version 1.2.
|
|
|
913
913
|
Return (pseudo-) random bitarray of length ``n`` with ``k`` elements
|
|
914
914
|
set to one. Mathematically equivalent to setting (in a bitarray of
|
|
915
915
|
length ``n``) all bits at indices ``random.sample(range(n), k)`` to one.
|
|
916
|
-
The random bitarrays are reproducible when
|
|
917
|
-
a specific seed value.
|
|
916
|
+
The random bitarrays are reproducible when calling Python's ``random.seed()``
|
|
917
|
+
with a specific seed value.
|
|
918
918
|
|
|
919
919
|
New in version 3.6
|
|
920
920
|
|
|
@@ -923,7 +923,7 @@ This sub-module was added in version 1.2.
|
|
|
923
923
|
Return (pseudo-) random bitarray of length ``n``, where each bit has
|
|
924
924
|
probability ``p`` of being one (independent of any other bits). Mathematically
|
|
925
925
|
equivalent to ``bitarray((random() < p for _ in range(n)), endian)``, but much
|
|
926
|
-
faster for large ``n``. The random bitarrays are reproducible when
|
|
926
|
+
faster for large ``n``. The random bitarrays are reproducible when calling
|
|
927
927
|
Python's ``random.seed()`` with a specific seed value.
|
|
928
928
|
|
|
929
929
|
This function requires Python 3.12 or higher, as it depends on the standard
|
|
@@ -3741,7 +3741,7 @@ binode_delete(binode *nd)
|
|
|
3741
3741
|
static int
|
|
3742
3742
|
binode_insert_symbol(binode *tree, bitarrayobject *a, PyObject *symbol)
|
|
3743
3743
|
{
|
|
3744
|
-
binode *nd = tree
|
|
3744
|
+
binode *nd = tree;
|
|
3745
3745
|
Py_ssize_t i;
|
|
3746
3746
|
|
|
3747
3747
|
if (a->nbits > MAX_CODE_LENGTH) {
|
|
@@ -3752,20 +3752,21 @@ binode_insert_symbol(binode *tree, bitarrayobject *a, PyObject *symbol)
|
|
|
3752
3752
|
|
|
3753
3753
|
for (i = 0; i < a->nbits; i++) {
|
|
3754
3754
|
int k = getbit(a, i);
|
|
3755
|
+
binode *next = nd->child[k];
|
|
3755
3756
|
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
if (nd) {
|
|
3760
|
-
if (nd->symbol) /* we cannot have already a symbol */
|
|
3757
|
+
if (next) {
|
|
3758
|
+
if (next->symbol) /* an existing code ends here */
|
|
3761
3759
|
goto ambiguity;
|
|
3760
|
+
/* existing node without a symbol must be an internal node */
|
|
3761
|
+
assert(next->child[0] || next->child[1]);
|
|
3762
3762
|
}
|
|
3763
3763
|
else { /* if node does not exist, create new one */
|
|
3764
|
-
|
|
3765
|
-
if (
|
|
3764
|
+
next = binode_new();
|
|
3765
|
+
if (next == NULL)
|
|
3766
3766
|
return -1;
|
|
3767
|
-
|
|
3767
|
+
nd->child[k] = next;
|
|
3768
3768
|
}
|
|
3769
|
+
nd = next; /* descend to the selected child */
|
|
3769
3770
|
}
|
|
3770
3771
|
/* the new leaf node cannot already have a symbol or children */
|
|
3771
3772
|
if (nd->symbol || nd->child[0] || nd->child[1])
|
|
@@ -3831,34 +3832,37 @@ binode_make_tree(PyObject *codedict)
|
|
|
3831
3832
|
return tree;
|
|
3832
3833
|
}
|
|
3833
3834
|
|
|
3834
|
-
/*
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3835
|
+
/* Starting at *index, follow bits from a through tree until reaching a leaf.
|
|
3836
|
+
Advance *index as valid tree edges are traversed, including when traversal
|
|
3837
|
+
ultimately fails, and return the leaf's symbol as a borrowed reference.
|
|
3838
|
+
Return NULL without an exception when called at the end of a; return NULL
|
|
3839
|
+
with an exception for an invalid or incomplete code.
|
|
3838
3840
|
*/
|
|
3839
3841
|
static PyObject *
|
|
3840
|
-
binode_traverse(binode *tree, bitarrayobject *
|
|
3842
|
+
binode_traverse(binode *tree, bitarrayobject *a, Py_ssize_t *index)
|
|
3841
3843
|
{
|
|
3842
3844
|
binode *nd = tree;
|
|
3843
|
-
Py_ssize_t start = *
|
|
3845
|
+
Py_ssize_t start = *index;
|
|
3844
3846
|
|
|
3845
|
-
while (*
|
|
3847
|
+
while (*index < a->nbits) {
|
|
3846
3848
|
assert(nd);
|
|
3847
|
-
nd = nd->child[getbit(
|
|
3849
|
+
nd = nd->child[getbit(a, *index)];
|
|
3848
3850
|
if (nd == NULL)
|
|
3849
3851
|
return PyErr_Format(PyExc_ValueError,
|
|
3850
|
-
"prefix code unrecognized in bitarray "
|
|
3851
|
-
"
|
|
3852
|
-
(*
|
|
3853
|
-
if (nd->symbol) {
|
|
3852
|
+
"prefix code unrecognized in bitarray at "
|
|
3853
|
+
"position %zd .. %zd", start, *index);
|
|
3854
|
+
(*index)++;
|
|
3855
|
+
if (nd->symbol) { /* leaf */
|
|
3854
3856
|
assert(nd->child[0] == NULL && nd->child[1] == NULL);
|
|
3855
3857
|
return nd->symbol;
|
|
3856
3858
|
}
|
|
3857
3859
|
}
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3860
|
+
|
|
3861
|
+
if (*index == start)
|
|
3862
|
+
return NULL; /* stop iteration */
|
|
3863
|
+
|
|
3864
|
+
return PyErr_Format(PyExc_ValueError,
|
|
3865
|
+
"incomplete prefix code at position %zd", start);
|
|
3862
3866
|
}
|
|
3863
3867
|
|
|
3864
3868
|
/* add the node's symbol to given dict */
|
|
@@ -3919,6 +3923,31 @@ binode_nodes(binode *nd, Py_ssize_t *n1, Py_ssize_t *n2, Py_ssize_t *ns)
|
|
|
3919
3923
|
binode_nodes(nd->child[1], n1, n2, ns);
|
|
3920
3924
|
}
|
|
3921
3925
|
|
|
3926
|
+
static PyObject *
|
|
3927
|
+
binode_tuple_nodes(binode *nd)
|
|
3928
|
+
{
|
|
3929
|
+
Py_ssize_t n1 = 0, n2 = 0, ns = 0;
|
|
3930
|
+
|
|
3931
|
+
binode_nodes(nd, &n1, &n2, &ns);
|
|
3932
|
+
return Py_BuildValue("nnn", n1, n2, ns);
|
|
3933
|
+
}
|
|
3934
|
+
|
|
3935
|
+
#ifndef NDEBUG
|
|
3936
|
+
static binode *
|
|
3937
|
+
binode_getnode(binode *tree, bitarrayobject *a)
|
|
3938
|
+
{
|
|
3939
|
+
binode *nd = tree;
|
|
3940
|
+
Py_ssize_t i;
|
|
3941
|
+
|
|
3942
|
+
for (i = 0; i < a->nbits; i++) {
|
|
3943
|
+
nd = nd->child[getbit(a, i)];
|
|
3944
|
+
if (nd == NULL)
|
|
3945
|
+
return NULL;
|
|
3946
|
+
}
|
|
3947
|
+
return nd;
|
|
3948
|
+
}
|
|
3949
|
+
#endif /* NDEBUG */
|
|
3950
|
+
|
|
3922
3951
|
/******************************** decodetree ******************************/
|
|
3923
3952
|
|
|
3924
3953
|
typedef struct {
|
|
@@ -4014,9 +4043,7 @@ reconstruction of the code dict which the object was created with.");
|
|
|
4014
4043
|
static PyObject *
|
|
4015
4044
|
decodetree_nodes(decodetreeobject *self)
|
|
4016
4045
|
{
|
|
4017
|
-
|
|
4018
|
-
binode_nodes(self->tree, &n1, &n2, &ns);
|
|
4019
|
-
return Py_BuildValue("nnn", n1, n2, ns);
|
|
4046
|
+
return binode_tuple_nodes(self->tree);
|
|
4020
4047
|
}
|
|
4021
4048
|
|
|
4022
4049
|
PyDoc_STRVAR(nodes_doc,
|
|
@@ -4028,6 +4055,64 @@ Return tuple with number of:\n\n\
|
|
|
4028
4055
|
2. leaf nodes (pointing to a symbol)\n");
|
|
4029
4056
|
|
|
4030
4057
|
|
|
4058
|
+
#ifndef NDEBUG
|
|
4059
|
+
static PyObject *
|
|
4060
|
+
make_node_dict(binode *nd)
|
|
4061
|
+
{
|
|
4062
|
+
const char *keys[] = {"left", "right"};
|
|
4063
|
+
PyObject *dict;
|
|
4064
|
+
int k;
|
|
4065
|
+
|
|
4066
|
+
assert(nd->symbol == NULL);
|
|
4067
|
+
|
|
4068
|
+
dict = PyDict_New();
|
|
4069
|
+
if (dict == NULL)
|
|
4070
|
+
return NULL;
|
|
4071
|
+
|
|
4072
|
+
for (k = 0; k < 2; k++) {
|
|
4073
|
+
binode *child = nd->child[k];
|
|
4074
|
+
|
|
4075
|
+
if (child) {
|
|
4076
|
+
PyObject *nodes = binode_tuple_nodes(child);
|
|
4077
|
+
|
|
4078
|
+
if (!nodes || PyDict_SetItemString(dict, keys[k], nodes) < 0) {
|
|
4079
|
+
Py_DECREF(dict);
|
|
4080
|
+
Py_XDECREF(nodes);
|
|
4081
|
+
return NULL;
|
|
4082
|
+
}
|
|
4083
|
+
Py_DECREF(nodes);
|
|
4084
|
+
}
|
|
4085
|
+
}
|
|
4086
|
+
return dict;
|
|
4087
|
+
}
|
|
4088
|
+
|
|
4089
|
+
static PyObject *
|
|
4090
|
+
decodetree_getnode(decodetreeobject *self, PyObject *obj)
|
|
4091
|
+
{
|
|
4092
|
+
binode *nd;
|
|
4093
|
+
|
|
4094
|
+
assert(bitarray_Check(obj));
|
|
4095
|
+
|
|
4096
|
+
Py_BEGIN_CRITICAL_SECTION(obj);
|
|
4097
|
+
nd = binode_getnode(self->tree, (bitarrayobject *) obj);
|
|
4098
|
+
Py_END_CRITICAL_SECTION();
|
|
4099
|
+
|
|
4100
|
+
if (nd == NULL) {
|
|
4101
|
+
PyErr_SetString(PyExc_ValueError, "node does not exist");
|
|
4102
|
+
return NULL;
|
|
4103
|
+
}
|
|
4104
|
+
|
|
4105
|
+
if (nd->symbol) {
|
|
4106
|
+
assert(nd->child[0] == NULL && nd->child[1] == NULL);
|
|
4107
|
+
return Py_NewRef(nd->symbol);
|
|
4108
|
+
}
|
|
4109
|
+
else {
|
|
4110
|
+
return make_node_dict(nd);
|
|
4111
|
+
}
|
|
4112
|
+
}
|
|
4113
|
+
#endif /* NDEBUG */
|
|
4114
|
+
|
|
4115
|
+
|
|
4031
4116
|
static PyObject *
|
|
4032
4117
|
decodetree_sizeof(decodetreeobject *self)
|
|
4033
4118
|
{
|
|
@@ -4047,12 +4132,13 @@ decodetree_dealloc(decodetreeobject *self)
|
|
|
4047
4132
|
}
|
|
4048
4133
|
|
|
4049
4134
|
static PyMethodDef decodetree_methods[] = {
|
|
4050
|
-
{"nodes", (PyCFunction) decodetree_nodes,
|
|
4051
|
-
|
|
4052
|
-
{"
|
|
4053
|
-
|
|
4054
|
-
{"
|
|
4055
|
-
|
|
4135
|
+
{"nodes", (PyCFunction) decodetree_nodes, METH_NOARGS, nodes_doc},
|
|
4136
|
+
{"todict", (PyCFunction) decodetree_todict, METH_NOARGS, todict_doc},
|
|
4137
|
+
{"__sizeof__", (PyCFunction) decodetree_sizeof, METH_NOARGS, 0},
|
|
4138
|
+
#ifndef NDEBUG
|
|
4139
|
+
{"_getnode", (PyCFunction) decodetree_getnode, METH_O, 0},
|
|
4140
|
+
#endif
|
|
4141
|
+
{NULL} /* sentinel */
|
|
4056
4142
|
};
|
|
4057
4143
|
|
|
4058
4144
|
PyDoc_STRVAR(decodetree_doc,
|
|
@@ -4245,7 +4331,7 @@ Raises `ValueError` if count is out of range.");
|
|
|
4245
4331
|
static PyMethodDef decodeiter_methods[] = {
|
|
4246
4332
|
{"skipbits", (PyCFunction) decodeiter_skipbits, METH_VARARGS,
|
|
4247
4333
|
decodeiter_skipbits_doc},
|
|
4248
|
-
{NULL}
|
|
4334
|
+
{NULL} /* sentinel */
|
|
4249
4335
|
};
|
|
4250
4336
|
|
|
4251
4337
|
|
|
@@ -4565,7 +4651,7 @@ static PyMethodDef bitarray_methods[] = {
|
|
|
4565
4651
|
{"_overlap", (PyCFunction) bitarray_overlap, METH_O, 0},
|
|
4566
4652
|
#endif
|
|
4567
4653
|
|
|
4568
|
-
{NULL
|
|
4654
|
+
{NULL} /* sentinel */
|
|
4569
4655
|
};
|
|
4570
4656
|
|
|
4571
4657
|
/* ------------------------ bitarray initialization -------------------- */
|
|
@@ -5194,7 +5280,7 @@ static PyMethodDef module_functions[] = {
|
|
|
5194
5280
|
get_default_endian_doc},
|
|
5195
5281
|
{"_sysinfo", (PyCFunction) sysinfo, METH_VARARGS,
|
|
5196
5282
|
sysinfo_doc},
|
|
5197
|
-
{NULL
|
|
5283
|
+
{NULL} /* sentinel */
|
|
5198
5284
|
};
|
|
5199
5285
|
|
|
5200
5286
|
/******************************* Install Module ***************************/
|