Fast path for FOR_ITER specialization.
(&self)
| 709 | impl PyListIterator { |
| 710 | /// Fast path for FOR_ITER specialization. |
| 711 | pub(crate) fn fast_next(&self) -> Option<PyObjectRef> { |
| 712 | self.internal |
| 713 | .lock() |
| 714 | .next(|list, pos| { |
| 715 | let vec = list.borrow_vec(); |
| 716 | Ok(PyIterReturn::from_result(vec.get(pos).cloned().ok_or(None))) |
| 717 | }) |
| 718 | .ok() |
| 719 | .and_then(|r| match r { |
| 720 | PyIterReturn::Return(v) => Some(v), |
| 721 | PyIterReturn::StopIteration(_) => None, |
| 722 | }) |
| 723 | } |
| 724 | } |
| 725 | |
| 726 | impl SelfIter for PyListIterator {} |