import pickle


def load_object(file_path: str):
    """
    Un-pickles an object from a binary file.
    This enables that certain objects don't have to be re-initialized.

    Be careful to use os.path.dirname(__file__) if you are not sure about relative path.
    For example, running a misc.helper script from tests will mean that regexes are going to
    try to load from tests\\compiled_regexes directory if using .\\compiled_regexes instead of
    C:\\...\\grammar\\compiled_regexes.

    The same goes for saving an object.

    :param str file_path: path to a file
    :return: unpickled object
    """
    with open(file_path, 'rb') as file:
        obj = pickle.load(file)
    return obj