summaryrefslogtreecommitdiffstatshomepage
path: root/py
Commit message (Collapse)AuthorAge
* py: For viper compile errors, add traceback with function and filename.Damien George2015-07-27
| | | | | | | | | ViperTypeError now includes filename and function name where the error occurred. The line number is the line number of the start of the function definition, which is the best that can be done without a lot more work. Partially addresses issue #1381.
* py: Disable REPL EMACS key bindings by default.Damien George2015-07-26
|
* lib/mp-readline: Add emacs-style control characters for cursor movement.Tom Soulanille2015-07-26
| | | | Disabled by default. Adds 108 bytes to Thumb2 arch when enabled.
* py/parse: Fix handling of empty input so it raises an exception.Damien George2015-07-24
|
* py/parse: De-duplicate and simplify code for parser "or" rule.Damien George2015-07-24
|
* py/lexer: Raise SyntaxError when str hex escape sequence is malformed.Damien George2015-07-23
| | | | Addresses issue #1390.
* py: Issue an error when compiling Viper functions with more than 4 args.Damien George2015-07-23
| | | | Otherwise it can be very hard to track down bugs.
* py: Allow viper functions to take up to 4 arguments.Damien George2015-07-23
| | | | Addresses issue #1380.
* py: reduce array slice assignment code sizeDelio Brignoli2015-06-06
|
* py: Small code space optimisations for memoryview slice assigment.Damien George2015-07-20
| | | | | Also adds #if guards to allow uPy core to compile without memoryview enabled, but with slice assignment enabled.
* py: Implement memoryview slice assignment.Delio Brignoli2015-07-20
| | | | | Adds ability to do "memcpy" with memoryview objects, such as: m1[0:3] = m2[2:5].
* py: Make qstr hash size configurable, defaults to 2 bytes.Damien George2015-07-20
| | | | | | | This patch makes configurable, via MICROPY_QSTR_BYTES_IN_HASH, the number of bytes used for a qstr hash. It was originally fixed at 2 bytes, and now defaults to 2 bytes. Setting it to 1 byte will save ROM and RAM at a small expense of hash collisions.
* modbuiltins: Implement round() to precision.Sebastian Plamauer2015-07-19
|
* py: Improve allocation policy of qstr data.Damien George2015-07-14
| | | | | | | | | | | | | | | | | | | | Previous to this patch all interned strings lived in their own malloc'd chunk. On average this wastes N/2 bytes per interned string, where N is the number-of-bytes for a quanta of the memory allocator (16 bytes on 32 bit archs). With this patch interned strings are concatenated into the same malloc'd chunk when possible. Such chunks are enlarged inplace when possible, and shrunk to fit when a new chunk is needed. RAM savings with this patch are highly varied, but should always show an improvement (unless only 3 or 4 strings are interned). New version typically uses about 70% of previous memory for the qstr data, and can lead to savings of around 10% of total memory footprint of a running script. Costs about 120 bytes code size on Thumb2 archs (depends on how many calls to gc_realloc are made).
* py: Prevent many extra vstr allocations.Dave Hylands2015-07-06
| | | | | | | | | | | | | | | | | | | | | | | | | I checked the entire codebase, and every place that vstr_init_len was called, there was a call to mp_obj_new_str_from_vstr after it. mp_obj_new_str_from_vstr always tries to reallocate a new buffer 1 byte larger than the original to store the terminating null character. In many cases, if we allocated the initial buffer to be 1 byte longer, we can prevent this extra allocation, and just reuse the originally allocated buffer. Asking to read 256 bytes and only getting 100 will still cause the extra allocation, but if you ask to read 256 and get 256 then the extra allocation will be optimized away. Yes - the reallocation is optimized in the heap to try and reuse the buffer if it can, but it takes quite a few cycles to figure this out. Note by Damien: vstr_init_len should now be considered as a string-init convenience function and used only when creating null-terminated objects.
* py/repl: Fix case where shorter names are shadowed by longer names.Damien George2015-07-06
| | | | | | Previous to this patch, if "abcd" and "ab" were possible completions to tab-completing "a", then tab would expand to "abcd" straight away if this identifier appeared first in the dict.
* modstruct: Raise NotImplementedError for unsupported repeat specification.Paul Sokolovsky2015-07-05
|
* extmod: Add a2b_base64 and b2a_base64 functions to ubinascii.Galen Hazelwood2015-07-04
|
* py/objarray.c: Allow to build with debugging and bytearray but no array.Damien George2015-07-02
|
* py: Add TimeoutError exception subclassed from OSError.Daniel Campora2015-07-02
| | | | | | | The TimeoutError is useful for some modules, specially the the socket module. TimeoutError can then be alised to socket.timeout and then Python code can differentiate between socket.error and socket.timeout.
* builtinimport: Fix running package submodule with -m.Paul Sokolovsky2015-06-29
| | | | | | | When "micropython -m pkg.mod" command was used, relative imports in pkg.mod didn't work, because pkg.mod.__name__ was set to __main__, and the fact that it's a package submodule was missed. This is an original workaround to this issue. TODO: investigate and compare how CPython deals with this issue.
* builtinimport: Catch case when relative import happens without active package.Paul Sokolovsky2015-06-27
| | | | | CPython raises SystemError in this case, but we don't have that enabled, so raise ImportError.
* runtime: Improve mp_import_name() debug logging.Paul Sokolovsky2015-06-27
|
* objstr: Add note that replace() is nicely optimized.Paul Sokolovsky2015-06-26
| | | | | Doesn't allocate memory and returns original string if no replacements are to be made.
* py: Remove mp_load_const_bytes and instead load precreated bytes object.Damien George2015-06-25
| | | | | | | | | | | | | | | | Previous to this patch each time a bytes object was referenced a new instance (with the same data) was created. With this patch a single bytes object is created in the compiler and is loaded directly at execute time as a true constant (similar to loading bignum and float objects). This saves on allocating RAM and means that bytes objects can now be used when the memory manager is locked (eg in interrupts). The MP_BC_LOAD_CONST_BYTES bytecode was removed as part of this. Generated bytecode is slightly larger due to storing a pointer to the bytes object instead of the qstr identifier. Code size is reduced by about 60 bytes on Thumb2 architectures.
* py: Remove mp_load_const_str and replace uses with inlined version.Damien George2015-06-25
|
* py: Clarify comment in parsenum.c about ValueError vs SyntaxError.Damien George2015-06-23
|
* py: Change exception type to ValueError when error reporting is terse.Daniel Campora2015-06-23
| | | | Addresses issue #1347
* py: Cast argument for printf to int, to be compatible with more ports.Damien George2015-06-22
| | | | This allows stmhal to be compiled with MICROPY_DEBUG_PRINTERS.
* py: Use a wrapper to explicitly check self argument of builtin methods.Damien George2015-06-20
| | | | | | | | | | | | | | | Previous to this patch a call such as list.append(1, 2) would lead to a seg fault. This is because list.append is a builtin method and the first argument to such methods is always assumed to have the correct type. Now, when a builtin method is extracted like this it is wrapped in a checker object which checks the the type of the first argument before calling the builtin function. This feature is contrelled by MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG and is enabled by default. See issue #1216.
* py: Make showbc decode UNPACK_EX, and use correct range for unop/binop.Damien George2015-06-18
|
* py: Implement divmod for mpz bignum.Damien George2015-06-13
|
* py: Add MP_BINARY_OP_DIVMOD to simplify and consolidate divmod builtin.Damien George2015-06-13
|
* py: Implement second arg for math.log (optional value for base).Damien George2015-06-13
|
* py: Rebuild port if mpconfigport.mk changed (if any).Paul Sokolovsky2015-06-11
| | | | | | | | mpconfigport.mk contains configuration options which affect the way MicroPython is linked. In this regard, it's "stronger" configuration dependency than even mpconfigport.h, so if we rebuild everything on mpconfigport.h change, we certianly should of that on mpconfigport.mk change too.
* py: Support unicode (utf-8 encoded) identifiers in Python source.Damien George2015-06-09
| | | | Enabled simply by making the identifier lexing code 8-bit clean.
* py: Fallback to stack alloca for Python-stack if heap alloc fails.Damien George2015-06-08
| | | | | | If heap allocation for the Python-stack of a function fails then we may as well allocate the Python-stack on the C stack. This will allow to run more code without using the heap.
* unix: Make micropython -m <module> work for frozen modules.Paul Sokolovsky2015-06-06
| | | | | This requires some special handling, which was previosuly applied only to the main code path.
* py: Expose KeyboardInterrupt in builtins module.Damien George2015-06-05
|
* unix: Allow to cat a script into stdin from the command line.Damien George2015-06-04
| | | | See issue #1306.
* py: Implement native multiply operation in viper emitter.Damien George2015-06-04
|
* py: Implement implicit cast to obj for viper load/store index/value.Damien George2015-06-04
| | | | | | | This allows to do "ar[i]" and "ar[i] = val" in viper when ar is a Python object and i and/or val are native viper types (eg ints). Patch also includes tests for this feature.
* py: Add stack check to mp_iternext, since it can be called recursively.Damien George2015-06-03
| | | | | | Eg, builtin map can map over a map, etc, and call iternext deeply. Addresses issue #1294.
* frozenmod: Include header with function prototypes.Paul Sokolovsky2015-05-31
|
* py: Wrap qstr defs in quotes to protect from C preprocessor.Damien George2015-05-30
| | | | | | | | | This patch converts Q(abc) to "Q(abc)" to protect the abc from the C preprocessor, then converts back after the preprocessor is finished. So now we can safely put includes in mpconfig(port).h, and also preprocess qstrdefsport.h (latter is now done also in this patch). Addresses issue #1252.
* py/parsenum.c: Rename "raise" func to "raise_exc" to avoid name clash.Damien George2015-05-30
| | | | "raise" is a common word that was found to exist in a vendor's stdlib.
* py: Add further autodetection of endianess in mpconfig.h.Damien George2015-05-30
| | | | This patch was needed for gcc 4.4.
* py: Get makeqstrdata.py and makeversionhdr.py running under Python 2.6.Damien George2015-05-30
| | | | | These scripts should run under as wide a range of Python versions as possible.
* py: Remove unnecessary extra handling of padding of nan/inf.Damien George2015-05-28
| | | | | | | C's printf will pad nan/inf differently to CPython. Our implementation originally conformed to C, now it conforms to CPython's way. Tests for this are also added in this patch.
* py: Reduce size of mp_printf by eliminating unnecessary code.Damien George2015-05-28
| | | | Saves around 120 bytes on Thumb2 archs.