summaryrefslogtreecommitdiff
path: root/py
AgeCommit message (Collapse)Author
2020-01-02remove unnecessary GCC pragmasRoy Hooper
2019-12-29Merge branch 'master' into pixelbuf-subscr-changeRoy Hooper
2019-12-20Remove `re` from CPX Displayio build to make space.Scott Shawcroft
2019-12-16py.mk: Fix race condition building .mo filesJeff Epler
By having an order-only dependency on the directory itself, the directory is sure to be created before the rule to create a .mo file is. This fixes a low-freqency error on github actions such as > msgfmt: error while opening "build/genhdr/en_US.mo" for writing: No such file or directory
2019-12-13try 2. make namedtuple types handle subclassesScott Shawcroft
2019-12-13Fix tuple testScott Shawcroft
2019-12-13Revert subscr signature changeRoy Hooper
2019-12-13push changesRoy Hooper
2019-12-13Merge branch 'master' into new-pixelbuf-apiRoy Hooper
2019-12-12merge from masterDan Halbert
2019-12-12py/nlrthumb: Save and restore VFP registers s16-s21 when CPU has them.Damien George
These s16-s21 registers are used by gcc so need to be saved. Future versions of gcc (beyond v9.1.0), or other compilers, may eventually need additional registers saved/restored. See issue #4844.
2019-12-12py/nlr: Use MP_UNREACHABLE at the end of arch-specific nlr_jump funcs.Damien George
Recent versions of gcc perform optimisations which can lead to the following code from the MP_NLR_JUMP_HEAD macro being omitted: top->ret_val = val; \ MP_NLR_RESTORE_PYSTACK(top); \ *_top_ptr = top->prev; \ This is noticeable (at least) in the unix coverage on x86-64 built with gcc 9.1.0. This is because the nlr_jump function is marked as no-return, so gcc deduces that the above code has no effect. Adding MP_UNREACHABLE tells the compiler that the asm code may branch elsewhere, and so it cannot optimise away the code.
2019-12-12py: Introduce MP_UNREACHABLE macro to annotate unreachable code.Damien George
And use it to replace the same pattern at the end of nlrthumb.c:nlr_jump.
2019-12-11Merge remote-tracking branch 'adafruit/master' into ld-cleanupDan Halbert
2019-12-10merge from upstreamDan Halbert
2019-12-10Merge branch 'master' into new-pixelbuf-apiRoy Hooper
2019-12-10working on all portsDan Halbert
2019-12-10gc_free: give a better error when freeing outside of VMJeff Epler
2019-12-10audiocore: Add MP3File using Adafruit_MP3 libraryJeff Epler
2019-12-09Merge pull request #2353 from jepler/audiosample-protocolScott Shawcroft
Convert audiosamples to use micropython "protocols" (safely)
2019-12-06atmel-samd workingDan Halbert
2019-12-05wipDan Halbert
2019-12-05proto: Use %q format-string shortcutJeff Epler
2019-12-04Add connection interval and debuggingScott Shawcroft
This also sets TinyUSB to master and to not include its submodules. It also fixes an old displayio example comment and retries gattc reads.
2019-12-04protocols: Allow them to be (optionally) type-safeJeff Epler
Protocols are nice, but there is no way for C code to verify whether a type's "protocol" structure actually implements some particular protocol. As a result, you can pass an object that implements the "vfs" protocol to one that expects the "stream" protocol, and the opposite of awesomeness ensues. This patch adds an OPTIONAL (but enabled by default) protocol identifier as the first member of any protocol structure. This identifier is simply a unique QSTR chosen by the protocol designer and used by each protocol implementer. When checking for protocol support, instead of just checking whether the object's type has a non-NULL protocol field, use `mp_proto_get` which implements the protocol check when possible. The existing protocols are now named: protocol_framebuf protocol_i2c protocol_pin protocol_stream protocol_spi protocol_vfs (most of these are unused in CP and are just inherited from MP; vfs and stream are definitely used though) I did not find any crashing examples, but here's one to give a flavor of what is improved, using `micropython_coverage`. Before the change, the vfs "ioctl" protocol is invoked, and the result is not intelligible as json (but it could have resulted in a hard fault, potentially): >>> import uos, ujson >>> u = uos.VfsPosix('/tmp') >>> ujson.load(u) Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: syntax error in JSON After the change, the vfs object is correctly detected as not supporting the stream protocol: >>> ujson.load(p) Traceback (most recent call last): File "<stdin>", line 1, in <module> OSError: stream operation not supported
2019-12-02Merge pull request #2345 from jepler/compressed-unicodeScott Shawcroft
translation: Compress as unicode, not bytes
2019-12-02makeqstrdata: reclaim some more bytes on some translationsJeff Epler
If a translation only has unicode code points 255 and below, the "values" array can be 8 bits instead of 16 bits. This reclaims some code size, e.g., in a local build, trinket_m0 / en_US reclaimed 112 bytes and de_DE reclaimed 104 bytes. However, languages like zh_Latn_pinyin, which use code points above 255, did not benefit.
2019-12-02Merge branch 'master' into new-pixelbuf-apiRoy Hooper
2019-12-02makeqstrdata: fix printing of 'increased length' messageJeff Epler
2019-12-02translation: Compress as unicode, not bytesJeff Epler
By treating each unicode code-point as a single entity for huffman compression, the overall compression rate can be somewhat improved without changing the algorithm. On the decompression side, when compressed values above 127 are encountered, they need to be converted from a 16-bit Unicode code point into a UTF-8 byte sequence. Doing this returns approximately 1.5kB of flash storage with the zh_Latn_pinyin translation. (292 -> 1768 bytes remaining in my build of trinket_m0) Other "more ASCII" translations benefit less, and in fact zh_Latn_pinyin is no longer the most constrained translation! (de_DE 1156 -> 1384 bytes free in flash, I didn't check others before pushing for CI) English is slightly pessimized, 2840 -> 2788 bytes, probably mostly because the "values" array was changed from uint8_t to uint16_t, which is strictly not required for an all-ASCII translation. This could probably be avoided in this case, but as English is not the most constrained translation it doesn't really matter. Testing performed: built for feather nRF52840 express and trinket m0 in English and zh_Latn_pinyin; ran and verified the localized messages such as Àn xià rènhé jiàn jìnrù REPL. Shǐyòng CTRL-D chóngxīn jiāzài. and Press any key to enter the REPL. Use CTRL-D to reload. were properly displayed.
2019-11-29Merge remote-tracking branch 'origin/master' into tick-refactorJeff Epler
2019-11-26remove unnecessary intermediate mp_obj_subscr wrapperRoy Hooper
2019-11-26Make the @micropython.native decorator no-op if support isn't enabledThea Flowers
When adding the ability for boards to turn on the `@micropython.native`, `viper`, and `asm_thumb` decorators it was pointed out that it's somewhat awkward to write libraries and drivers that can take advantage of this since the decorators raise `SyntaxErrors` if they aren't enabled. In the case of `viper` and `asm_thumb` this behavior makes sense as they require writing non-normative code. Drivers could have a normal and viper/thumb implementation and implement them as such: ```python try: import _viper_impl as _impl except SyntaxError: import _python_impl as _impl def do_thing(): return _impl.do_thing() ``` For `native`, however, this behavior and the pattern to work around it is less than ideal. Since `native` code should also be valid Python code (although not necessarily the other way around) using the pattern above means *duplicating* the Python implementation and adding `@micropython.native` in the code. This is an unnecessary maintenance burden. This commit *modifies* the behavior of the `@micropython.native` decorator. On boards with `CIRCUITPY_ENABLE_MPY_NATIVE` turned on it operates as usual. On boards with it turned off it does *nothing*- it doesn't raise a `SyntaxError` and doesn't apply optimizations. This means we can write our drivers/libraries once and take advantage of speedups on boards where they are enabled.
2019-11-24Merge pull request #2317 from babygrimes/frozen-mpy-bytes-gc_long_lived-crashScott Shawcroft
Only make objects long lived if they are on the GC heap
2019-11-23disable -Wunused-parameter on subscr functionsRoy Hooper
2019-11-23Merge branch 'master' into new-pixelbuf-apiRoy Hooper
2019-11-23use base for errorsRoy Hooper
2019-11-23make ->subscr take an instance to pass when instance_subscr is called from ↵Roy Hooper
subscr.
2019-11-22Merge remote-tracking branch 'origin/master' into tick-refactorJeff Epler
2019-11-22* only make objects long lived if they are on the GC heapDavid Grimes
2019-11-22Merge remote-tracking branch 'adafruit/master' into testing-fixesDan Halbert
2019-11-20Use BluetoothError in _bleioScott Shawcroft
This better differentiates errors than using OSError everywhere.
2019-11-18run_background_tasks: Do nothing unless there has been a tickJeff Epler
This improves performance of running python code by 34%, based on the "pystone" benchmark on metro m4 express at 5000 passes (1127.65 -> 1521.6 passes/second). In addition, by instrumenting the tick function and monitoring on an oscilloscope, the time actually spent in run_background_tasks() on the metro m4 decreases from average 43% to 0.5%. (however, there's some additional overhead that is moved around and not accounted for in that "0.5%" figure, each time supervisor_run_background_tasks_if_tick is called but no tick has occurred) On the CPB, it increases pystone from 633 to 769, a smaller percentage increase of 21%. I did not measure the time actually spent in run_background_tasks() on CPB. Testing performed: on metro m4 and cpb, run pystone adapted from python3.4 (change time.time to time.monotonic for sub-second resolution) Besides running a 5000 pass test, I also ran a 50-pass test while scoping how long an output pin was set. Average: 34.59ms or 1445/s on m4, 67.61ms or 739/s on cbp, both matching the other pystone result reasonably well. import pystone import board import digitalio import time d = digitalio.DigitalInOut(board.D13) d.direction = digitalio.Direction.OUTPUT while True: d.value = 0 time.sleep(.01) d.value = 1 pystone.main(50)
2019-11-18Supervisor: move most of systick to the supervisorJeff Epler
This code is shared by most parts, except where not all the #ifdefs inside the tick function were present in all ports. This mostly would have broken gamepad tick support on non-samd ports. The "ms32" and "ms64" variants of the tick functions are introduced because there is no 64-bit atomic read. Disabling interrupts avoids a low probability bug where milliseconds could be off by ~49.5 days once every ~49.5 days (2^32 ms). Avoiding disabling interrupts when only the low 32 bits are needed is a minor optimization. Testing performed: on metro m4 express, USB still works and time.monotonic_ns() still counts up
2019-11-18circuitpy_mpconfig.h: Express HOOKS in terms of RUN_BACKGROUND_TASKSJeff Epler
.. this means that when we want to modify RUN_BACKGROUND_TASKS, only one change is needed instead of 3
2019-11-18circuitpy_mpconfig.h: Move includes after include-guardJeff Epler
To benefit from gcc's "once-only headers" implementation, the "wrapper-#ifndef" must be the first non-comment part of the file, according to the manual for various gcc/cpp versions.
2019-11-16use instance for verbose errorsRoy Hooper
2019-11-05Fix bad call to mp_arg_check_numThea Flowers
2019-11-05Allow boards to enable the `micropython.native` decoratorThea Flowers
Adds the `CIRCUITPY_ENABLE_MPY_NATIVE` for `mpconfigboard.mk` that enables the `micropython.native` decorator.
2019-10-28wipDan Halbert