summaryrefslogtreecommitdiff
path: root/py
AgeCommit message (Collapse)Author
2016-01-04py/objstr: In str.format, handle case of no format spec for string arg.Damien George
Handles, eg, "{:>20}".format("foo"), where there is no explicit spec for the type of the argument.
2016-01-03py: Implement __dict__ for instances.stijn
Note that even though wrapped in MICROPY_CPYTHON_COMPAT, it is not fully compatible because the modifications to the dictionary do not propagate to the actual instance members.
2016-01-03py: Make dir report instance membersDave Hylands
2016-01-03py: Use polymorphic iterator type where possible to reduce code size.Damien George
Only types whose iterator instances still fit in 4 machine words have been changed to use the polymorphic iterator. Reduces Thumb2 arch code size by 264 bytes.
2016-01-03py/frozenmod: Store frozen module names together, to quickly scan them.Paul Sokolovsky
2016-01-03py: Change struct and macro for builtin fun so they can be type checked.Damien George
2016-01-02py: Change exception traceback data to use size_t instead of mp_uint_t.Damien George
The traceback array stores qstrs and line numbers. qstrs are typed as size_t, and line numbers should safely fit in size_t as well.
2016-01-01py: Clean up instantiation of dupterm object.Paul Sokolovsky
To comply with already established scheme for extmod's.
2016-01-01py/mpconfig: Make configuration of dupterm object reusable.Paul Sokolovsky
2016-01-01extmod/moduos_dupterm: Make uos.dupterm() implementation reusable.Paul Sokolovsky
That's just function which sets/gets dup terminal object, and can be easily reused across ports.
2016-01-01py/frozenmod: Make frozen module content be 0-terminated.Paul Sokolovsky
To allow simple zero-terminated lexers.
2015-12-31py/map: In map lookup, check for fixed map independent of ordered map.Damien George
It's possible to have a fixed map that is properly hashed (ie not simply ordered).
2015-12-28stmhal: Add struct qstr to block of qstrs needed for MICROPY_PY_STRUCT.Dave Hylands
Otherwise build fails if uctypes is disabled.
2015-12-27py/gc: Improve mark/sweep debug output.Paul Sokolovsky
Previously, mark operation weren't logged at all, while it's quite useful to see cascade of marks in case of over-marking (and in other cases too). Previously, sweep was logged for each block of object in memory, but that doesn't make much sense and just lead to longer output, harder to parse by a human. Instead, log sweep only once per object. This is similar to other memory manager operations, e.g. an object is allocated, then freed. Or object is allocated, then marked, otherwise swept (one log entry per operation, with the same memory address in each case).
2015-12-26py/map: Add fast-path for hashing of map index when it is a qstr.Damien George
Map indicies are most commonly a qstr, and adding a fast-path for hashing of a qstr increases overall performance of the runtime. On pyboard there is a 4% improvement in the pystone benchmark for a cost of 20 bytes of code size. It's about a 2% improvement on unix.
2015-12-26py: Be more restrictive binding self when looking up instance attrs.Damien George
When looking up and extracting an attribute of an instance, some attributes must bind self as the first argument to make a working method call. Previously to this patch, any attribute that was callable had self bound as the first argument. But Python specs require the check to be more restrictive, and only functions, closures and generators should have self bound as the first argument Addresses issue #1675.
2015-12-25extmod/fsusermount: Move module qstrs to global pool from stmhal port.Paul Sokolovsky
2015-12-24py: Handle case of return within the finally block of try-finally.Damien George
Addresses issue #1636.
2015-12-23unix/unix_mphal: Raise KeyboardInterrupt straight from signal handler.Paul Sokolovsky
POSIX doesn't guarantee something like that to work, but it works on any system with careful signal implementation. Roughly, the requirement is that signal handler is executed in the context of the process, its main thread, etc. This is true for Linux. Also tested to work without issues on MacOSX.
2015-12-20py/objstr: Applying % (format) operator to bytes should return bytes, not str.Paul Sokolovsky
2015-12-20py/objstr: Make sure that b"%s" % b"foo" uses undecorated bytes value.Paul Sokolovsky
I.e. the expected result for above is b"foo", whereas previously we got b"b'foo'".
2015-12-19py/mpprint: Fix printing of 64bit integers for 64bit windows buildsstijn
This makes all tests pass again for 64bit windows builds which would previously fail for anything printing ranges (builtin_range/unpack1) because they were printed as range( ld, ld ). This is done by reusing the mp_vprintf implementation for MICROPY_OBJ_REPR_D for 64bit windows builds (both msvc and mingw-w64) since the format specifier used for 64bit integers is also %lld, or %llu for the unsigned version. Note these specifiers used to be fetched from inttypes.h, which is the C99 way of working with printf/scanf in a portable way, but mingw-w64 wants to be backwards compatible with older MS C runtimes and uses the non-portable %I64i instead of %lld in inttypes.h, so remove the use of said header again in mpconfig.h and define the specifiers manually.
2015-12-18py/obj: Fix float constants for MICROPY_OBJ_REPR_C.Damien George
2015-12-18py/gc: When printing info, use %u instead of UINT_FMT for size_t args.Damien George
Ideally we'd use %zu for size_t args, but that's unlikely to be supported by all runtimes, and we would then need to implement it in mp_printf. So simplest and most portable option is to use %u and cast the argument to uint(=unsigned int). Note: reason for the change is that UINT_FMT can be %llu (size suitable for mp_uint_t) which is wider than size_t and prints incorrect results.
2015-12-18py: Add MICROPY_ENABLE_COMPILER and MICROPY_PY_BUILTINS_EVAL_EXEC opts.Damien George
MICROPY_ENABLE_COMPILER can be used to enable/disable the entire compiler, which is useful when only loading of pre-compiled bytecode is supported. It is enabled by default. MICROPY_PY_BUILTINS_EVAL_EXEC controls support of eval and exec builtin functions. By default they are only included if MICROPY_ENABLE_COMPILER is enabled. Disabling both options saves about 40k of code size on 32-bit x86.
2015-12-18py/emitglue: Add include of unistd.h for read function.Damien George
2015-12-18py/compile: Simplify compilation of comprehension iterators.Damien George
Saves 88 bytes on Thumb2, and 200 bytes on x86-64 archs.
2015-12-18ports: Rename "machine" module to "umachine".Paul Sokolovsky
To let unix port implement "machine" functionality on Python level, and keep consistent naming in other ports (baremetal ports will use magic module "symlinking" to still load it on "import machine"). Fixes #1701.
2015-12-17py/parse: Include stddef.h for definition of size_t.Damien George
2015-12-17py/modgc: Remove obsolete extern declaration.Damien George
2015-12-17py/compile: Use size_t or uintptr_t instead of mp_uint_t.Damien George
2015-12-17py/parse: Replace mp_int_t/mp_uint_t with size_t etc, where appropriate.Damien George
2015-12-17py/qstr: Change type of qstr from mp_uint_t to size_t.Damien George
For builds where mp_uint_t is larger than size_t, it doesn't make sense to use such a wide type for qstrs. There can only be as many qstrs as there is address space on the machine, so size_t is the correct type to use. Saves about 3000 bytes of code size when building unix/ port with MICROPY_OBJ_REPR_D.
2015-12-17py/qstr: Use size_t instead of mp_uint_t when counting allocated bytes.Damien George
2015-12-17py/bc: Use size_t instead of mp_uint_t to count size of state and args.Damien George
2015-12-17py: Fix MICROPY_STACKLESS mode to compile with MICROPY_OBJ_REPR_D.Damien George
2015-12-17py/mpprint: Implement %llu and %lld format specifiers for mp_printf.Damien George
Only enabled for MICROPY_OBJ_REPR_D.
2015-12-16py/gc: Use size_t instead of mp_uint_t to count things related to heap.Damien George
size_t is the correct type to use to count things related to the size of the address space. Using size_t (instead of mp_uint_t) is important for the efficiency of ports that configure mp_uint_t to larger than the machine word size.
2015-12-16py/gc: For finaliser, interpret a pointer into the heap as concrete obj.Damien George
2015-12-16py/gc: Scan GC blocks as an array of pointers, not an array of objects.Damien George
The GC should search for pointers within the heap. This patch makes a difference when an object is larger than a pointer (eg 64-bit NaN boxing).
2015-12-16py/modsys: Fix module globals table to use MP_ROM_QSTR.Damien George
2015-12-14py/objpolyiter: Implement instance-polymorphic iterator type.Paul Sokolovsky
This allows to have single itertaor type for various internal iterator types (save rodata space by not having repeating almost-empty type structures). It works by looking "iternext" method stored in particular object instance (should be first object field after "base").
2015-12-13unix: Move modmachine into unix directoryDave Hylands
This leaves behind the common functionality in extmod/machine_mem.c which can be used by all ports.
2015-12-12py/modmath: Add domain error checking to sqrt, log, log2, log10.Michael Buesch
These functions will raise 'ValueError: math domain error' on invalid input.
2015-12-12py: Fix compiler to handle lambdas used as default arguments.Damien George
Addresses issue #1709.
2015-12-10py: Make UNARY_OP_NOT a first-class op, to agree with Py not semantics.Damien George
Fixes #1684 and makes "not" match Python semantics. The code is also simplified (the separate MP_BC_NOT opcode is removed) and the patch saves 68 bytes for bare-arm/ and 52 bytes for minimal/. Previously "not x" was implemented as !mp_unary_op(x, MP_UNARY_OP_BOOL), so any given object only needs to implement MP_UNARY_OP_BOOL (and the VM had a special opcode to do the ! bit). With this patch "not x" is implemented as mp_unary_op(x, MP_UNARY_OP_NOT), but this operation is caught at the start of mp_unary_op and dispatched as !mp_obj_is_true(x). mp_obj_is_true has special logic to test for truthness, and is the correct way to handle the not operation.
2015-12-10py/emitinlinethumb: Add support for MRS instruction.Henrik Sölver
Only IPSR and BASEPRI special registers supported at the moment, but easy to extend in the future.
2015-12-10py/mkrules.mk: Don't pass COPT to linker.Paul Sokolovsky
Oftentimes, libc, libm, etc. don't come compiled with CPU compressed code option (Thumb, MIPS16, etc.), but we may still want to use such compressed code for MicroPython itself.
2015-12-09py: Add mp_get_stream_raise to factor out check for stream methods.Damien George
2015-12-09py: Fix calling of parent classmethod from instance of subclass.Damien George
Addresses issue #1697.