Open mine-bach opened 5 years ago
enumerate seems to work properly for strings and lists but not for generators.
A fix is in place for v3.9.4 but needs more testing, and maybe a performance check.
Instead of using zip
, enumerate
has instead been changed to use a JS generator, which I had some issues getting exported from the built-ins module. On the plus side, it wasn't much more code than what was already there and enumerate
is now lazy. Autotests are all currently passing.
function* __enumerate__ (iterable, start=0) {
if (start.hasOwnProperty("__kwargtrans__")) {
// start was likely passed in as kwarg
start = start['start'];
}
let n = start
for (const item of iterable) {
yield [n, item]
n += 1
}
}
export var py_enumerate = __enumerate__;
Hello,
I have slighly modified the "iterators_and_generators" autotest code. (I didn't understood all comments, but....)
Trying to use enumerate with the given Iterable does not seems to work :