Skip to content

Commit f2ebe68

Browse files
committed
Initial MicroPython v1.21.0 merge; not compiled yet
2 parents 9f94b1b + e00a144 commit f2ebe68

File tree

533 files changed

+8122
-4785
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

533 files changed

+8122
-4785
lines changed

.git-blame-ignore-revs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# all: Fix various spelling mistakes found by codespell 2.2.6.
2+
cf490a70917a1b2d38ba9b58e763e0837d0f7ca7
3+
4+
# all: Fix spelling mistakes based on codespell check.
5+
b1229efbd1509654dec6053865ab828d769e29db
6+
17
# top: Update Python formatting to black "2023 stable style".
28
8b2748269244304854b3462cb8902952b4dcb892
39

CODE_OF_CONDUCT.md

Lines changed: 0 additions & 135 deletions
This file was deleted.

docs/library/gc.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Functions
2424

2525
.. function:: mem_alloc()
2626

27-
Return the number of bytes of heap RAM that are allocated.
27+
Return the number of bytes of heap RAM that are allocated by Python code.
2828

2929
.. admonition:: Difference to CPython
3030
:class: attention
@@ -33,8 +33,8 @@ Functions
3333

3434
.. function:: mem_free()
3535

36-
Return the number of bytes of available heap RAM, or -1 if this amount
37-
is not known.
36+
Return the number of bytes of heap RAM that is available for Python
37+
code to allocate, or -1 if this amount is not known.
3838

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

docs/library/gzip.rst

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
:mod:`gzip` -- gzip compression & decompression
2+
===============================================
3+
4+
.. module:: gzip
5+
:synopsis: gzip compression & decompression
6+
7+
|see_cpython_module| :mod:`python:gzip`.
8+
9+
This module allows compression and decompression of binary data with the
10+
`DEFLATE algorithm <https://en.wikipedia.org/wiki/DEFLATE>`_ used by the gzip
11+
file format.
12+
13+
.. note:: Prefer to use :class:`deflate.DeflateIO` instead of the functions in this
14+
module as it provides a streaming interface to compression and decompression
15+
which is convenient and more memory efficient when working with reading or
16+
writing compressed data to a file, socket, or stream.
17+
18+
**Availability:**
19+
20+
* This module is **not present by default** in official MicroPython firmware
21+
releases as it duplicates functionality available in the :mod:`deflate
22+
<deflate>` module.
23+
24+
* A copy of this module can be installed (or frozen)
25+
from :term:`micropython-lib` (`source <https://github.com/micropython/micropython-lib/blob/master/python-stdlib/gzip/gzip.py>`_).
26+
See :ref:`packages` for more information. This documentation describes that module.
27+
28+
* Compression support will only be available if compression support is enabled
29+
in the built-in :mod:`deflate <deflate>` module.
30+
31+
Functions
32+
---------
33+
34+
.. function:: open(filename, mode, /)
35+
36+
Wrapper around built-in :func:`open` returning a GzipFile instance.
37+
38+
.. function:: decompress(data, /)
39+
40+
Decompresses *data* into a bytes object.
41+
42+
.. function:: compress(data, /)
43+
44+
Compresses *data* into a bytes object.
45+
46+
Classes
47+
-------
48+
49+
.. class:: GzipFile(*, fileobj, mode)
50+
51+
This class can be used to wrap a *fileobj* which is any
52+
:term:`stream-like <stream>` object such as a file, socket, or stream
53+
(including :class:`io.BytesIO`). It is itself a stream and implements the
54+
standard read/readinto/write/close methods.
55+
56+
When the *mode* argument is ``"rb"``, reads from the GzipFile instance will
57+
decompress the data in the underlying stream and return decompressed data.
58+
59+
If compression support is enabled then the *mode* argument can be set to
60+
``"wb"``, and writes to the GzipFile instance will be compressed and written
61+
to the underlying stream.
62+
63+
By default the GzipFile class will read and write data using the gzip file
64+
format, including a header and footer with checksum and a window size of 512
65+
bytes.
66+
67+
The **file**, **compresslevel**, and **mtime** arguments are not
68+
supported. **fileobj** and **mode** must always be specified as keyword
69+
arguments.
70+
71+
Examples
72+
--------
73+
74+
A typical use case for :class:`gzip.GzipFile` is to read or write a compressed
75+
file from storage:
76+
77+
.. code:: python
78+
79+
import gzip
80+
81+
# Reading:
82+
with open("data.gz", "rb") as f:
83+
with gzip.GzipFile(fileobj=f, mode="rb") as g:
84+
# Use g.read(), g.readinto(), etc.
85+
86+
# Same, but using gzip.open:
87+
with gzip.open("data.gz", "rb") as f:
88+
# Use f.read(), f.readinto(), etc.
89+
90+
# Writing:
91+
with open("data.gz", "wb") as f:
92+
with gzip.GzipFile(fileobj=f, mode="wb") as g:
93+
# Use g.write(...) etc
94+
95+
# Same, but using gzip.open:
96+
with gzip.open("data.gz", "wb") as f:
97+
# Use f.write(...) etc
98+
99+
# Write a dictionary as JSON in gzip format, with a
100+
# small (64 byte) window size.
101+
config = { ... }
102+
with gzip.open("config.gz", "wb") as f:
103+
json.dump(config, f)
104+
105+
For guidance on working with gzip sources and choosing the window size see the
106+
note at the :ref:`end of the deflate documentation <deflate_wbits>`.

