- 20 Apr, 2015 1 commit
-
-
Damien George authored
This fixes a long standing problem that viper code generation gave terrible error messages, and actually no errors on pyboard where assertions are disabled. Now all compile-time errors are raised as proper Python exceptions, and are of type ViperTypeError. Addresses issue #940.
-
- 16 Apr, 2015 1 commit
-
-
Damien George authored
Previous to this patch the printing mechanism was a bit of a tangled mess. This patch attempts to consolidate printing into one interface. All (non-debug) printing now uses the mp_print* family of functions, mainly mp_printf. All these functions take an mp_print_t structure as their first argument, and this structure defines the printing backend through the "print_strn" function of said structure. Printing from the uPy core can reach the platform-defined print code via two paths: either through mp_sys_stdout_obj (defined pert port) in conjunction with mp_stream_write; or through the mp_plat_print structure which uses the MP_PLAT_PRINT_STRN macro to define how string are printed on the platform. The former is only used when MICROPY_PY_IO is defined. With this new scheme printing is generally more efficient (less layers to go through, less arguments to pass), and, given an mp_print_t* structure, one can call mp_print_str for efficiency instead of mp_printf("%s", ...). Code size is also reduced by around 200 bytes on Thumb2 archs.
-
- 11 Apr, 2015 1 commit
-
-
Damien George authored
This simplifies the API for objects and reduces code size (by around 400 bytes on Thumb2, and around 2k on x86). Performance impact was measured with Pystone score, but change was barely noticeable.
-
- 07 Apr, 2015 1 commit
-
-
Damien George authored
This patch gets full function argument passing working with native emitter. Includes named args, keyword args, default args, var args and var keyword args. Fully Python compliant. It reuses the bytecode mp_setup_code_state function to do all the hard work. This function is slightly adjusted to accommodate native calls, and the native emitter is forced a bit to emit similar prelude and code-info as bytecode.
-
- 04 Apr, 2015 1 commit
-
-
Damien George authored
-
- 03 Apr, 2015 1 commit
-
-
Damien George authored
-
- 25 Mar, 2015 1 commit
-
-
Paul Sokolovsky authored
mp_obj_t internal representation doesn't have to be a pointer to object, it can be anything. There's also a support for back-conversion in the form of MP_OBJ_UNCAST. This is kind of optimization/status quo preserver to minimize patching the existing code and avoid doing potentially expensive MP_OBJ_CAST over and over. But then one may imagine implementations where MP_OBJ_UNCAST is very expensive. But such implementations are unlikely interesting in practice.
-
- 20 Mar, 2015 3 commits
-
-
stijn authored
Disabled by default. Enabled on unix and stmhal ports.
-
Damien George authored
Addresses issue #1160.
-
Paul Sokolovsky authored
Given that there's already support for "fixed table" maps, which are essentially ordered maps, the implementation of OrderedDict just extends "fixed table" maps by adding an "is ordered" flag and add/remove operations, and reuses 95% of objdict code, just making methods tolerant to both dict and OrderedDict. Some things are missing so far, like CPython-compatible repr and comparison. OrderedDict is Disabled by default; enabled on unix and stmhal ports.
-
- 06 Mar, 2015 1 commit
-
-
Paul Sokolovsky authored
This follows existing pattern for object constructor API and allows to create memoryview objects e.g. in external modules.
-
- 27 Feb, 2015 1 commit
-
-
Paul Sokolovsky authored
This is rarely used feature which takes enough code to implement, so is controlled by MICROPY_PY_ARRAY_SLICE_ASSIGN config setting, default off. But otherwise it may be useful, as allows to update arbitrary-sized data buffers in-place. Slice is yet to implement, and actually, slice assignment implemented in such a way that RHS of assignment should be array of the exact same item typecode as LHS. CPython has it more relaxed, where RHS can be any sequence of compatible types (e.g. it's possible to assign list of int's to a bytearray slice). Overall, when all "slice write" features are implemented, it may cost ~1KB of code.
-
- 23 Feb, 2015 1 commit
-
-
Paul Sokolovsky authored
Still too shy to implement UnicodeEncodeError which was really needed for micropython-lib case.
-
- 21 Feb, 2015 1 commit
-
-
Damien George authored
-
- 15 Feb, 2015 1 commit
-
-
Damien George authored
-
- 08 Feb, 2015 1 commit
-
-
Damien George authored
-
- 25 Jan, 2015 1 commit
-
-
Damien George authored
Defining NDEBUG (to any value, even 0) disables debugging. Otherwise, if it's not defined, debugging is enabled.
-
- 21 Jan, 2015 2 commits
-
-
Damien George authored
With this patch str/bytes construction is streamlined. Always use a vstr to build a str/bytes object. If the size is known beforehand then use vstr_init_len to allocate only required memory. Otherwise use vstr_init and the vstr will grow as needed. Then use mp_obj_new_str_from_vstr to create a str/bytes object using the vstr memory. Saves code ROM: 68 bytes on stmhal, 108 bytes on bare-arm, and 336 bytes on unix x64.
-
Damien George authored
This patch allows to reuse vstr memory when creating str/bytes object. This improves memory usage. Also saves code ROM: 128 bytes on stmhal, 92 bytes on bare-arm, and 88 bytes on unix x64.
-
- 16 Jan, 2015 1 commit
-
-
Damien George authored
See issue #699.
-
- 11 Jan, 2015 1 commit
-
-
Damien George authored
Previous patch c38dc3cc allowed any object to be compared with any other, using pointer comparison for a fallback. As such, existing code which checked for this case is no longer needed.
-
- 29 Dec, 2014 3 commits
-
-
Paul Sokolovsky authored
-
Paul Sokolovsky authored
This fixes conversion when float type has more mantissa bits than small int, and float value has small exponent. This is for example the case of 32-bit platform using doubles, and converting value of time.time(). Conversion of floats with larg exponnet is still not handled correctly.
-
Damien George authored
-
- 10 Dec, 2014 1 commit
-
-
Damien George authored
-
- 09 Dec, 2014 1 commit
-
-
Damien George authored
This patch adds a configuration option (MICROPY_CAN_OVERRIDE_BUILTINS) which, when enabled, allows to override all names within the builtins module. A builtins override dict is created the first time the user assigns to a name in the builtins model, and then that dict is searched first on subsequent lookups. Note that this implementation doesn't allow deleting of names. This patch also does some refactoring of builtins code, creating the modbuiltins.c file. Addresses issue #959.
-
- 08 Dec, 2014 1 commit
-
-
Paul Sokolovsky authored
The function is modeled after traceback.print_exception(), but unbloated, and put into existing module to save overhead on adding another module. Compliant traceback.print_exception() is intended to be implemented in micropython-lib in terms of sys.print_exception(). This change required refactoring mp_obj_print_exception() to take pfenv_t interface arguments. Addresses #751.
-
- 05 Dec, 2014 1 commit
-
-
Damien George authored
mp_obj_int_get_truncated is used as a "fast path" int accessor that doesn't check for overflow and returns the int truncated to the machine word size, ie mp_int_t. Use mp_obj_int_get_truncated to fix struct.pack when packing maximum word sized values. Addresses issues #779 and #998.
-
- 29 Nov, 2014 1 commit
-
-
Damien George authored
This is just a clean-up of the code. Generated code is exactly the same.
-
- 27 Nov, 2014 1 commit
-
-
Paul Sokolovsky authored
Useful when need to call kw-receiving functions without any keywords from C, etc.
-
- 16 Nov, 2014 2 commits
-
-
Paul Sokolovsky authored
Also, implement for unix port.
-
Paul Sokolovsky authored
This is more efficient, as allows to use register calling convention. If needed, a structure pointer can be passed as argument to pass more data.
-
- 25 Oct, 2014 3 commits
-
-
Damien George authored
This allows to implement KeyboardInterrupt on unix, and a much safer ctrl-C in stmhal port. First ctrl-C is a soft one, with hope that VM will notice it; second ctrl-C is a hard one that kills anything (for both unix and stmhal). One needs to check for a pending exception in the VM only for jump opcodes. Others can't produce an infinite loop (infinite recursion is caught by stack check).
-
Paul Sokolovsky authored
-
Damien George authored
This saves a lot of RAM for 2 reasons: 1. For functions that don't have default values, var args or var kw args (which is a large number of functions in the general case), the mp_obj_fun_bc_t type now fits in 1 GC block (previously needed 2 because of the extra pointer to point to the arg_names array). So this saves 16 bytes per function (32 bytes on 64-bit machines). 2. Combining separate memory regions generally saves RAM because the unused bytes at the end of the GC block are saved for 1 of the blocks (since that block doesn't exist on its own anymore). So generally this saves 8 bytes per function. Tested by importing lots of modules: - 64-bit Linux gave about an 8% RAM saving for 86k of used RAM. - pyboard gave about a 6% RAM saving for 31k of used RAM.
-
- 23 Oct, 2014 1 commit
-
-
Damien George authored
-
- 22 Oct, 2014 1 commit
-
-
Damien George authored
It's purpose is for internal errors that are not catastrophic (ie not as bad as RuntimeError). Since we don't use it, we don't need it.
-
- 21 Oct, 2014 1 commit
-
-
Damien George authored
-
- 03 Oct, 2014 1 commit
-
-
Damien George authored
Addressing issue #50.
-
- 30 Sep, 2014 1 commit
-
-
Damien George authored
In CPython IOError (and EnvironmentError) is deprecated and aliased to OSError. All modules that used to raise IOError now raise OSError (or a derived exception). In Micro Python we never used IOError (except 1 place, incorrectly) and so don't need to keep it. See http://legacy.python.org/dev/peps/pep-3151/ for background.
-