def index(self, val, start=None, stop=None):
_len = self._len<EOL>if not _len:<EOL><INDENT>raise ValueError('<STR_LIT>'.format(val))<EOL><DEDENT>if start is None:<EOL><INDENT>start = <NUM_LIT:0><EOL><DEDENT>if start < <NUM_LIT:0>:<EOL><INDENT>start += _len<EOL><DEDENT>if start < <NUM_LIT:0>:<EOL><INDENT>start = <NUM_LIT:0><EOL><DEDENT>if stop is None:<EOL><INDENT>stop = _len<EOL><DEDENT>if stop < <NUM_LIT:0>:<EOL><INDENT>stop += _len<EOL><DEDENT>if stop > _len:<EOL><INDENT>stop = _len<EOL><DEDENT>if stop <= start:<EOL><INDENT>raise ValueError('<STR_LIT>'.format(val))<EOL><DEDENT>_maxes = self._maxes<EOL>key = self._key(val)<EOL>pos = bisect_left(_maxes, key)<EOL>if pos == len(_maxes):<EOL><INDENT>raise ValueError('<STR_LIT>'.format(val))<EOL><DEDENT>stop -= <NUM_LIT:1><EOL>_lists = self._lists<EOL>_keys = self._keys<EOL>idx = bisect_left(_keys[pos], key)<EOL>len_keys = len(_keys)<EOL>len_sublist = len(_keys[pos])<EOL>while True:<EOL><INDENT>if _keys[pos][idx] != key:<EOL><INDENT>raise ValueError('<STR_LIT>'.format(val))<EOL><DEDENT>if _lists[pos][idx] == val:<EOL><INDENT>loc = self._loc(pos, idx)<EOL>if start <= loc <= stop:<EOL><INDENT>return loc<EOL><DEDENT>elif loc > stop:<EOL><INDENT>break<EOL><DEDENT><DEDENT>idx += <NUM_LIT:1><EOL>if idx == len_sublist:<EOL><INDENT>pos += <NUM_LIT:1><EOL>if pos == len_keys:<EOL><INDENT>raise ValueError('<STR_LIT>'.format(val))<EOL><DEDENT>len_sublist = len(_keys[pos])<EOL>idx = <NUM_LIT:0><EOL><DEDENT><DEDENT>raise ValueError('<STR_LIT>'.format(val))<EOL>
Return the smallest *k* such that L[k] == val and i <= k < j`.  Raises
ValueError if *val* is not present.  *stop* defaults to the end of the
list. *start* defaults to the beginning. Negative indices are supported,
as for slice indices.