← index #5046PR #16902
Likely Duplicate · high · value 1.012
QUERY · ISSUE

RFC: MICROPY_PY_BUILTINS_NEXT2 always set to (0) ?

openby pmp-popened 2019-08-27updated 2022-12-22
rfc

Current settings for all ports break cpython script compatibility on next()

https://docs.python.org/3.5/library/functions.html#next

because
MICROPY_PY_BUILTINS_NEXT2 is never defined to 1 except in coverage and defaults to 0
https://github.com/micropython/micropython/blob/master/py/mpconfig.h#L910

CANDIDATE · PULL REQUEST

py/mpconfig: Enable 2-argument built-in next() at basic feature level.

mergedby dpgeorgeopened 2025-03-11updated 2025-03-27
py-core

Summary

Enable the 2-argument form of the built-in next() function at the basic feature level (which is one above core features).

This is a pretty fundamental built-in and having CPython-compatible behaviour is beneficial. The code size increase is not much, and ports/boards can still disable it if needed to save space.

Addresses issue #5384.

Testing

CI should test this.

Trade-offs and Alternatives

Could leave it disabled and document better the differences. But I think it's worth the increase in code size, most big boards have enough space.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied