def _elements_to_dict(data, position, obj_end, opts):
 result = opts.document_class()
 pos = position
 for (key, value, pos) in _iterate_elements(data, position, obj_end, opts):
  result[key] = value
 if (pos != obj_end):
  raise InvalidBSON('bad object or element length')
 return result

def _elements_to_dict ( data , position , obj_end , opts ) : result = opts . document_class ( ) pos = position for ( key , value , pos ) in _iterate_elements ( data , position , obj_end , opts ) : result [ key ] = value if ( pos != obj_end ) : raise InvalidBSON ( 'bad object or element length' ) return result
decode a bson document .