From e4a900dd88fda4d99629e281875783d49148b45a Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Wed, 17 Sep 2025 14:37:59 +0800 Subject: [PATCH] Update PyDict.c --- src/public/PyDict.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/public/PyDict.c b/src/public/PyDict.c index 0cc797e2..1e65e13b 100644 --- a/src/public/PyDict.c +++ b/src/public/PyDict.c @@ -651,10 +651,18 @@ bool dict_items__next__(int argc, py_Ref argv) { return StopIteration(); } +bool dict_items__len__(int argc, py_Ref argv) { + PY_CHECK_ARGC(1); + DictIterator* iter = py_touserdata(py_arg(0)); + py_newint(py_retval(), iter->dict->length); + return true; +} + py_Type pk_dict_items__register() { py_Type type = pk_newtype("dict_iterator", tp_object, NULL, NULL, false, true); py_bindmagic(type, __iter__, pk_wrapper__self); py_bindmagic(type, __next__, dict_items__next__); + py_bindmagic(type, __len__, dict_items__len__); return type; }