bittypes package

The bittypes package contains modules for handling various bit types.

class bytemaker.bittypes.BFloat16(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Float

Google Brain’s BFloat16 format with 8 exponent bits and 7 mantissa bits.

num_exponent_bits: Final[int] = 8

The number of bits used to store the exponent.

num_mantissa_bits: Final[int] = 7

The number of bits used to store the mantissa.

class bytemaker.bittypes.BitType(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: ABC, Generic[T]

A type representable by a sequence of bits.

Allows for editing the value of the type pythonically through the value property or through the underlying sequence of bits through the bits property.

Also allows treating the BitType as the underlying (Pythonic) value for regular operations.

Variables:
  • num_bits (int) – The number of bits in the BitType.

  • base_bit_type (Type[BitType]) – The base BitType this class derives from (e.g. UInt for UInt8).

  • py_type (Type[T]) – The Pythonic type that this BitType can be converted to/from.

  • bits (BitVector) – The underlying sequence of bits of this BitType object.

  • value (py_type) – The (Pythonic) value of this BitType object.

  • endianness (Literal["big", "little"]) – The endianness of this BitType object.

base_bit_type: Final[Type[BitType]]

The base BitType this class derives from (e.g. UInt for UInt8).

property bits: BitVector

Getter/setter for the sequence of bits the BitType uses to represent its value.

Returns:

The sequence of bits the BitType uses to represent its value.

Return type:

BitVector

property endianness: Literal['big', 'little']

A readonly property holding the endianness of the BitType.

Returns:

The endianness of the BitType.

Return type:

Literal[“big”, “little”]

classmethod from_bits(bits: BitVector)[source]

DEPRECATED Use the constructor with a BitVector-like object instead.

Creates a new BitType object from a sequence of bits.

Parameters:

bits (BitVector) – The sequence of bits to create the BitType from.

num_bits

A readonly classproperty holding the number of bits in the BitType.

Returns:

The number of bits in the BitType.

Return type:

int

py_type: Final[Type[T]]

The Pythonic type that this BitType can be converted to/from.

to_bits() BitVector[source]

DEPRECATED Use the bits property instead.

Obtains the bit representation of the BitType.

Returns:

The sequence of bits of the BitType.

Return type:

BitVector

abstract property value: T

The (readonly) getter for the (Pythonic) value of the BitType.

To set the value directly, use the value setter. To directly adjust the value more complicatedly,

use operations available directly on BitType object rather than on the value returned by this property.

Returns:

The (Pythonic) value of the BitType.

Return type:

T

class bytemaker.bittypes.Buffer(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: BitType[BitVector]

A BitType that represents a buffer of bits.

Use the specialize method to create a subclass with the desired number of bits

or use one of the pre-defined subclasses.

Class Attributes:

num_bitsint

The number of bits in instances of this Buffer subclass.

base_bit_typeType[Buffer]

The base BitType this class derives from. It will be Buffer.

py_typeType[BitVector]

The type that this BitType represents. It is BitVector.

Instance Attributes

bitsBitVector

The underlying sequence of bits of this Buffer object. Identical to value.

valueBitVector

The BitVector value of this Buffer object. Identical to bits.

base_bit_type

alias of Buffer

py_type

alias of BitVector

classmethod specialize(num_bits_: int, name_: str | None = None)[source]

Returns a subclass of Buffer with the specified number of bits.

Parameters:
  • num_bits (int) – The number of bits the buffer should have.

  • name (Optional[str], optional) – The name of the subclass. Defaults to None, meaning the name will be _Buffer.

Returns:

A subclass of Buffer with the specified number of bits.

Return type:

Type[BufferSelf]

property value

The (readonly) getter for the (Pythonic) value of the BitType.

To set the value directly, use the value setter. To directly adjust the value more complicatedly,

use operations available directly on BitType object rather than on the value returned by this property.

Returns:

The (Pythonic) value of the BitType.

Return type:

T

class bytemaker.bittypes.Buffer1(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.Buffer10(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.Buffer100(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.Buffer1000(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.Buffer1024(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.Buffer11(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.Buffer12(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.Buffer128(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.Buffer13(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.Buffer14(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.Buffer15(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.Buffer16(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.Buffer17(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.Buffer18(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.Buffer19(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.Buffer2(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.Buffer20(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.Buffer200(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.Buffer21(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.Buffer22(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.Buffer23(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.Buffer24(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.Buffer25(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.Buffer250(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.Buffer256(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.Buffer26(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.Buffer27(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.Buffer28(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.Buffer29(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.Buffer3(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.Buffer30(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.Buffer31(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.Buffer32(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.Buffer4(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.Buffer5(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.Buffer50(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.Buffer500(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.Buffer512(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.Buffer6(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.Buffer64(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.Buffer7(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.Buffer8(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.Buffer9(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.FP24(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Float

AMD’s FP24 format with 7 exponent bits and 16 mantissa bits.

num_exponent_bits: Final[int] = 7

The number of bits used to store the exponent.

num_mantissa_bits: Final[int] = 16

The number of bits used to store the mantissa.

class bytemaker.bittypes.Float(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: BitType[float]

A BitType that represents an integer.

Use the specialize method to create a subclass with the desired number of

exponent and mantissa bits or use one of the pre-defined subclasses.

The floating-point format in use is as follows: - The first bit is the sign bit - The next num_exponent_bits bits are the exponent - The next num_mantissa_bits bits are the mantissa

Class Attributes:

num_bitsint

The number of bits in the Float.

base_bit_typeType[Float]

The base BitType this class derives from. It is Float.

py_typeType[float]

The Pythonic type that this Int can be converted to/from. It is float.

num_exponent_bitsint

The number of bits used to store the exponent.

num_mantissa_bitsint

The number of bits used to store the mantissa.

Instance Attributes

bitsBitVector

The underlying sequence of bits of this Float object.

valuefloat

The float value of this Float object.

base_bit_type

alias of Float

num_bits
num_exponent_bits: Final[int]

The number of bits used to store the exponent.

num_mantissa_bits: Final[int]

The number of bits used to store the mantissa.

py_type

alias of float

classmethod specialize(num_exponent_bits_, num_mantissa_bits_, packing_format_letter_: str | None = None, name_: str | None = None)[source]
Produce a subclass of Float with the specified number of bits

in the exponent and mantissa.

If packing_format_letter is provided, the subclass will also be a

StructPackedBitType and use struct’s packing/unpacking functions with the provided letter.

If name_ is provided, the subclass will have that name internally after class

creation. Otherwise, the subclass will be named _Float.

Parameters:
  • num_exponent_bits (int) – The number of bits to use for the exponent.

  • num_mantissa_bits (int) – The number of bits to use for the mantissa.

  • packing_format_letter (Optional[str], optional) – The struct packing format letter to use, if any. Defaults to None, meaning no struct (un)packing.

  • name (Optional[str], optional) – What to rename the subclass, if anything. Defaults to None, meaning the subclass’s name will be _Float.

Returns:

The subclass of Float with the specified number of bits.

Return type:

type[Float]

to_binstring(num_exponent_bits=8, num_mantissa_bits=23) str[source]

Convert a float (or a Float) to a binary string.

Parameters:
  • num_exponent_bits (int) – The number of bits to use for the exponent.

  • num_mantissa_bits (int) – The number of bits to use for the mantissa.

Returns:

The unprefixed binary string representation of the float.

Return type:

str

property value: float

The (readonly) getter for the (Pythonic) value of the BitType.

To set the value directly, use the value setter. To directly adjust the value more complicatedly,

use operations available directly on BitType object rather than on the value returned by this property.

Returns:

The (Pythonic) value of the BitType.

Return type:

T

class bytemaker.bittypes.Float16(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: StructPackedBitType, Float

num_exponent_bits: Final[int] = 5

The number of bits used to store the exponent.

num_mantissa_bits: Final[int] = 10

The number of bits used to store the mantissa.

packing_format_letter: Final[str] = 'e'

The packing format letter for struct to use for converting to/from bytes.

class bytemaker.bittypes.Float32(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: StructPackedBitType, Float

num_exponent_bits: Final[int] = 8

The number of bits used to store the exponent.

num_mantissa_bits: Final[int] = 23

The number of bits used to store the mantissa.

packing_format_letter: Final[str] = 'f'

The packing format letter for struct to use for converting to/from bytes.

class bytemaker.bittypes.Float64(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: StructPackedBitType, Float

num_exponent_bits: Final[int] = 11

The number of bits used to store the exponent.

num_mantissa_bits: Final[int] = 52

The number of bits used to store the mantissa.

packing_format_letter: Final[str] = 'd'

The packing format letter for struct to use for converting to/from bytes.

class bytemaker.bittypes.Int(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: BitType[int]

A BitType that represents an integer.

Is further subclassed into SInt and UInt for signed and unsigned integers,

Class Attributes:

num_bitsint

The number of bits in the BitType.

base_bit_typeType[BitType]

The base BitType this class derives from.

py_typeType[T]

The Pythonic type that this Int can be converted to/from. It is int.

is_signedbool

Whether the integer type is signed.

Instance Attributes

bitsBitVector

The underlying sequence of bits of this Int object.

valueint

The int value of this Int object.

endiannessLiteral[“big”, “little”]

The endianness of this Int object.

is_signed: Final[bool]

Whether the integer type is signed.

static min_bit_length(value: int, signed: bool = True, bin_format: Literal['twos_complement', 'signed_magnitude', 'ones_complement'] | None = None) int[source]

Calculate the minimum number of bits required to represent an integer. Note that this is not the same as len(bin(value)), which assumes an unsigned representation (possibly with - in front).

Parameters:
  • value (int) – The integer to represent.

  • signed (bool, optional) – Whether the representation format should be signed. Default is True.

  • bin_format (Optional[str], optional) – The format for signed integers. Can be “twos_complement”, “signed_magnitude”, or “ones_complement”. Default is “twos_complement”.

py_type

alias of int

to_bitstring(signed: bool = True, bit_length: int | None = None, rep_format: Literal['twos_complement', 'signed_magnitude', 'ones_complement'] | None = None) str[source]

Convert an integer to a bitstring.

Parameters: - integer (int): The integer to convert. - signed (bool, optional): Whether the integer should be treated as signed.

Default is True.

  • bit_length (int, optional): The length of the bitstring.

  • rep_format (Optional[str], optional): The format for signed integers.

    Can be “twos_complement”, “signed_magnitude”, or “ones_complement”. Default is “twos_complement”.

Returns: - str: The bitstring representation of the integer.

to_pyint(signed: bool | None = None, bin_format: Literal['twos_complement', 'signed_magnitude', 'ones_complement'] = 'twos_complement')[source]

Convert a bitstring to an integer.

Parameters: - bitstring (str): The bitstring to convert. - signed (Optional[bool], optional) Whether the bitstring represents

a signed integer (vs unsigned). Default is cls.is_signed or True.

  • bin_format (Optional[str], optional): The format for signed integers.

    Can be “twos_complement”, “signed_magnitude”, or “ones_complement”. Default is “twos_complement”.

Returns: - int: The integer representation of the bitstring.

class bytemaker.bittypes.SInt(source: int | BitVector | BitType | None = None, value: int | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big', int_format: Literal['twos_complement', 'signed_magnitude', 'ones_complement'] | None = None)[source]

Bases: Int

A BitType that represents a signed integer.

Use the specialize method to create a subclass with the desired number of bits

or use one of the pre-defined subclasses.

To change the signed integer format, use the Config class

(or set the int_format parameter in the constructor). The default signed integer format is two’s complement.

Class Attributes:
base_bit_typeType[BitType]

The base class (this is SInt for SInt children).

num_bitsint

The number of bits in the integer.

is_signedbool

Whether the integer is signed (this is True for SInts).

Instance Attributes:
int_formatOptional[str]

The format for this signed integer. Can be “twos_complement”, “signed_magnitude”, or “ones_complement”. If this is left as None, the format will be taken from the Config class. Default is “twos_complement.

valueint

The int value of the SInt.

bitsBitVector

The bits representing the value.

base_bit_type

alias of SInt

is_signed: Final[bool] = True

Whether the integer type is signed.

classmethod specialize(num_bits_: int, packing_format_letter_: str | None = None, name_: str | None = None)[source]

Produce a subclass of SInt with the specified number of bits.

If a packing format letter is provided, the subclass will also be a

StructPackedBitType and use struct’s packing/unpacking functions with the provided letter.

If name_ is provided, the subclass will have that name internally after class

creation. Otherwise, the subclass will be named _SInt.

Parameters:
  • num_bits (int) – The number of bits in integers of this type.

  • packing_format_letter (Optional[str], optional) – The struct packing format letter to use, if any. Defaults to None, meaning no struct (un)packing.

  • name (Optional[str], optional) – What to rename the subclass, if anything. Defaults to None, meaning the subclass’s name will be _SInt.

Returns:

The subclass of SInt with the specified number of bits.

Return type:

type[SInt]

property value

The (readonly) getter for the (Pythonic) value of the BitType.

To set the value directly, use the value setter. To directly adjust the value more complicatedly,

use operations available directly on BitType object rather than on the value returned by this property.

Returns:

The (Pythonic) value of the BitType.

Return type:

T

class bytemaker.bittypes.SInt1(source: int | BitVector | BitType | None = None, value: int | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big', int_format: Literal['twos_complement', 'signed_magnitude', 'ones_complement'] | None = None)[source]

Bases: SInt

class bytemaker.bittypes.SInt10(source: int | BitVector | BitType | None = None, value: int | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big', int_format: Literal['twos_complement', 'signed_magnitude', 'ones_complement'] | None = None)[source]

Bases: SInt

class bytemaker.bittypes.SInt11(source: int | BitVector | BitType | None = None, value: int | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big', int_format: Literal['twos_complement', 'signed_magnitude', 'ones_complement'] | None = None)[source]

Bases: SInt

class bytemaker.bittypes.SInt12(source: int | BitVector | BitType | None = None, value: int | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big', int_format: Literal['twos_complement', 'signed_magnitude', 'ones_complement'] | None = None)[source]

Bases: SInt

class bytemaker.bittypes.SInt128(source: int | BitVector | BitType | None = None, value: int | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big', int_format: Literal['twos_complement', 'signed_magnitude', 'ones_complement'] | None = None)[source]

Bases: SInt

class bytemaker.bittypes.SInt13(source: int | BitVector | BitType | None = None, value: int | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big', int_format: Literal['twos_complement', 'signed_magnitude', 'ones_complement'] | None = None)[source]

Bases: SInt

class bytemaker.bittypes.SInt14(source: int | BitVector | BitType | None = None, value: int | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big', int_format: Literal['twos_complement', 'signed_magnitude', 'ones_complement'] | None = None)[source]

Bases: SInt

class bytemaker.bittypes.SInt15(source: int | BitVector | BitType | None = None, value: int | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big', int_format: Literal['twos_complement', 'signed_magnitude', 'ones_complement'] | None = None)[source]

Bases: SInt

class bytemaker.bittypes.SInt16(source: int | BitVector | BitType | None = None, value: int | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big', int_format: Literal['twos_complement', 'signed_magnitude', 'ones_complement'] | None = None)[source]

Bases: StructPackedBitType, SInt

packing_format_letter: Final[str] = 'h'

The packing format letter for struct to use for converting to/from bytes.

property skip_struct_packing
If true, the struct packing/unpacking will be skipped and the value will be

be calculated using parent methods.

Most of the time this will be false

class bytemaker.bittypes.SInt2(source: int | BitVector | BitType | None = None, value: int | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big', int_format: Literal['twos_complement', 'signed_magnitude', 'ones_complement'] | None = None)[source]

Bases: SInt

class bytemaker.bittypes.SInt256(source: int | BitVector | BitType | None = None, value: int | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big', int_format: Literal['twos_complement', 'signed_magnitude', 'ones_complement'] | None = None)[source]

Bases: SInt

class bytemaker.bittypes.SInt3(source: int | BitVector | BitType | None = None, value: int | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big', int_format: Literal['twos_complement', 'signed_magnitude', 'ones_complement'] | None = None)[source]

Bases: SInt

class bytemaker.bittypes.SInt32(source: int | BitVector | BitType | None = None, value: int | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big', int_format: Literal['twos_complement', 'signed_magnitude', 'ones_complement'] | None = None)[source]

Bases: StructPackedBitType, SInt

packing_format_letter: Final[str] = 'i'

The packing format letter for struct to use for converting to/from bytes.

property skip_struct_packing
If true, the struct packing/unpacking will be skipped and the value will be

be calculated using parent methods.

Most of the time this will be false

class bytemaker.bittypes.SInt4(source: int | BitVector | BitType | None = None, value: int | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big', int_format: Literal['twos_complement', 'signed_magnitude', 'ones_complement'] | None = None)[source]

Bases: SInt

class bytemaker.bittypes.SInt5(source: int | BitVector | BitType | None = None, value: int | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big', int_format: Literal['twos_complement', 'signed_magnitude', 'ones_complement'] | None = None)[source]

Bases: SInt

class bytemaker.bittypes.SInt6(source: int | BitVector | BitType | None = None, value: int | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big', int_format: Literal['twos_complement', 'signed_magnitude', 'ones_complement'] | None = None)[source]

Bases: SInt

class bytemaker.bittypes.SInt64(source: int | BitVector | BitType | None = None, value: int | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big', int_format: Literal['twos_complement', 'signed_magnitude', 'ones_complement'] | None = None)[source]

Bases: StructPackedBitType, SInt

packing_format_letter: Final[str] = 'q'

The packing format letter for struct to use for converting to/from bytes.

property skip_struct_packing
If true, the struct packing/unpacking will be skipped and the value will be

be calculated using parent methods.

Most of the time this will be false

class bytemaker.bittypes.SInt7(source: int | BitVector | BitType | None = None, value: int | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big', int_format: Literal['twos_complement', 'signed_magnitude', 'ones_complement'] | None = None)[source]

Bases: SInt

class bytemaker.bittypes.SInt8(source: int | BitVector | BitType | None = None, value: int | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big', int_format: Literal['twos_complement', 'signed_magnitude', 'ones_complement'] | None = None)[source]

Bases: StructPackedBitType, SInt

packing_format_letter: Final[str] = 'b'

The packing format letter for struct to use for converting to/from bytes.

property skip_struct_packing
If true, the struct packing/unpacking will be skipped and the value will be

be calculated using parent methods.

Most of the time this will be false

class bytemaker.bittypes.SInt9(source: int | BitVector | BitType | None = None, value: int | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big', int_format: Literal['twos_complement', 'signed_magnitude', 'ones_complement'] | None = None)[source]

Bases: SInt

class bytemaker.bittypes.SignedConfig[source]

Bases: object

A class to change the default representation and conversion
for all non-user-implemented or non-user-specified signed integers

simultaneously.

If this is unadjusted, the default signed integer format is two’s complement.

signed_int_format: Literal['signed_magnitude', 'ones_complement', 'twos_complement'] = 'twos_complement'
class bytemaker.bittypes.StandardEncodingString(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: String

A class for strings that use a standard Python encoding (str.encode/decode)

classmethod decoding(bits: BitVector) str[source]

The method used to decode a BitVector into a string.

Parameters:

bits (BitVector) – The BitVector to decode into a string

Returns:

The decoded string representation of the input BitVector

Return type:

str

classmethod encoding(value: str) BitVector[source]

The method used to encode a string into a BitVector.

Parameters:

value (str) – The string to encode into a BitVector

Returns:

The encoded BitVector representation of the input string

Return type:

BitVector

encoding_name: str

The name of the Python-supported encoding to use for encoding/decoding.

py_type

alias of str

class bytemaker.bittypes.Str1(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UTF8String

class bytemaker.bittypes.Str10(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UTF8String

class bytemaker.bittypes.Str11(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UTF8String

class bytemaker.bittypes.Str12(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UTF8String

class bytemaker.bittypes.Str128(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UTF8String

class bytemaker.bittypes.Str13(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UTF8String

class bytemaker.bittypes.Str14(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UTF8String

class bytemaker.bittypes.Str15(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UTF8String

class bytemaker.bittypes.Str16(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UTF8String

class bytemaker.bittypes.Str2(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UTF8String

class bytemaker.bittypes.Str256(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UTF8String

class bytemaker.bittypes.Str3(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UTF8String

class bytemaker.bittypes.Str32(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UTF8String

class bytemaker.bittypes.Str4(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UTF8String

class bytemaker.bittypes.Str5(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UTF8String

class bytemaker.bittypes.Str512(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UTF8String

class bytemaker.bittypes.Str6(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UTF8String

class bytemaker.bittypes.Str64(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UTF8String

class bytemaker.bittypes.Str7(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UTF8String

class bytemaker.bittypes.Str8(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UTF8String

class bytemaker.bittypes.Str9(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UTF8String

class bytemaker.bittypes.String(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: BitType[str]

base_bit_type

alias of String

codepoint_changes = None
abstract classmethod decoding(bits: BitVector) str[source]

The method used to decode a BitVector into a string.

Parameters:

bits (BitVector) – The BitVector to decode into a string

Returns:

The decoded string representation of the input BitVector

Return type:

str

abstract classmethod encoding(value: str) BitVector[source]

The method used to encode a string into a BitVector.

Parameters:

value (str) – The string to encode into a BitVector

Returns:

The encoded BitVector representation of the input string

Return type:

BitVector

classmethod perform_codepoint_substitution(input_string, codepoint_changes: HashableMapping[str, str], changes_regex: Pattern[str])[source]

Performs codepoint substitutions on the input string.

Parameters:
  • input_string (str) – The input string to perform substitutions on

  • codepoint_changes (HashableMapping[str, str]) – The codepoint changes mapping

  • changes_regex (re.Pattern[str]) – The compiled regex pattern for the codepoint changes

Returns:

The input string with codepoint substitutions applied

Return type:

str

py_type

alias of str

classmethod specialize(num_bits_: int, name_: str | None = None)[source]
property value

The (readonly) getter for the (Pythonic) value of the BitType.

To set the value directly, use the value setter. To directly adjust the value more complicatedly,

use operations available directly on BitType object rather than on the value returned by this property.

Returns:

The (Pythonic) value of the BitType.

Return type:

T

class bytemaker.bittypes.StructPackedBitType(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: BitType[T]

Abstract base class for all BitType objects that use struct for packing/unpacking.

Class Attributes:

packing_format_letterstr

The packing format letter for the subclass.

Instance Attributes

skip_struct_packingbool
If true, the struct packing/unpacking will be skipped and the value will be

be calculated using other methods on the MRO.

packing_formatstr
The struct-packing format for the subclass that struct uses. It is calculated

based on the endianness

property packing_format: str

Returns the packing format for the class.

Parameters:

endianness (str) – the endianness of the packing format. Defaults to little

Returns:

the struct packing format for the subclass.

Return type:

str

packing_format_letter: Final[str]

The packing format letter for struct to use for converting to/from bytes.

property skip_struct_packing: bool
If true, the struct packing/unpacking will be skipped and the value will be

be calculated using parent methods.

Most of the time this will be false

property value: T

The (readonly) getter for the (Pythonic) value of the BitType.

To set the value directly, use the value setter. To directly adjust the value more complicatedly,

use operations available directly on BitType object rather than on the value returned by this property.

Returns:

The (Pythonic) value of the BitType.

Return type:

T

class bytemaker.bittypes.TF19(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Float

NVidia’s TensorFloat-19 format with 8 exponent bits and 10 mantissa bits.

num_exponent_bits: Final[int] = 8

The number of bits used to store the exponent.

num_mantissa_bits: Final[int] = 10

The number of bits used to store the mantissa.

class bytemaker.bittypes.UInt(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Int

A BitType that represents an unsigned integer.

Use the specialize method to create a subclass with the desired number of bits

or use one of the pre-defined subclasses.

Class Attributes:

base_bit_type (Type[BitType]): The base class (this is UInt). num_bits (int): The number of bits in the integer. is_signed (bool): Whether the integer is signed. (This is False)

Properties:

value (int): The integer value of the bits. bits (BitVector): The bits representing the integer value.

base_bit_type

alias of UInt

is_signed: Final[bool] = False

Whether the integer type is signed.

classmethod specialize(num_bits_: int, packing_format_letter_: str | None = None, name_: str | None = None)[source]

Produce a subclass of UInt with the specified number of bits.

If a packing format letter is provided, the subclass will also be a

StructPackedBitType and use struct’s packing/unpacking functions with the provided letter.

If name_ is provided, the subclass will have that name internally after class

creation. Otherwise, the subclass will be named _UInt.

Parameters:
  • num_bits (int) – The number of bits in integers of this type.

  • packing_format_letter (Optional[str], optional) – The struct packing format letter to use, if any. Defaults to None, meaning no struct (un)packing.

  • name (Optional[str], optional) – What to rename the subclass, if anything. Defaults to None, meaning the subclass’s name will be _UInt.

Returns:

The subclass of UInt with the specified number of bits.

Return type:

type[UInt]

property value

The (readonly) getter for the (Pythonic) value of the BitType.

To set the value directly, use the value setter. To directly adjust the value more complicatedly,

use operations available directly on BitType object rather than on the value returned by this property.

Returns:

The (Pythonic) value of the BitType.

Return type:

T

class bytemaker.bittypes.UInt1(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UInt

class bytemaker.bittypes.UInt10(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UInt

class bytemaker.bittypes.UInt11(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UInt

class bytemaker.bittypes.UInt12(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UInt

class bytemaker.bittypes.UInt128(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UInt

class bytemaker.bittypes.UInt13(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UInt

class bytemaker.bittypes.UInt14(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UInt

class bytemaker.bittypes.UInt15(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UInt

class bytemaker.bittypes.UInt16(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: StructPackedBitType, UInt

packing_format_letter: Final[str] = 'H'

The packing format letter for struct to use for converting to/from bytes.

class bytemaker.bittypes.UInt2(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UInt

class bytemaker.bittypes.UInt256(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UInt

class bytemaker.bittypes.UInt3(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UInt

class bytemaker.bittypes.UInt32(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: StructPackedBitType, UInt

packing_format_letter: Final[str] = 'I'

The packing format letter for struct to use for converting to/from bytes.

class bytemaker.bittypes.UInt4(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UInt

class bytemaker.bittypes.UInt5(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UInt

class bytemaker.bittypes.UInt6(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UInt

class bytemaker.bittypes.UInt64(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: StructPackedBitType, UInt

packing_format_letter: Final[str] = 'Q'

The packing format letter for struct to use for converting to/from bytes.

class bytemaker.bittypes.UInt7(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UInt

class bytemaker.bittypes.UInt8(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: StructPackedBitType, UInt

packing_format_letter: Final[str] = 'B'

The packing format letter for struct to use for converting to/from bytes.

class bytemaker.bittypes.UInt9(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UInt

class bytemaker.bittypes.UTF8String(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: StandardEncodingString

encoding_name: str = 'utf-8'

The name of the Python-supported encoding to use for encoding/decoding.

bytemaker.bittypes.bytes_to_bittype(unitbytes: bytes, unittype: type[BitType]) BitType[source]

Converts a bytes object to an instance of the provided BitType object.

Parameters:
  • unitbytes (bytes) – The bytes object to convert.

  • unittype (type[BitType]) – The BitType object to convert to.

Returns:

The BitType object created from the bytes object.

Return type:

BitType

Modules

BitType

class bytemaker.bittypes.bittype.BitType(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: ABC, Generic[T]

A type representable by a sequence of bits.

Allows for editing the value of the type pythonically through the value property or through the underlying sequence of bits through the bits property.

Also allows treating the BitType as the underlying (Pythonic) value for regular operations.

Variables:
  • num_bits (int) – The number of bits in the BitType.

  • base_bit_type (Type[BitType]) – The base BitType this class derives from (e.g. UInt for UInt8).

  • py_type (Type[T]) – The Pythonic type that this BitType can be converted to/from.

  • bits (BitVector) – The underlying sequence of bits of this BitType object.

  • value (py_type) – The (Pythonic) value of this BitType object.

  • endianness (Literal["big", "little"]) – The endianness of this BitType object.

base_bit_type: Final[Type[BitType]]

The base BitType this class derives from (e.g. UInt for UInt8).

property bits: BitVector

Getter/setter for the sequence of bits the BitType uses to represent its value.

Returns:

The sequence of bits the BitType uses to represent its value.

Return type:

BitVector

property endianness: Literal['big', 'little']

A readonly property holding the endianness of the BitType.

Returns:

The endianness of the BitType.

Return type:

Literal[“big”, “little”]

classmethod from_bits(bits: BitVector)[source]

DEPRECATED Use the constructor with a BitVector-like object instead.

Creates a new BitType object from a sequence of bits.

Parameters:

bits (BitVector) – The sequence of bits to create the BitType from.

num_bits

A readonly classproperty holding the number of bits in the BitType.

Returns:

The number of bits in the BitType.

Return type:

int

py_type: Final[Type[T]]

The Pythonic type that this BitType can be converted to/from.

to_bits() BitVector[source]

DEPRECATED Use the bits property instead.

Obtains the bit representation of the BitType.

Returns:

The sequence of bits of the BitType.

Return type:

BitVector

abstract property value: T

The (readonly) getter for the (Pythonic) value of the BitType.

To set the value directly, use the value setter. To directly adjust the value more complicatedly,

use operations available directly on BitType object rather than on the value returned by this property.

Returns:

The (Pythonic) value of the BitType.

Return type:

T

class bytemaker.bittypes.bittype.StructPackedBitType(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: BitType[T]

Abstract base class for all BitType objects that use struct for packing/unpacking.

Class Attributes:

packing_format_letterstr

The packing format letter for the subclass.

Instance Attributes

skip_struct_packingbool
If true, the struct packing/unpacking will be skipped and the value will be

be calculated using other methods on the MRO.

packing_formatstr
The struct-packing format for the subclass that struct uses. It is calculated

based on the endianness

base_bit_type: Final[Type[BitType]]

The base BitType this class derives from (e.g. UInt for UInt8).

property packing_format: str

Returns the packing format for the class.

Parameters:

endianness (str) – the endianness of the packing format. Defaults to little

Returns:

the struct packing format for the subclass.

Return type:

str

packing_format_letter: Final[str]

The packing format letter for struct to use for converting to/from bytes.

py_type: Final[Type[T]]

The Pythonic type that this BitType can be converted to/from.

property skip_struct_packing: bool
If true, the struct packing/unpacking will be skipped and the value will be

be calculated using parent methods.

Most of the time this will be false

property value: T

The (readonly) getter for the (Pythonic) value of the BitType.

To set the value directly, use the value setter. To directly adjust the value more complicatedly,

use operations available directly on BitType object rather than on the value returned by this property.

Returns:

The (Pythonic) value of the BitType.

Return type:

T

bytemaker.bittypes.bittype.bytes_to_bittype(unitbytes: bytes, unittype: type[BitType]) BitType[source]

Converts a bytes object to an instance of the provided BitType object.

Parameters:
  • unitbytes (bytes) – The bytes object to convert.

  • unittype (type[BitType]) – The BitType object to convert to.

Returns:

The BitType object created from the bytes object.

Return type:

BitType

Buffer

class bytemaker.bittypes.buffer.Buffer(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: BitType[BitVector]

A BitType that represents a buffer of bits.

Use the specialize method to create a subclass with the desired number of bits

or use one of the pre-defined subclasses.

Class Attributes:

num_bitsint

The number of bits in instances of this Buffer subclass.

base_bit_typeType[Buffer]

The base BitType this class derives from. It will be Buffer.

py_typeType[BitVector]

The type that this BitType represents. It is BitVector.

Instance Attributes

bitsBitVector

The underlying sequence of bits of this Buffer object. Identical to value.

valueBitVector

The BitVector value of this Buffer object. Identical to bits.

base_bit_type

alias of Buffer

py_type

alias of BitVector

classmethod specialize(num_bits_: int, name_: str | None = None)[source]

Returns a subclass of Buffer with the specified number of bits.

Parameters:
  • num_bits (int) – The number of bits the buffer should have.

  • name (Optional[str], optional) – The name of the subclass. Defaults to None, meaning the name will be _Buffer.

Returns:

A subclass of Buffer with the specified number of bits.

Return type:

Type[BufferSelf]

property value

The (readonly) getter for the (Pythonic) value of the BitType.

To set the value directly, use the value setter. To directly adjust the value more complicatedly,

use operations available directly on BitType object rather than on the value returned by this property.

Returns:

The (Pythonic) value of the BitType.

Return type:

T

class bytemaker.bittypes.buffer.Buffer1(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.buffer.Buffer10(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.buffer.Buffer100(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.buffer.Buffer1000(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.buffer.Buffer1024(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.buffer.Buffer11(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.buffer.Buffer12(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.buffer.Buffer128(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.buffer.Buffer13(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.buffer.Buffer14(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.buffer.Buffer15(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.buffer.Buffer16(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.buffer.Buffer17(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.buffer.Buffer18(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.buffer.Buffer19(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.buffer.Buffer2(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.buffer.Buffer20(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.buffer.Buffer200(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.buffer.Buffer21(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.buffer.Buffer22(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.buffer.Buffer23(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.buffer.Buffer24(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.buffer.Buffer25(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.buffer.Buffer250(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.buffer.Buffer256(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.buffer.Buffer26(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.buffer.Buffer27(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.buffer.Buffer28(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.buffer.Buffer29(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.buffer.Buffer3(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.buffer.Buffer30(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.buffer.Buffer31(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.buffer.Buffer32(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.buffer.Buffer4(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.buffer.Buffer5(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.buffer.Buffer50(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.buffer.Buffer500(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.buffer.Buffer512(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.buffer.Buffer6(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.buffer.Buffer64(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.buffer.Buffer7(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.buffer.Buffer8(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

class bytemaker.bittypes.buffer.Buffer9(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Buffer

Float

class bytemaker.bittypes.float.BFloat16(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Float

Google Brain’s BFloat16 format with 8 exponent bits and 7 mantissa bits.

num_exponent_bits: Final[int] = 8

The number of bits used to store the exponent.

num_mantissa_bits: Final[int] = 7

The number of bits used to store the mantissa.

class bytemaker.bittypes.float.FP24(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Float

AMD’s FP24 format with 7 exponent bits and 16 mantissa bits.

num_exponent_bits: Final[int] = 7

The number of bits used to store the exponent.

num_mantissa_bits: Final[int] = 16

The number of bits used to store the mantissa.

class bytemaker.bittypes.float.Float(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: BitType[float]

A BitType that represents an integer.

Use the specialize method to create a subclass with the desired number of

exponent and mantissa bits or use one of the pre-defined subclasses.

The floating-point format in use is as follows: - The first bit is the sign bit - The next num_exponent_bits bits are the exponent - The next num_mantissa_bits bits are the mantissa

Class Attributes:

num_bitsint

The number of bits in the Float.

base_bit_typeType[Float]

The base BitType this class derives from. It is Float.

py_typeType[float]

The Pythonic type that this Int can be converted to/from. It is float.

num_exponent_bitsint

The number of bits used to store the exponent.

num_mantissa_bitsint

The number of bits used to store the mantissa.

Instance Attributes

bitsBitVector

The underlying sequence of bits of this Float object.

valuefloat

The float value of this Float object.

base_bit_type

alias of Float

num_bits
num_exponent_bits: Final[int]

The number of bits used to store the exponent.

num_mantissa_bits: Final[int]

The number of bits used to store the mantissa.

py_type

alias of float

classmethod specialize(num_exponent_bits_, num_mantissa_bits_, packing_format_letter_: str | None = None, name_: str | None = None)[source]
Produce a subclass of Float with the specified number of bits

in the exponent and mantissa.

If packing_format_letter is provided, the subclass will also be a

StructPackedBitType and use struct’s packing/unpacking functions with the provided letter.

If name_ is provided, the subclass will have that name internally after class

creation. Otherwise, the subclass will be named _Float.

Parameters:
  • num_exponent_bits (int) – The number of bits to use for the exponent.

  • num_mantissa_bits (int) – The number of bits to use for the mantissa.

  • packing_format_letter (Optional[str], optional) – The struct packing format letter to use, if any. Defaults to None, meaning no struct (un)packing.

  • name (Optional[str], optional) – What to rename the subclass, if anything. Defaults to None, meaning the subclass’s name will be _Float.

Returns:

The subclass of Float with the specified number of bits.

Return type:

type[Float]

to_binstring(num_exponent_bits=8, num_mantissa_bits=23) str[source]

Convert a float (or a Float) to a binary string.

Parameters:
  • num_exponent_bits (int) – The number of bits to use for the exponent.

  • num_mantissa_bits (int) – The number of bits to use for the mantissa.

Returns:

The unprefixed binary string representation of the float.

Return type:

str

property value: float

The (readonly) getter for the (Pythonic) value of the BitType.

To set the value directly, use the value setter. To directly adjust the value more complicatedly,

use operations available directly on BitType object rather than on the value returned by this property.

Returns:

The (Pythonic) value of the BitType.

Return type:

T

class bytemaker.bittypes.float.Float16(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: StructPackedBitType, Float

num_exponent_bits: Final[int] = 5

The number of bits used to store the exponent.

num_mantissa_bits: Final[int] = 10

The number of bits used to store the mantissa.

packing_format_letter: Final[str] = 'e'

The packing format letter for struct to use for converting to/from bytes.

class bytemaker.bittypes.float.Float32(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: StructPackedBitType, Float

num_exponent_bits: Final[int] = 8

The number of bits used to store the exponent.

num_mantissa_bits: Final[int] = 23

The number of bits used to store the mantissa.

packing_format_letter: Final[str] = 'f'

The packing format letter for struct to use for converting to/from bytes.

class bytemaker.bittypes.float.Float64(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: StructPackedBitType, Float

num_exponent_bits: Final[int] = 11

The number of bits used to store the exponent.

num_mantissa_bits: Final[int] = 52

The number of bits used to store the mantissa.

packing_format_letter: Final[str] = 'd'

The packing format letter for struct to use for converting to/from bytes.

class bytemaker.bittypes.float.TF19(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Float

NVidia’s TensorFloat-19 format with 8 exponent bits and 10 mantissa bits.

num_exponent_bits: Final[int] = 8

The number of bits used to store the exponent.

num_mantissa_bits: Final[int] = 10

The number of bits used to store the mantissa.

Int (SInt and UInt)

class bytemaker.bittypes.int.Int(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: BitType[int]

A BitType that represents an integer.

Is further subclassed into SInt and UInt for signed and unsigned integers,

Class Attributes:

num_bitsint

The number of bits in the BitType.

base_bit_typeType[BitType]

The base BitType this class derives from.

py_typeType[T]

The Pythonic type that this Int can be converted to/from. It is int.

is_signedbool

Whether the integer type is signed.

Instance Attributes

bitsBitVector

The underlying sequence of bits of this Int object.

valueint

The int value of this Int object.

endiannessLiteral[“big”, “little”]

The endianness of this Int object.

base_bit_type: Final[Type[BitType]]

The base BitType this class derives from (e.g. UInt for UInt8).

is_signed: Final[bool]

Whether the integer type is signed.

static min_bit_length(value: int, signed: bool = True, bin_format: Literal['twos_complement', 'signed_magnitude', 'ones_complement'] | None = None) int[source]

Calculate the minimum number of bits required to represent an integer. Note that this is not the same as len(bin(value)), which assumes an unsigned representation (possibly with - in front).

Parameters:
  • value (int) – The integer to represent.

  • signed (bool, optional) – Whether the representation format should be signed. Default is True.

  • bin_format (Optional[str], optional) – The format for signed integers. Can be “twos_complement”, “signed_magnitude”, or “ones_complement”. Default is “twos_complement”.

py_type

alias of int

to_bitstring(signed: bool = True, bit_length: int | None = None, rep_format: Literal['twos_complement', 'signed_magnitude', 'ones_complement'] | None = None) str[source]

Convert an integer to a bitstring.

Parameters: - integer (int): The integer to convert. - signed (bool, optional): Whether the integer should be treated as signed.

Default is True.

  • bit_length (int, optional): The length of the bitstring.

  • rep_format (Optional[str], optional): The format for signed integers.

    Can be “twos_complement”, “signed_magnitude”, or “ones_complement”. Default is “twos_complement”.

Returns: - str: The bitstring representation of the integer.

to_pyint(signed: bool | None = None, bin_format: Literal['twos_complement', 'signed_magnitude', 'ones_complement'] = 'twos_complement')[source]

Convert a bitstring to an integer.

Parameters: - bitstring (str): The bitstring to convert. - signed (Optional[bool], optional) Whether the bitstring represents

a signed integer (vs unsigned). Default is cls.is_signed or True.

  • bin_format (Optional[str], optional): The format for signed integers.

    Can be “twos_complement”, “signed_magnitude”, or “ones_complement”. Default is “twos_complement”.

Returns: - int: The integer representation of the bitstring.

class bytemaker.bittypes.int.SInt(source: int | BitVector | BitType | None = None, value: int | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big', int_format: Literal['twos_complement', 'signed_magnitude', 'ones_complement'] | None = None)[source]

Bases: Int

A BitType that represents a signed integer.

Use the specialize method to create a subclass with the desired number of bits

or use one of the pre-defined subclasses.

To change the signed integer format, use the Config class

(or set the int_format parameter in the constructor). The default signed integer format is two’s complement.

Class Attributes:
base_bit_typeType[BitType]

The base class (this is SInt for SInt children).

num_bitsint

The number of bits in the integer.

is_signedbool

Whether the integer is signed (this is True for SInts).

Instance Attributes:
int_formatOptional[str]

The format for this signed integer. Can be “twos_complement”, “signed_magnitude”, or “ones_complement”. If this is left as None, the format will be taken from the Config class. Default is “twos_complement.

valueint

The int value of the SInt.

bitsBitVector

The bits representing the value.

base_bit_type

alias of SInt

int_format: Literal['twos_complement', 'signed_magnitude', 'ones_complement']
is_signed: Final[bool] = True

Whether the integer type is signed.

classmethod specialize(num_bits_: int, packing_format_letter_: str | None = None, name_: str | None = None)[source]

Produce a subclass of SInt with the specified number of bits.

If a packing format letter is provided, the subclass will also be a

StructPackedBitType and use struct’s packing/unpacking functions with the provided letter.

If name_ is provided, the subclass will have that name internally after class

creation. Otherwise, the subclass will be named _SInt.

Parameters:
  • num_bits (int) – The number of bits in integers of this type.

  • packing_format_letter (Optional[str], optional) – The struct packing format letter to use, if any. Defaults to None, meaning no struct (un)packing.

  • name (Optional[str], optional) – What to rename the subclass, if anything. Defaults to None, meaning the subclass’s name will be _SInt.

Returns:

The subclass of SInt with the specified number of bits.

Return type:

type[SInt]

property value

The (readonly) getter for the (Pythonic) value of the BitType.

To set the value directly, use the value setter. To directly adjust the value more complicatedly,

use operations available directly on BitType object rather than on the value returned by this property.

Returns:

The (Pythonic) value of the BitType.

Return type:

T

class bytemaker.bittypes.int.SInt1(source: int | BitVector | BitType | None = None, value: int | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big', int_format: Literal['twos_complement', 'signed_magnitude', 'ones_complement'] | None = None)[source]

Bases: SInt

class bytemaker.bittypes.int.SInt10(source: int | BitVector | BitType | None = None, value: int | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big', int_format: Literal['twos_complement', 'signed_magnitude', 'ones_complement'] | None = None)[source]

Bases: SInt

class bytemaker.bittypes.int.SInt11(source: int | BitVector | BitType | None = None, value: int | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big', int_format: Literal['twos_complement', 'signed_magnitude', 'ones_complement'] | None = None)[source]

Bases: SInt

class bytemaker.bittypes.int.SInt12(source: int | BitVector | BitType | None = None, value: int | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big', int_format: Literal['twos_complement', 'signed_magnitude', 'ones_complement'] | None = None)[source]

Bases: SInt

class bytemaker.bittypes.int.SInt128(source: int | BitVector | BitType | None = None, value: int | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big', int_format: Literal['twos_complement', 'signed_magnitude', 'ones_complement'] | None = None)[source]

Bases: SInt

class bytemaker.bittypes.int.SInt13(source: int | BitVector | BitType | None = None, value: int | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big', int_format: Literal['twos_complement', 'signed_magnitude', 'ones_complement'] | None = None)[source]

Bases: SInt

class bytemaker.bittypes.int.SInt14(source: int | BitVector | BitType | None = None, value: int | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big', int_format: Literal['twos_complement', 'signed_magnitude', 'ones_complement'] | None = None)[source]

Bases: SInt

class bytemaker.bittypes.int.SInt15(source: int | BitVector | BitType | None = None, value: int | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big', int_format: Literal['twos_complement', 'signed_magnitude', 'ones_complement'] | None = None)[source]

Bases: SInt

class bytemaker.bittypes.int.SInt16(source: int | BitVector | BitType | None = None, value: int | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big', int_format: Literal['twos_complement', 'signed_magnitude', 'ones_complement'] | None = None)[source]

Bases: StructPackedBitType, SInt

int_format: Literal['twos_complement', 'signed_magnitude', 'ones_complement']
packing_format_letter: Final[str] = 'h'

The packing format letter for struct to use for converting to/from bytes.

property skip_struct_packing
If true, the struct packing/unpacking will be skipped and the value will be

be calculated using parent methods.

Most of the time this will be false

class bytemaker.bittypes.int.SInt2(source: int | BitVector | BitType | None = None, value: int | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big', int_format: Literal['twos_complement', 'signed_magnitude', 'ones_complement'] | None = None)[source]

Bases: SInt

class bytemaker.bittypes.int.SInt256(source: int | BitVector | BitType | None = None, value: int | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big', int_format: Literal['twos_complement', 'signed_magnitude', 'ones_complement'] | None = None)[source]

Bases: SInt

class bytemaker.bittypes.int.SInt3(source: int | BitVector | BitType | None = None, value: int | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big', int_format: Literal['twos_complement', 'signed_magnitude', 'ones_complement'] | None = None)[source]

Bases: SInt

class bytemaker.bittypes.int.SInt32(source: int | BitVector | BitType | None = None, value: int | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big', int_format: Literal['twos_complement', 'signed_magnitude', 'ones_complement'] | None = None)[source]

Bases: StructPackedBitType, SInt

int_format: Literal['twos_complement', 'signed_magnitude', 'ones_complement']
packing_format_letter: Final[str] = 'i'

The packing format letter for struct to use for converting to/from bytes.

property skip_struct_packing
If true, the struct packing/unpacking will be skipped and the value will be

be calculated using parent methods.

Most of the time this will be false

class bytemaker.bittypes.int.SInt4(source: int | BitVector | BitType | None = None, value: int | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big', int_format: Literal['twos_complement', 'signed_magnitude', 'ones_complement'] | None = None)[source]

Bases: SInt

class bytemaker.bittypes.int.SInt5(source: int | BitVector | BitType | None = None, value: int | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big', int_format: Literal['twos_complement', 'signed_magnitude', 'ones_complement'] | None = None)[source]

Bases: SInt

class bytemaker.bittypes.int.SInt6(source: int | BitVector | BitType | None = None, value: int | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big', int_format: Literal['twos_complement', 'signed_magnitude', 'ones_complement'] | None = None)[source]

Bases: SInt

class bytemaker.bittypes.int.SInt64(source: int | BitVector | BitType | None = None, value: int | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big', int_format: Literal['twos_complement', 'signed_magnitude', 'ones_complement'] | None = None)[source]

Bases: StructPackedBitType, SInt

int_format: Literal['twos_complement', 'signed_magnitude', 'ones_complement']
packing_format_letter: Final[str] = 'q'

The packing format letter for struct to use for converting to/from bytes.

property skip_struct_packing
If true, the struct packing/unpacking will be skipped and the value will be

be calculated using parent methods.

Most of the time this will be false

class bytemaker.bittypes.int.SInt7(source: int | BitVector | BitType | None = None, value: int | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big', int_format: Literal['twos_complement', 'signed_magnitude', 'ones_complement'] | None = None)[source]

Bases: SInt

class bytemaker.bittypes.int.SInt8(source: int | BitVector | BitType | None = None, value: int | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big', int_format: Literal['twos_complement', 'signed_magnitude', 'ones_complement'] | None = None)[source]

Bases: StructPackedBitType, SInt

int_format: Literal['twos_complement', 'signed_magnitude', 'ones_complement']
packing_format_letter: Final[str] = 'b'

The packing format letter for struct to use for converting to/from bytes.

property skip_struct_packing
If true, the struct packing/unpacking will be skipped and the value will be

be calculated using parent methods.

Most of the time this will be false

class bytemaker.bittypes.int.SInt9(source: int | BitVector | BitType | None = None, value: int | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big', int_format: Literal['twos_complement', 'signed_magnitude', 'ones_complement'] | None = None)[source]

Bases: SInt

class bytemaker.bittypes.int.SignedConfig[source]

Bases: object

A class to change the default representation and conversion
for all non-user-implemented or non-user-specified signed integers

simultaneously.

If this is unadjusted, the default signed integer format is two’s complement.

signed_int_format: Literal['signed_magnitude', 'ones_complement', 'twos_complement'] = 'twos_complement'
class bytemaker.bittypes.int.UInt(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: Int

A BitType that represents an unsigned integer.

Use the specialize method to create a subclass with the desired number of bits

or use one of the pre-defined subclasses.

Class Attributes:

base_bit_type (Type[BitType]): The base class (this is UInt). num_bits (int): The number of bits in the integer. is_signed (bool): Whether the integer is signed. (This is False)

Properties:

value (int): The integer value of the bits. bits (BitVector): The bits representing the integer value.

base_bit_type

alias of UInt

is_signed: Final[bool] = False

Whether the integer type is signed.

classmethod specialize(num_bits_: int, packing_format_letter_: str | None = None, name_: str | None = None)[source]

Produce a subclass of UInt with the specified number of bits.

If a packing format letter is provided, the subclass will also be a

StructPackedBitType and use struct’s packing/unpacking functions with the provided letter.

If name_ is provided, the subclass will have that name internally after class

creation. Otherwise, the subclass will be named _UInt.

Parameters:
  • num_bits (int) – The number of bits in integers of this type.

  • packing_format_letter (Optional[str], optional) – The struct packing format letter to use, if any. Defaults to None, meaning no struct (un)packing.

  • name (Optional[str], optional) – What to rename the subclass, if anything. Defaults to None, meaning the subclass’s name will be _UInt.

Returns:

The subclass of UInt with the specified number of bits.

Return type:

type[UInt]

property value

The (readonly) getter for the (Pythonic) value of the BitType.

To set the value directly, use the value setter. To directly adjust the value more complicatedly,

use operations available directly on BitType object rather than on the value returned by this property.

Returns:

The (Pythonic) value of the BitType.

Return type:

T

class bytemaker.bittypes.int.UInt1(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UInt

class bytemaker.bittypes.int.UInt10(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UInt

class bytemaker.bittypes.int.UInt11(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UInt

class bytemaker.bittypes.int.UInt12(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UInt

class bytemaker.bittypes.int.UInt128(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UInt

class bytemaker.bittypes.int.UInt13(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UInt

class bytemaker.bittypes.int.UInt14(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UInt

class bytemaker.bittypes.int.UInt15(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UInt

class bytemaker.bittypes.int.UInt16(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: StructPackedBitType, UInt

packing_format_letter: Final[str] = 'H'

The packing format letter for struct to use for converting to/from bytes.

class bytemaker.bittypes.int.UInt2(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UInt

class bytemaker.bittypes.int.UInt256(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UInt

class bytemaker.bittypes.int.UInt3(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UInt

class bytemaker.bittypes.int.UInt32(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: StructPackedBitType, UInt

packing_format_letter: Final[str] = 'I'

The packing format letter for struct to use for converting to/from bytes.

class bytemaker.bittypes.int.UInt4(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UInt

class bytemaker.bittypes.int.UInt5(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UInt

class bytemaker.bittypes.int.UInt6(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UInt

class bytemaker.bittypes.int.UInt64(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: StructPackedBitType, UInt

packing_format_letter: Final[str] = 'Q'

The packing format letter for struct to use for converting to/from bytes.

class bytemaker.bittypes.int.UInt7(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UInt

class bytemaker.bittypes.int.UInt8(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: StructPackedBitType, UInt

packing_format_letter: Final[str] = 'B'

The packing format letter for struct to use for converting to/from bytes.

class bytemaker.bittypes.int.UInt9(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UInt

String

class bytemaker.bittypes.string.StandardEncodingString(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: String

A class for strings that use a standard Python encoding (str.encode/decode)

classmethod decoding(bits: BitVector) str[source]

The method used to decode a BitVector into a string.

Parameters:

bits (BitVector) – The BitVector to decode into a string

Returns:

The decoded string representation of the input BitVector

Return type:

str

classmethod encoding(value: str) BitVector[source]

The method used to encode a string into a BitVector.

Parameters:

value (str) – The string to encode into a BitVector

Returns:

The encoded BitVector representation of the input string

Return type:

BitVector

encoding_name: str

The name of the Python-supported encoding to use for encoding/decoding.

py_type

alias of str

class bytemaker.bittypes.string.Str1(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UTF8String

class bytemaker.bittypes.string.Str10(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UTF8String

class bytemaker.bittypes.string.Str11(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UTF8String

class bytemaker.bittypes.string.Str12(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UTF8String

class bytemaker.bittypes.string.Str128(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UTF8String

class bytemaker.bittypes.string.Str13(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UTF8String

class bytemaker.bittypes.string.Str14(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UTF8String

class bytemaker.bittypes.string.Str15(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UTF8String

class bytemaker.bittypes.string.Str16(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UTF8String

class bytemaker.bittypes.string.Str2(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UTF8String

class bytemaker.bittypes.string.Str256(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UTF8String

class bytemaker.bittypes.string.Str3(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UTF8String

class bytemaker.bittypes.string.Str32(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UTF8String

class bytemaker.bittypes.string.Str4(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UTF8String

class bytemaker.bittypes.string.Str5(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UTF8String

class bytemaker.bittypes.string.Str512(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UTF8String

class bytemaker.bittypes.string.Str6(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UTF8String

class bytemaker.bittypes.string.Str64(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UTF8String

class bytemaker.bittypes.string.Str7(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UTF8String

class bytemaker.bittypes.string.Str8(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UTF8String

class bytemaker.bittypes.string.Str9(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: UTF8String

class bytemaker.bittypes.string.String(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: BitType[str]

base_bit_type

alias of String

codepoint_changes = None
abstract classmethod decoding(bits: BitVector) str[source]

The method used to decode a BitVector into a string.

Parameters:

bits (BitVector) – The BitVector to decode into a string

Returns:

The decoded string representation of the input BitVector

Return type:

str

abstract classmethod encoding(value: str) BitVector[source]

The method used to encode a string into a BitVector.

Parameters:

value (str) – The string to encode into a BitVector

Returns:

The encoded BitVector representation of the input string

Return type:

BitVector

classmethod perform_codepoint_substitution(input_string, codepoint_changes: HashableMapping[str, str], changes_regex: Pattern[str])[source]

Performs codepoint substitutions on the input string.

Parameters:
  • input_string (str) – The input string to perform substitutions on

  • codepoint_changes (HashableMapping[str, str]) – The codepoint changes mapping

  • changes_regex (re.Pattern[str]) – The compiled regex pattern for the codepoint changes

Returns:

The input string with codepoint substitutions applied

Return type:

str

py_type

alias of str

classmethod specialize(num_bits_: int, name_: str | None = None)[source]
property value

The (readonly) getter for the (Pythonic) value of the BitType.

To set the value directly, use the value setter. To directly adjust the value more complicatedly,

use operations available directly on BitType object rather than on the value returned by this property.

Returns:

The (Pythonic) value of the BitType.

Return type:

T

class bytemaker.bittypes.string.UTF8String(source: T | BitVector | BitType | None = None, value: T | None = None, bits: BitVector | None = None, endianness: Literal['big', 'little', 'source_else_big'] = 'source_else_big')[source]

Bases: StandardEncodingString

encoding_name: str = 'utf-8'

The name of the Python-supported encoding to use for encoding/decoding.