summaryrefslogtreecommitdiffstatshomepage
path: root/py
Commit message (Collapse)AuthorAge
* 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.
* py: Remove unnecessary argument in bytearray print.Damien George2014-07-17
|
* formatfloat.c: Typo fix in comment.Paul Sokolovsky2014-07-17
|
* py, inline asm: Change "and" op name to "and_" to avoid keyword clash.Damien George2014-07-17
| | | | Addresses issue #753.
* stream: Factor out mp_stream_write() method to write a memstring to stream.Paul Sokolovsky2014-07-13
|
* py: Add generic helper to align a pointer.Paul Sokolovsky2014-07-12
|
* emitbc: Fix structure field alignment issue.Paul Sokolovsky2014-07-12
| | | | | | | 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).
* moductypes: Add symbolic constants to specify bitfield position/length.Paul Sokolovsky2014-07-11
|
* moductypes: Foreign data interface module, roughly based on ctype ideas.Paul Sokolovsky2014-07-09
| | | | | But much smaller and memory-efficient. Uses Python builtin data structures (dict, tuple, int) to describe structure layout.
* binary: Factor out mp_binary_set_int().Paul Sokolovsky2014-07-05
|
* py: Automatically ake __new__ a staticmethod.Damien George2014-07-05
| | | | Addresses issue #622.
* py: Implement sys.maxsize, standard way to check platform "bitness".Paul Sokolovsky2014-07-03
| | | | | Implementing it as a static constant is a bit peculiar and require cooperation from long int implementation.
* parser: Convert (u)int to mp_(u)int_t.Damien George2014-07-03
|
* lexer: Convert type (u)int to mp_(u)int_t.Damien George2014-07-03
|
* Rename machine_(u)int_t to mp_(u)int_t.Damien George2014-07-03
| | | | See discussion in issue #50.
* Merge branch 'teensy-new' of github.com:dhylands/micropython into ↵Damien George2014-07-02
|\ | | | | | | | | | | | | | | | | | | | | | | dhylands-teensy-new Conflicts: stmhal/pin_named_pins.c stmhal/readline.c Renamed HAL_H to MICROPY_HAL_H. Made stmhal/mphal.h which intends to define the generic Micro Python HAL, which in stmhal sits above the ST HAL.
| * Updated teensy to build.Dave Hylands2014-06-15
| | | | | | | | Refactored some stmhal files which are shared with teensy.
* | py, objexcept: Only check for locked gc if gc is enabled.Damien George2014-07-01
| |
* | Merge branch 'preserve-except' of github.com:dhylands/micropython into ↵Damien George2014-07-01
|\ \ | | | | | | | | | dhylands-preserve-except
| * | Try not to cause a MemoryError when raising an exception during nterrupt ↵Dave Hylands2014-06-30
| | | | | | | | | | | | | | | | | | handling. Step 1 fixes #732
* | | stackctrl: Add "mp_" prefix.Paul Sokolovsky2014-07-01
| | |
* | | Merge pull request #710 from iabdalkader/assertDamien George2014-06-30
|\ \ \ | | | | | | | | Fix assert_func warning/error
| * | | Fix asser_func warning/errormux2014-06-21
| | | | | | | | | | | | | | | | | | | | * Add while(1) to assert_func to avoid func returns warning * Define a weak attr in mpconfig.h
* | | | py: Improvements to native emitter.Damien George2014-06-30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Native emitter can now compile try/except blocks using nlr_push/nlr_pop. It probably only works for 1 level of exception handling. It doesn't work on Thumb (only x64). Native emitter can also handle some additional op codes. With this patch, 198 tests now pass using "-X emit=native" option to micropython.
* | | | windows: Sync mpconfigport.h with the unix' versionstijn2014-06-29
| | | | | | | | | | | | | | | | | | | | | | | | - rearrange/add definitions that were not there so it's easier to compare both - use MICROPY_PY_SYS_PLATFORM in main.c since it's available anyway - define EWOULDBLOCK, it is missing from ingw32
* | | | py: Make unichar_charlen() accept/return machine_uint_t.Paul Sokolovsky2014-06-28
| | | |
* | | | py: Add missing #endif.Damien George2014-06-28
| | | |
* | | | py: Small comments, name changes, use of machine_int_t.Damien George2014-06-28
| | | |
* | | | Merge branch 'master' into unicodeDamien George2014-06-28
|\ \ \ \ | | |/ / | |/| | | | | | | | | | Conflicts: py/mpconfig.h
| * | | py: Add protection against printing too nested or recursive data structures.Paul Sokolovsky2014-06-28
| | | | | | | | | | | | | | | | With a test which cannot be automatically validated so far.
| * | | py: Allow to disable array module and bytearray type.Paul Sokolovsky2014-06-27
| | | | | | | | | | | | | | | | | | | | array.array and bytearray share big deal of code, so to get real savings, both need to be disabled.
| * | | py: Move stack_ctrl_init() to mp_init().Paul Sokolovsky2014-06-27
| | | | | | | | | | | | | | | | | | | | | | | | As stack checking is enabled by default, ports which don't call stack_ctrl_init() are broken now (report RuntimeError on startup). Save them trouble and just init stack control framework in interpreter init.