[issue23086] Add start and stop parameters to the Sequence.index() ABC mixin method

Josh Rosenberg report at bugs.python.org
Thu Jan 8 23:49:41 CET 2015


Josh Rosenberg added the comment:

Note: index returns without the caller having a chance to execute code that would change the sequence length directly. But other threads could change it, as could a custom __eq__ on an object stored in the sequence (or a poorly implemented __getitem__ or __len__ on the sequence itself, but that's getting even more pathological). Thread consistency is the code's responsibility though (we just need to make sure we behave the best we can, and hope they use locks correctly), and the odds of equality of __getitem__ altering the sequence are much lower than the odds of someone iterating the sequence and changing it as they go (which is what __iter__'s implementation allows, responding with potentially incomplete results since items might be skipped due to the mutation), but keeping the sequence in a consistent state.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23086>
_______________________________________


More information about the Python-bugs-list mailing list