Skip to content

docs/builtins: Add basic builtins documentation. - #19595

Open
Josverl wants to merge 1 commit into
micropython:masterfrom
Josverl:docs/builtins
Open

docs/builtins: Add basic builtins documentation.#19595
Josverl wants to merge 1 commit into
micropython:masterfrom
Josverl:docs/builtins

Conversation

@Josverl

@Josverl Josverl commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Summary

The documentation for builtins was rather terse , and missing even the MicroPython specific execfile() method, making things hard to discover and learn.

This PR aims to add minimal documentation on the built-in methods and classes, and refer to CPython for more details.
Where there are known differences, there are referrals to more detailed documentation.

Testing

Trade-offs and Alternatives

There is some overlap with the documentation based on cpydiff tests, but I think that is unavoidable and acceptable.

Generative AI

I used generative AI tools when creating this PR, but a human has checked the
documentation and is responsible for the docs and the description above.

@Josverl Josverl added the docs label Aug 7, 2026
@Josverl Josverl changed the title docs/builtins: Add basic builtins documentaion. docs/builtins: Add basic builtins documentation. Aug 7, 2026

@pavelrevak pavelrevak left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work on this — the builtins page has been a bare list for far too long, and the cpydiff cross-referencing is well done: all 35 labels resolve and the paraphrases match the source descriptions.

I look through it and focused on correctness — signatures or claims that don't match the implementation. I verified each against py/modbuiltins.c and by running it on a freshly built ports/unix at master; evidence is inline.

Most cluster into two patterns, so the fix is smaller than the comment count suggests:

  1. Optional args written as =None (getattr, next, min/max) — they have no default; omitting them raises AttributeError / StopIteration / ValueError.
  2. / markers on args that do accept keywords (enumerate, open) — plus slice, which can't be called at all.

There's also some unevenness in completeness and style — execfile is still missing (the PR description names it as the motivation) and the "optional feature" availability notes cover only about a third of the builtins that need them — but nothing there is blocking.

Comment thread docs/library/builtins.rst Outdated
Comment thread docs/library/builtins.rst Outdated
Comment thread docs/library/builtins.rst Outdated
Comment thread docs/library/builtins.rst Outdated
Comment thread docs/library/builtins.rst Outdated
Comment thread docs/library/builtins.rst Outdated
Comment thread docs/library/builtins.rst Outdated
Comment thread docs/library/builtins.rst Outdated
Comment thread docs/library/builtins.rst Outdated
Comment thread docs/library/builtins.rst Outdated
@Josverl

Josverl commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

I look through it and focused on correctness — signatures or claims that don't match the implementation. I verified each against py/modbuiltins.c and by running it on a freshly built ports/unix at master; evidence is inline.

Thank you, I created a draft because that work still needed to be done, but I was in the middle of 4 different things with interdependencies.

@Josverl

Josverl commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

@pavelrevak,
Thanks for the detailed and constructive review. Much appreciated.
I have gone through and adjusted the signatures and wording based on your feedback.

Ill leave it in draft as I want to verify a few more things.

@Josverl
Josverl force-pushed the docs/builtins branch 3 times, most recently from dff0b27 to f3c0e2a Compare August 9, 2026 11:31
@Josverl
Josverl marked this pull request as ready for review August 9, 2026 11:32
@Josverl

Josverl commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

Rebased on current master which included merging other updates
Improved formatting and layout.
Ready for review.

Regarding the availability / Only available on builds with MPY_GUARD ,
I'm considering moving that to a all-up paragraph instead.
I have previously tried to capture the macros on the wiki, so could also add a reference to that

@pavelrevak pavelrevak left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice rebuild

Comment thread docs/library/builtins.rst Outdated
Comment thread docs/library/builtins.rst Outdated
@Josverl
Josverl force-pushed the docs/builtins branch 2 times, most recently from 4020edb to ba4b5d1 Compare August 15, 2026 13:50
Add basic parameters to methods.

For Micropython specific differences.
- Add a concise description of the differences

For CPython equivalent:
- Add one line description & reference to CPython.

Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants