(data, position, obj_end, opts, element_name)
return result, position + 1
Decode a BSON array to python list.
Decode a BSON array to python list.
Decode a BSON array to python list .
def _get_array(data, position, obj_end, opts, element_name):
    """Decode a BSON array to python list."""
    size = _UNPACK_INT(data[position:position + 4])[0]
    end = position + size - 1
    if data[end:end + 1] != b"\x00":
        raise InvalidBSON("bad eoo")

    position += 4
    end -= 1
    result = []

    # Avoid doing global and attibute lookups in the loop.
    append = result.append
    index = data.index
    getter = _ELEMENT_GETTER

    while position < end:
        element_type = data[position:position + 1]
        # Just skip the keys.
        position = index(b'\x00', position) + 1
        try:
            value, position = getter[element_type](
                data, position, obj_end, opts, element_name)
        except KeyError:
            _raise_unknown_type(element_type, element_name)
        append(value)

    if position != end + 1:
        raise InvalidBSON('bad array length')
    return result, position + 1
def _get_array ( data , position , obj_end , opts , element_name ) : size = _UNPACK_INT ( data [ position : position + 4 ] ) [ 0 ] end = position + size - 1 if data [ end : end + 1 ] != b"\x00" : raise InvalidBSON ( "bad eoo" ) position += 4 end -= 1 result = [ ] # Avoid doing global and attibute lookups in the loop. append = result . append index = data . index getter = _ELEMENT_GETTER while position < end : element_type = data [ position : position + 1 ] # Just skip the keys. position = index ( b'\x00' , position ) + 1 try : value , position = getter [ element_type ] ( data , position , obj_end , opts , element_name ) except KeyError : _raise_unknown_type ( element_type , element_name ) append ( value ) if position != end + 1 : raise InvalidBSON ( 'bad array length' ) return result , position + 1