MicroPython 与 CPython 的差异 ¶
本章节列出的操作是在 MicroPython 中产生冲突的结果,相较标准 Python。MicroPython 实现了 Python 3.4 和 Python 3.5 的一些选择特征。
- 句法
-
核心语言
- f-strings don’t support concatenation with adjacent literals if the adjacent literals contain braces
- f-strings cannot support expressions that require parsing to resolve nested braces
- Raw f-strings are not supported
- f-strings don’t support the !r, !s, and !a conversions
- Special method __del__ not implemented for user-defined classes
- Method Resolution Order (MRO) is not compliant with CPython
- When inheriting from multiple classes super() only calls one class
- Calling super() getter property in subclass will return a property object, not the value
- Error messages for methods may display unexpected argument counts
-
Function objects do not have the
__module__
attribute - User-defined attributes for functions are not supported
- Context manager __exit__() not called in a generator which does not run to completion
- Local variables aren’t included in locals() result
- Code running in eval() function doesn’t have access to local variables
- __all__ is unsupported in __init__.py in MicroPython.
- __path__ attribute of a package has a different type (single string instead of list of strings) in MicroPython
- Failed to load modules are still registered as loaded
- MicroPython does’t support namespace packages split across filesystem.
- 内置类型
- 模块