| Commit message (Collapse) | Author | Age |
| |
|
| |
|
|
|
|
|
| |
The Mac version of find doesn't support -printf, so this changes
things to use sed to strip off the leading path element instead.
|
| |
|
|
|
|
|
|
|
|
| |
This includes StopIteration and thus are important to make Python-coded
iterables work with yield from/await.
Exceptions in Python send() are still not handled and left for future
consideration and optimization.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We allow 'exc.__traceback__ = None' assignment as a low-level optimization
of pre-allocating exception instance and raising it repeatedly - this
avoids memory allocation during raise. However, uPy will keep adding
traceback entries to such exception instance, so before throwing it,
traceback should be cleared like above.
'exc.__traceback__ = None' syntax is CPython compatible. However, unlike
it, reading that attribute or setting it to any other value is not
supported (and not intended to be supported, again, the only reason for
adding this feature is to allow zero-memalloc exception raising).
|
|
|
|
|
|
| |
Its addition was due to an early exploration on how to add CPython-like
stream interface. It's clear that it's not needed and just takes up
bytes in all ports.
|
| |
|
|
|
|
|
|
|
|
| |
With this patch one can now do "make FROZEN_MPY_DIR=../../frozen" to
specify a directory containing scripts to be frozen (as well as absolute
paths).
The compiled .mpy files are now stored in $(BUILD)/frozen_mpy/.
|
|
|
|
|
|
| |
Now, to use frozen bytecode all a port needs to do is define
FROZEN_MPY_DIR to the directory containing the .py files to freeze, and
define MICROPY_MODULE_FROZEN_MPY and MICROPY_QSTR_EXTRA_POOL.
|
|
|
|
|
|
| |
All float constants in the core should use this macro to prevent
unnecessary creation of double-precision floats, which makes code less
efficient.
|
|
|
|
|
| |
With MICROPY_ENABLE_GC set to false the alternate memory manager may not
clear all memory that is allocated, so it must be cleared in m_malloc0.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In both parse.c and qstr.c, an internal chunking allocator tidies up
by calling m_renew to shrink an allocated chunk to the size used, and
assumes that the chunk will not move. However, when MICROPY_ENABLE_GC
is false, m_renew calls the system realloc, which does not guarantee
this behaviour. Environments where realloc may return a different
pointer include:
(1) mbed-os with MBED_HEAP_STATS_ENABLED (which adds a wrapper around
malloc & friends; this is where I was hit by the bug);
(2) valgrind on linux (how I diagnosed it).
The fix is to call m_renew_maybe with allow_move=false.
|
| |
|
| |
|
| |
|
| |
|
|
|
|
| |
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.
|