summaryrefslogtreecommitdiffstatshomepage
path: root/py/objstr.c
Commit message (Collapse)AuthorAge
* py: Use mp_obj_get_array where sequence may be a tuple or a list.Krzysztof Blazewicz2017-03-07
|
* py: Add iter_buf to getiter type method.Damien George2017-02-16
| | | | | | | | | | | | | | | Allows to iterate over the following without allocating on the heap: - tuple - list - string, bytes - bytearray, array - dict (not dict.keys, dict.values, dict.items) - set, frozenset Allows to call the following without heap memory: - all, any, min, max, sum TODO: still need to allocate stack memory in bytecode for iter_buf.
* py/objstr: Convert mp_uint_t to size_t (and use int) where appropriate.Damien George2017-02-16
|
* py/objstr: Convert some instances of mp_uint_t to size_t.Damien George2017-02-03
|
* py/objstr: Give correct behaviour when passing a dict to %-formatting.Damien George2017-02-03
| | | | | | This patch fixes two main things: - dicts can be printed directly using '%s' % dict - %-formatting should not crash when passed a non-dict to, eg, '%(foo)s'
* py/objstr: Optimize string concatenation with empty string.Paul Sokolovsky2017-01-27
| | | | | | | | | | | | | | In this, don't allocate copy, just return non-empty string. This helps with a standard pattern of buffering data in case of short reads: buf = b"" while ...: s = f.read(...) buf += s ... For a typical case when single read returns all data needed, there won't be extra allocation. This optimization helps uasyncio.
* py/objstr: Remove unreachable function used only for terse error msgs.Damien George2016-09-27
|
* py: If str/bytes hash is 0 then explicitly compute it.Damien George2016-09-02
|
* py/objstr: Use mp_raise_{Type,Value}Error instead of mp_raise_msg.Damien George2016-08-14
| | | | | This patch does further refactoring using the new mp_raise_TypeError and mp_raise_ValueError functions.
* py: Get rid of assert() in method argument checking functions.Paul Sokolovsky2016-08-12
| | | | | | Checks for number of args removes where guaranteed by function descriptor, self checking is replaced with mp_check_self(). In few cases, exception is raised instead of assert.
* py/runtime: Factor out exception raising helpers.Paul Sokolovsky2016-08-12
| | | | | | Introduce mp_raise_msg(), mp_raise_ValueError(), mp_raise_TypeError() instead of previous pattern nlr_raise(mp_obj_new_exception_msg(...)). Save few bytes on each call, which are many.
* py/objstr,objstrunicode: Fix inconistent #if indentation.Paul Sokolovsky2016-08-07
|
* py/objstr: Make .partition()/.rpartition() methods configurable.Paul Sokolovsky2016-08-07
| | | | Default is disabled, enabled for unix port. Saves 600 bytes on x86.
* py/objstr: Fix mix-signed comparison in str.center().Paul Sokolovsky2016-05-22
|
* py/objstr*: Properly ifdef str.center().Dave Hylands2016-05-22
|
* py/objstr: Implement str.center().Paul Sokolovsky2016-05-22
| | | | | | Disabled by default, enabled in unix port. Need for this method easily pops up when working with text UI/reporting, and coding workalike manually again and again counter-productive.
* py/objstr: Make dedicated splitlines function, supporting diff newlines.Damien George2016-05-13
| | | | | | | | It now supports \n, \r and \r\n as newline separators. Adds 56 bytes to stmhal and 80 bytes to unix x86-64. Fixes issue #1689.
* Revert "py/objstr: .format(): Avoid call to vstr_null_terminated_str()."Paul Sokolovsky2016-05-09
| | | | | | This reverts commit 6de8dbb4880e58c68a08205cb2b9c15940143439. The change was incorrect (correct change would require comparing with end pointer in each if statement in the block).
* py/objstr: .format(): Avoid call to vstr_null_terminated_str().Paul Sokolovsky2016-05-09
| | | | | By comparing with string end pointer instead of checking for NUL byte. Should alleviate reallocations and fragmentation a tiny bit.
* py/objstr: Binary type of str/bytes for buffer protocol is 'B'.Damien George2016-05-07
| | | | | | The type is an unsigned 8-bit value, since bytes objects are exactly that. And it's also sensible for unicode strings to return unsigned values when accessed in a byte-wise manner (CPython does not allow this).
* py/makeqstrdata: Add special case to handle \n qstr.Damien George2016-04-14
|
* py/objarray: Implement "in" operator for bytearray.Paul Sokolovsky2016-02-14
|
* py/objstr: Make mp_obj_str_format_helper static.Damien George2016-02-02
|
* py/objstr: For str.format, don't allocate on the heap for field name.Damien George2016-02-02
|
* py/objstr: For str.format, add nested/computed fields support.pohmelie2016-02-02
| | | | | | | Eg: '{:{}}'.format(123, '>20') @pohmelie was the original author of this patch, but @dpgeorge made significant changes to reduce code size and improve efficiency.
* py: Use new code pattern for parsing kw args with mp_arg_parse_all.Damien George2016-01-13
| | | | Makes code easier to read and more maintainable.
* 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/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: 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/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: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR.Damien George2015-11-29
| | | | | | | | | This allows the mp_obj_t type to be configured to something other than a pointer-sized primitive type. This patch also includes additional changes to allow the code to compile when sizeof(mp_uint_t) != sizeof(void*), such as using size_t instead of mp_uint_t, and various casts.
* py: Add MP_ROM_* macros and mp_rom_* types and use them.Damien George2015-11-29
|
* py: Change qstr_* functions to use size_t as the type for str len arg.Damien George2015-11-29
|
* py: With obj repr "C", change raw str accessor from macro to function.Damien George2015-10-20
| | | | | | This saves around 1000 bytes (Thumb2 arch) because in repr "C" it is costly to check and extract a qstr. So making such check/extract a function instead of a macro saves lots of code space.
* py: Add mp_obj_is_float function (macro) and use it where appropriate.Damien George2015-10-20
|
* py: Rename MP_BOOL() to mp_obj_new_bool() for consistency in naming.Paul Sokolovsky2015-10-11
|
* py: Eliminate some cases which trigger unused parameter warnings.Damien George2015-09-04
|
* py/objstr: Check for keyword args before checking for no posn args.Damien George2015-09-04
| | | | Otherwise something like bytes(abc=123) will succeed.
* py/objstr: For str.endswith(s, start) raise NotImpl instead of assert.Damien George2015-09-04
|
* py: Use mp_not_implemented consistently for not implemented features.Damien George2015-09-03
|
* py/objstr: Simplify printing of bytes objects when unicode enabled.Damien George2015-09-03
|
* py: Inline single use of mp_obj_str_get_len in mp_obj_len_maybe.Damien George2015-09-03
| | | | | | Gets rid of redundant double check for string type. Also remove obsolete declaration of mp_obj_str_get_hash.
* py/objstr: Make str.rsplit(None,n) raise NotImpl instead of assert(0).Damien George2015-09-01
|
* py/objstr: Simplify error handling for bad conversion specifier.Damien George2015-08-30
|
* py/objstr: Fix error reporting for unexpected end of modulo format str.Damien George2015-08-29
|
* py/objstr: Fix error type for badly formatted format specifier.Damien George2015-08-29
| | | | Was KeyError, should be ValueError.
* py/objstr: Make string formatting 8-bit clean.Damien George2015-08-29
|