Skip to content

Commit 52a5061

Browse files
author
Aitzol Naberan
committed
Add missing modules in the docs bbcmicrobit#655
1 parent a92ca9b commit 52a5061

File tree

7 files changed

+888
-0
lines changed

7 files changed

+888
-0
lines changed

docs/array.rst

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
:mod:`array` -- arrays of numeric data
2+
======================================
3+
4+
.. module:: array
5+
:synopsis: efficient arrays of numeric data
6+
7+
|see_cpython_module| :mod:`python:array`.
8+
9+
Supported format codes: ``b``, ``B``, ``h``, ``H``, ``i``, ``I``, ``l``,
10+
``L``, ``q``, ``Q``, ``f``, ``d`` (the latter 2 depending on the
11+
floating-point support).
12+
13+
Classes
14+
-------
15+
16+
.. class:: array.array(typecode, [iterable])
17+
18+
Create array with elements of given type. Initial contents of the
19+
array are given by *iterable*. If it is not provided, an empty
20+
array is created.
21+
22+
.. method:: append(val)
23+
24+
Append new element *val* to the end of array, growing it.
25+
26+
.. method:: extend(iterable)
27+
28+
Append new elements as contained in *iterable* to the end of
29+
array, growing it.

docs/builtins.rst

Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
Builtin functions and exceptions
2+
================================
3+
4+
All builtin functions and exceptions are described here. They are also
5+
available via ``builtins`` module.
6+
7+
Functions and types
8+
-------------------
9+
10+
.. function:: abs()
11+
12+
.. function:: all()
13+
14+
.. function:: any()
15+
16+
.. function:: bin()
17+
18+
.. class:: bool()
19+
20+
.. class:: bytearray()
21+
22+
.. class:: bytes()
23+
24+
|see_cpython| `python:bytes`.
25+
26+
.. function:: callable()
27+
28+
.. function:: chr()
29+
30+
.. function:: classmethod()
31+
32+
.. function:: compile()
33+
34+
.. class:: complex()
35+
36+
.. function:: delattr(obj, name)
37+
38+
The argument *name* should be a string, and this function deletes the named
39+
attribute from the object given by *obj*.
40+
41+
.. class:: dict()
42+
43+
.. function:: dir()
44+
45+
.. function:: divmod()
46+
47+
.. function:: enumerate()
48+
49+
.. function:: eval()
50+
51+
.. function:: exec()
52+
53+
.. function:: filter()
54+
55+
.. class:: float()
56+
57+
.. class:: frozenset()
58+
59+
.. function:: getattr()
60+
61+
.. function:: globals()
62+
63+
.. function:: hasattr()
64+
65+
.. function:: hash()
66+
67+
.. function:: hex()
68+
69+
.. function:: id()
70+
71+
.. function:: input()
72+
73+
.. class:: int()
74+
75+
.. classmethod:: from_bytes(bytes, byteorder)
76+
77+
In MicroPython, `byteorder` parameter must be positional (this is
78+
compatible with CPython).
79+
80+
.. method:: to_bytes(size, byteorder)
81+
82+
In MicroPython, `byteorder` parameter must be positional (this is
83+
compatible with CPython).
84+
85+
.. function:: isinstance()
86+
87+
.. function:: issubclass()
88+
89+
.. function:: iter()
90+
91+
.. function:: len()
92+
93+
.. class:: list()
94+
95+
.. function:: locals()
96+
97+
.. function:: map()
98+
99+
.. function:: max()
100+
101+
.. class:: memoryview()
102+
103+
.. function:: min()
104+
105+
.. function:: next()
106+
107+
.. class:: object()
108+
109+
.. function:: oct()
110+
111+
.. function:: open()
112+
113+
.. function:: ord()
114+
115+
.. function:: pow()
116+
117+
.. function:: print()
118+
119+
.. function:: property()
120+
121+
.. function:: range()
122+
123+
.. function:: repr()
124+
125+
.. function:: reversed()
126+
127+
.. function:: round()
128+
129+
.. class:: set()
130+
131+
.. function:: setattr()
132+
133+
.. class:: slice()
134+
135+
The *slice* builtin is the type that slice objects have.
136+
137+
.. function:: sorted()
138+
139+
.. function:: staticmethod()
140+
141+
.. class:: str()
142+
143+
.. function:: sum()
144+
145+
.. function:: super()
146+
147+
.. class:: tuple()
148+
149+
.. function:: type()
150+
151+
.. function:: zip()
152+
153+
154+
Exceptions
155+
----------
156+
157+
.. exception:: AssertionError
158+
159+
.. exception:: AttributeError
160+
161+
.. exception:: Exception
162+
163+
.. exception:: ImportError
164+
165+
.. exception:: IndexError
166+
167+
.. exception:: KeyboardInterrupt
168+
169+
.. exception:: KeyError
170+
171+
.. exception:: MemoryError
172+
173+
.. exception:: NameError
174+
175+
.. exception:: NotImplementedError
176+
177+
.. exception:: OSError
178+
179+
|see_cpython| `python:OSError`. MicroPython doesn't implement ``errno``
180+
attribute, instead use the standard way to access exception arguments:
181+
``exc.args[0]``.
182+
183+
.. exception:: RuntimeError
184+
185+
.. exception:: StopIteration
186+
187+
.. exception:: SyntaxError
188+
189+
.. exception:: SystemExit
190+
191+
|see_cpython| `python:SystemExit`.
192+
193+
.. exception:: TypeError
194+
195+
|see_cpython| `python:TypeError`.
196+
197+
.. exception:: ValueError
198+
199+
.. exception:: ZeroDivisionError

