summaryrefslogtreecommitdiff
path: root/py
AgeCommit message (Collapse)Author
2016-11-30py/asmthumb: Fix build for F7 MCUs after recent code refactoring.Damien George
2016-11-28py: Factor out common code from assemblers into asmbase.[ch].Damien George
All assemblers should "derive" from mp_asm_base_t.
2016-11-26py/compile: Remove comment about TODO for short circuiting for if-stmt.Damien George
Short circuiting is handled correctly by c_if_cond, and constants within short-circuit expressions are optimised by the parser.
2016-11-22py/objtype: Implement __call__ handling for an instance w/o heap alloc.Paul Sokolovsky
By refactoring and reusing code from objboundmeth.
2016-11-21stmhal/moduselect: Move to extmod/ for reuse by other ports.Paul Sokolovsky
2016-11-16py/lexer: Make lexer use an mp_reader as its source.Damien George
2016-11-16py/lexer: Rewrite mp_lexer_new_from_fd in terms of mp_reader.Damien George
2016-11-16py/lexer: Provide generic mp_lexer_new_from_file based on mp_reader.Damien George
If a port defines MICROPY_READER_POSIX or MICROPY_READER_FATFS then lexer.c now provides an implementation of mp_lexer_new_from_file using the mp_reader_new_file function.
2016-11-16py/lexer: Rewrite mp_lexer_new_from_str_len in terms of mp_reader_mem.Damien George
2016-11-16py: Factor out persistent-code reader into separate files.Damien George
Implementations of persistent-code reader are provided for POSIX systems and systems using FatFS. Macros to use these are MICROPY_READER_POSIX and MICROPY_READER_FATFS respectively. If an alternative implementation is needed then a port can define the function mp_reader_new_file.
2016-11-16py: Factor persistent code load/save funcs into persistentcode.[ch].Damien George
2016-11-15py/parse: Add code to fold logical constants in or/and/not operations.Damien George
Adds about 200 bytes to the code size when constant folding is enabled.
2016-11-15py/parse: Make mp_parse_node_new_leaf an inline function.Damien George
It is split into 2 functions, one to make small ints and the other to make a non-small-int leaf node. This reduces code size by 32 bytes on bare-arm, 64 bytes on unix (x64-64) and 144 bytes on stmhal.
2016-11-15py/parse: Move function to check for const parse node to parse.[ch].Damien George
2016-11-15py/*.mk: Replace uses of 'sed' with $(SED).Damien George
2016-11-15py/mkrules.mk: Rework find command so it works on OSX.Dave Hylands
The Mac version of find doesn't support -printf, so this changes things to use sed to strip off the leading path element instead.
2016-11-15py/runtime: mp_resume: Fix exception handling for nanbox port.Paul Sokolovsky
2016-11-15py/runtime: mp_resume: Handle exceptions in Python __next__().Paul Sokolovsky
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.
2016-11-14py/objexcept: Allow clearing traceback with 'exc.__traceback__ = None'.Paul Sokolovsky
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).
2016-11-14all: Remove readall() method, which is equivalent to read() w/o args.Paul Sokolovsky
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.
2016-11-10py/emitnative: Fix native import emitter when in viper mode.Damien George
2016-11-08py: Strip leading dirs from frozen mpy files, so any path can be used.Damien George
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/.
2016-11-08py: Move frozen bytecode Makefile rules from ports to common mk files.Damien George
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.
2016-11-03py: Add MICROPY_FLOAT_CONST macro for defining float constants.Damien George
All float constants in the core should use this macro to prevent unnecessary creation of double-precision floats, which makes code less efficient.
2016-11-03py: Change config default so m_malloc0 uses memset if GC not enabled.Colin Hogben
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.
2016-11-02py: Fix wrong assumption that m_renew will not move if shrinkingColin Hogben
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.
2016-11-02unix: fix symbol references for x86 MacJan Pochyla
2016-10-31py: remove asserts that are always true in emitbc.cPavol Rusnak
2016-10-31py: fix null pointer dereference in mpz.c, fix missing va_end in warning.cPavol Rusnak
2016-10-30py/sequence: Fix reverse slicing of lists.Fabio Utzig
2016-10-30extmod/utime_mphal: Allow ticks functions period be configurable by a port.Paul Sokolovsky
Using MICROPY_PY_UTIME_TICKS_PERIOD config var.
2016-10-27py/stream: Typo fix in comment.Paul Sokolovsky
2016-10-26extmod/moduos_dupterm: Renamed to uos_dupterm.Paul Sokolovsky
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/).
2016-10-24py: Add "delattr" builtin, conditional on MICROPY_CPYTHON_COMPAT.Damien George
2016-10-24py/modbuiltins: Add builtin "slice", pointing to existing slice type.Damien George
2016-10-22py/{modbuiltins,obj}: Use MP_PYTHON_PRINTER where possible.Paul Sokolovsky
2016-10-21lib/utils/pyhelp.c: Use mp_printf() instead of printf()Erik Moqvist
This patch introduces MP_PYTHON_PRINTER for general use.
2016-10-21py: Specialise builtin funcs to use separate type for fixed arg count.Damien George
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.
2016-10-21py: Be more specific with MP_DECLARE_CONST_FUN_OBJ macros.Damien George
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.
2016-10-21py/py.mk: Automatically add frozen.c to source list if FROZEN_DIR is defined.Paul Sokolovsky
Now frozen modules generation handled fully by py.mk and available for reuse by any port.
2016-10-17py: Use mp_raise_msg helper function where appropriate.Damien George
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.
2016-10-17py/objdict: Actually provide the key that failed in KeyError exception.Damien George
The failed key is available as exc.args[0], as per CPython.
2016-10-17py/objdict: Fix optimisation for allocating result in fromkeys.Damien George
Iterables don't respond to __len__, so call __len__ on the original argument.
2016-10-14extmod/utime_mphal: Factor out implementations in terms of mp_hal_* for reuse.Paul Sokolovsky
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.
2016-10-14py/vstr: Combine vstr_new_size with vstr_new since they are rarely used.Damien George
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).
2016-10-13extmod/modujson: Implement ujson.load() to load JSON from a stream.Damien George
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.
2016-10-12esp8266: Enable importing of precompiled .mpy files.Damien George
2016-10-12py/lexer: Remove unnecessary code, and unreachable code.Damien George
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.
2016-10-12py/compile: Remove debugging code for compiler dispatch.Damien George
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.
2016-10-11py/objint: Use size_t for arguments that measure bytes/sizes.Damien George