Skip to main content

C-based extension implementing fast integer bit sets.

Project description

https://img.shields.io/travis/inveniosoftware/intbitset.svg https://img.shields.io/github/tag/inveniosoftware/intbitset.svg https://img.shields.io/pypi/dm/intbitset.svg https://img.shields.io/github/license/inveniosoftware/intbitset.svg

Installation

intbitset is on PyPI so all you need pip:

pip install intbitset

We provide pre-built wheels for the most common operating systems and CPU architectures. Otherwise, you will need a C compiler.

Documentation

The intbitset library provides a set implementation to store sorted unsigned integers either 32-bits integers (between 0 and 2**31 - 1 or intbitset.__maxelem__) or an infinite range with fast set operations implemented via bit vectors in a Python C extension for speed and reduced memory usage.

The inbitset class emulates the Python built-in set class interface with some additional specific methods such as its own fast dump and load marshalling functions.

>>> from intbitset import intbitset
>>> x = intbitset([1,2,3])
>>> y = intbitset([3,4,5])
>>> x & y
intbitset([3])
>>> x | y
intbitset([1, 2, 3, 4, 5])

Additionally, intbitset supports:

  • The pickle protocol,

  • The iterator protocol

  • intbitset can behave like a sequence that can be sliced.

  • Natural min and max. Because the integers are always stored sorted, the fist element of a non-empty set [0] is also the min() integer and the last element [-1] is also the max() integer in the set.

When compared to the standard library set class, intbitset set operations and the intersection, union and difference of intbitset``can be up to 5000 faster for dense integer sets than the standard library ``set.

Complete documentation is available at <http://intbitset.readthedocs.io> or can be built using Sphinx:

pip install sphinx
python setup.py build_sphinx

Testing

Running the tests are as simple as:

pip install -e .[tests]
pytest

Running the tests on multiple Python versions:

pip install tox
tox

Development

To regenerate the C code with Cython:

pip install cython
cython intbitset/intbitset.pyx

Then commit the regenrated C source and update the CHANGELOG.rst

License

Copyright (C) CERN and others

SPDX-License-Identifier: LGPL-3.0-or-later

intbitset is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

intbitset is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with intbitset; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.

In applying this licence, CERN does not waive the privileges and immunities granted to it by virtue of its status as an Intergovernmental Organization or submit itself to any jurisdiction.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

intbitset-3.0.2.tar.gz (152.4 kB view hashes)

Uploaded Source

Built Distributions

intbitset-3.0.2-cp311-cp311-win_amd64.whl (61.4 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

intbitset-3.0.2-cp311-cp311-musllinux_1_1_x86_64.whl (401.7 kB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.1+ x86-64

intbitset-3.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (392.4 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

intbitset-3.0.2-cp311-cp311-macosx_10_9_x86_64.whl (77.4 kB view hashes)

Uploaded CPython 3.11 macOS 10.9+ x86-64

intbitset-3.0.2-cp311-cp311-macosx_10_9_universal2.whl (138.3 kB view hashes)

Uploaded CPython 3.11 macOS 10.9+ universal2 (ARM64, x86-64)

intbitset-3.0.2-cp310-cp310-win_amd64.whl (62.7 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

intbitset-3.0.2-cp310-cp310-musllinux_1_1_x86_64.whl (395.8 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.1+ x86-64

intbitset-3.0.2-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (352.4 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.12+ x86-64 manylinux: glibc 2.5+ x86-64

intbitset-3.0.2-cp310-cp310-macosx_10_9_x86_64.whl (81.0 kB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

intbitset-3.0.2-cp310-cp310-macosx_10_9_universal2.whl (145.1 kB view hashes)

Uploaded CPython 3.10 macOS 10.9+ universal2 (ARM64, x86-64)

intbitset-3.0.2-cp39-cp39-win_amd64.whl (63.1 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

intbitset-3.0.2-cp39-cp39-musllinux_1_1_x86_64.whl (397.4 kB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.1+ x86-64

intbitset-3.0.2-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl (272.8 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.5+ x86-64

intbitset-3.0.2-cp39-cp39-macosx_10_9_x86_64.whl (80.2 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

intbitset-3.0.2-cp39-cp39-macosx_10_9_universal2.whl (143.6 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ universal2 (ARM64, x86-64)

intbitset-3.0.2-cp38-cp38-win_amd64.whl (63.2 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

intbitset-3.0.2-cp38-cp38-musllinux_1_1_x86_64.whl (407.0 kB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.1+ x86-64

intbitset-3.0.2-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl (286.3 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.5+ x86-64

intbitset-3.0.2-cp38-cp38-macosx_10_9_x86_64.whl (79.0 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

intbitset-3.0.2-cp38-cp38-macosx_10_9_universal2.whl (141.4 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ universal2 (ARM64, x86-64)

intbitset-3.0.2-cp37-cp37m-win_amd64.whl (61.9 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

intbitset-3.0.2-cp37-cp37m-musllinux_1_1_x86_64.whl (360.7 kB view hashes)

Uploaded CPython 3.7m musllinux: musl 1.1+ x86-64

intbitset-3.0.2-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (282.4 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.5+ x86-64

intbitset-3.0.2-cp37-cp37m-macosx_10_9_x86_64.whl (77.9 kB view hashes)

Uploaded CPython 3.7m macOS 10.9+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page