summaryrefslogtreecommitdiffstatshomepage
path: root/py
Commit message (Collapse)AuthorAge
* stmhal: Make enable_irq and disable_irq inline functions.Damien George2014-08-25
| | | | | | | | | | | | These functions are generally 1 machine instruction, and are used in critical code, so makes sense to have them inline. Also leave these functions uninverted (ie 0 means enable, 1 means disable) and provide macro constants if you really need to distinguish the states. This makes for smaller code as well (combined with inlining). Applied to teensy port as well.
* Add save/restore_irqDave Hylands2014-08-25
| | | | Factored irq functions into a separate file.
* py: Consolidate min/max functions into one, and add key= argument.Damien George2014-08-24
| | | | Addresses issue #811.
* py: Fix bug where GC collected native/viper/asm function data.Damien George2014-08-24
| | | | | | | | Because (for Thumb) a function pointer has the LSB set, pointers to dynamic functions in RAM (eg native, viper or asm functions) were not being traced by the GC. This patch is a comprehensive fix for this. Addresses issue #820.
* py: Change hash and len members of str from 16 bit to full word.Damien George2014-08-22
| | | | | This allows to make strings longer than 64k. It doesn't use any more RAM with current GC because a str object still fits in a GC block.
* py: Small cleanup in stream.c.Damien George2014-08-22
|
* py: Speed up GC allocation.Damien George2014-08-22
| | | | | | | | | This simple patch gives a very significant speed up for memory allocation with the GC. Eg, on PYBv1.0: tests/basics/dict_del.py: 3.55 seconds -> 1.19 seconds tests/misc/rge_sm.py: 15.3 seconds -> 2.48 seconds
* py: Code clean-up in native emitter; improve thumb native calls.Damien George2014-08-16
|
* py: Viper can call functions with native types, and raise exceptions.Damien George2014-08-16
|
* py: Put SystemExit in builtin namespace.Damien George2014-08-16
| | | | Also fix unix port so that SystemExit with no arg exits with value 0.
* py: Viper can now store to global.Damien George2014-08-15
|
* py: Fix typing of viper locals; allow default types in annotation.Damien George2014-08-15
|
* py: Allow viper to have type annotations.Damien George2014-08-15
| | | | | | | | | Viper functions can now be annotated with the type of their arguments and return value. Eg: @micropython.viper def f(x:int) -> int: return x + 1
* py: Clean up and simplify functions in scope; add STATIC in compiler.Damien George2014-08-15
| | | | | Some small code clean-ups that result in about 80 bytes ROM saving for stmhal.
* py: Fix mult by negative number of tuple, list, str, bytes.Damien George2014-08-13
| | | | | | | Multiplication of a tuple, list, str or bytes now yields an empty sequence (instead of crashing). Addresses issue #799 Also added ability to mult bytes on LHS by integer.
* modzlibd: Decompress part of "zlib" module, based on miniz tinfl.c .Paul Sokolovsky2014-08-13
|
* py: #if guard qstrs that are optional.Damien George2014-08-12
| | | | Also disable gc module on bare-arm port.
* py: Add .real and .imag attributes to complex numbers.Damien George2014-08-12
|
* py: Improve range: add len, subscr, proper print.Damien George2014-08-12
| | | | | | | | Can now index ranges with integers and slices, and reverse ranges (although reversing is not very efficient). Not sure how useful this stuff is, but gets us closer to having all of Python's builtins.
* py: Implement builtin reversed() function.Damien George2014-08-12
| | | | | | | | reversed function now implemented, and works for tuple, list, str, bytes and user objects with __len__ and __getitem__. Renamed mp_builtin_len to mp_obj_len to make it publically available (eg for reversed).
* py: Make a function static; replace NULL with MP_OBJ_NULL.Damien George2014-08-12
|
* py, objstr: Optimise bytes subscr when unicode is enabled.Damien George2014-08-11
| | | | Saves code bytes and makes it faster, so why not?
* py, modcmath: Fix doc comment, and add some more of them.Damien George2014-08-11
|
* objstr: Make sure that bytes are indexed as bytes, not as unicode.Paul Sokolovsky2014-08-11
| | | | Fixes #795.
* objstr: split(): check arg type consistency (str vs bytes).Paul Sokolovsky2014-08-10
| | | | Similar to other methods and following CPython3 strictness.
* py: binary.c: Properly implement alignment for native unpacked structs.Paul Sokolovsky2014-08-10
|
* doc: Fix up a few docs in sys module.Damien George2014-08-10
|
* doc: Document gc, sys, math, cmath.Damien George2014-08-10
|
* objarray: Implement equality testing between arrays and other buffers.Paul Sokolovsky2014-08-10
|
* py: mp_buffer_info_t::buf may be valid, but NULL for empty objects.Paul Sokolovsky2014-08-10
| | | | | | This happens for example for zero-size arrays. As .get_buffer() method now has explicit return value, it's enough to distinguish success vs failure of getting buffer.
* py: Fix bug where GC finaliser table was not completely zeroed out.Damien George2014-08-08
| | | | | | | | | | | | This was a nasty bug to track down. It only had consequences when the heap size was just the right size to expose the rounding error in the calculation of the finaliser table size. And, a script had to allocate a small (1 or 2 cell) object at the very end of the heap. And, this object must not have a finaliser. And, the initial state of the heap must have been all bits set to 1. All these conspire on the pyboard, but only if your run the script fresh (so unused memory is all 1's), and if your script allocates a lot of small objects (eg 2-char strings that are not interned).
* py: Fix bug in mpn_shl (multi-prec int shift left).Damien George2014-08-07
| | | | | Before this patch, eg, 1 << 75 (or any large multiple of 15) was setting the MSB in the digits, which is outside the valid range of DIG_MASK.
* Put call to qstr_init and mp_init_emergency_exc_buf in mp_init.Damien George2014-08-04
| | | | | | | qstr_init is always called exactly before mp_init, so makes sense to just have mp_init call it. Similarly with mp_init_emergency_exception_buf. Doing this makes the ports simpler and less error prone (ie they can no longer forget to call these).
* py: Improve encoding scheme for line-number to bytecode map.Damien George2014-07-31
| | | | | | | | | | | | | | | | | | | | Reduces by about a factor of 10 on average the amount of RAM needed to store the line-number to bytecode map in the bytecode prelude. Using CPython3.4's stdlib for statistics: previously, an average of 13 bytes were used per (bytecode offset, line-number offset) pair, and now with this improvement, that's down to 1.3 bytes on average. Large RAM usage before was due to some very large steps in line numbers, both from the start of the first line in a function way down in the file, and also functions that have big comments and/or big strings in them (both cases were significant). Although the savings are large on average for the CPython stdlib, it won't have such a big effect for small scripts used in embedded programming. Addresses issue #648.
* Merge branch 'master' of https://github.com/micropython/micropythonDamien George2014-07-31
|\
| * py: Make MP_OBJ_NEW_SMALL_INT cast arg to mp_int_t itself.Damien George2014-07-31
| | | | | | | | Addresses issue #724.
| * py: Add mp_obj_str_builder_end_with_len.Damien George2014-07-31
| | | | | | | | | | This allows to create str's with a smaller length than initially asked for.
* | py: Improve handling of long-int overflow.Damien George2014-07-31
|/ | | | | | | | | | This removes mpz_as_int, since that was a terrible function (it implemented saturating conversion). Use mpz_as_int_checked and mpz_as_uint_checked. These now work correctly (they previously had wrong overflow checking, eg print(chr(10000000000000)) on 32-bit machine would incorrectly convert this large number to a small int).
* py: Change lexer stream API to return bytes not chars.Damien George2014-07-30
| | | | Lexer is now 8-bit clean inside strings.
* Merge pull request #738 from dhylands/except-argsDamien George2014-07-29
|\ | | | | Add support for storing args during an exception raised by an irq.
| * Add support for storing args during an exception raised by an irq.Dave Hylands2014-07-25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The user code should call micropython.alloc_emergency_exception_buf(size) where size is the size of the buffer used to print the argument passed to the exception. With the test code from #732, and a call to micropython.alloc_emergenncy_exception_buf(100) the following error is now printed: ```python >>> import heartbeat_irq Uncaught exception in Timer(4) interrupt handler Traceback (most recent call last): File "0://heartbeat_irq.py", line 14, in heartbeat_cb NameError: name 'led' is not defined ```
* | py: Implement __file__ attribute for modules.Paul Sokolovsky2014-07-28
| |
* | py: Make id() return small int for the most common address space mapping.Paul Sokolovsky2014-07-28
| | | | | | | | | | | | | | | | | | | | | | Many OSes/CPUs have affinity to put "user" data into lower half of address space. Take advantage of that and remap such addresses into full small int range (including negative part). If address is from upper half, long int will be used. Previously, small int was returned for lower quarter of address space, and upper quarter. For 2 middle quarters, long int was used, which is clearly worse schedule than the above.
* | py: Change stream protocol API: fns return uint; is_text for text.Damien George2014-07-27
|/
* py: Make long ints hashable.Damien George2014-07-24
| | | | Addresses issue #765.
* streams: Treat non-error output size as unsigned.Paul Sokolovsky2014-07-23
|
* stream: Revert to checking for the correct error value.Paul Sokolovsky2014-07-23
|
* Deal with reading a buffer less than what was allocated.Dave Hylands2014-07-21
| | | | With this fix, file_long_read now passes.
* py: Make print() accept "file" argument, and actually print to stream.Paul Sokolovsky2014-07-19
| | | | | And not system printf(), like it was before. For this, move pfenv_printf() from stmhal port to py/.
* py: Add stream reading of n unicode chars; unicode support by default.Damien George2014-07-19
| | | | | | | | | | | | | With unicode enabled, this patch allows reading a fixed number of characters from text-mode streams; eg file.read(5) will read 5 unicode chars, which can made of more than 5 bytes. For an ASCII stream (ie no chars > 127) it only needs to do 1 read. If there are lots of non-ASCII chars in a stream, then it needs multiple reads of the underlying object. Adds a new test for this case. Enables unicode support by default on unix and stmhal ports.