summaryrefslogtreecommitdiffstatshomepage
path: root/py
Commit message (Collapse)AuthorAge
...
| * py/objstringio: Add MP_STREAM_FLUSH ioctl and flush() method.Paul Sokolovsky2016-07-28
| | | | | | | | No-op for this object.
| * py/stream: Implement generic flush() method, in terms of C-level ioctl.Paul Sokolovsky2016-07-27
| |
| * py/stream: Stream module works with errno's, so should include mperrno.h.Paul Sokolovsky2016-07-26
| |
| * py/objstrunicode: str_index_to_ptr: Implement positive indexing properly.Paul Sokolovsky2016-07-25
| | | | | | | | Order out-of-bounds check, completion check, and increment in the right way.
| * py/objstrunicode: str_index_to_ptr: Should handle bytes too.Paul Sokolovsky2016-07-25
| | | | | | | | | | There's single str_index_to_ptr() function, called for both bytes and unicode objects, so should handle each properly.
| * py/stream.h: Remove dated comment of POSIX-specificity of EAGAIN.Paul Sokolovsky2016-07-25
| | | | | | | | We have adopted POSIX-compatible error numbers as MicroPython's native.
| * py/stream.h: Move mp_stream_write_adaptor() inside ifdef block.Paul Sokolovsky2016-07-25
| |
| * unix: Enable MICROPY_PY_STR_BYTES_CMP_WARN.Paul Sokolovsky2016-07-22
| | | | | | | | Also, fix a warning text (remove "duplicate" BytesWarning).
| * 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: Fix nlrthumb.c when DEBUG=1 is definedDave Hylands2016-07-21
| |
| * 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).
| * esp8266: Cache Xtensa-built libaxtls.a in local build dir.Paul Sokolovsky2016-07-16
| | | | | | | | Allows to build the library variant for other archs in parallel.
| * py/stream: Implement 2- and 3-arg write() method as an extension to CPython.Paul Sokolovsky2016-07-14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 3-arg form: stream.write(data, offset, length) 2-arg form: stream.write(data, length) These allow efficient buffer writing without incurring extra memory allocation for slicing or creating memoryview() object, what is important for low-memory ports. All arguments must be positional. It might be not so bad idea to standardize on 3-arg form, but 2-arg case would need check and raising an exception anyway then, so instead it was just made to work.
| * extmod/modussl_axtls: Further changes to allow alternative SSL modules.Paul Sokolovsky2016-07-13
| | | | | | | | | | Make variable MICROPY_SSL_AXTLS=1 should be defined to activate modussl_axtls and link with -laxtls.
| * extmod/modussl: Rename to modussl_axtls.c, to allow impl using other SSL libs.Paul Sokolovsky2016-07-13
| |
| * py/nlrx64.S: Prefix mp_thread_get_state with an underscore on Mac.Damien George2016-07-11
| |
| * qemu-arm: Enable gcc LTO option for nlrthumb.cDaniel Tralamazza2016-07-11
| | | | | | | | LTO can't "see" inside naked functions, but we can mark `nlr_push_tail` as used.
* | Merge tag 'v1.8.2' into parse-bytecodeDamien George2017-08-14
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Thread support, ESP8266 memory improvements, btree module, improved docs This release brings multi-threading support in the form of the _thread module, which closely matches the semantics of the corresponding CPython module. There is support for GIL and non-GIL builds; without the GIL enabled one must protect concurrent access to mutable Python state at the Python level using Lock objects. Threading with the GIL is enabled in the cc3200 port on the WiPy. Threading without the GIL is enabled on the unix port. The ESP8266 port has support for frozen bytecode (for scripts in the modules/ subdirectory), as well as optimisations for reduced memory usage and decreased memory fragmentation. The ESP8266 RTC also resumes correctly after a deepsleep. An initial "btree" module has been implemented for database support (unix port only), and the documentation has been further improved, with pre-built PDF versions of the docs now available. py core: - parse: treat constants that start with underscore as private - objdict: implemented OrderedDict equality check - support to build berkeley db 1.85 and "btree" module - mpconfig.h: MP_NOINLINE is universally useful, move from unix port - makeqstrdefs.py: remove restriction that source path can't be absolute - mkrules.mk: define "lib" outside conditional block - rename __QSTR_EXTRACT flag to NO_QSTR - objtype: instance: inherit protocol vtable from a base class - mphal.h: if virtpin API is used, automagically include its header - objtype: inherit protocol vtable from base class only if it exists - add MP_STATE_THREAD to hold state specific to a given thread - add basic _thread module, with ability to start a new thread - modthread: properly cast concrete exception pointer to an object - modthread: add stack_size() function - modthread: add exit() function - modthread: implement lock object, for creating a mutex - modthread: add with-context capabilities to lock object - gc: make memory manager and garbage collector thread safe - modthread: satisfy unused-args warning - gc: fix 2 cases of concurrent access to ATB and FTB - modthread: be more careful with root pointers when creating a thread - modthread: call mp_thread_start/mp_thread_finish around threads - gc: fix GC+thread bug where ptr gets lost because it's not computed - make interning of qstrs thread safe - implement a simple global interpreter lock (GIL) - don't use gc or qstr mutex when the GIL is enabled, there is no need - modthread: make Lock objects work when GIL is enabled - mpthread.h: move GIL macros outside MICROPY_PY_THREAD block - modthread: allow to properly set the stack limit of a thread - nlrthumb: convert NLR thumb funcs from asm to C with inline-asm - nlrsetjmp: update to take into account new location of nlr_top - mpthread: include mpstate.h when defining GIL macros - gc: be sure to count last allocated block at heap end in stats - gc: calculate (and report) maximum contiguous free block size - builtinimport: disable "imported as namespace package" warning - mpconfig.h: mention MICROPY_PY_BTREE config option - objarray: split out header to allow direct access to object - rename mp_obj_type_t::stream_p to "protocol" extmod: - modbtree: initial implementation of "btree" module based on BerkeleyDB - modbtree: handle default value and error check - modbtree: implement .items() iterator - modbtree: actually implement end key support for .items() - modbtree: items(): Implement "end key inclusive" flag - modbtree: items(): Implement DESC flag - modbtree: __getitem__() should raise KeyError for non-existing key - modbtree: open(): Support "in-memory" database with filename=None - machine_pinbase: implementation of PinBase class - machine_pinbase: fix nanbox build - modlwip: store a chain of incoming pbufs, instead of only one - modbtree: implement keys(), values(), items() iterators - modbtree: cleverly implement "for key in btree:" syntax - modwebsocket: add readinto() method - modwebrepl: add readinto() method - modbtree: fix unused argument warning - modbtree: fixes for nanbox build - moduos_dupterm: reserve buffer bytearray object for dupterm - moduos_dupterm: reuse dupterm_arr_obj for write operations lib: - berkeley-db-1.xx: add Berkeley DB 1.85 as a submodule - berkeley-db-1.xx: update to upstream which builds for uPy - fatfs/option/ccsbcs: follow uPy optional features model - libm: format code to pass gcc v6.1.1 warning - libm: remove unused definition of "one" drivers: - display/ssd1306: add width arg and support 64px wide displays tests: - recursive_iternext: clang/Linux is even more stack-frugal than MacOS - bench: add testcase to compare bytes(N) vs b"\0" * N - add testcase for OrderedDict equality - add a testcase for machine.PinBase class - extmod: add "btree" module test - btree1: add testcase for iterating btree object directly - add tests for _thread module - add 3 more tests for _thread module - thread: remove need to sleep to wait for completion in some tests - thread: add tests for running GC within a thread, and heap stress - thread: rename thread_stress_XXX.py to stress_XXX.py - thread: add tests that mutate shared objects - thread: add test for concurrent interning of strings - thread: add test for concurrent mutating of user instance - thread: make stack-size test run correctly and reliable on uPy - thread: make sure that thread tests don't rely on floating point - thread: allow thread_sleep1 to run without floating point - thread: allow some tests to run on ports with not much heap - meminfo: update for addition of "max free sz" output - run-tests: If running thread tests on unix, don't run mutate ones unix port: - unbreak "minimal" target by disabling FatFs - mpconfigport_minimal.h: clearly mark where user-define config ends - deprecate support for GNU Readline (MICROPY_USE_READLINE=2) - time to build with --gc-sections - move "utime" module config to C level instead of make level - Makefile: libffi: Build with -Os - alloc: add option to use uPy's alloc-exec implementation even for libffi - alloc: make coverage build and its overzealous warnings happy - disable FatFs VFS for normal build, keep enabled for coverage - modmachine: include PinBase class - modmachine: enable time_pulse_us() function - fix Makefile to handle gc-sections linker flags on Mac OS - add basic thread support using pthreads - file: if write syscall returns because of EINTR then try again - implement garbage collection with threading - mpthreadport: use SA_SIGINFO for GC signal handler - gccollect: provide declaration of exported function - mpthreadport: suppress compiler warning about unused arguments - modtime: release the GIL when sleeping - enable btree module - Makefile: make "minimal" build be minimal again - mpconfigport_minimal.h: allow to print a string within 1KB of heap - main: error out on unknown value of suffix in -X heapsize= option - main: improve help for -X options a bit - main: when preparing sys.path, allocate exact strings on uPy heap - disable the GIL to improve performance of non-thread code windows port: - follow unix port changes regarding "utime" module - msvc: include machine_pinbase.c in build and enable umachine module stmhal port: - add board definition files for Olimex STM32-E407 - port of f4 hal commit 1d7fb82 to l4 hal (SD card modifications) - correct DMA to allow SD card on L4 MCUs - enable SD card on L4 MCUs cc3200 port: - update FreeRTOS to v9.0.0 - define our own FreeRTOS heap so it can go in a special segment - add basic threading capabilities - fix call to new exception to be _msg instead of _arg1 - use xTaskCreateStatic instead of osi_TaskCreate - mpthreadport: make mutex statically allocated - mpthreadport: properly initialise the main thread's data - gccollect: use MP_STATE_THREAD(stack_top) to get top of stack - mpthreadport: scan more root pointers from thread data - mpthreadport: move mem alloc outside the thread_mutex lock - enable the GIL - in FreeRTOSConfig.h, comment on configSUPPORT_STATIC_ALLOCATION - remove .boot section attribute from osi_TaskCreate function - start the simplelink spawn task using the static task creator - shrink the FreeRTOS heap and place TCB+stack in freed location - allow to compile bootloader with threading enabled - remove obsolete singleton heart-beat object teensy port: - update the README with OSX specific information and tips esp8266 port: - modnetwork: use struct bss_info::ssid_len for ESSID length - let RTC work correctly after deepsleep - switch floating-point arith routines to BootROM - Makefile: enable --verify option for esptool.py write_flash - use RTC to set date & time stamps for files - main.c: clear the command line history when (re)booting - enable frozen bytecode, with scripts in modules/ subdir - README: describe how to build mpy-cross - websocket_helper.py: avoid extra string allocations - websocket_helper.py: fix typo in debug output - modpybuart: allow setting baudrate and other params - explicitly collect garbage in bootstrap scripts - switch webrepl_setup to use frozen bytecode - switch webrepl to use frozen bytecode - README: promote from "highly experimental" to "experimental" - main: init recently added dupterm_arr_obj port state var - esp_mphal: call_dupterm_read: Use readinto() method - esp_mphal: properly handle dupterm EOF after switching to readinto() qemu-arm port: - disable gcc LTO option for nlrthumb.c docs: - esp8266/tutorial/network_basics: minor typo fix, ap becomes ap_if - add link to PDF version of docs in sidebar - library/network: wipy: fix literal block indentation - esp.socket: remove unused file - ure: typo fix - usocket: there must be empty line after .only:: - library/machine.Pin: mention GPIO and cross-link .value() function - machine.*: add "currentmodule:: machine" directive - pyb.*: add "currentmodule:: pyb" directive - machine.Pin: remove explicit target - machine.UART: cleanup pyboard section - machine.*: use proper class case in method headers - machine.Pin: add class designator to all constants - pyb.CAN: mark CAN.initfilterbanks() as classmethod explicitly - pyb.Pin: af_list() is a normal method, not a class method - pyb.ExtInt,pyb.Pin: mark up class methods as such - pyb.*: use proper class case in method headers - pyb.Pin: sort .af() and .af_list() methods together - builtins: enumerate all builtin functions implemented - library/index: add builtins.rst - machine.Pin: disambiguate object call method - machine*: remove explicit targets and "machine." prefixes on classes - uctypes: improve documentation - sys: detailed description of print_exception() diff from traceback module - add sphinx_selective_exclude extension suite - conf.py: active sphinx_selective_exclude extensions - rebuild docs from scratch, as required for proper only:: handling - select: add an article - sys: print_exception: Fixes/clarifications - conf.py: exclude cmath from modindex for wipy - library: fix typo in docs for usocket.listen() examples: - unix/ffi_example.py: update for current "ffi" module API - unix/ffi_example.py: remove TODO, make output more clear
| * py/objarray: Split out header to allow direct access to object.Paul Sokolovsky2016-07-06
| | | | | | | | | | | | This follows source code/header file organization similar to few other objects, and intended to be used only is special cases, where efficiency/ simplicity matters.
| * extmod/moduos_dupterm: Reserve buffer bytearray object for dupterm.Paul Sokolovsky2016-07-04
| | | | | | | | | | Allocating it for each read/write operation is a memory fragmentation hazard.
| * 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/builtinimport: Disable "imported as namespace package" warning.Paul Sokolovsky2016-07-02
| | | | | | | | | | Namespace packages are natural part of Python3, CPython3 doesn't have such warning, it made sense only from point of view of Python2 legacy.
| * py/gc: Calculate (and report) maximum contiguous free block size.Paul Sokolovsky2016-07-01
| | | | | | | | | | Just as maximum allocated block size, it's reported in allocation units (not bytes).
| * py/gc: Be sure to count last allocated block at heap end in stats.Paul Sokolovsky2016-06-30
| | | | | | | | | | | | Previously, if there was chain of allocated blocks ending with the last block of heap, it wasn't included in number of 1/2-block or max block size stats.
| * py/mpthread: Include mpstate.h when defining GIL macros.Damien George2016-06-28
| |
| * py/nlrsetjmp: Update to take into account new location of nlr_top.Damien George2016-06-28
| | | | | | | | It's now accessed via the MP_STATE_THREAD macro.
| * py/nlrthumb: Convert NLR thumb funcs from asm to C with inline-asm.Damien George2016-06-28
| | | | | | | | | | | | | | Now only the bits that really need to be written in assembler are written in it, otherwise C is used. This means that the assembler code no longer needs to know about the global state structure which makes it much easier to maintain.
| * py/modthread: Allow to properly set the stack limit of a thread.Damien George2016-06-28
| | | | | | | | | | We rely on the port setting and adjusting the stack size so there is enough room to recover from hitting the stack limit.
| * py/mpthread.h: Move GIL macros outside MICROPY_PY_THREAD block.Damien George2016-06-28
| | | | | | | | The GIL macros are needed even if threading is not enabled.
| * py/modthread: Make Lock objects work when GIL is enabled.Damien George2016-06-28
| |
| * py: Don't use gc or qstr mutex when the GIL is enabled.Damien George2016-06-28
| | | | | | | | | | There is no need since the GIL already makes gc and qstr operations atomic.
| * 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: Make interning of qstrs thread safe.Damien George2016-06-28
| |
| * py/gc: Fix GC+thread bug where ptr gets lost because it's not computed.Damien George2016-06-28
| | | | | | | | | | | | | | | | | | | | | | GC_EXIT() can cause a pending thread (waiting on the mutex) to be scheduled right away. This other thread may trigger a garbage collection. If the pointer to the newly-allocated block (allocated by the original thread) is not computed before the switch (so it's just left as a block number) then the block will be wrongly reclaimed. This patch makes sure the pointer is computed before allowing any thread switch to occur.
| * py/modthread: Call mp_thread_start/mp_thread_finish around threads.Damien George2016-06-28
| | | | | | | | So the underlying thread implementation can do any necessary bookkeeping.
| * py/modthread: Be more careful with root pointers when creating a thread.Damien George2016-06-28
| |
| * py/gc: Fix 2 cases of concurrent access to ATB and FTB.Damien George2016-06-28
| |
| * py/modthread: Satisfy unused-args warning.Damien George2016-06-28
| |
| * py/gc: Make memory manager and garbage collector thread safe.Damien George2016-06-28
| | | | | | | | | | | | By using a single, global mutex, all memory-related functions (alloc, free, realloc, collect, etc) are made thread safe. This means that only one thread can be in such a function at any one time.
| * py/modthread: Add with-context capabilities to lock object.Damien George2016-06-28
| |
| * py/modthread: Implement lock object, for creating a mutex.Damien George2016-06-28
| |
| * py/modthread: Add exit() function.Damien George2016-06-28
| | | | | | | | Simply raises the SystemExit exception.
| * py/modthread: Add stack_size() function.Damien George2016-06-28
| |
| * py/modthread: Properly cast concrete exception pointer to an object.Damien George2016-06-28
| |
| * py: Add basic _thread module, with ability to start a new thread.Damien George2016-06-28
| |
| * py: Add MP_STATE_THREAD to hold state specific to a given thread.Damien George2016-06-28
| |
| * py/objtype: Inherit protocol vtable from base class only if it exists.Paul Sokolovsky2016-06-19
| |
| * py/mphal.h: If virtpin API is used, automagically include its header.Paul Sokolovsky2016-06-19
| |
| * py/objtype: instance: Inherit protocol vtable from a base class.Paul Sokolovsky2016-06-19
| | | | | | | | | | | | | | This allows to define an abstract base class which would translate C-level protocol to Python method calls, and any subclass inheriting from it will support this feature. This in particular actually enables recently introduced machine.PinBase class.