summaryrefslogtreecommitdiff
path: root/py
AgeCommit message (Collapse)Author
2014-08-15py: Fix typing of viper locals; allow default types in annotation.Damien George
2014-08-15py: Allow viper to have type annotations.Damien George
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
2014-08-15py: Clean up and simplify functions in scope; add STATIC in compiler.Damien George
Some small code clean-ups that result in about 80 bytes ROM saving for stmhal.
2014-08-13py: Fix mult by negative number of tuple, list, str, bytes.Damien George
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.
2014-08-13modzlibd: Decompress part of "zlib" module, based on miniz tinfl.c .Paul Sokolovsky
2014-08-12py: #if guard qstrs that are optional.Damien George
Also disable gc module on bare-arm port.
2014-08-12py: Add .real and .imag attributes to complex numbers.Damien George
2014-08-12py: Improve range: add len, subscr, proper print.Damien George
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.
2014-08-12py: Implement builtin reversed() function.Damien George
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).
2014-08-12py: Make a function static; replace NULL with MP_OBJ_NULL.Damien George
2014-08-11py, objstr: Optimise bytes subscr when unicode is enabled.Damien George
Saves code bytes and makes it faster, so why not?
2014-08-11py, modcmath: Fix doc comment, and add some more of them.Damien George
2014-08-11objstr: Make sure that bytes are indexed as bytes, not as unicode.Paul Sokolovsky
Fixes #795.
2014-08-10objstr: split(): check arg type consistency (str vs bytes).Paul Sokolovsky
Similar to other methods and following CPython3 strictness.
2014-08-10py: binary.c: Properly implement alignment for native unpacked structs.Paul Sokolovsky
2014-08-10doc: Fix up a few docs in sys module.Damien George
2014-08-10doc: Document gc, sys, math, cmath.Damien George
2014-08-10objarray: Implement equality testing between arrays and other buffers.Paul Sokolovsky
2014-08-10py: mp_buffer_info_t::buf may be valid, but NULL for empty objects.Paul Sokolovsky
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.
2014-08-08py: Fix bug where GC finaliser table was not completely zeroed out.Damien George
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).
2014-08-07py: Fix bug in mpn_shl (multi-prec int shift left).Damien George
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.
2014-08-04Put call to qstr_init and mp_init_emergency_exc_buf in mp_init.Damien George
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).
2014-07-31py: Improve encoding scheme for line-number to bytecode map.Damien George
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.
2014-07-31Merge branch 'master' of https://github.com/micropython/micropythonDamien George
2014-07-31py: Improve handling of long-int overflow.Damien George
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).
2014-07-31py: Make MP_OBJ_NEW_SMALL_INT cast arg to mp_int_t itself.Damien George
Addresses issue #724.
2014-07-31py: Add mp_obj_str_builder_end_with_len.Damien George
This allows to create str's with a smaller length than initially asked for.
2014-07-30py: Change lexer stream API to return bytes not chars.Damien George
Lexer is now 8-bit clean inside strings.
2014-07-29Merge pull request #738 from dhylands/except-argsDamien George
Add support for storing args during an exception raised by an irq.
2014-07-28py: Implement __file__ attribute for modules.Paul Sokolovsky
2014-07-28py: Make id() return small int for the most common address space mapping.Paul Sokolovsky
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.
2014-07-27py: Change stream protocol API: fns return uint; is_text for text.Damien George
2014-07-25Add support for storing args during an exception raised by an irq.Dave Hylands
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 ```
2014-07-24py: Make long ints hashable.Damien George
Addresses issue #765.
2014-07-23streams: Treat non-error output size as unsigned.Paul Sokolovsky
2014-07-23stream: Revert to checking for the correct error value.Paul Sokolovsky
2014-07-21Deal with reading a buffer less than what was allocated.Dave Hylands
With this fix, file_long_read now passes.
2014-07-19py: Make print() accept "file" argument, and actually print to stream.Paul Sokolovsky
And not system printf(), like it was before. For this, move pfenv_printf() from stmhal port to py/.
2014-07-19py: Add stream reading of n unicode chars; unicode support by default.Damien George
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.
2014-07-17py: Remove unnecessary argument in bytearray print.Damien George
2014-07-17formatfloat.c: Typo fix in comment.Paul Sokolovsky
2014-07-17py, inline asm: Change "and" op name to "and_" to avoid keyword clash.Damien George
Addresses issue #753.
2014-07-13stream: Factor out mp_stream_write() method to write a memstring to stream.Paul Sokolovsky
2014-07-12py: Add generic helper to align a pointer.Paul Sokolovsky
2014-07-12emitbc: Fix structure field alignment issue.Paul Sokolovsky
dummy_data field is accessed as uint value (e.g. in emit_write_bytecode_byte_ptr), but is not aligned as such, which causes bus errors or incorrect behavior on any arch requiring strictly aligned data (ARM pre-v7, MIPS, etc, etc).
2014-07-11moductypes: Add symbolic constants to specify bitfield position/length.Paul Sokolovsky
2014-07-09moductypes: Foreign data interface module, roughly based on ctype ideas.Paul Sokolovsky
But much smaller and memory-efficient. Uses Python builtin data structures (dict, tuple, int) to describe structure layout.
2014-07-05binary: Factor out mp_binary_set_int().Paul Sokolovsky
2014-07-05py: Automatically ake __new__ a staticmethod.Damien George
Addresses issue #622.
2014-07-03py: Implement sys.maxsize, standard way to check platform "bitness".Paul Sokolovsky
Implementing it as a static constant is a bit peculiar and require cooperation from long int implementation.