Paul Sokolovsky
ff8e35b42e
objstr: Common subexpression elimination for vstr_str(field_name).
2015-01-04 13:23:44 +02:00
Paul Sokolovsky
c114496641
objstr: Implement kwargs support for str.format().
2015-01-04 00:26:31 +02:00
Damien George
51dfcb4bb7
py: Move to guarded includes, everywhere in py/ core.
...
Addresses issue #1022 .
2015-01-01 20:32:09 +00:00
Paul Sokolovsky
2c75665445
objstr: Fix %d-formatting of floats.
2014-12-31 02:21:19 +02:00
Damien George
c55a4d82cf
py: Make bytes objs work with more str methods; add tests.
2014-12-24 20:28:30 +00:00
Damien George
81836c28b3
py: Use str_to_int function in more places to reduce code size.
2014-12-21 21:07:03 +00:00
Damien George
b4fe6e28eb
py: Fix function type: () -> (void).
2014-12-10 18:05:42 +00:00
Damien George
32ef3a3517
py: Allow bytes/bytearray/array to be init'd by buffer protocol objects.
...
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).
2014-12-04 15:46:14 +00:00
Damien George
6f5eb84c19
py: #if guard str_make_new when not needed.
2014-11-27 16:55:47 +00:00
Damien George
1e9a92f84f
py: Use shorter, static error msgs when ERROR_REPORTING_TERSE enabled.
...
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.
2014-11-06 17:36:16 +00:00
Damien George
be8e99c7d4
py: Allow bytes object as argument to some str methods.
...
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.
2014-11-05 16:45:54 +00:00
Damien George
a65c03c6c0
py: Allow +, in, and compare ops between bytes and bytearray/array.
...
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.
2014-11-05 16:30:34 +00:00
Paul Sokolovsky
e62a0fe367
objstr: Allow to convert any buffer proto object to str.
...
Original motivation is to support converting bytearrays, but easier to just
support buffer protocol at all.
2014-10-31 00:03:53 +02:00
Paul Sokolovsky
31619cc589
py: mp_obj_str_get_str(): Work with bytes too.
...
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().
2014-10-31 00:00:39 +02:00
Damien George
3aa09f5784
py: Use MP_OBJ_NULL instead of NULL in a few places.
2014-10-23 12:06:53 +01:00
Damien George
20f59e182e
py: Make mp_const_empty_bytes globally available.
2014-10-21 21:02:56 +01:00
Damien George
39dc145478
py: Change [u]int to mp_[u]int_t in qstr.[ch], and some other places.
...
This should pretty much resolve issue #50 .
2014-10-03 19:52:22 +01:00
Damien George
cde0ca21bf
py: Simplify JSON str printing (while still conforming to JSON spec).
...
The JSON specs are relatively flexible and allow us to use one function
to print strings, be they ascii, bytes or utf-8 encoded.
2014-09-25 17:35:56 +01:00
Damien George
612045f53f
py: Add native json printing using existing print framework.
...
Also add start of ujson module with dumps implemented. Enabled in unix
and stmhal ports. Test passes on both.
2014-09-17 22:56:34 +01:00
Damien George
4abff7500f
py: Change uint to mp_uint_t in runtime.h, stackctrl.h, binary.h.
...
Part of code cleanup, working towards resolving issue #50 .
2014-08-30 14:59:21 +01:00
Damien George
4d91723587
py: Remove use of int type in obj.h.
...
Part of code cleanup, working towards resolving issue #50 .
2014-08-30 14:28:06 +01:00
Damien George
d182b98a37
py: Change all uint to mp_uint_t in obj.h.
...
Part of code cleanup, working towards resolving issue #50 .
2014-08-30 14:19:41 +01:00
Damien George
9c4cbe2ac0
py: Make tuple and list use mp_int_t/mp_uint_t.
...
Part of code cleanup, to resolve issue #50 .
2014-08-30 14:04:14 +01:00
Damien George
ecc88e949c
Change some parts of the core API to use mp_uint_t instead of uint/int.
...
Addressing issue #50 , still some way to go yet.
2014-08-30 00:35:11 +01:00
Damien George
17ae2395c2
py: Use memmove instead of memcpy when appropriate.
...
Found this bug by running unix/ tests with DEBUG=1 enabled when
compiling.
2014-08-29 21:07:54 +01:00