Skip to content
Merged
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
11 changes: 8 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,15 @@ Differences from `MicroPython <https://github.com/micropython/micropython>`__

CircuitPython:

- includes a port for Atmel SAMD21 (Commonly known as M0 in Adafruit
product names.)
- supports only Atmel SAMD21 and ESP8266 ports.
- includes a ports for MicroChip SAMD21 (Commonly known as M0 in Adafruit
product names and SAMD51 (M4).
- supports only SAMD21, SAMD51, and ESP8266 ports. An nRF port is under
development.
- tracks MicroPython's releases (not master).
- Longints (arbitrary-length integers) are enabled for most M0
Express boards (those boards with SPI flash chips external
to the microcontroller), and for all M4 builds.
Longints are disabled on other boards due to lack of flash space.

Behavior
~~~~~~~~
Expand Down
4 changes: 2 additions & 2 deletions docs/design_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -441,10 +441,10 @@ buffers.
Examples
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

ustruct.pack
struct.pack
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Use `ustruct.pack_into` instead of `ustruct.pack`.
Use `struct.pack_into` instead of `struct.pack`.

Sensor properties and units
--------------------------------------------------------------------------------
Expand Down
2 changes: 0 additions & 2 deletions docs/library/array.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
:mod:`array` -- arrays of numeric data
======================================

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd prefer to have these docs inline rather than in files separate from the implementation. Until then I'd like to call them unsupported because its hard to keep them up to date.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I'm reluctant to call them unsupported. To me that means you shouldn't use them, or that we wouldn't fix bugs in them. If you want to say that they may change in the future, that seems more like what you want to imply. But we couldn't write a lot of useful code without struct, array, sys, os, etc. in our libraries and use them in Learn Guides, so maybe something milder than "unsupported".

.. include:: ../templates/unsupported_in_circuitpython.inc

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

Expand Down
18 changes: 9 additions & 9 deletions docs/library/builtins.rst
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
Builtin functions and exceptions
================================

.. warning::

These builtins are inherited from MicroPython and may not work in CircuitPython
as documented or at all! If work differently from CPython, then their behavior
may change.

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

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

Not all of these functions and types are turned on in all CircuitPython ports, for space reasons.

.. function:: abs()

.. function:: all()
Expand Down Expand Up @@ -62,6 +58,8 @@ Functions and types

.. class:: frozenset()

`frozenset()` is not enabled on non-Express CircuitPython boards.

.. function:: getattr()

.. function:: globals()
Expand All @@ -80,12 +78,12 @@ Functions and types

.. classmethod:: from_bytes(bytes, byteorder)

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

.. method:: to_bytes(size, byteorder)

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

.. function:: isinstance()
Expand Down Expand Up @@ -130,6 +128,8 @@ Functions and types

.. function:: reversed()

`reversed()` is not enabled on non-Express CircuitPython boards.

.. function:: round()

.. class:: set()
Expand Down Expand Up @@ -182,7 +182,7 @@ Exceptions

.. exception:: OSError

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

Expand Down
6 changes: 3 additions & 3 deletions docs/library/gc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Functions
.. admonition:: Difference to CPython
:class: attention

This function is MicroPython extension.
This function is a MicroPython extension.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Lets not call gc supported until we move the extensions out of here.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

"The functionality of gc may change in the future to more closely match that of CPython."


.. function:: mem_free()

Expand All @@ -41,7 +41,7 @@ Functions
.. admonition:: Difference to CPython
:class: attention

This function is MicroPython extension.
This function is a MicroPython extension.

.. function:: threshold([amount])

Expand All @@ -63,6 +63,6 @@ Functions
.. admonition:: Difference to CPython
:class: attention

This function is a MicroPython extension. CPython has a similar
This function is a a MicroPython extension. CPython has a similar
function - ``set_threshold()``, but due to different GC
implementations, its signature and semantics are different.
57 changes: 44 additions & 13 deletions docs/library/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,74 @@
MicroPython libraries
=====================

Python standard libraries and micro-libraries
---------------------------------------------

These libraries are inherited from MicroPython.
They are similar to the standard Python libraries with the same name
or with the "u" prefix dropped.
They implement a subset of or a variant of the corresponding
standard Python library.

.. warning::

These modules are inherited from MicroPython and may not work in CircuitPython
as documented or at all! If they do work, they may change at any time.
Though these MicroPython-based libraries are available in CircuitPython,
their functionality may change in the future, perhaps significantly.
As CircuitPython continues to develop, new versions of these libraries will
be created that are more compliant with the standard Python libraries.
You may need to change your code later if you rely
on any non-standard functionality they currently provide.

CircuitPython's goal long-term goalis that code written in CircuitPython
using Python standard libraries will be runnable on CPython without changes.

Python standard libraries and micro-libraries
---------------------------------------------
Some libraries below are not enabled on CircuitPython builds with
limited flash memory, usually on non-Express builds:
``uerrno``, ``ure``.

Some libraries are not currently enabled in any CircuitPython build, but may be in the future:
``uio``, ``ujson``, ``uzlib``.

Some libraries are only enabled only WiFi-capable ports (ESP8266, nRF)
because they are typically used for network software:
``binascii``, ``hashlib``, ``uheapq``, ``uselect``, ``ussl``.
Not all of these are enabled on all WiFi-capable ports.

.. toctree::
:maxdepth: 1

builtins.rst
uheapq.rst
array.rst
gc.rst
sys.rst
binascii.rst
collections.rst
uerrno.rst
gc.rst
hashlib.rst
uheapq.rst
sys.rst
uerrno.rst
uio.rst
ujson.rst
ure.rst
uselect.rst
usocket.rst
ussl.rst
ustruct.rst
uzlib.rst

Omitted functions in the ``string`` library
-------------------------------------------

A few string operations are not enabled on CircuitPython
M0 non-Express builds, due to limited flash memory:
``string.center()``, ``string.partition()``, ``string.splitlines()``,
``string.reversed()``.


MicroPython-specific libraries
------------------------------
CircuitPython/MicroPython-specific libraries
--------------------------------------------

Functionality specific to the MicroPython implementation is available in
the following libraries.
Functionality specific to the CircuitPython/MicroPython implementation is available in
the following libraries. These libraries may change signficantly or be removed in future
versions of CircuitPtyon.

.. toctree::
:maxdepth: 1
Expand Down
20 changes: 10 additions & 10 deletions docs/library/sys.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,26 +45,26 @@ Constants
.. data:: implementation

Object with information about the current Python implementation. For
MicroPython, it has following attributes:
CircuitPython, it has following attributes:

* *name* - string "micropython"
* *name* - string "circuitpython"
* *version* - tuple (major, minor, micro), e.g. (1, 7, 0)

This object is the recommended way to distinguish MicroPython from other
This object is the recommended way to distinguish CircuitPython from other
Python implementations (note that it still may not exist in the very
minimal ports).

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

CPython mandates more attributes for this object, but the actual useful
bare minimum is implemented in MicroPython.
bare minimum is implemented in CircuitPython.

.. data:: maxsize

Maximum value which a native integer type can hold on the current platform,
or maximum value representable by MicroPython integer type, if it's smaller
than platform max value (that is the case for MicroPython ports without
or maximum value representable by CircuitPython integer type, if it's smaller
than platform max value (that is the case for CircuitPython ports without
long int support).

This attribute is useful for detecting "bitness" of a platform (32-bit vs
Expand Down Expand Up @@ -96,11 +96,11 @@ Constants

.. data:: platform

The platform that MicroPython is running on. For OS/RTOS ports, this is
The platform that CircuitPython is running on. For OS/RTOS ports, this is
usually an identifier of the OS, e.g. ``"linux"``. For baremetal ports it
is an identifier of a board, e.g. ``"pyboard"`` for the original MicroPython
reference board. It thus can be used to distinguish one board from another.
If you need to check whether your program runs on MicroPython (vs other
is an identifier of the chip on a board, e.g. ``"MicroChip SAMD51"``.
It thus can be used to distinguish one board from another.
If you need to check whether your program runs on CircuitPython (vs other
Python implementation), use `sys.implementation` instead.

.. data:: stderr
Expand Down
44 changes: 0 additions & 44 deletions docs/library/ustruct.rst

This file was deleted.

9 changes: 6 additions & 3 deletions docs/templates/unsupported_in_circuitpython.inc
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
.. warning::

This module is inherited from MicroPython and may not work in CircuitPython
as documented or at all! If they do work, they may change at any time. It is
unsupported.
Though this MicroPython-based library is available for use in CircuitPython,
its functionality may change in the future, perhaps significantly.
As CircuitPython continues to develop, it may be changed
to comply more closely with the corresponding standard Python library.
You may need to change your code later if you rely
on any non-standard functionality it currently provides.