summaryrefslogtreecommitdiffstatshomepage
path: root/py
Commit message (Collapse)AuthorAge
* py/modsys: Initial implementation of sys.getsizeof().Paul Sokolovsky2017-08-11
| | | | | Implemented as a new MP_UNARY_OP. This patch adds support lists, dicts and instances.
* all: Make use of $(TOP) variable in Makefiles, instead of "..".Damien George2017-08-11
| | | | | $(TOP) is defined in py/mkenv.mk and should be used to refer to the top level of this repository.
* py/objstr: Raise an exception for wrong type on RHS of str binary op.Damien George2017-08-09
| | | | | The main case to catch is invalid types for the containment operator, of the form str.__contains__(non-str).
* py/objtuple: Allow to use inplace-multiplication operator on tuples.Damien George2017-08-09
|
* py/mkrules.mk: Show frozen modules sizes together with executable size.Paul Sokolovsky2017-08-06
| | | | This works for Unix and similar ports so far.
* py,extmod,stmhal: Use "static inline" for funcs that should be inline.Damien George2017-08-02
| | | | | "STATIC inline" can expand to "inline" if STATIC is defined to nothing, and this case can lead to link errors.
* all: Use the name MicroPython consistently in commentsAlexander Steffen2017-07-31
| | | | | There were several different spellings of MicroPython present in comments, when there should be only one.
* py/modsys: Use MP_ROM_INT for int values in an mp_rom_map_elem_t.Damien George2017-07-31
|
* py/modio: BufferedWriter: Convert to mp_rom_map_elem_t.Paul Sokolovsky2017-07-28
|
* py: Implement raising a big-int to a negative power.Damien George2017-07-25
| | | | | Before this patch raising a big-int to a negative power would just return 0. Now it returns a floating-point number with the correct value.
* py/mpz: Make mpz_is_zero() an inline function.Damien George2017-07-25
| | | | It's more efficient as an inline function, and saves code size.
* all: Don't include system errno.h when it's not needed.Damien George2017-07-24
|
* py/mperrno: Allow mperrno.h to be correctly included before other hdrs.Damien George2017-07-24
| | | | | | Before this patch the mperrno.h file could be included and would silently succeed with incorrect config settings, because mpconfig.h was not yet included.
* py/py.mk: Make berkeley-db C-defs apply only to relevant source files.Damien George2017-07-24
| | | | | Otherwise they can interfere (eg redefinition of "abort") with other source files in a given uPy port.
* py/builtinevex: Add typechecking of globals/locals args to eval/exec.Tom Collins2017-07-21
|
* all: Remove trailing spaces, per coding conventions.Damien George2017-07-19
|
* py/modmicropython: Cast stack_limit value so it prints correctly.Damien George2017-07-18
| | | | Without this cast the print will give a wrong result on nan-boxing builds.
* py/asmx64: Support moving a 64-bit immediate to one of top 8 registers.Damien George2017-07-18
| | | | | | | If constants (eg mp_const_none_obj) are placed in very high memory locations that require 64-bits for the pointer then the assembler must be able to emit instructions to move such pointers to one of the top 8 registers (ie r8-r15).
* py/vm: Make n_state variable local to just set-up part of VM.Damien George2017-07-18
| | | | | | It's not used anywhere else in the VM loop, and clashes with (is shadowed by) the n_state variable that's redeclared towards the end of the mp_execute_bytecode function. Code size is unchanged.
* all: Unify header guard usage.Alexander Steffen2017-07-18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The code conventions suggest using header guards, but do not define how those should look like and instead point to existing files. However, not all existing files follow the same scheme, sometimes omitting header guards altogether, sometimes using non-standard names, making it easy to accidentally pick a "wrong" example. This commit ensures that all header files of the MicroPython project (that were not simply copied from somewhere else) follow the same pattern, that was already present in the majority of files, especially in the py folder. The rules are as follows. Naming convention: * start with the words MICROPY_INCLUDED * contain the full path to the file * replace special characters with _ In addition, there are no empty lines before #ifndef, between #ifndef and one empty line before #endif. #endif is followed by a comment containing the name of the guard macro. py/grammar.h cannot use header guards by design, since it has to be included multiple times in a single C file. Several other files also do not need header guards as they are only used internally and guaranteed to be included only once: * MICROPY_MPHALPORT_H * mpconfigboard.h * mpconfigport.h * mpthreadport.h * pin_defs_*.h * qstrdefs*.h
* py/gc: Refactor assertions in gc_free function.Damien George2017-07-12
| | | | | gc_free() expects either NULL or a valid pointer into the heap, so the checks for a valid pointer can be turned into assertions.
* py/compile: Fix enum variable declaration.Damien George2017-07-09
|
* py/objgenerator: Allow to hash generators and generator instances.Damien George2017-07-07
| | | | | Adds nothing to the code size, since it uses existing empty slots in the type structures.
* py,extmod: Some casts and minor refactors to quiet compiler warnings.Tom Collins2017-07-07
|
* py/compile: Use switch-case to match token and operator.Krzysztof Blazewicz2017-07-05
| | | | Reduces code size.
* py/compile: Combine arith and bit-shift ops into 1 compile routine.Krzysztof Blazewicz2017-07-05
| | | | This refactoring saves code space.
* py/repl: Change mp_uint_t to size_t in repl helpers.Damien George2017-07-04
|
* py: Change mp_uint_t to size_t in builtins code.Damien George2017-07-04
|
* py/objdict: Factorise dict accessor helper to reduce code size.Damien George2017-07-04
| | | | | | | | | | | | Code size change in bytes for this patch is: bare-arm: -72 minimal x86: -48 unix x64: -32 unix nanbox: -120 stmhal: -68 cc3200: -64 esp8266: -56
* py/makeversionhdr.py: Update to parse new release line in docs/conf.py.Damien George2017-07-04
| | | | | The line in docs/conf.py with the release/version number was recently changed and this patch makes the makeversionhdr.py script work again.
* py/modmath: Check for zero division in log with 2 args.Damien George2017-07-04
|
* py/vm: Make "if" control flow more obvious in YIELD_FROM opcode.Damien George2017-07-04
|
* py/objstr: Remove unnecessary "sign" variable in formatting code.Damien George2017-07-04
|
* py/runtime: Mark m_malloc_fail() as NORETURN.Damien George2017-07-04
|
* py/binary: Add missing "break" statements.Damien George2017-07-04
|
* py/objstr: Move uPy function wrappers to just after the C function.Damien George2017-07-02
| | | | This matches the coding/layout style of all the other objects.
* py/mpprint: Remove unreachable check for neg return of mp_format_float.Damien George2017-06-30
|
* py/objnamedtuple: Simplify and remove use of alloca building namedtuple.Damien George2017-06-29
| | | | | | | | | | | | | | | | Prior to this patch there were 2 paths for creating the namedtuple, one for when no keyword args were passed, and one when there were keyword args. And alloca was used in the keyword-arg path to temporarily create the array of elements for the namedtuple, which would then be copied to a heap-allocated object (the namedtuple itself). This patch simplifies the code by combining the no-keyword and keyword paths, and removing the need for the alloca by constructing the namedtuple on the heap before populating it. Heap usage in unchanged, stack usage is reduced, use of alloca is removed, and code size is not increased and is actually reduced by between 20-30 bytes for most ports.
* py/builtinimport: Remove unreachable code for relative imports.Damien George2017-06-28
| | | | | | | | | | | | The while-loop that calls chop_component will guarantee that level==-1 at the end of the loop. Hence the code following it is unnecessary. The check for p==this_name will catch imports that are beyond the top-level, and also covers the case of new_mod_q==MP_QSTR_ (equivalent to new_mod_l==0) so that check is removed. There is also a new check at the start for level>=0 to guard against __import__ being called with bad level values.
* py/frozenmod.h: Add missing header guardsAlexander Steffen2017-06-28
|
* py/mpconfig.h: Remove spaces in "Micro Python" and remove blank line.Damien George2017-06-26
|
* py/compile: Optimise emitter label indices to save a word of heap.Damien George2017-06-22
| | | | | | | Previous to this patch, a label with value "0" was used to indicate an invalid label, but that meant a wasted word (at slot 0) in the array of label offsets. This patch adjusts the label indices so the first one starts at 0, and the maximum value indicates an invalid label.
* py/compile: Fix bug with break/continue in else of optimised for-range.Damien George2017-06-22
| | | | | | | | | | | | | | | | | This patch fixes a bug whereby the Python stack was not correctly reset if there was a break/continue statement in the else black of an optimised for-range loop. For example, in the following code the "j" variable from the inner for loop was not being popped off the Python stack: for i in range(4): for j in range(4): pass else: continue This is now fixed with this patch.
* py/objint: In to_bytes(), allow length arg to be any int and check sign.Damien George2017-06-15
|
* py/objint: Support "big" byte-order in int.to_bytes().Damien George2017-06-15
|
* all: Make more use of mp_raise_{msg,TypeError,ValueError} helpers.Damien George2017-06-15
|
* py/compile: Raise SyntaxError if positional args are given after */**.Damien George2017-06-14
| | | | | | | | In CPython 3.4 this raises a SyntaxError. In CPython 3.5+ having a positional after * is allowed but uPy has the wrong semantics and passes the arguments in the incorrect order. To prevent incorrect use of a function going unnoticed it is important to raise the SyntaxError in uPy, until the behaviour is fixed to follow CPython 3.5+.
* py/modthread: Raise RuntimeError in release() if lock is not acquired.Damien George2017-06-14
|
* py/formatfloat: Fix number of digits and exponent sign when rounding.Damien George2017-06-13
| | | | | | | This patch fixes 2 things when printing a floating-point number that requires rounding up of the mantissa: - retain the correct precision; eg 0.99 becomes 1.0, not 1.00 - if the exponent goes from -1 to 0 then render it as +0, not -0
* py/objstringio: If created from immutable object, follow copy on write policy.Paul Sokolovsky2017-06-09
| | | | | Don't create copy of immutable object's contents until .write() is called on BytesIO.