Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 0 additions & 95 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,100 +160,6 @@ jobs:
ls -la

- name: Run pytest
env:
BITSTRING_USE_RUST_CORE: ${{ matrix.rust.env_var }}
run: |
python -m pytest tests/ --benchmark-disable

test-rust:
name: Test ${{ matrix.os.name }} ${{ matrix.python.name }} (Rust core)
if: always()
needs:
- test-standard
runs-on: ${{ matrix.os.runs-on }}
strategy:
fail-fast: false
matrix:
os:
- name: 🐧
runs-on: ubuntu-latest
- name: 🍎
runs-on: macos-15
- name: 🪟
runs-on: windows-latest
python:
- name: CPython 3.8
major_dot_minor: '3.8'
action: '3.8'
- name: CPython 3.9
major_dot_minor: '3.9'
action: '3.9'
- name: CPython 3.10
major_dot_minor: '3.10'
action: '3.10'
- name: CPython 3.11
major_dot_minor: '3.11'
action: '3.11'
- name: CPython 3.12
major_dot_minor: '3.12'
action: '3.12'
- name: CPython 3.13
major_dot_minor: '3.13'
action: '3.13'
- name: CPython 3.14
major_dot_minor: '3.14'
action: '3.14'
exclude:
- os:
name: "🍎"
runs-on: macos-15
python:
name: "CPython 3.8"
major_dot_minor: '3.8'
action: '3.8'
- os:
name: "🍎"
runs-on: macos-15
python:
name: "CPython 3.9"
major_dot_minor: '3.9'
action: '3.9'
- os:
name: "🍎"
runs-on: macos-15
python:
name: "CPython 3.10"
major_dot_minor: '3.10'
action: '3.10'
steps:
- uses: actions/checkout@v4
with:
path: repo

- name: Download package files
uses: actions/download-artifact@v4
with:
name: packages
path: dist

- uses: actions/setup-python@v5
with:
python-version: ${{ fromJSON(format('["{0}", "{1}"]', format('{0}.0-alpha - {0}.X', matrix.python.action), matrix.python.action))[startsWith(matrix.python.action, 'pypy')] }}
architecture: x64

- name: Setup environment
run: |
python --version --version
# make sure we test the installed code
cp -R repo/tests/ tests/
python -m pip install -r tests/requirements.txt
python -m pip install ./dist/*.whl
# show the directory contents for diagnostics
ls -la

- name: Run pytest
env:
BITSTRING_USE_RUST_CORE: '1'
run: |
python -m pytest tests/ --benchmark-disable

Expand All @@ -268,7 +174,6 @@ jobs:
# a merge.
- build
- test-standard
- test-rust
steps:
- name: Require all successes
uses: re-actors/alls-green@v1.2.2
Expand Down
19 changes: 3 additions & 16 deletions bitstring/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,26 +55,13 @@
THE SOFTWARE.
"""

__version__ = "4.4.0"
__version__ = "5.0.0"

__author__ = "Scott Griffiths"

import sys
import os
import importlib

# New ability to use tibs for core operations instead of bitarray.
# Tibs is written in Rust and is still in beta. Use the environment variable
# BITSTRING_USE_RUST_CORE=1 before importing the module to turn it on.
_env_core = os.getenv('BITSTRING_USE_RUST_CORE', '').strip().lower()
_USE_RUST_CORE = _env_core in ('1', 'true', 'yes', 'on')
if _USE_RUST_CORE:
bitstore = importlib.import_module('bitstring.bitstore_tibs')
bitstore_helpers = importlib.import_module('bitstring.bitstore_tibs_helpers')
else:
bitstore = importlib.import_module('bitstring.bitstore_bitarray')
bitstore_helpers = importlib.import_module('bitstring.bitstore_bitarray_helpers')
bitstore_common_helpers = importlib.import_module('bitstring.bitstore_common_helpers')
import bitstring.bitstore_tibs as bitstore
# import bitstring.bitstore_helpers as bitstore_helpers

from .bits import Bits
from .bitstring_options import Options
Expand Down
16 changes: 6 additions & 10 deletions bitstring/bitarray_.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from bitstring.bits import Bits, BitsType, TBits

import bitstring.dtypes
common_helpers = bitstring.bitstore_common_helpers
import bitstring.bitstore_helpers as helpers

MutableBitStore = bitstring.bitstore.MutableBitStore

Expand Down Expand Up @@ -52,7 +52,6 @@ class BitArray(Bits):
rfind() -- Seek backwards to find a sub-bitstring.
split() -- Create generator of chunks split by a delimiter.
startswith() -- Return whether the bitstring starts with a sub-bitstring.
tobitarray() -- Return bitstring as a bitarray from the bitarray package.
tobytes() -- Return bitstring as bytes, padding if needed.
tofile() -- Write bitstring to file, padding if needed.
unpack() -- Interpret bits using format string.
Expand Down Expand Up @@ -122,10 +121,7 @@ def __new__(cls: Type[TBits], auto: Optional[Union[BitsType, int]] = None, /, le
x = super(Bits, cls).__new__(cls)
if auto is None and not kwargs:
# No initialiser so fill with zero bits up to length
if length is not None:
x._bitstore = MutableBitStore.from_zeros(length)
else:
x._bitstore = MutableBitStore()
x._bitstore = MutableBitStore.from_zeros(length if length is not None else 0)
return x
x._initialise(auto, length, offset, immutable=False, **kwargs)
return x
Expand All @@ -134,7 +130,7 @@ def __new__(cls: Type[TBits], auto: Optional[Union[BitsType, int]] = None, /, le
def fromstring(cls: TBits, s: str, /) -> TBits:
"""Create a new bitstring from a formatted string."""
x = super().__new__(cls)
b = common_helpers.str_to_bitstore(s)
b = helpers.str_to_bitstore(s)
x._bitstore = b._mutable_copy()
return x

Expand Down Expand Up @@ -280,17 +276,17 @@ def __imul__(self: TBits, n: int) -> TBits:

def __ior__(self: TBits, bs: BitsType) -> TBits:
bs = self._create_from_bitstype(bs)
self._bitstore |= bs._bitstore
self._bitstore.tibs |= bs._bitstore.tibs
return self

def __iand__(self: TBits, bs: BitsType) -> TBits:
bs = self._create_from_bitstype(bs)
self._bitstore &= bs._bitstore
self._bitstore.tibs &= bs._bitstore.tibs
return self

def __ixor__(self: TBits, bs: BitsType) -> TBits:
bs = self._create_from_bitstype(bs)
self._bitstore ^= bs._bitstore
self._bitstore.tibs ^= bs._bitstore.tibs
return self

def _replace(self, old: Bits, new: Bits, start: int, end: int, count: int, bytealigned: Optional[bool]) -> int:
Expand Down
Loading
Loading