Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing modules in the docs #655 #670

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions docs/array.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
:mod:`array` -- arrays of numeric data
======================================

.. module:: array
:synopsis: efficient arrays of numeric data

|see_cpython_module| :mod:`python:array`.

Supported format codes: ``b``, ``B``, ``h``, ``H``, ``i``, ``I``, ``l``,
``L``, ``q``, ``Q``, ``f``, ``d`` (the latter 2 depending on the
floating-point support).

Classes
-------

.. class:: array.array(typecode, [iterable])

Create array with elements of given type. Initial contents of the
array are given by *iterable*. If it is not provided, an empty
array is created.

.. method:: append(val)

Append new element *val* to the end of array, growing it.

.. method:: extend(iterable)

Append new elements as contained in *iterable* to the end of
array, growing it.
199 changes: 199 additions & 0 deletions docs/builtins.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
Builtin functions and exceptions
================================

All builtin functions and exceptions are described here. They are also
available via ``builtins`` module.

Functions and types
-------------------

.. function:: abs()

.. function:: all()

.. function:: any()

.. function:: bin()

.. class:: bool()

.. class:: bytearray()

.. class:: bytes()

|see_cpython| `python:bytes`.

.. function:: callable()

.. function:: chr()

.. function:: classmethod()

.. function:: compile()

.. class:: complex()

.. function:: delattr(obj, name)

The argument *name* should be a string, and this function deletes the named
attribute from the object given by *obj*.

.. class:: dict()

.. function:: dir()

.. function:: divmod()

.. function:: enumerate()

.. function:: eval()

.. function:: exec()

.. function:: filter()

.. class:: float()

.. class:: frozenset()

.. function:: getattr()

.. function:: globals()

.. function:: hasattr()

.. function:: hash()

.. function:: hex()

.. function:: id()

.. function:: input()

.. class:: int()

.. classmethod:: from_bytes(bytes, byteorder)

In MicroPython, `byteorder` parameter must be positional (this is
compatible with CPython).

.. method:: to_bytes(size, byteorder)

In MicroPython, `byteorder` parameter must be positional (this is
compatible with CPython).

.. function:: isinstance()

.. function:: issubclass()

.. function:: iter()

.. function:: len()

.. class:: list()

.. function:: locals()

.. function:: map()

.. function:: max()

.. class:: memoryview()

.. function:: min()

.. function:: next()

.. class:: object()

.. function:: oct()

.. function:: open()

.. function:: ord()

.. function:: pow()

.. function:: print()

.. function:: property()

.. function:: range()

.. function:: repr()

.. function:: reversed()

.. function:: round()

.. class:: set()

.. function:: setattr()

.. class:: slice()

The *slice* builtin is the type that slice objects have.

.. function:: sorted()

.. function:: staticmethod()

.. class:: str()

.. function:: sum()

.. function:: super()

.. class:: tuple()

.. function:: type()

.. function:: zip()


Exceptions
----------

.. exception:: AssertionError

.. exception:: AttributeError

.. exception:: Exception

.. exception:: ImportError

.. exception:: IndexError

.. exception:: KeyboardInterrupt

.. exception:: KeyError

.. exception:: MemoryError

.. exception:: NameError

.. exception:: NotImplementedError

.. exception:: OSError

|see_cpython| `python:OSError`. MicroPython doesn't implement ``errno``
attribute, instead use the standard way to access exception arguments:
``exc.args[0]``.

.. exception:: RuntimeError

.. exception:: StopIteration

.. exception:: SyntaxError

.. exception:: SystemExit

|see_cpython| `python:SystemExit`.

.. exception:: TypeError

|see_cpython| `python:TypeError`.

.. exception:: ValueError

.. exception:: ZeroDivisionError
66 changes: 66 additions & 0 deletions docs/gc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
:mod:`gc` -- control the garbage collector
==========================================

.. module:: gc
:synopsis: control the garbage collector

|see_cpython_module| :mod:`python:gc`.

Functions
---------

.. function:: enable()

Enable automatic garbage collection.

.. function:: disable()

Disable automatic garbage collection. Heap memory can still be allocated,
and garbage collection can still be initiated manually using :meth:`gc.collect`.

.. function:: collect()

Run a garbage collection.

.. function:: mem_alloc()

Return the number of bytes of heap RAM that are allocated.

.. admonition:: Difference to CPython
:class: attention

This function is MicroPython extension.

.. function:: mem_free()

Return the number of bytes of available heap RAM, or -1 if this amount
is not known.

.. admonition:: Difference to CPython
:class: attention

This function is MicroPython extension.

.. function:: threshold([amount])

Set or query the additional GC allocation threshold. Normally, a collection
is triggered only when a new allocation cannot be satisfied, i.e. on an
out-of-memory (OOM) condition. If this function is called, in addition to
OOM, a collection will be triggered each time after *amount* bytes have been
allocated (in total, since the previous time such an amount of bytes
have been allocated). *amount* is usually specified as less than the
full heap size, with the intention to trigger a collection earlier than when the
heap becomes exhausted, and in the hope that an early collection will prevent
excessive memory fragmentation. This is a heuristic measure, the effect
of which will vary from application to application, as well as
the optimal value of the *amount* parameter.

Calling the function without argument will return the current value of
the threshold. A value of -1 means a disabled allocation threshold.

.. admonition:: Difference to CPython
:class: attention

This function is a MicroPython extension. CPython has a similar
function - ``set_threshold()``, but due to different GC
implementations, its signature and semantics are different.
Loading