summaryrefslogtreecommitdiffstatshomepage
path: root/py/objstr.c
Commit message (Collapse)AuthorAge
* objstr: Fix bytes creation from array of long ints.Paul Sokolovsky2015-02-09
|
* py: Change vstr_null_terminate -> vstr_null_terminated_str, returns str.Damien George2015-01-29
|
* py: Change vstr so that it doesn't null terminate buffer by default.Damien George2015-01-28
| | | | | | | | | This cleans up vstr so that it's a pure "variable buffer", and the user can decide whether they need to add a terminating null byte. In most places where vstr is used, the vstr did not need to be null terminated and so this patch saves code size, a tiny bit of RAM, and makes vstr usage more efficient. When null termination is needed it must be done explicitly using vstr_null_terminate.
* py: bytes(): Make sure we add values as bytes, not as chars.Paul Sokolovsky2015-01-28
|
* py: Remove duplicated mp_obj_str_make_new function from objstrunicode.c.Damien George2015-01-28
|
* objstr: Remove code duplication and unbreak Windows build.Paul Sokolovsky2015-01-23
| | | | | | | | There was really weird warning (promoted to error) when building Windows port. Exact cause is still unknown, but it uncovered another issue: 8-bit and unicode str_make_new implementations should be mutually exclusive, and not built at the same time. What we had is that bytes_decode() pulled 8-bit str_make_new() even for unicode build.
* objstr*: Use separate names for locals_dict of 8-bit and unicode str's.Paul Sokolovsky2015-01-23
| | | | To somewhat unbreak -DSTATIC="" compile.
* py: Add comments for vstr_init and mp_obj_new_str.Damien George2015-01-21
|
* py: Remove mp_obj_str_builder and use vstr instead.Damien George2015-01-21
| | | | | | | | | | | | With this patch str/bytes construction is streamlined. Always use a vstr to build a str/bytes object. If the size is known beforehand then use vstr_init_len to allocate only required memory. Otherwise use vstr_init and the vstr will grow as needed. Then use mp_obj_new_str_from_vstr to create a str/bytes object using the vstr memory. Saves code ROM: 68 bytes on stmhal, 108 bytes on bare-arm, and 336 bytes on unix x64.
* py: Add mp_obj_new_str_from_vstr, and use it where relevant.Damien George2015-01-21
| | | | | | | | This patch allows to reuse vstr memory when creating str/bytes object. This improves memory usage. Also saves code ROM: 128 bytes on stmhal, 92 bytes on bare-arm, and 88 bytes on unix x64.
* py, unix: Allow to compile with -Wunused-parameter.Damien George2015-01-20
| | | | See issue #699.
* py, unix, stmhal: Allow to compile with -Wshadow.Damien George2015-01-20
| | | | See issue #699.
* py, unix: Allow to compile with -Wsign-compare.Damien George2015-01-16
| | | | See issue #699.
* py, unix: Allow to compile with -Wdouble-promotion.Damien George2015-01-12
| | | | Ref issue #699.
* py: Remove unnecessary BINARY_OP_EQUAL code that just checks pointers.Damien George2015-01-11
| | | | | | | Previous patch c38dc3ccc76d1a9bf867704f43ea5d15da3fea7b allowed any object to be compared with any other, using pointer comparison for a fallback. As such, existing code which checked for this case is no longer needed.
* objstr: Common subexpression elimination for vstr_str(field_name).Paul Sokolovsky2015-01-04
|
* objstr: Implement kwargs support for str.format().Paul Sokolovsky2015-01-04
|
* py: Move to guarded includes, everywhere in py/ core.Damien George2015-01-01
| | | | Addresses issue #1022.
* objstr: Fix %d-formatting of floats.Paul Sokolovsky2014-12-31
|
* py: Make bytes objs work with more str methods; add tests.Damien George2014-12-24
|
* py: Use str_to_int function in more places to reduce code size.Damien George2014-12-21
|
* py: Fix function type: () -> (void).Damien George2014-12-10
|
* 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: #if guard str_make_new when not needed.Damien George2014-11-27
|
* 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: 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.
* 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: Use MP_OBJ_NULL instead of NULL in a few places.Damien George2014-10-23
|
* py: Make mp_const_empty_bytes globally available.Damien George2014-10-21
|
* py: Change [u]int to mp_[u]int_t in qstr.[ch], and some other places.Damien George2014-10-03
| | | | This should pretty much resolve issue #50.
* py: Simplify JSON str printing (while still conforming to JSON spec).Damien George2014-09-25
| | | | | The JSON specs are relatively flexible and allow us to use one function to print strings, be they ascii, bytes or utf-8 encoded.
* py: Add native json printing using existing print framework.Damien George2014-09-17
| | | | | Also add start of ujson module with dumps implemented. Enabled in unix and stmhal ports. Test passes on both.
* py: Change uint to mp_uint_t in runtime.h, stackctrl.h, binary.h.Damien George2014-08-30
| | | | Part of code cleanup, working towards resolving issue #50.
* py: Remove use of int type in obj.h.Damien George2014-08-30
| | | | Part of code cleanup, working towards resolving issue #50.
* py: Change all uint to mp_uint_t in obj.h.Damien George2014-08-30
| | | | Part of code cleanup, working towards resolving issue #50.
* py: Make tuple and list use mp_int_t/mp_uint_t.Damien George2014-08-30
| | | | Part of code cleanup, to resolve issue #50.
* Change some parts of the core API to use mp_uint_t instead of uint/int.Damien George2014-08-30
| | | | Addressing issue #50, still some way to go yet.
* py: Use memmove instead of memcpy when appropriate.Damien George2014-08-29
| | | | | Found this bug by running unix/ tests with DEBUG=1 enabled when compiling.
* py: Improve efficiency of MP_OBJ_IS_STR_OR_BYTES.Damien George2014-08-27
| | | | | Saves ROM (16 on stmhal, 240 on 64-bit unix) and should be quicker since there is 1 less branch.
* Make int(b'123') work properly.Dave Hylands2014-08-26
|
* py: Fix mult by negative number of tuple, list, str, bytes.Damien George2014-08-13
| | | | | | | Multiplication of a tuple, list, str or bytes now yields an empty sequence (instead of crashing). Addresses issue #799 Also added ability to mult bytes on LHS by integer.
* py, objstr: Optimise bytes subscr when unicode is enabled.Damien George2014-08-11
| | | | Saves code bytes and makes it faster, so why not?
* objstr: Make sure that bytes are indexed as bytes, not as unicode.Paul Sokolovsky2014-08-11
| | | | Fixes #795.
* objstr: split(): check arg type consistency (str vs bytes).Paul Sokolovsky2014-08-10
| | | | Similar to other methods and following CPython3 strictness.
* py: Make MP_OBJ_NEW_SMALL_INT cast arg to mp_int_t itself.Damien George2014-07-31
| | | | Addresses issue #724.
* py: Add mp_obj_str_builder_end_with_len.Damien George2014-07-31
| | | | | This allows to create str's with a smaller length than initially asked for.
* Rename machine_(u)int_t to mp_(u)int_t.Damien George2014-07-03
| | | | See discussion in issue #50.
* py: Make unichar_charlen() accept/return machine_uint_t.Paul Sokolovsky2014-06-28
|