summaryrefslogtreecommitdiffstatshomepage
path: root/py
Commit message (Collapse)AuthorAge
* py: Change first arg of type.make_new from mp_obj_t to mp_obj_type_t*.Damien George2016-01-11
| | | | | | | | The first argument to the type.make_new method is naturally a uPy type, and all uses of this argument cast it directly to a pointer to a type structure. So it makes sense to just have it a pointer to a type from the very beginning (and a const pointer at that). This patch makes such a change, and removes all unnecessary casting to/from mp_obj_t.
* py: Change type signature of builtin funs that take variable or kw args.Damien George2016-01-11
| | | | | With this patch the n_args parameter is changed type from mp_uint_t to size_t.
* py: Change type of .make_new and .call args: mp_uint_t becomes size_t.Damien George2016-01-11
| | | | | | | This patch changes the type signature of .make_new and .call object method slots to use size_t for n_args and n_kw (was mp_uint_t. Makes code more efficient when mp_uint_t is larger than a machine word. Doesn't affect ports when size_t and mp_uint_t have the same size.
* py: Remove long-obsolete mp_method_t typedef.Damien George2016-01-10
|
* py/objint: Fix classification of float so it works for OBJ_REPR_D.Damien George2016-01-08
|
* py/mpz: Fix conversion of float to mpz so it works on big endian archs.Damien George2016-01-08
|
* py/runtime: Use appropriate printf fmt for malloc num_bytes.Damien George2016-01-08
|
* py/smallint: Allow to override MP_SMALL_INT_MIN et al.Damien George2016-01-08
| | | | | This allows a port to specify exactly how many bits are in a small int (eg for a uPy bytecode cross compiler).
* py/obj: For OBJ_REPR_D, use uint32_t cast when extracting qstr value.Damien George2016-01-08
|
* py/parse: Include unistd.h for ssize_t definition.Damien George2016-01-08
| | | | In some cases ssize_t is not defined by already included headers.
* py/emitglue: Add more feature flags to .mpy persistent bytecode output.Damien George2016-01-08
| | | | | Need to record in .mpy file whether unicode is enabled, and how many bits are in a small int.
* py/viper: Truncate viper integer args so they can be up to 32-bit.Damien George2016-01-07
|
* py/inlinethumb: Remove 30-bit restriction on movwt instruction.Damien George2016-01-07
| | | | movwt can now move a full 32-bit constant into a register.
* py/inlinethumb: Allow assembler to use big ints as args to instructions.Damien George2016-01-07
|
* py/parse: Improve constant folding to operate on small and big ints.Damien George2016-01-07
| | | | | | | | | | | | | | | Constant folding in the parser can now operate on big ints, whatever their representation. This is now possible because the parser can create parse nodes holding arbitrary objects. For the case of small ints the folding is still efficient in RAM because the folded small int is stored inplace in the parse node. Adds 48 bytes to code size on Thumb2 architecture. Helps reduce heap usage because more constants can be computed at compile time, leading to a smaller parse tree, and most importantly means that the constants don't have to be computed at runtime (perhaps more than once). Parser will now be a little slower when folding due to calls to runtime to do the arithmetic.
* py: Change mp_obj_int_is_positive to more general mp_obj_int_sign.Damien George2016-01-07
| | | | This function returns the sign (-1, 0 or 1) of the integer object.
* py/parse: Optimise away parse node that's just parenthesis around expr.Damien George2016-01-07
| | | | | | | | | | Before this patch, (x+y)*z would be parsed to a tree that contained a redundant identity parse node corresponding to the parenthesis. With this patch such nodes are optimised away, which reduces memory requirements for expressions with parenthesis, and simplifies the compiler because it doesn't need to handle this identity case. A parenthesis parse node is still needed for tuples.
* py/modbuiltins: Fix access of mp_obj_t variable, wrap in MP_OBJ_TO_PTR.Damien George2016-01-04
|
* py/objstr: In str.format, handle case of no format spec for string arg.Damien George2016-01-04
| | | | | Handles, eg, "{:>20}".format("foo"), where there is no explicit spec for the type of the argument.
* py: Implement __dict__ for instances.stijn2016-01-03
| | | | | | 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.
* py: Make dir report instance membersDave Hylands2016-01-03
|
* py: Use polymorphic iterator type where possible to reduce code size.Damien George2016-01-03
| | | | | | | 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.
* py/frozenmod: Store frozen module names together, to quickly scan them.Paul Sokolovsky2016-01-03
|
* py: Change struct and macro for builtin fun so they can be type checked.Damien George2016-01-03
|
* py: Change exception traceback data to use size_t instead of mp_uint_t.Damien George2016-01-02
| | | | | 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.
* py: Clean up instantiation of dupterm object.Paul Sokolovsky2016-01-01
| | | | To comply with already established scheme for extmod's.
* py/mpconfig: Make configuration of dupterm object reusable.Paul Sokolovsky2016-01-01
|
* extmod/moduos_dupterm: Make uos.dupterm() implementation reusable.Paul Sokolovsky2016-01-01
| | | | | That's just function which sets/gets dup terminal object, and can be easily reused across ports.
* py/frozenmod: Make frozen module content be 0-terminated.Paul Sokolovsky2016-01-01
| | | | To allow simple zero-terminated lexers.
* py/map: In map lookup, check for fixed map independent of ordered map.Damien George2015-12-31
| | | | | It's possible to have a fixed map that is properly hashed (ie not simply ordered).
* stmhal: Add struct qstr to block of qstrs needed for MICROPY_PY_STRUCT.Dave Hylands2015-12-28
| | | | Otherwise build fails if uctypes is disabled.
* py/gc: Improve mark/sweep debug output.Paul Sokolovsky2015-12-27
| | | | | | | | | | | 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).
* py/map: Add fast-path for hashing of map index when it is a qstr.Damien George2015-12-26
| | | | | | | | 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.
* py: Be more restrictive binding self when looking up instance attrs.Damien George2015-12-26
| | | | | | | | | | | 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.
* extmod/fsusermount: Move module qstrs to global pool from stmhal port.Paul Sokolovsky2015-12-25
|
* py: Handle case of return within the finally block of try-finally.Damien George2015-12-24
| | | | Addresses issue #1636.
* unix/unix_mphal: Raise KeyboardInterrupt straight from signal handler.Paul Sokolovsky2015-12-23
| | | | | | | | 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.
* py/objstr: Applying % (format) operator to bytes should return bytes, not str.Paul Sokolovsky2015-12-20
|
* py/objstr: Make sure that b"%s" % b"foo" uses undecorated bytes value.Paul Sokolovsky2015-12-20
| | | | | I.e. the expected result for above is b"foo", whereas previously we got b"b'foo'".
* py/mpprint: Fix printing of 64bit integers for 64bit windows buildsstijn2015-12-19
| | | | | | | | | | | | | | | | 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.
* py/obj: Fix float constants for MICROPY_OBJ_REPR_C.Damien George2015-12-18
|
* py/gc: When printing info, use %u instead of UINT_FMT for size_t args.Damien George2015-12-18
| | | | | | | | | | 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.
* py: Add MICROPY_ENABLE_COMPILER and MICROPY_PY_BUILTINS_EVAL_EXEC opts.Damien George2015-12-18
| | | | | | | | | | | | 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.
* py/emitglue: Add include of unistd.h for read function.Damien George2015-12-18
|
* py/compile: Simplify compilation of comprehension iterators.Damien George2015-12-18
| | | | Saves 88 bytes on Thumb2, and 200 bytes on x86-64 archs.
* ports: Rename "machine" module to "umachine".Paul Sokolovsky2015-12-18
| | | | | | | | 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.
* py/parse: Include stddef.h for definition of size_t.Damien George2015-12-17
|
* py/modgc: Remove obsolete extern declaration.Damien George2015-12-17
|
* py/compile: Use size_t or uintptr_t instead of mp_uint_t.Damien George2015-12-17
|
* py/parse: Replace mp_int_t/mp_uint_t with size_t etc, where appropriate.Damien George2015-12-17
|