import random


def shuffle_list(py_list, inplace=False):
    """Shuffle a list
    If `inplace=True` the input list is modified (faster & less memory), if `inplace=False` a new list is
    generated (slower & more memory).
    Args:
        py_list (list): A list of elements.
        inplace (bool): If `True` the input list is modified, if `False` a new list is generated.
    Returns:
        result_list (list): A list with the values shuffled.
    Examples:
        >>> py_list = [1,2,3,4,5]
        >>> l = shuffle_list(py_list, False)
        >>> all(elem in l  for elem in py_list)
        True

    """
    if inplace:
        random.shuffle(py_list)
    else:
        # fastest way to shallow copy a list https://stackoverflow.com/a/2612990
        l = py_list[:]
        random.shuffle(l)
        return l