summaryrefslogtreecommitdiffstatshomepage
path: root/py
Commit message (Collapse)AuthorAge
* unix: fast: Set initial module dict size big to have high pystone score.Paul Sokolovsky2014-11-05
| | | | For this, introduce MICROPY_MODULE_DICT_SIZE config setting.
* py: Explicitly set uninitialised struct member to false.Damien George2014-11-03
| | | | | | | | | | Uninitialised struct members get a default value of 0/false, so this is not strictly needed. But it actually decreases code size because when all members are initialised the compiler doesn't need to insert a call to memset to clear everything. In other words, setting 1 extra member to 0 uses less code than calling memset. ROM savings in bytes: 32-bit unix: 100; bare-arm: 44; stmhal: 52.
* py: Fix builtin callable so it checks user-defined instances correctly.Damien George2014-11-03
| | | | Addresses issue #953.
* py: Fix bug with right-shifting small ints by large amounts.Paul Sokolovsky2014-11-02
| | | | Undefined behavior in C, needs explicit check.
* py: Make gc.enable/disable just control auto-GC; alloc is still allowed.Damien George2014-10-31
| | | | | | gc.enable/disable are now the same as CPython: they just control whether automatic garbage collection is enabled or not. If disabled, you can still allocate heap memory, and initiate a manual collection.
* py: Add builtin round function.Damien George2014-10-31
| | | | Addresses issue #934.
* mpz: Fix 64bit msvc buildstijn2014-10-30
| | | | | | msvc does not treat 1L a 64bit integer hence all occurences of shifting it left or right result in undefined behaviour since the maximum allowed shift count for 32bit ints is 31. Forcing the correct type explicitely, stored in MPZ_LONG_1, solves this.
* objstr: Allow to convert any buffer proto object to str.Paul Sokolovsky2014-10-31
| | | | | Original motivation is to support converting bytearrays, but easier to just support buffer protocol at all.
* py: mp_obj_str_get_str(): Work with bytes too.Paul Sokolovsky2014-10-31
| | | | | | | It should be fair to say that almost in all cases where some API call expects string, it should be also possible to pass byte string. For example, it should be open/delete/rename file with name as bytestring. Note that similar change was done quite a long ago to mp_obj_str_get_data().
* py: Allow to override port config file and thus have >1 configs per port.Paul Sokolovsky2014-10-29
| | | | | | Use it like: make CFLAGS_EXTRA='-DMP_CONFIGFILE="<mpconfigport_my.h>"'
* Fix errors after enabling -Wpointer-arithstijn2014-10-29
|
* unix: Make -v dump memory info at exit.Paul Sokolovsky2014-10-26
| | | | Also, move bytecode dumps to -v -v, because they're too verbose for just -v.
* unix: Implement -m option (execute module from stdlib).Paul Sokolovsky2014-10-26
| | | | | | | | Support for packages as argument not implemented, but otherwise error and exit handling should be correct. This for example will allow to do: pip-micropython install micropython-test.pystone micropython -m test.pystone
* py: Fix memoryview referencing so it retains ptr to original buffer.Damien George2014-10-26
| | | | | This way, if original parent object is GC'd, the memoryview still points to the underlying buffer data so that buffer is not GC'd.
* py: Fix VM dispatch following a pending exception check.Damien George2014-10-26
|
* py: Add mp_pending_exception global variable, for VM soft interrupt.Damien George2014-10-25
| | | | | | | | | | | This allows to implement KeyboardInterrupt on unix, and a much safer ctrl-C in stmhal port. First ctrl-C is a soft one, with hope that VM will notice it; second ctrl-C is a hard one that kills anything (for both unix and stmhal). One needs to check for a pending exception in the VM only for jump opcodes. Others can't produce an infinite loop (infinite recursion is caught by stack check).
* py: Implement compile builtin, enabled only on unix port.Damien George2014-10-25
| | | | | | | This should be pretty compliant with CPython, except perhaps for some corner cases to do with globals/locals context. Addresses issue #879.
* py: Factor out mp_obj_is_package() function.Paul Sokolovsky2014-10-25
|
* py: mp_builtin___import__(): Add const to arg type.Paul Sokolovsky2014-10-25
|
* py: Compress load-int, load-fast, store-fast, unop, binop bytecodes.Damien George2014-10-25
| | | | | | | | | | | | | | | | | | | | | | There is a lot potential in compress bytecodes and make more use of the coding space. This patch introduces "multi" bytecodes which have their argument included in the bytecode (by addition). UNARY_OP and BINARY_OP now no longer take a 1 byte argument for the opcode. Rather, the opcode is included in the first byte itself. LOAD_FAST_[0,1,2] and STORE_FAST_[0,1,2] are removed in favour of their multi versions, which can take an argument between 0 and 15 inclusive. The majority of LOAD_FAST/STORE_FAST codes fit in this range and so this saves a byte for each of these. LOAD_CONST_SMALL_INT_MULTI is used to load small ints between -16 and 47 inclusive. Such ints are quite common and now only need 1 byte to store, and now have much faster decoding. In all this patch saves about 2% RAM for typically bytecode (1.8% on 64-bit test, 2.5% on pyboard test). It also reduces the binary size (because bytecodes are simplified) and doesn't harm performance.
* py: Store bytecode arg names in bytecode (were in own array).Damien George2014-10-25
| | | | | | | | | | | | | | | | | | | | This saves a lot of RAM for 2 reasons: 1. For functions that don't have default values, var args or var kw args (which is a large number of functions in the general case), the mp_obj_fun_bc_t type now fits in 1 GC block (previously needed 2 because of the extra pointer to point to the arg_names array). So this saves 16 bytes per function (32 bytes on 64-bit machines). 2. Combining separate memory regions generally saves RAM because the unused bytes at the end of the GC block are saved for 1 of the blocks (since that block doesn't exist on its own anymore). So generally this saves 8 bytes per function. Tested by importing lots of modules: - 64-bit Linux gave about an 8% RAM saving for 86k of used RAM. - pyboard gave about a 6% RAM saving for 31k of used RAM.
* py: Improve memory usage debugging; better GC AT dumping.Damien George2014-10-24
| | | | In unix port, mem_info(1) now prints pretty GC alloc table.
* py: Fix debug-printing of bytecode line numbers.Damien George2014-10-24
| | | | Also move the raw bytecode printing code from emitglue to mp_bytecode_print.
* py: Use mp_uint_t where appropriate in stream functions.Damien George2014-10-24
|
* stream: Add optional 2nd "length" arg to .readinto() - extension to CPython.Paul Sokolovsky2014-10-23
| | | | | While extension to file.readinto() definition of CPython, the additional arg is similar to what in CPython available in socket.recv_into().
* py: Properly free string parse-node; add assertion to gc_free.Damien George2014-10-23
|
* py: Add builtin memoryview object (mostly using array code).Damien George2014-10-23
|
* py: Use MP_OBJ_NULL instead of NULL in a few places.Damien George2014-10-23
|
* py: Clean up edge cases of malloc/realloc/free.Damien George2014-10-23
|
* extmod: Add uheapq module.Damien George2014-10-22
|
* py: Fix smallint modulo with negative arguments.Damien George2014-10-22
| | | | Addresses issue #927.
* py: Remove unused and unneeded SystemError exception.Damien George2014-10-22
| | | | | It's purpose is for internal errors that are not catastrophic (ie not as bad as RuntimeError). Since we don't use it, we don't need it.
* py: Make mp_const_empty_bytes globally available.Damien George2014-10-21
|
* Implement kwargs for builtin open() and _io.FileIOstijn2014-10-21
| | | | | | | This makes open() and _io.FileIO() more CPython compliant. The mode kwarg is fully iplemented. The encoding kwarg is allowed but not implemented; mainly to allow the tests to specify encoding for CPython, see #874
* py: Partially fix viper multi-comparison; add test for it.Damien George2014-10-19
|
* unix, stmhal: Implement file.readinto() method.Paul Sokolovsky2014-10-18
| | | | | | Also, usocket.readinto(). Known issue is that .readinto() should be available only for binary files, but micropython uses single method table for both binary and text files.
* py: Improve stream_read so it doesn't need to alloc 2 bits of heap.Damien George2014-10-17
|
* py: Add more compiler optimisations for constant if/while conditions.Damien George2014-10-17
|
* py: Simplify compilation of elif blocks.Damien George2014-10-17
|
* py: Add more debug printing code in gc_dump_alloc_table.Damien George2014-10-17
|
* py: Fix compiling of nested while/for and exception handler.Damien George2014-10-17
| | | | Addresses issue #912.
* py: Take gc_pool_start out of bss section, to reclaim 1st block of heap.Damien George2014-10-16
|
* stream: Handle non-blocking errors in readline() properly.Paul Sokolovsky2014-10-16
| | | | | | Just like they handled in other read*(). Note that behavior of readline() in case there's no data when it's called is underspecified in Python lib spec, implemented to behave as read() - return None.
* stream: Return errno value as first arg of OSError exception.Paul Sokolovsky2014-10-16
| | | | This is CPython-compatible convention established yet in acb13886fc837a1bb9.
* objclosure: Fix printing of generator closures.Paul Sokolovsky2014-10-16
| | | | The code previously assumed that only functions can be closed over.
* py: Fix GC realloc issue, where memory chunks were never shrunk.Damien George2014-10-15
| | | | | Previously, a realloc to a smaller memory chunk size would not free the unused blocks in the tail of the chunk.
* py: Fix dummy definition of BEGIN/END_ATOMIC_SECTION.Damien George2014-10-15
|
* modzlibd: Remove, superceded by moduzlib.Paul Sokolovsky2014-10-13
|
* Merge pull request #904 from pfalcon/moduzlibDamien George2014-10-12
|\ | | | | Module "uzlib" - based on similarly named library
| * moduzlib: Integrate into the system.Paul Sokolovsky2014-10-13
| |