| Commit message (Collapse) | Author | Age |
| |
|
| |
|
| |
|
| |
|
|
|
|
| |
Using MICROPY_PY_UTIME_TICKS_PERIOD config var.
|
| |
|
|
|
|
|
|
| |
As part of file naming clean up (moduos_dupterm doesn't implement a
full module, so should skip "mod" prefix, similar to other files in
extmod/).
|
| |
|
| |
|
| |
|
|
|
|
| |
This patch introduces MP_PYTHON_PRINTER for general use.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Builtin functions with a fixed number of arguments (0, 1, 2 or 3) are
quite common. Before this patch the wrapper for such a function cost
3 machine words. After this patch it only takes 2, which can reduce the
code size by quite a bit (and pays off even more, the more functions are
added). It also makes function dispatch slightly more efficient in CPU
usage, and furthermore reduces stack usage for these cases. On x86 and
Thumb archs the dispatch functions are now tail-call optimised by the
compiler.
The bare-arm port has its code size increase by 76 bytes, but stmhal drops
by 904 bytes. Stack usage by these builtin functions is decreased by 48
bytes on Thumb2 archs.
|
|
|
|
|
|
|
| |
In order to have more fine-grained control over how builtin functions are
constructed, the MP_DECLARE_CONST_FUN_OBJ macros are made more specific,
with suffix of _0, _1, _2, _3, _VAR, _VAR_BETEEN or _KW. These names now
match the MP_DEFINE_CONST_FUN_OBJ macros.
|
|
|
|
|
| |
Now frozen modules generation handled fully by py.mk and available for reuse
by any port.
|
|
|
|
|
| |
Saves the following number of bytes of code space: 176 for bare-arm, 352
for minimal, 272 for unix x86-64, 140 for stmhal, 120 for esp8266.
|
|
|
|
| |
The failed key is available as exc.args[0], as per CPython.
|
|
|
|
|
| |
Iterables don't respond to __len__, so call __len__ on the original
argument.
|
|
|
|
|
|
| |
As long as a port implement mp_hal_sleep_ms(), mp_hal_ticks_ms(), etc.
functions, it can just use standard implementations of utime.sleel_ms(),
utime.ticks_ms(), etc. Python-level functions.
|
|
|
|
|
|
|
| |
Now there is just one function to allocate a new vstr, namely vstr_new
(in addition to vstr_init etc). The caller of this function should know
what initial size to allocate for the buffer, or at least have some policy
or config option, instead of leaving it to a default (as it was before).
|
|
|
|
|
|
|
| |
This refactors ujson.loads(s) to behave as ujson.load(StringIO(s)).
Increase in code size is: 366 bytes for unix x86-64, 180 bytes for
stmhal, 84 bytes for esp8266.
|
| |
|
|
|
|
|
|
|
|
|
| |
Setting emit_dent=0 is unnecessary because arriving in that part of the
if-logic will guarantee that emit_dent is already zero.
The block to check indent_top(lex)>0 is unreachable because a newline is
always inserted an the end of the input stream, and hence dedents are
always processed before EOF.
|
|
|
|
|
| |
It was a relic from the days of developing the compiler and is no longer
needed, and it's impossible to trigger via a test.
|
| |
|
| |
|
| |
|
|
|
|
| |
The check for division by zero is made by the caller of this function.
|
| |
|
|
|
|
| |
This allows to get/set at runtime the optimisation level of the compiler.
|
|
|
|
| |
Also, drop deprecated (as for MicroPython) readall() method.
|
|
|
|
|
| |
This is an often used code pattern, and its use reduces code size of the
core by about 100 bytes.
|
|
|
|
|
| |
The deleted code is unreachable because calcsize_items guarantees that
num_items corresponds to how many items there are in fmt to unpack.
|
|
|
|
| |
Reduces code size for some archs.
|
|
|
|
|
|
|
| |
Similar to how binary op already works. Common unary operations already
have fast paths for bool so there's no need to have explicit handling of
ops in bool_unary_op, especially since they have the same behaviour as
integers.
|
| |
|
| |
|
|
|
|
| |
Saves 50-100 bytes of code.
|
|
|
|
|
|
|
|
|
|
| |
On 32-bit archs this makes the scope_t struct 48 bytes in size, which fits
in 3 GC blocks (previously it used 4 GC blocks). This will lead to some
savings when compiling scripts because there are usually quite a few scopes,
one for each function and class.
Note that qstrs will fit in 16 bits, this assumption is made in a few other
places.
|
|
|
|
| |
Generates slightly smaller and more efficient code.
|
|
|
|
|
| |
There is now just the exception instance on the stack when an exception is
raised, not the full (type, exc, traceback).
|
| |
|
|
|
|
|
|
|
|
|
| |
Following how other objects work, set/frozenset methods should use the
mp_check_self() macro to check the type of the self argument, because in
most cases this check can be a null operation.
Saves about 100-180 bytes of code for builds with set and frozenset
enabled.
|
|
|
|
| |
It's simpler and improves code coverage.
|
|
|
|
|
| |
The native emitter/compiler restricts viper functions to 4 args, so there
is no need for an extra check in the dynamic dispatch.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
| |
Having a micropython.const identity function, and writing "from micropython
import const" at the start of scripts that use the const feature, allows to
write scripts which are compatible with CPython, and with uPy builds that
don't include const optimisation.
This patch adds such a function and updates the tests to do the import.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When an exception is raised and is to be handled by the VM, it is stored
on the Python value stack so the bytecode can access it. CPython stores
3 objects on the stack for each exception: exc type, exc instance and
traceback. uPy followed this approach, but it turns out not to be
necessary. Instead, it is enough to store just the exception instance on
the Python value stack. The only place where the 3 values are needed
explicitly is for the __exit__ handler of a with-statement context, but
for these cases the 3 values can be extracted from the single exception
instance.
This patch removes the need to store 3 values on the stack, and instead
just stores the exception instance.
Code size is reduced by about 50-100 bytes, the compiler and VM are
slightly simpler, generate bytecode is smaller (by 2 bytes for each try
block), and the Python value stack is reduced in size for functions that
handle exceptions.
|
| |
|