summaryrefslogtreecommitdiffstatshomepage
path: root/py
Commit message (Collapse)AuthorAge
* py: Fix a semantic issue with range optimisation.Damien George2014-12-11
| | | | | | | Now you can assign to the range variable within the for loop and it will still work. Partially addresses issue #565.
* py: Tidy up a few function declarations.Damien George2014-12-10
|
* py: Remove static from definition of pfenv_printf.Damien George2014-12-10
| | | | It's used by stmhal, but not unix.
* py: Make functions static where appropriate.Damien George2014-12-10
|
* py: Fix function type: () -> (void).Damien George2014-12-10
|
* py: Allow builtins to be overridden.Damien George2014-12-09
| | | | | | | | | | | | | | This patch adds a configuration option (MICROPY_CAN_OVERRIDE_BUILTINS) which, when enabled, allows to override all names within the builtins module. A builtins override dict is created the first time the user assigns to a name in the builtins model, and then that dict is searched first on subsequent lookups. Note that this implementation doesn't allow deleting of names. This patch also does some refactoring of builtins code, creating the modbuiltins.c file. Addresses issue #959.
* modsys: Add sys.print_exception(exc, file=sys.stdout) function.Paul Sokolovsky2014-12-08
| | | | | | | | | | | | The function is modeled after traceback.print_exception(), but unbloated, and put into existing module to save overhead on adding another module. Compliant traceback.print_exception() is intended to be implemented in micropython-lib in terms of sys.print_exception(). This change required refactoring mp_obj_print_exception() to take pfenv_t interface arguments. Addresses #751.
* py: Rename mp_obj_int_get to mp_obj_int_get_truncated; fix struct.pack.Damien George2014-12-05
| | | | | | | | | | | mp_obj_int_get_truncated is used as a "fast path" int accessor that doesn't check for overflow and returns the int truncated to the machine word size, ie mp_int_t. Use mp_obj_int_get_truncated to fix struct.pack when packing maximum word sized values. Addresses issues #779 and #998.
* py: Fix printing of size_t entity; fix qemu-arm for changes to lexer.Damien George2014-12-05
|
* py: Optimise lexer by exposing lexer type.Damien George2014-12-05
| | | | | | | | | mp_lexer_t type is exposed, mp_token_t type is removed, and simple lexer functions (like checking current token kind) are now inlined. This saves 784 bytes ROM on 32-bit unix, 348 bytes on stmhal, and 460 bytes on bare-arm. It also saves a tiny bit of RAM since mp_lexer_t is a bit smaller. Also will run a bit more efficiently.
* py: Allow bytes/bytearray/array to be init'd by buffer protocol objects.Damien George2014-12-04
| | | | | | | Behaviour of array initialisation is subtly different for bytes, bytearray and array.array when argument has buffer protocol. This patch gets us CPython conformant (except we allow initialisation of array.array by buffer with length not a multiple of typecode).
* py, vm: Make unum a local variable for each opcode that uses it.Damien George2014-12-02
| | | | | This makes no change to the generated code, but it's now easier to understand since unum is not a "global" variable anymore.
* modmicropython: Move mem_info() and qstr_info() functions from unix port.Paul Sokolovsky2014-12-01
| | | | TODO: Merge useful functionality from modpyb too.
* py: Generalise and reduce code size of array +, += and .extend().Damien George2014-11-30
| | | | | | | | By using the buffer protocol for these array operations, we now allow addition of memoryview objects, and objects with "incompatible" typecodes (in this case it just adds bytes naively). This is an extension to CPython which seems sensible. It also reduces the code size.
* py: Implement +, += and .extend for bytearray and array objs.Damien George2014-11-30
| | | | Addresses issue #994.
* Use MP_DEFINE_CONST_DICT macro to define module dicts.Damien George2014-11-29
| | | | | This is just a clean-up of the code. Generated code is exactly the same.
* modubinascii: Add, with hexlify() implementation.Paul Sokolovsky2014-11-29
|
* py: Add NLR support for xtensa CPU.Damien George2014-11-27
|
* pfenv_printf: Properly implement %p format specifier.Paul Sokolovsky2014-11-27
| | | | Previously, it truncated pointer value to 32 bits on 64-bit systems.
* builtin: Reimplement __repl_print__() in terms of print().Paul Sokolovsky2014-11-27
| | | | | | | Before, __repl_print__() used libc printf(), while print() used uPy streams and own printf() implementation. This led to subtle, but confusing differences in output when just doing "foo" vs "print(foo)" on interactive prompt.
* map: Add empty fixed map.Paul Sokolovsky2014-11-27
| | | | | Useful when need to call kw-receiving functions without any keywords from C, etc.
* py: #if guard str_make_new when not needed.Damien George2014-11-27
|
* moduhashlib: Initial module skeleton.Paul Sokolovsky2014-11-22
|
* py: Add support for float/double arrays in array module.Damien George2014-11-21
| | | | Addresses issue #981.
* py: Make stream seek correctly check for ioctl fn; add seek for textio.Damien George2014-11-16
|
* stream: Implement seek operation support via ioctl, wrapped in generic method.Paul Sokolovsky2014-11-17
| | | | Also, implement for unix port.
* stream: Convert .ioctl() to take fixed number of args.Paul Sokolovsky2014-11-17
| | | | | | This is more efficient, as allows to use register calling convention. If needed, a structure pointer can be passed as argument to pass more data.
* py: Use __hash__ method if a type defines itstijn2014-11-15
|
* py: Fix order-only dependencies in mkrules.mk and py.mk.Sven Wegener2014-11-06
| | | | | | | | | Currently compilation sporadically fails, because the automatic dependency gets created *during* the compilation of objects. OBJ is a auperset of PY_O and the dependencies apply to all objects. Signed-off-by: Sven Wegener <sven.wegener@stealer.net>
* py: Use shorter, static error msgs when ERROR_REPORTING_TERSE enabled.Damien George2014-11-06
| | | | | | | | Going from MICROPY_ERROR_REPORTING_NORMAL to MICROPY_ERROR_REPORTING_TERSE now saves 2020 bytes ROM for ARM Thumb2, and 2200 bytes ROM for 32-bit x86. This is about a 2.5% code size reduction for bare-arm.
* py: Remove obsolute function declaration.Damien George2014-11-06
|
* py: Add order-only dependency for py-version.hSven Wegener2014-11-05
| | | | | | Else the directory might not exist. Signed-off-by: Sven Wegener <sven.wegener@stealer.net>
* py: Deactivate more code without MICROPY_PY_SYSSven Wegener2014-11-05
| | | | | | | | When compiler optimization has been turned on, gcc knows that this code block is not going to be executed. But with -O0 it complains about path_items being used uninitialized. Signed-off-by: Sven Wegener <sven.wegener@stealer.net>
* py: Fix some macros defines; cleanup some includes.Damien George2014-11-05
|
* py: Allow bytes object as argument to some str methods.Damien George2014-11-05
| | | | | | This turns failing assertions to type exceptions for things like b"123".find(...). We still don't support operations like this on bytes objects (unlike CPython), but at least it no longer crashes.
* py: Allow +, in, and compare ops between bytes and bytearray/array.Damien George2014-11-05
| | | | | | Eg b"123" + bytearray(2) now works. This patch actually decreases code size while adding functionality: 32-bit unix down by 128 bytes, stmhal down by 84 bytes.
* 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.