summaryrefslogtreecommitdiffstatshomepage
path: root/py
Commit message (Collapse)AuthorAge
* py/parse: Move function to check for const parse node to parse.[ch].Damien George2016-11-15
|
* py/*.mk: Replace uses of 'sed' with $(SED).Damien George2016-11-15
|
* py/mkrules.mk: Rework find command so it works on OSX.Dave Hylands2016-11-15
| | | | | The Mac version of find doesn't support -printf, so this changes things to use sed to strip off the leading path element instead.
* py/runtime: mp_resume: Fix exception handling for nanbox port.Paul Sokolovsky2016-11-15
|
* py/runtime: mp_resume: Handle exceptions in Python __next__().Paul Sokolovsky2016-11-15
| | | | | | | | 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.
* py/objexcept: Allow clearing traceback with 'exc.__traceback__ = None'.Paul Sokolovsky2016-11-14
| | | | | | | | | | | | | 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).
* all: Remove readall() method, which is equivalent to read() w/o args.Paul Sokolovsky2016-11-14
| | | | | | 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.
* py/emitnative: Fix native import emitter when in viper mode.Damien George2016-11-10
|
* py: Strip leading dirs from frozen mpy files, so any path can be used.Damien George2016-11-08
| | | | | | | | 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/.
* py: Move frozen bytecode Makefile rules from ports to common mk files.Damien George2016-11-08
| | | | | | 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.
* py: Add MICROPY_FLOAT_CONST macro for defining float constants.Damien George2016-11-03
| | | | | | All float constants in the core should use this macro to prevent unnecessary creation of double-precision floats, which makes code less efficient.
* py: Change config default so m_malloc0 uses memset if GC not enabled.Colin Hogben2016-11-03
| | | | | 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.
* py: Fix wrong assumption that m_renew will not move if shrinkingColin Hogben2016-11-02
| | | | | | | | | | | | | | | | 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.
* 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.