blueloveTH 1 rok pred
rodič
commit
24a7e6f060

+ 0 - 8
docs/modules/itertools.md

@@ -1,8 +0,0 @@
----
-icon: package
-label: itertools
----
-
-### `itertools.zip_longest(a, b)`
-
-Returns an iterator that aggregates elements from the input iterables. If the input iterables are of different lengths, missing values are filled-in with `None`.

+ 0 - 1
include/pocketpy/common/_generated.h

@@ -11,7 +11,6 @@ extern const char kPythonLibs_dataclasses[];
 extern const char kPythonLibs_datetime[];
 extern const char kPythonLibs_functools[];
 extern const char kPythonLibs_heapq[];
-extern const char kPythonLibs_itertools[];
 extern const char kPythonLibs_operator[];
 extern const char kPythonLibs_pickle[];
 extern const char kPythonLibs_this[];

+ 1 - 1
include/typings/linalg.pyi

@@ -66,7 +66,7 @@ class mat3x3:
 
     def __invert__(self) -> mat3x3: ...
 
-    def matmul(self, other: mat3x3, out: mat3x3 = None) -> mat3x3 | None: ...
+    def matmul(self, other: mat3x3, out: mat3x3) -> mat3x3 | None: ...
     def determinant(self) -> float: ...
 
     def copy(self) -> mat3x3: ...

+ 0 - 3
include/typings/pkpy.pyi

@@ -1,4 +1 @@
 from typing import Any
-
-def next(iter) -> Any | StopIteration:
-    ...

+ 4 - 5
python/builtins.py

@@ -1,5 +1,3 @@
-from pkpy import next as __pkpy_next
-
 def all(iterable):
     for i in iterable:
         if not i:
@@ -37,9 +35,10 @@ def zip(a, b):
     a = iter(a)
     b = iter(b)
     while True:
-        ai = __pkpy_next(a)
-        bi = __pkpy_next(b)
-        if ai is StopIteration or bi is StopIteration:
+        try:
+            ai = next(a)
+            bi = next(b)
+        except StopIteration:
             break
         yield ai, bi
 

+ 0 - 15
python/itertools.py

@@ -1,15 +0,0 @@
-from pkpy import next
-
-def zip_longest(a, b):
-    a = iter(a)
-    b = iter(b)
-    while True:
-        ai = next(a)
-        bi = next(b)
-        if ai is StopIteration and bi is StopIteration:
-            break
-        if ai is StopIteration:
-            ai = None
-        if bi is StopIteration:
-            bi = None
-        yield ai, bi

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 0 - 0
src/common/_generated.c


+ 1 - 17
src/modules/pkpy.c

@@ -1,21 +1,5 @@
 #include "pocketpy/pocketpy.h"
 
-#include "pocketpy/common/utils.h"
-#include "pocketpy/objects/object.h"
-#include "pocketpy/common/sstream.h"
-#include "pocketpy/interpreter/vm.h"
-
-static bool pkpy_next(int argc, py_Ref argv) {
-    PY_CHECK_ARGC(1);
-    int res = py_next(argv);
-    if(res == -1) return false;
-    if(res) return true;
-    py_assign(py_retval(), py_tpobject(tp_StopIteration));
-    return true;
-}
-
 void pk__add_module_pkpy() {
-    py_Ref mod = py_newmodule("pkpy");
-
-    py_bindfunc(mod, "next", pkpy_next);
+    py_newmodule("pkpy");
 }

+ 8 - 9
tests/29_iter.py

@@ -1,13 +1,12 @@
-from pkpy import next
-
 a = [1, 2, 3]
 a = iter(a)
 
 total = 0
 
 while True:
-    obj = next(a)
-    if obj is StopIteration:
+    try:
+        obj = next(a)
+    except StopIteration:
         break
     total += obj
 
@@ -36,11 +35,11 @@ assert next(i) == 2
 assert next(i) == 3
 assert next(i) == 4
 assert next(i) == 5
-assert next(i) == StopIteration
-assert next(i) == StopIteration
-
-# test normal next
-from builtins import next
+try:
+    next(i)
+    exit(1)
+except StopIteration:
+    pass
 
 a = iter([1])
 assert next(a) == 1

+ 0 - 6
tests/73_itertools.py

@@ -1,6 +0,0 @@
-from itertools import zip_longest
-
-a = [1, 2, 3]
-b = [2]
-
-assert list(zip_longest(a, b)) == [(1, 2), (2, None), (3, None)]

Niektoré súbory nie sú zobrazené, pretože je v týchto rozdielových dátach zmenené mnoho súborov