docs/library/platform.rst

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
:mod:`platform` -- access to underlying platform’s identifying data
2+
===================================================================
3+
4+
.. module:: platform
5+
:synopsis: access to underlying platform’s identifying data
6+
7+
|see_cpython_module| :mod:`python:platform`.
8+
9+
This module tries to retrieve as much platform-identifying data as possible. It
10+
makes this information available via function APIs.
11+
12+
Functions
13+
---------
14+
15+
.. function:: platform()
16+
17+
Returns a string identifying the underlying platform. This string is composed
18+
of several substrings in the following order, delimited by dashes (``-``):
19+
20+
- the name of the platform system (e.g. Unix, Windows or MicroPython)
21+
- the MicroPython version
22+
- the architecture of the platform
23+
- the version of the underlying platform
24+
- the concatenation of the name of the libc that MicroPython is linked to
25+
and its corresponding version.
26+
27+
For example, this could be
28+
``"MicroPython-1.20.0-xtensa-IDFv4.2.4-with-newlib3.0.0"``.
29+
30+
.. function:: python_compiler()
31+
32+
Returns a string identifying the compiler used for compiling MicroPython.
33+
34+
.. function:: libc_ver()
35+
36+
Returns a tuple of strings *(lib, version)*, where *lib* is the name of the
37+
libc that MicroPython is linked to, and *version* the corresponding version
38+
of this libc.

docs/library/sys.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Constants
3333

3434
* *name* - string "circuitpython"
3535
* *version* - tuple (major, minor, micro), e.g. (1, 7, 0)
36+
* *_machine* - string describing the underlying machine
3637
* *_mpy* - supported mpy file-format version (optional attribute)
3738

3839
This object is the recommended way to distinguish CircuitPython from other

docs/reference/glossary.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Glossary
3232

3333
callee-owned tuple
3434
This is a MicroPython-specific construct where, for efficiency
35-
reasons, some built-in functions or methods may re-use the same
35+
reasons, some built-in functions or methods may reuse the same
3636
underlying tuple object to return data. This avoids having to allocate
3737
a new tuple for every call, and reduces heap fragmentation. Programs
3838
should not hold references to callee-owned tuples and instead only
@@ -120,7 +120,7 @@ Glossary
120120
<https://github.com/micropython/micropython-lib>`_ which provides
121121
implementations for many modules from CPython's standard library.
122122

123-
Some of the modules are are implemented in pure Python, and are able to
123+
Some of the modules are implemented in pure Python, and are able to
124124
be used on all ports. However, the majority of these modules use
125125
:term:`FFI` to access operating system functionality, and as such can
126126
only be used on the :term:`MicroPython Unix port` (with limited support
@@ -158,8 +158,10 @@ Glossary
158158
network-capable boards, and internally by tools such
159159
as :term:`mpremote`.
160160

161+
See :ref:`packages` for more information on using ``mip``.
162+
161163
mpremote
162-
A tool for interacting with a MicroPython device.
164+
A tool for interacting with a MicroPython device. See :ref:`mpremote`.
163165

164166
.mpy file
165167
The output of the :term:`cross-compiler`. A compiled form of a

0 commit comments

Comments
 (0)