docs/gc.rst

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
:mod:`gc` -- control the garbage collector
2+
==========================================
3+
4+
.. module:: gc
5+
:synopsis: control the garbage collector
6+
7+
|see_cpython_module| :mod:`python:gc`.
8+
9+
Functions
10+
---------
11+
12+
.. function:: enable()
13+
14+
Enable automatic garbage collection.
15+
16+
.. function:: disable()
17+
18+
Disable automatic garbage collection. Heap memory can still be allocated,
19+
and garbage collection can still be initiated manually using :meth:`gc.collect`.
20+
21+
.. function:: collect()
22+
23+
Run a garbage collection.
24+
25+
.. function:: mem_alloc()
26+
27+
Return the number of bytes of heap RAM that are allocated.
28+
29+
.. admonition:: Difference to CPython
30+
:class: attention
31+
32+
This function is MicroPython extension.
33+
34+
.. function:: mem_free()
35+
36+
Return the number of bytes of available heap RAM, or -1 if this amount
37+
is not known.
38+
39+
.. admonition:: Difference to CPython
40+
:class: attention
41+
42+
This function is MicroPython extension.
43+
44+
.. function:: threshold([amount])
45+
46+
Set or query the additional GC allocation threshold. Normally, a collection
47+
is triggered only when a new allocation cannot be satisfied, i.e. on an
48+
out-of-memory (OOM) condition. If this function is called, in addition to
49+
OOM, a collection will be triggered each time after *amount* bytes have been
50+
allocated (in total, since the previous time such an amount of bytes
51+
have been allocated). *amount* is usually specified as less than the
52+
full heap size, with the intention to trigger a collection earlier than when the
53+
heap becomes exhausted, and in the hope that an early collection will prevent
54+
excessive memory fragmentation. This is a heuristic measure, the effect
55+
of which will vary from application to application, as well as
56+
the optimal value of the *amount* parameter.
57+
58+
Calling the function without argument will return the current value of
59+
the threshold. A value of -1 means a disabled allocation threshold.
60+
61+
.. admonition:: Difference to CPython
62+
:class: attention
63+
64+
This function is a MicroPython extension. CPython has a similar
65+
function - ``set_threshold()``, but due to different GC
66+
implementations, its signature and semantics are different.

0 commit comments

Comments
 (0)