| 763 | |
| 764 | #[pyfunction] |
| 765 | fn iter( |
| 766 | iter_target: PyObjectRef, |
| 767 | sentinel: OptionalArg<PyObjectRef>, |
| 768 | vm: &VirtualMachine, |
| 769 | ) -> PyResult<PyIter> { |
| 770 | if let OptionalArg::Present(sentinel) = sentinel { |
| 771 | let callable = ArgCallable::try_from_object(vm, iter_target)?; |
| 772 | let iterator = PyCallableIterator::new(callable, sentinel) |
| 773 | .into_ref(&vm.ctx) |
| 774 | .into(); |
| 775 | Ok(PyIter::new(iterator)) |
| 776 | } else { |
| 777 | iter_target.get_iter(vm) |
| 778 | } |
| 779 | } |
| 780 | |
| 781 | #[pyfunction] |
| 782 | fn aiter(iter_target: PyObjectRef, vm: &VirtualMachine) -> PyResult { |