summaryrefslogtreecommitdiffstatshomepage
path: root/py
Commit message (Collapse)AuthorAge
* unix: fix symbol references for x86 MacJan Pochyla2016-11-02
|
* py: remove asserts that are always true in emitbc.cPavol Rusnak2016-10-31
|
* py: fix null pointer dereference in mpz.c, fix missing va_end in warning.cPavol Rusnak2016-10-31
|
* py/sequence: Fix reverse slicing of lists.Fabio Utzig2016-10-30
|
* extmod/utime_mphal: Allow ticks functions period be configurable by a port.Paul Sokolovsky2016-10-30
| | | | Using MICROPY_PY_UTIME_TICKS_PERIOD config var.
* py/stream: Typo fix in comment.Paul Sokolovsky2016-10-27
|
* extmod/moduos_dupterm: Renamed to uos_dupterm.Paul Sokolovsky2016-10-26
| | | | | | 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/).
* py: Add "delattr" builtin, conditional on MICROPY_CPYTHON_COMPAT.Damien George2016-10-24
|
* py/modbuiltins: Add builtin "slice", pointing to existing slice type.Damien George2016-10-24
|
* py/{modbuiltins,obj}: Use MP_PYTHON_PRINTER where possible.Paul Sokolovsky2016-10-22
|
* lib/utils/pyhelp.c: Use mp_printf() instead of printf()Erik Moqvist2016-10-21
| | | | This patch introduces MP_PYTHON_PRINTER for general use.
* py: Specialise builtin funcs to use separate type for fixed arg count.Damien George2016-10-21
| | | | | | | | | | | | | | | 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.
* py: Be more specific with MP_DECLARE_CONST_FUN_OBJ macros.Damien George2016-10-21
| | | | | | | 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.
* py/py.mk: Automatically add frozen.c to source list if FROZEN_DIR is defined.Paul Sokolovsky2016-10-21
| | | | | Now frozen modules generation handled fully by py.mk and available for reuse by any port.
* py: Use mp_raise_msg helper function where appropriate.Damien George2016-10-17
| | | | | 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.
* py/objdict: Actually provide the key that failed in KeyError exception.Damien George2016-10-17
| | | | The failed key is available as exc.args[0], as per CPython.
* py/objdict: Fix optimisation for allocating result in fromkeys.Damien George2016-10-17
| | | | | Iterables don't respond to __len__, so call __len__ on the original argument.
* extmod/utime_mphal: Factor out implementations in terms of mp_hal_* for reuse.Paul Sokolovsky2016-10-14
| | | | | | 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.
* py/vstr: Combine vstr_new_size with vstr_new since they are rarely used.Damien George2016-10-14
| | | | | | | 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).
* extmod/modujson: Implement ujson.load() to load JSON from a stream.Damien George2016-10-13
| | | | | | | 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.
* esp8266: Enable importing of precompiled .mpy files.Damien George2016-10-12
|
* py/lexer: Remove unnecessary code, and unreachable code.Damien George2016-10-12
| | | | | | | | | 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.
* py/compile: Remove debugging code for compiler dispatch.Damien George2016-10-12
| | | | | 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.
* py/objint: Use size_t for arguments that measure bytes/sizes.Damien George2016-10-11
|
* py: Factor duplicated function to calculate size of formatted int.Damien George2016-10-11
|
* py/mpz: Use assert to verify mpz does not have a fixed digit buffer.Damien George2016-10-11
|
* py/mpz: In divmod, replace check for rhs!=0 with assert.Damien George2016-10-11
| | | | The check for division by zero is made by the caller of this function.
* py/compile: Remove unreachable code.Damien George2016-10-11
|
* py/modmicropython: Add micropython.opt_level([value]) function.Damien George2016-10-11
| | | | This allows to get/set at runtime the optimisation level of the compiler.
* py/objstringio: Add readinto() method.Paul Sokolovsky2016-10-09
| | | | Also, drop deprecated (as for MicroPython) readall() method.
* py: Add mp_raise_OSError(errno) helper function.Damien George2016-10-07
| | | | | This is an often used code pattern, and its use reduces code size of the core by about 100 bytes.
* py/modstruct: Remove unreachable code, and add comment about CPy diff.Damien George2016-10-07
| | | | | The deleted code is unreachable because calcsize_items guarantees that num_items corresponds to how many items there are in fmt to unpack.
* py/objbool: Make a slight simplification of bool constructor.Damien George2016-09-30
| | | | Reduces code size for some archs.
* py/objbool: Defer bool's unary op implementation to small int.Damien George2016-09-30
| | | | | | | 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.
* py/argcheck: Simplify if-chain so that the last one is the default.Damien George2016-09-30
|
* py/compile: Fix typo when checking for parse-node kind.Damien George2016-09-30
|
* py/scope: Factor common code to find locals and close over them.Damien George2016-09-30
| | | | Saves 50-100 bytes of code.
* py/scope: Shrink scope_t struct by 1 machine word.Damien George2016-09-30
| | | | | | | | | | 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.
* py/scope: Use lookup-table to determine a scope's simple name.Damien George2016-09-30
| | | | Generates slightly smaller and more efficient code.
* py/compile: Fix async-for/async-with to work with simpler exc on stack.Damien George2016-09-28
| | | | | There is now just the exception instance on the stack when an exception is raised, not the full (type, exc, traceback).
* py/objset: Ensure that use of frozenset.update raises an exception.Damien George2016-09-28
|
* py/objset: Use mp_check_self() to check args of set/frozenset methods.Damien George2016-09-28
| | | | | | | | | 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.
* py/objfun: Use if instead of switch to check return value of VM execute.Damien George2016-09-27
| | | | It's simpler and improves code coverage.
* py/objfun: Remove unnecessary check for viper fun with 5 or more args.Damien George2016-09-27
| | | | | The native emitter/compiler restricts viper functions to 4 args, so there is no need for an extra check in the dynamic dispatch.
* py/emitbc: Remove/refactor unreachable code, to improve coverage.Damien George2016-09-27
|
* py/objstr: Remove unreachable function used only for terse error msgs.Damien George2016-09-27
|
* py/modmicropython: Add micropython.const, alias for identity function.Damien George2016-09-27
| | | | | | | | | 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.
* py/vm: Use MP_OBJ_FROM_PTR to cast a type to an object.Damien George2016-09-27
|
* py: Only store the exception instance on Py stack in bytecode try block.Damien George2016-09-27
| | | | | | | | | | | | | | | | | | | | 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.
* py/py.mk: Add support for building modussl_mbedtls.Paul Sokolovsky2016-09-23
|