summaryrefslogtreecommitdiff
path: root/py
AgeCommit message (Collapse)Author
2015-09-03py/objstr: Simplify printing of bytes objects when unicode enabled.Damien George
2015-09-03py: Inline single use of mp_obj_str_get_len in mp_obj_len_maybe.Damien George
Gets rid of redundant double check for string type. Also remove obsolete declaration of mp_obj_str_get_hash.
2015-09-03py: Make "enumerate" qstr be conditional on MICROPY_PY_BUILTINS_ENUMERATE.Paul Sokolovsky
2015-09-01py/binary: Add support for array('q') and array('Q').Damien George
2015-09-01py/objstr: Make str.rsplit(None,n) raise NotImpl instead of assert(0).Damien George
2015-09-01vm: Handle "raise X from Y" statements the best way we can.Paul Sokolovsky
By issuing a warning that exception chaining is not supported, and ignoring "from Y" argument.
2015-08-31modbuiltins: Consistently use indentation for #if.Paul Sokolovsky
2015-08-30py/objstr: Simplify error handling for bad conversion specifier.Damien George
2015-08-30py/objgetitemiter: Make it_iternext() recognize IndexError.Tom Soulanille
2015-08-29py/objstr: Fix error reporting for unexpected end of modulo format str.Damien George
2015-08-29py/objstr: Fix error type for badly formatted format specifier.Damien George
Was KeyError, should be ValueError.
2015-08-29py/objstr: Make string formatting 8-bit clean.Damien George
2015-08-29py: Treat -m32 flag as part of CC, LD, etc.Paul Sokolovsky
Indeed, this flag efectively selects architecture target, and must consistently apply to all compiles and links, including 3rd-party libraries, unlike CFLAGS, which have MicroPython-specific setting.
2015-08-28objset: frozensets are hashable.Paul Sokolovsky
2015-08-20py: Add MICROPY_PY_BUILTINS_FILTER, disable for minimal ports.Paul Sokolovsky
Saves 320 bytes on x86.
2015-08-17py: Remove unused compile scope flags, and irrelevant flag compute code.Damien George
2015-08-17unix-cpy: Remove unix-cpy. It's no longer needed.Damien George
unix-cpy was originally written to get semantic equivalent with CPython without writing functional tests. When writing the initial implementation of uPy it was a long way between lexer and functional tests, so the half-way test was to make sure that the bytecode was correct. The idea was that if the uPy bytecode matched CPython 1-1 then uPy would be proper Python if the bytecodes acted correctly. And having matching bytecode meant that it was less likely to miss some deep subtlety in the Python semantics that would require an architectural change later on. But that is all history and it no longer makes sense to retain the ability to output CPython bytecode, because: 1. It outputs CPython 3.3 compatible bytecode. CPython's bytecode changes from version to version, and seems to have changed quite a bit in 3.5. There's no point in changing the bytecode output to match CPython anymore. 2. uPy and CPy do different optimisations to the bytecode which makes it harder to match. 3. The bytecode tests are not run. They were never part of Travis and are not run locally anymore. 4. The EMIT_CPYTHON option needs a lot of extra source code which adds heaps of noise, especially in compile.c. 5. Now that there is an extensive test suite (which tests functionality) there is no need to match the bytecode. Some very subtle behaviour is tested with the test suite and passing these tests is a much better way to stay Python-language compliant, rather than trying to match CPy bytecode.
2015-08-13py: Add stream_tell method, and use for unix and stmhal file tell.blmorris
2015-08-12py: In native ARM emitter, load r7 with table earlier in func prelude.Damien George
r7 may be needed to set up code state, so it must be loaded before the set-up function is called.
2015-08-12py/makeversionhdr.py: Use returncode attr to be Python2.7 compat.Damien George
2015-08-11py/makeversionhdr.py: Fallback to using docs version if no git repo.Damien George
Addresses issue #1420.
2015-08-02py/objlist: Make list += accept all arguments and add test.Damien George
2015-07-31makeqstrdata.py: Typo fix in comment.Paul Sokolovsky
2015-07-29py/compile: Give more precise line number for compile errors.Damien George
Previous to this patch there were some cases where line numbers for errors were 0 (unknown). Now the compiler attempts to give a better line number where possible, in some cases giving the line number of the closest statement, and other cases the line number of the inner-most scope of the error (eg the line number of the start of the function). This helps to give good (and sometimes exact) line numbers for ViperTypeError exceptions. This patch also makes sure that the first compile error (eg SyntaxError) that is encountered is reported (previously it was the last one that was reported).
2015-07-29py/repl: Don't look inside strings for unmatched brackets/quotes.Damien George
When looking to see if the REPL input needs to be continued on the next line, don't look inside strings for unmatched ()[]{} ''' or """. Addresses issue #1387.
2015-07-27py: For viper compile errors, add traceback with function and filename.Damien George
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.
2015-07-26py: Disable REPL EMACS key bindings by default.Damien George
2015-07-26lib/mp-readline: Add emacs-style control characters for cursor movement.Tom Soulanille
Disabled by default. Adds 108 bytes to Thumb2 arch when enabled.
2015-07-24py/parse: Fix handling of empty input so it raises an exception.Damien George
2015-07-24py/parse: De-duplicate and simplify code for parser "or" rule.Damien George
2015-07-23py/lexer: Raise SyntaxError when str hex escape sequence is malformed.Damien George
Addresses issue #1390.
2015-07-23py: Issue an error when compiling Viper functions with more than 4 args.Damien George
Otherwise it can be very hard to track down bugs.
2015-07-23py: Allow viper functions to take up to 4 arguments.Damien George
Addresses issue #1380.
2015-06-06py: reduce array slice assignment code sizeDelio Brignoli
2015-07-20py: Small code space optimisations for memoryview slice assigment.Damien George
Also adds #if guards to allow uPy core to compile without memoryview enabled, but with slice assignment enabled.
2015-07-20py: Implement memoryview slice assignment.Delio Brignoli
Adds ability to do "memcpy" with memoryview objects, such as: m1[0:3] = m2[2:5].
2015-07-20py: Make qstr hash size configurable, defaults to 2 bytes.Damien George
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.
2015-07-19modbuiltins: Implement round() to precision.Sebastian Plamauer
2015-07-14py: Improve allocation policy of qstr data.Damien George
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).
2015-07-06py: Prevent many extra vstr allocations.Dave Hylands
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.
2015-07-06py/repl: Fix case where shorter names are shadowed by longer names.Damien George
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.
2015-07-05modstruct: Raise NotImplementedError for unsupported repeat specification.Paul Sokolovsky
2015-07-04extmod: Add a2b_base64 and b2a_base64 functions to ubinascii.Galen Hazelwood
2015-07-02py/objarray.c: Allow to build with debugging and bytearray but no array.Damien George
2015-07-02py: Add TimeoutError exception subclassed from OSError.Daniel Campora
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.
2015-06-29builtinimport: Fix running package submodule with -m.Paul Sokolovsky
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.
2015-06-27builtinimport: Catch case when relative import happens without active package.Paul Sokolovsky
CPython raises SystemError in this case, but we don't have that enabled, so raise ImportError.
2015-06-27runtime: Improve mp_import_name() debug logging.Paul Sokolovsky
2015-06-26objstr: Add note that replace() is nicely optimized.Paul Sokolovsky
Doesn't allocate memory and returns original string if no replacements are to be made.
2015-06-25py: Remove mp_load_const_bytes and instead load precreated bytes object.Damien George
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.