# Path: mom/builtins.py
# def byte(number):
# def bytes_leading(raw_bytes, needle=_compat.ZERO_BYTE):
# def bytes_trailing(raw_bytes, needle=_compat.ZERO_BYTE):
# def bin(number, prefix="0b"):
# def hex(number, prefix="0x"):
# def is_sequence(obj):
# def is_unicode(obj):
# def is_bytes(obj):
# def is_bytes_or_unicode(obj):
# def is_integer(obj):
# def integer_byte_length(number):
# def integer_byte_size(number):
# def integer_bit_length(number):
# def integer_bit_size(number):
# def integer_bit_count(number):
# def is_even(num):
# def is_odd(num):
# def is_positive(num):
# def is_negative(num):


from array import array
from mom import builtins


# TODO: Keep these functions around.
def bytearray_to_long(byte_array):
  """
  Converts a byte array to long.

  :param byte_array:
      The byte array.
  :returns:
      Long.
  """
  total = 0
  multiplier = 1
  for count in range(len(byte_array) - 1, -1, -1):
    byte_val = byte_array[count]
    total += multiplier * byte_val
    multiplier *= 256
  return total


def long_to_bytearray(num):
  """
  Converts a long into a byte array.

  :param num:
      Long value
  :returns:
      Long.
  """

# Path: mom/builtins.py
# def byte(number):
# def bytes_leading(raw_bytes, needle=_compat.ZERO_BYTE):
# def bytes_trailing(raw_bytes, needle=_compat.ZERO_BYTE):
# def bin(number, prefix="0b"):
# def hex(number, prefix="0x"):
# def is_sequence(obj):
# def is_unicode(obj):
# def is_bytes(obj):
# def is_bytes_or_unicode(obj):
# def is_integer(obj):
# def integer_byte_length(number):
# def integer_byte_size(number):
# def integer_bit_length(number):
# def integer_bit_size(number):
# def integer_bit_count(number):
# def is_even(num):
# def is_odd(num):
# def is_positive(num):
# def is_negative(num):


# Path: mom/_types/bytearray.py
from array import array
from mom import builtins



# TODO: Keep these functions around.
def bytearray_to_long(byte_array):
  """
  Converts a byte array to long.

  :param byte_array:
      The byte array.
  :returns:
      Long.
  """
  total = 0
  multiplier = 1
  for count in range(len(byte_array) - 1, -1, -1):
    byte_val = byte_array[count]
    total += multiplier * byte_val
    multiplier *= 256
  return total


def long_to_bytearray(num):
  """
  Converts a long into a byte array.

  :param num:
      Long value
  :returns:
      Long.
  """

  bytes_count = builtins.integer_byte_length(num)