Paul Sokolovsky
0ef01d0a75
py: Implement core of OrderedDict type.
...
Given that there's already support for "fixed table" maps, which are
essentially ordered maps, the implementation of OrderedDict just extends
"fixed table" maps by adding an "is ordered" flag and add/remove
operations, and reuses 95% of objdict code, just making methods tolerant
to both dict and OrderedDict.
Some things are missing so far, like CPython-compatible repr and comparison.
OrderedDict is Disabled by default; enabled on unix and stmhal ports.
2015-03-20 17:26:10 +00:00
Damien George
8e9a71257d
py: Implement DELETE_GLOBAL in showbc.c.
2015-03-20 17:12:09 +00:00
Paul Sokolovsky
3425431370
objtype: More comment clarification for attribute lookup.
2015-03-20 00:51:55 +02:00
Damien George
2e2e404ff7
py: Allow to compile with extra warnings (sign-compare, unused-param).
2015-03-19 00:25:33 +00:00
Paul Sokolovsky
1954d8021f
objtype: Clarify comment why we call mp_load_method_maybe() for native sub-obj.
2015-03-17 02:08:08 +02:00
Paul Sokolovsky
3cb766344d
objtype: Refactor dealing with native sub-objects for clarity.
2015-03-16 14:00:01 +02:00
Paul Sokolovsky
f0dc0d50e3
objtype: mp_obj_class_lookup: Remove implausible condition.
...
We already have branch for lookup->is_type == true, so here it's guaranteed
to be false.
2015-03-16 13:41:57 +02:00
Paul Sokolovsky
2b67a40fdb
objtype: Clarify comment for mp_obj_class_lookup().
2015-03-16 13:36:58 +02:00
Paul Sokolovsky
66c11ec581
objtype: Clarify code by consistently using common subexpression.
2015-03-16 13:36:58 +02:00
Damien George
d4bd37a561
py: Fix printing of error message when parsing malformed integer.
2015-03-16 10:42:50 +00:00
Damien George
1ef26b35c1
py, extmod: Remove include of unnecessary system headers.
2015-03-14 23:11:25 +00:00
Damien George
836e46976f
py: In pfenv_vprintf, adjust type from mp_uint_t to unsigned int.
2015-03-14 23:09:57 +00:00
Damien George
fa1edff006
py: Remove unnecessary and unused sgn argument from pfenv_print_mp_int.
2015-03-14 22:32:40 +00:00
Damien George
6837d46c1d
py: Fix builtin abs so it works for bools and bignum.
2015-03-14 22:07:30 +00:00
Damien George
42e0c59308
py: Add MICROPY_COMP_{DOUBLE,TRIPLE}_TUPLE_ASSIGN config options.
...
These allow to fine-tune the compiler to select whether it optimises
tuple assignments of the form a, b = c, d and a, b, c = d, e, f.
Sensible defaults are provided.
2015-03-14 13:11:35 +00:00
Damien George
a77ffe66b2
py: In compiler, put macro guard around potentially unused asm vars.
2015-03-14 12:59:31 +00:00
Damien George
848dd0e762
py: Make some mpz functions static and remove unused ones.
2015-03-12 22:48:45 +00:00
Peter D. Gray
b2a237d337
py: Add support for start/stop/step attributes of builtin range object.
2015-03-11 20:02:06 +00:00
Paul Sokolovsky
cb0fc063ed
objmemoryview: Introduce mp_obj_new_memoryview().
...
This follows existing pattern for object constructor API and allows to
create memoryview objects e.g. in external modules.
2015-03-06 21:37:28 +02:00
Paul Sokolovsky
24c1000741
objarray: Support array('O'), array of objects, as extension to CPython.
...
Might be useful at least for memoryview hacks.
2015-03-05 22:58:31 +02:00
Paul Sokolovsky
16b1f5e842
objarray: Fix typo in null TYPECODE_MASK.
2015-03-04 23:03:31 +02:00
Damien George
d891452a73
py: Add MICROPY_MALLOC_USES_ALLOCATED_SIZE to allow simpler malloc API.
2015-03-03 21:23:13 +00:00
Paul Sokolovsky
e104acdb8c
runtime: Typo fixes in comments.
2015-03-03 21:37:50 +02:00
Damien George
dc790977d4
py: In inline assembler, reset labels on code-size pass.
2015-03-03 17:34:49 +00:00
Damien George
3665d0b2ff
py: Simplify some inline-assembler error messages, but retain meaning.
...
Just to reduce code size. Messages are still to the point and
unambiguous.
2015-03-03 17:11:18 +00:00
Damien George
9c5cabb502
py: Give error for duplicate label in inline assembler.
2015-03-03 17:08:02 +00:00
stijn
803264bb17
py: Guard against redef of nlr_push with DEBUG + MICROPY_NLR_SETJMP.
2015-03-03 14:34:40 +00:00
Damien George
67c5f89af5
py: In inline assembler, fix branch out-of-range error reporting.
...
Should only give an error on the last pass of the assembler, since
that's when we are certain about the branch size.
2015-03-02 17:51:32 +00:00
Damien George
db1e10d5ea
py: Use SMALL_INT creation macro in builtin sum.
2015-03-02 17:19:44 +00:00
Damien George
9f142f0c84
py: For inline assembler, add bcc_n and bcc_w ops.
...
Addresses issue #1143 .
2015-03-02 14:29:52 +00:00
Damien George
a2e383820d
py: Clean up and comment out unused functions in mpz.
2015-03-02 12:58:06 +00:00
Damien George
62a3a287d9
py: Set compiler scope before folding constants so error messages work.
...
Addresses issue #1140 .
2015-03-01 12:04:05 +00:00
Damien George
7711afbb4a
py: Combine complie functions for or_test/and_test to reduce code size.
...
Saves around 60 bytes code on Thumb2 archs.
2015-02-28 15:10:18 +00:00
Damien George
63f3832e81
py: Combine emit functions for jump true/false to reduce code size.
...
Saves 116 bytes for stmhal and 56 bytes for cc3200 port.
2015-02-28 15:04:06 +00:00
Damien George
0b2fd91890
py: Combine logic for compiling and/or tests, to reduce code size.
...
Reduces code size by 72 bytes on Thumb2 archs.
2015-02-28 14:37:54 +00:00
Paul Sokolovsky
cefcbb22b2
objarray: Implement array slice assignment.
...
This is rarely used feature which takes enough code to implement, so is
controlled by MICROPY_PY_ARRAY_SLICE_ASSIGN config setting, default off.
But otherwise it may be useful, as allows to update arbitrary-sized data
buffers in-place.
Slice is yet to implement, and actually, slice assignment implemented in
such a way that RHS of assignment should be array of the exact same item
typecode as LHS. CPython has it more relaxed, where RHS can be any sequence
of compatible types (e.g. it's possible to assign list of int's to a
bytearray slice).
Overall, when all "slice write" features are implemented, it may cost ~1KB
of code.
2015-02-27 22:17:15 +02:00
Damien George
0bb971370b
py: Transform assert logic in compiler to save code space.
...
Saves about 250 code bytes for Thumb2 archs.
2015-02-27 14:25:47 +00:00
Damien George
4d77e1a034
py: Use m_{new,renew,del} consistently.
...
This is so all memory requests go through the same interface.
2015-02-27 09:34:51 +00:00
Damien George
4852e09c79
py: Fix adding of traceback so that it appends to existing info.
...
This makes exception traceback info self contained (ie doesn't rely on
list object, which was a bit of a hack), reduces code size, and reduces
RAM footprint of exception by eliminating the list object.
Addresses part of issue #1126 .
2015-02-27 00:36:39 +00:00
Damien George
12d6d777e1
py: Small optimisation of logic flow in BC_WITH_CLEANUP bytecode.
...
Slightly smaller code, and does not need to use C stack to save
temporaries.
2015-02-26 17:54:50 +00:00
Damien George
534574348e
py: Make inline assembler raise exception when branch not in range.
...
Addresses issue #1132 .
2015-02-25 15:45:55 +00:00
Damien George
993f067fa2
py: In inline assembler, add return statement to fix flow logic.
2015-02-24 22:43:01 +00:00
Damien George
e5315f7ffd
py: Factor some code in inline thumb assembler to reduce code size.
2015-02-24 16:35:37 +00:00
Damien George
e41b21c01e
py: Make more asmthumb functions inline to reduce code size.
2015-02-24 16:32:52 +00:00
Damien George
8f7976ba0d
py: Reduce code size of inline thumb assembler by using static tables.
...
Reduces stmhal by about 300 bytes ROM.
2015-02-24 16:10:58 +00:00
nhtshot
5d323defe4
py: Update parse.c&mpconfig.h to reflect rename of mp_lexer_show_token.
...
This function is only used when DEBUG_PRINTERS and USE_RULE_NAME are
enabled.
2015-02-23 21:36:05 +00:00
Paul Sokolovsky
71ebd4b7f0
py: Implement UnicodeError.
...
Still too shy to implement UnicodeEncodeError which was really needed for
micropython-lib case.
2015-02-23 23:20:16 +02:00
Damien George
5cbeacebdb
py: Make math special functions configurable and disabled by default.
...
The implementation of these functions is very large (order 4k) and they
are rarely used, so we don't enable them by default.
They are however enabled in stmhal and unix, since we have the room.
2015-02-22 14:48:18 +00:00
Paul Sokolovsky
e06cf89f04
py: Add few more special methods.
2015-02-22 01:21:08 +02:00
Damien George
eff359e114
py: Expose mp_obj_list_remove as a public function.
2015-02-21 14:47:02 +00:00