Go to file
2022-08-06 20:21:25 -04:00
bitmask Bump version 2022-08-06 20:21:25 -04:00
tests bitmask.py: increase unit test coverage 2022-08-03 17:15:49 -04:00
.flake8 .flake8: added configuration 2022-08-03 16:08:53 -04:00
.gitignore Package bitmask using hatch 2022-07-31 19:35:09 -04:00
LICENSE Add LICENSE 2022-07-26 20:20:24 -04:00
pyproject.toml pyproject.toml: add flake8, black as dependencies 2022-08-02 18:09:53 -04:00
README.md README.md: add installation instructions 2022-08-03 22:16:42 -04:00

Bitmask

Implementation of a Bitmask class in Python, allowing easy manipulation of EnumFlag values.

Features

  • create bitmasks from any EnumFlag type

  • simple "flag in Bitmask" syntax

  • bitwise operations, e.g. AND (&), OR (|), XOR (^)

  • assignment with operators (+=, -=, &=, etc.)

  • convenience functions like Bitmask.add(), or Bitmask.discard()

For development and tinkering:

  • included unit tests

  • ample documentation and examples in code

Example usage

from bitmask import Bitmask
from enum import IntFlag

class Desc(IntFlag):
	SMALL = 1
	ROUND = 1 << 1
	FUNKY = 1 << 2
	LARGE = 1 << 3

marble = Bitmask(Desc.SMALL, Desc.ROUND, Desc.FUNKY)

Desc.SMALL in marble
>>> True

Desc.LARGE in marble
>>> False

Bitmask(Desc.SMALL, Desc.ROUND) in marble
>>> True

Installation

$ pip install git+https://github.com/dogeystamp/bitmask@main