summaryrefslogtreecommitdiffstatshomepage
path: root/py/mpconfig.h
Commit message (Collapse)AuthorAge
* py: Add MICROPY_USE_SMALL_HEAP_COMPILER option, disabled by default.Damien George2017-08-30
| | | | This new option allows the original and new parser/compiler to coexist.
* py: Add verbose debug compile-time flag MICROPY_DEBUG_VERBOSE.Stefan Naumann2017-08-15
| | | | It enables all the DEBUG_printf outputs in the py/ source code.
* 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: 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/mpconfig.h: Remove spaces in "Micro Python" and remove blank line.Damien George2017-06-26
|
* py/modbuiltins: Add core-provided version of input() function.Damien George2017-06-01
| | | | | | | The implementation is taken from stmhal/input.c, with code added to handle ctrl-C. This built-in is controlled by MICROPY_PY_BUILTINS_INPUT and is disabled by default. It uses readline() to capture input but this can be overridden by defining the mp_hal_readline macro.
* various: Spelling fixesVille Skyttä2017-05-29
|
* py/modio: Implement uio.resource_stream(package, resource_path).Paul Sokolovsky2017-05-03
| | | | | | | | | | | | | | The with semantics of this function is close to pkg_resources.resource_stream() function from setuptools, which is the canonical way to access non-source files belonging to a package (resources), regardless of what medium the package uses (e.g. individual source files vs zip archive). In the case of MicroPython, this function allows to access resources which are frozen into the executable, besides accessing resources in the file system. This is initial stage of the implementation, which actually doesn't implement "package" part of the semantics, just accesses frozen resources from "root", or filesystem resource - from current dir.
* py/compile: Add COMP_RETURN_IF_EXPR option to enable return-if-else opt.Damien George2017-04-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With this optimisation enabled the compiler optimises the if-else expression within a return statement. The optimisation reduces bytecode size by 2 bytes for each use of such a return-if-else statement. Since such a statement is not often used, and costs bytes for the code, the feature is disabled by default. For example the following code: def f(x): return 1 if x else 2 compiles to this bytecode with the optimisation disabled (left column is bytecode offset in bytes): 00 LOAD_FAST 0 01 POP_JUMP_IF_FALSE 8 04 LOAD_CONST_SMALL_INT 1 05 JUMP 9 08 LOAD_CONST_SMALL_INT 2 09 RETURN_VALUE and to this bytecode with the optimisation enabled: 00 LOAD_FAST 0 01 POP_JUMP_IF_FALSE 6 04 LOAD_CONST_SMALL_INT 1 05 RETURN_VALUE 06 LOAD_CONST_SMALL_INT 2 07 RETURN_VALUE So the JUMP to RETURN_VALUE is optimised and replaced by RETURN_VALUE, saving 2 bytes and making the code a bit faster.
* py/modmicropython: Add micropython.kbd_intr() function.Damien George2017-04-18
| | | | | | | It controls the character that's used to (asynchronously) raise a KeyboardInterrupt exception. Passing "-1" allows to disable the interception of the interrupt character (as long as a port allows such a behaviour).
* py/objfloat: Add implementation of high-quality float hashing.Damien George2017-04-12
| | | | Disabled by default.
* py/objstr: Use MICROPY_FULL_CHECKS for range checking when constructing bytes.Paul Sokolovsky2017-04-02
| | | | | | | Split this setting from MICROPY_CPYTHON_COMPAT. The idea is to be able to keep MICROPY_CPYTHON_COMPAT disabled, but still pass more of regression testsuite. In particular, this fixes last failing test in basics/ for Zephyr port.
* all: Move BYTES_PER_WORD definition from ports to py/mpconfig.hDamien George2017-04-01
| | | | | It can still be overwritten by a port in mpconfigport.h but for almost all cases one can use the provided default.
* py: Add micropython.schedule() function and associated runtime code.Damien George2017-03-20
|
* py/moduerrno: Make uerrno.errorcode dict configurable.Damien George2017-02-22
| | | | | | | | It's configured by MICROPY_PY_UERRNO_ERRORCODE and enabled by default (since that's the behaviour before this patch). Without this dict the lookup of errno codes to strings must use the uerrno module itself.
* py/vm: Add MICROPY_PY_THREAD_GIL_VM_DIVISOR option.Damien George2017-02-15
| | | | | | This improves efficiency of GIL release within the VM, by only doing the release after a fixed number of jump-opcodes have executed in the current thread.
* py/objtype: Implement __delattr__ and __setattr__.dmazzella2017-02-09
| | | | | | This patch implements support for class methods __delattr__ and __setattr__ for customising attribute access. It is controlled by the config option MICROPY_PY_DELATTR_SETATTR and is disabled by default.
* py/mpconfig.h: Move PY_BUILTINS_POW3 config option to diff part of file.Damien George2017-02-03
| | | | | With so many config options it's good to (at least try to) keep them grouped into logical sections.
* py: Added optimised support for 3-argument calls to builtin.pow()Nicko van Someren2017-02-02
| | | | | | Updated modbuiltin.c to add conditional support for 3-arg calls to pow() using MICROPY_PY_BUILTINS_POW3 config parameter. Added support in objint_mpz.c for for optimised implementation.
* extmod: Remove MICROPY_FSUSERMOUNT and related files.Damien George2017-01-30
| | | | Replaced by MICROPY_VFS and the VFS sub-system.
* extmod/vfs_fat: Remove MICROPY_READER_FATFS component.Damien George2017-01-30
|
* extmod: Add generic VFS sub-system.Damien George2017-01-27
| | | | | | | | | | | | This provides mp_vfs_XXX functions (eg mount, open, listdir) which are agnostic to the underlying filesystem type, and just require an object with the relevant filesystem-like methods (eg .mount, .open, .listidr) which can then be mounted. These mp_vfs_XXX functions would typically be used by a port to implement the "uos" module, and mp_vfs_open would be the builtin open function. This feature is controlled by MICROPY_VFS, disabled by default.
* py/builtinhelp: Implement help('modules') to list available modules.Damien George2017-01-22
| | | | | | | | This is how CPython does it, and it's very useful to help users discover the available modules for a given port, especially built-in and frozen modules. The function does not list modules that are in the filesystem because this would require a fair bit of work to do correctly, and is very port specific (depending on the filesystem).
* py: Add builtin help function to core, with default help msg.Damien George2017-01-22
| | | | | This builtin is configured using MICROPY_PY_BUILTINS_HELP, and is disabled by default.
* py/lexer: Permanently disable the mp_lexer_show_token function.Damien George2016-12-22
| | | | | The lexer is very mature and this debug function is no longer used. If it's really needed one can uncomment it and recompile.
* extmod/modutimeq: Refactor into optimized class.Paul Sokolovsky2016-12-22
| | | | | | | | | | import utimeq, utime # Max queue size, the queue allocated statically on creation q = utimeq.utimeq(10) q.push(utime.ticks_ms(), data1, data2) res = [0, 0, 0] # Items in res are filled up with results q.pop(res)
* py: Add MICROPY_KBD_EXCEPTION config option to provide mp_kbd_exception.Damien George2016-12-15
| | | | | | | | Defining and initialising mp_kbd_exception is boiler-plate code and so the core runtime can provide it, instead of each port needing to do it themselves. The exception object is placed in the VM state rather than on the heap.
* py/mpconfig.h: Enable MICROPY_PY_SYS_EXIT by default.Paul Sokolovsky2016-12-14
| | | | | | sys.exit() is an important function to terminate a program. In particular, the testsuite relies on it to skip tests (i.e. any other functionality may be disabled, but sys.exit() is required to at least report that properly).
* py: Add inline Xtensa assembler.Damien George2016-12-09
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds the MICROPY_EMIT_INLINE_XTENSA option, which, when enabled, allows the @micropython.asm_xtensa decorator to be used. The following opcodes are currently supported (ax is a register, a0-a15): ret_n() callx0(ax) j(label) jx(ax) beqz(ax, label) bnez(ax, label) mov(ax, ay) movi(ax, imm) # imm can be full 32-bit, uses l32r if needed and_(ax, ay, az) or_(ax, ay, az) xor(ax, ay, az) add(ax, ay, az) sub(ax, ay, az) mull(ax, ay, az) l8ui(ax, ay, imm) l16ui(ax, ay, imm) l32i(ax, ay, imm) s8i(ax, ay, imm) s16i(ax, ay, imm) s32i(ax, ay, imm) l16si(ax, ay, imm) addi(ax, ay, imm) ball(ax, ay, label) bany(ax, ay, label) bbc(ax, ay, label) bbs(ax, ay, label) beq(ax, ay, label) bge(ax, ay, label) bgeu(ax, ay, label) blt(ax, ay, label) bnall(ax, ay, label) bne(ax, ay, label) bnone(ax, ay, label) Upon entry to the assembly function the registers a0, a12, a13, a14 are pushed to the stack and the stack pointer (a1) decreased by 16. Upon exit, these registers and the stack pointer are restored, and ret.n is executed to return to the caller (caller address is in a0). Note that the ABI for the Xtensa emitters is non-windowing.
* py: Allow inline-assembler emitter to be generic.Damien George2016-12-09
| | | | | This patch refactors some code so that it is easier to integrate new inline assemblers for different architectures other than ARM Thumb.
* py: Integrate Xtensa assembler into native emitter.Damien George2016-12-09
| | | | | | The config option MICROPY_EMIT_XTENSA can now be enabled to target the Xtensa architecture with @micropython.native and @micropython.viper decorators.
* stmhal/moduselect: Move to extmod/ for reuse by other ports.Paul Sokolovsky2016-11-21
|
* py: Factor out persistent-code reader into separate files.Damien George2016-11-16
| | | | | | | 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.
* py: Add MICROPY_FLOAT_CONST macro for defining float constants.Damien George2016-11-03
| | | | | | All float constants in the core should use this macro to prevent unnecessary creation of double-precision floats, which makes code less efficient.
* py: Change config default so m_malloc0 uses memset if GC not enabled.Colin Hogben2016-11-03
| | | | | 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.
* extmod/utime_mphal: Allow ticks functions period be configurable by a port.Paul Sokolovsky2016-10-30
| | | | Using MICROPY_PY_UTIME_TICKS_PERIOD config var.
* extmod/utime_mphal: Factor out implementations in terms of mp_hal_* for reuse.Paul Sokolovsky2016-10-14
| | | | | | 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.
* py: Add MICROPY_USE_INTERNAL_PRINTF option, defaults to enabled.Delio Brignoli2016-09-05
| | | | | | | | This new config option allows to control whether MicroPython uses its own internal printf or not (if not, an external one should be linked in). Accompanying this new option is the inclusion of lib/utils/printf.c in the core list of source files, so that ports no longer need to include it themselves.
* extmod: Add machine_spi with generic SPI C-protocol and helper methods.Damien George2016-09-01
| | | | | | | The idea is that all ports can use these helper methods and only need to provide initialisation of the SPI bus, as well as a single transfer function. The coding pattern follows the stream protocol and helper methods.
* py/gc: Add MICROPY_GC_CONSERVATIVE_CLEAR option to always zero memory.Damien George2016-08-26
| | | | | | | | | There can be stray pointers in memory blocks that are not properly zero'd after allocation. This patch adds a new config option to always zero all allocated memory (via gc_alloc and gc_realloc) and hence help to eliminate stray pointers. See issue #2195.
* extmod/modubinascii: Make crc32() support configurable.Paul Sokolovsky2016-08-24
| | | | Disable by default, enable in unix port.
* py/mpconfig.h: Define MP_ALWAYSINLINE for reuse.Paul Sokolovsky2016-08-07
| | | | Similar to existing MP_NOINLINE.
* py/objstr: Make .partition()/.rpartition() methods configurable.Paul Sokolovsky2016-08-07
| | | | Default is disabled, enabled for unix port. Saves 600 bytes on x86.
* py/mpconfig.h: Add MICROPY_STREAMS_POSIX_API setting.Paul Sokolovsky2016-07-30
| | | | | | To filter out even prototypes of mp_stream_posix_*() functions, which require POSIX types like ssize_t & off_t, which may be not available in some ports.
* py/mpconfig.h: Fix description for MICROPY_PY_STR_BYTES_CMP_WARN.Paul Sokolovsky2016-07-22
|
* py/obj: Issue a warning when str and bytes objects are compared.Paul Sokolovsky2016-07-22
| | | | | | | | | | Something like: if foo == "bar": will be always false if foo is b"bar". In CPython, warning is issued if interpreter is started as "python3 -b". In MicroPython, MICROPY_PY_STR_BYTES_CMP_WARN setting controls it.
* py/gc: Implement GC running by allocation threshold.Paul Sokolovsky2016-07-21
| | | | | | | | | | | | | | | | | | | | | | | | | | Currently, MicroPython runs GC when it could not allocate a block of memory, which happens when heap is exhausted. However, that policy can't work well with "inifinity" heaps, e.g. backed by a virtual memory - there will be a lot of swap thrashing long before VM will be exhausted. Instead, in such cases "allocation threshold" policy is used: a GC is run after some number of allocations have been made. Details vary, for example, number or total amount of allocations can be used, threshold may be self-adjusting based on GC outcome, etc. This change implements a simple variant of such policy for MicroPython. Amount of allocated memory so far is used for threshold, to make it useful to typical finite-size, and small, heaps as used with MicroPython ports. And such GC policy is indeed useful for such types of heaps too, as it allows to better control fragmentation. For example, if a threshold is set to half size of heap, then for an application which usually makes big number of small allocations, that will (try to) keep half of heap memory in a nice defragmented state for an occasional large allocation. For an application which doesn't exhibit such behavior, there won't be any visible effects, except for GC running more frequently, which however may affect performance. To address this, the GC threshold is configurable, and by default is off so far. It's configured with gc.threshold(amount_in_bytes) call (can be queries without an argument).
* py/mpconfig.h: Mention MICROPY_PY_BTREE config option.Paul Sokolovsky2016-07-02
| | | | | However, as it requires linking with external libraries, it actually should be ste on Makefile level.
* py: Implement a simple global interpreter lock.Damien George2016-06-28
| | | | | This makes the VM/runtime thread safe, at the cost of not being able to run code in parallel.
* py: Add basic _thread module, with ability to start a new thread.Damien George2016-06-28
|