(value, offset, size, rev, bw)
return value[bitstart - 1:bitstart - size * bw]
Extremely cute utility to pretend you've serialized a value to stored bytes, sliced it a la python slicing, and then
    deserialized those bytes to an integer again.

    :param value:   The bitvector to slice
    :param offset:  The byte offset from the first stored byte to slice from, or a negative offset from the end.
    :param size:    The number of bytes to return. If None, return all bytes from the offset to the end. If larger than
                    the number of bytes from the offset to the end, return all bytes from the offset to the end.
    :param rev:     Whether the pretend-serialization should be little-endian
    :param bw:      The byte width
    :return:        The new bitvector
Extremely cute utility to pretend you've serialized a value to stored bytes, sliced it a la python slicing, and then
    deserialized those bytes to an integer again.
Extremely cute utility to pretend you ve serialized a value to stored bytes sliced it a la python slicing and then deserialized those bytes to an integer again .
def bv_slice(value, offset, size, rev, bw):
    """
    Extremely cute utility to pretend you've serialized a value to stored bytes, sliced it a la python slicing, and then
    deserialized those bytes to an integer again.

    :param value:   The bitvector to slice
    :param offset:  The byte offset from the first stored byte to slice from, or a negative offset from the end.
    :param size:    The number of bytes to return. If None, return all bytes from the offset to the end. If larger than
                    the number of bytes from the offset to the end, return all bytes from the offset to the end.
    :param rev:     Whether the pretend-serialization should be little-endian
    :param bw:      The byte width
    :return:        The new bitvector
    """

    vsize = len(value) // bw

    if offset < 0:
        offset = vsize + offset

    if size is None or offset + size > vsize:
        size = vsize - offset
    if rev:
        offset = vsize - (offset + size)

    if offset == 0 and size == vsize:
        return value

    bitstart = len(value) - offset * bw
    return value[bitstart - 1:bitstart - size * bw]
def bv_slice ( value , offset , size , rev , bw ) : vsize = len ( value ) // bw if offset < 0 : offset = vsize + offset if size is None or offset + size > vsize : size = vsize - offset if rev : offset = vsize - ( offset + size ) if offset == 0 and size == vsize : return value bitstart = len ( value ) - offset * bw return value [ bitstart - 1 : bitstart - size * bw ]