From 402de82d47a08f20637176a1901b2f9a39601aba Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Sat, 4 May 2024 23:09:15 +0800 Subject: [PATCH] Update 1_5_0.md --- docs/1_5_0.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/docs/1_5_0.md b/docs/1_5_0.md index fe6b2317..7fb753f5 100644 --- a/docs/1_5_0.md +++ b/docs/1_5_0.md @@ -133,4 +133,16 @@ for a, b in my_iter: for t in my_iter: # Create a tuple lazily ... -``` \ No newline at end of file +``` + +## Builtin function `next()` + +Previously, `next()` returns `StopIteration` when the iterator is exhausted. +In `v1.5.0`, it raises `StopIteration` exception instead, which is consistent with CPython. +If you like the old way, you can use the following snippet to import the old `next()` function: + +```python +from __builtins import next +``` + +Related C++ APIs do not change. They still return `vm->StopIteration` to indicate the end of iteration.