- Feb 12, 2019
-
-
Damien George authored
These macros could in principle be (inline) functions so it makes sense to have them lower case, to match the other C API functions. The remaining macros that are upper case are: - MP_OBJ_TO_PTR, MP_OBJ_FROM_PTR - MP_OBJ_NEW_SMALL_INT, MP_OBJ_SMALL_INT_VALUE - MP_OBJ_NEW_QSTR, MP_OBJ_QSTR_VALUE - MP_OBJ_FUN_MAKE_SIG - MP_DECLARE_CONST_xxx - MP_DEFINE_CONST_xxx These must remain macros because they are used when defining const data (at least, MP_OBJ_NEW_SMALL_INT is so it makes sense to have MP_OBJ_SMALL_INT_VALUE also a macro). For those macros that have been made lower case, compatibility macros are provided for the old names so that users do not need to change their code immediately.
-
- Feb 05, 2019
-
-
Paul Sokolovsky authored
Based on git history.
-
- Oct 22, 2018
-
-
Paul Sokolovsky authored
Configurable via MICROPY_PY_BUILTINS_STR_COUNT. Default is enabled. Disabled for bare-arm, minimal, unix-minimal and zephyr ports. Disabling it saves 408 bytes on x86.
-
- Sep 26, 2018
-
-
Paul Sokolovsky authored
This is an improvement over previous behavior when str was returned for both str and bytes input format. This new behaviour is also consistent with how the % operator works, as well as many other str/bytes methods. It should be noted that it's not how current versions of CPython work, where there's a gap in the functionality and bytes.format() is not supported.
-
- Sep 20, 2018
-
-
Paul Sokolovsky authored
Default is enabled, disabled for minimal builds. Saves 1296 bytes on x86, 976 bytes on ARM.
-
Damien George authored
-
- Jul 30, 2018
-
-
Damien George authored
This error message did not consume all of its variable args, a bug introduced long ago in baf6f14d. By fixing it to use %s (instead of keeping the string as-is and deleting the last arg) the same error message string is now reused three times in this format function and gives a code size reduction of around 130 bytes. It also now gives a better error message when a non-string is passed in as an argument to format, eg '{:d}'.format([]).
-
- Apr 05, 2018
-
-
Jeff Epler authored
-
- Mar 30, 2018
-
-
Damien George authored
Prior to this patch the code would crash if a key in a ** dict was anything other than a str or qstr. This is because mp_setup_code_state() assumes that keys in kwargs are qstrs (for efficiency). Thanks to @jepler for finding the bug.
-
- Feb 20, 2018
-
-
Damien George authored
At this point in the code the variable "splits" is guaranteed to be positive due to the check for "splits == 0" above it.
-
- Feb 19, 2018
-
-
Damien George authored
Prior to this patch uPy (on a 32-bit arch) would have severe issues when calling bytes(-1): such a call would call vstr_init_len(vstr, -1) which would then +1 on the len and call vstr_init(vstr, 0), which would then round this up and allocate a small amount of memory for the vstr. The bytes constructor would then attempt to zero out all this memory, thinking it had allocated 2^32-1 bytes.
-
- Feb 14, 2018
-
-
Damien George authored
This patch provides inline versions of the utf8 helper functions for the case when unicode is disabled (MICROPY_PY_BUILTINS_STR_UNICODE set to 0). This saves code size. The unichar_charlen function is also renamed to utf8_charlen to match the other utf8 helper functions, and the signature of this function is adjusted for consistency (const char* -> const byte*, mp_uint_t -> size_t).
-
- Nov 29, 2017
-
-
Damien George authored
-
- Nov 24, 2017
-
-
Damien George authored
Before this patch MP_BINARY_OP_IN had two meanings: coming from bytecode it meant that the args needed to be swapped, but coming from within the runtime meant that the args were already in the correct order. This lead to some confusion in the code and comments stating how args were reversed. It also lead to 2 bugs: 1) containment for a subclass of a native type didn't work; 2) the expression "{True} in True" would illegally succeed and return True. In both of these cases it was because the args to MP_BINARY_OP_IN ended up being reversed twice. To fix these things this patch introduces MP_BINARY_OP_CONTAINS which corresponds exactly to the __contains__ special method, and this is the operator that built-in types should implement. MP_BINARY_OP_IN is now only emitted by the compiler and is converted to MP_BINARY_OP_CONTAINS by swapping the arguments.
-
- Nov 16, 2017
-
-
Damien George authored
This patch uses existing qstr data where possible when constructing a str from a bytes object.
-
Damien George authored
The function mp_obj_new_str_of_type is a general str object constructor used in many places in the code to create either a str or bytes object. When creating a str it should first check if the string data already exists as an interned qstr, and if so then return the qstr object. This patch makes the function have such behaviour, which helps to reduce heap usage by reusing existing interned data where possible. The old behaviour of mp_obj_new_str_of_type (which didn't check for existing interned data) is made available through the function mp_obj_new_str_copy, but should only be used in very special cases. One consequence of this patch is that the following expression is now True: 'abc' is ' abc '.split()[0]
-
Damien George authored
This patch simplifies the str creation API to favour the common case of creating a str object that is not forced to be interned. To force interning of a new str the new mp_obj_new_str_via_qstr function is added, and should only be used if warranted. Apart from simplifying the mp_obj_new_str function (and making it have the same signature as mp_obj_new_bytes), this patch also reduces code size by a bit (-16 bytes for bare-arm and roughly -40 bytes on the bare-metal archs).
-
- Oct 04, 2017
-
-
Damien George authored
Because a lot of string processing functions assume there is a null terminating byte, so they can work in an efficient way. Fixes issue #3334.
-
Damien George authored
Header files that are considered internal to the py core and should not normally be included directly are: py/nlr.h - internal nlr configuration and declarations py/bc0.h - contains bytecode macro definitions py/runtime0.h - contains basic runtime enums Instead, the top-level header files to include are one of: py/obj.h - includes runtime0.h and defines everything to use the mp_obj_t type py/runtime.h - includes mpstate.h and hence nlr.h, obj.h, runtime0.h, and defines everything to use the general runtime support functions Additional, specific headers (eg py/objlist.h) can be included if needed.
-
- Sep 19, 2017
-
-
Paul Sokolovsky authored
An issue was due to incorrectly taking size of default strip characters set.
-
- Sep 06, 2017
-
-
tll authored
This patch adds a function utf8_check() to check for a valid UTF-8 encoded string, and calls it when constructing a str from raw bytes. The feature is selectable at compile time via MICROPY_PY_BUILTINS_STR_UNICODE_CHECK and is enabled if unicode is enabled. It costs about 110 bytes on Thumb-2, 150 bytes on Xtensa and 170 bytes on x86-64.
-
- Aug 29, 2017
-
-
Damien George authored
The unary-op/binary-op enums are already defined, and there are no arithmetic tricks used with these types, so it makes sense to use the correct enum type for arguments that take these values. It also reduces code size quite a bit for nan-boxing builds.
-
- Aug 28, 2017
-
-
Paul Sokolovsky authored
Otherwise, it will silently get incorrect result on other values types, including CPython tuple form like "foo.png".endswith(("png", "jpg")) (which MicroPython doesn't support for unbloatedness).
-
- Aug 13, 2017
-
-
Javier Candeira authored
- Changed: ValueError, TypeError, NotImplementedError - OSError invocations unchanged, because the corresponding utility function takes ints, not strings like the long form invocation. - OverflowError, IndexError and RuntimeError etc. not changed for now until we decide whether to add new utility functions.
-
- Aug 09, 2017
-
-
Damien George authored
The main case to catch is invalid types for the containment operator, of the form str.__contains__(non-str).
-
- Jul 31, 2017
-
-
Alexander Steffen authored
There were several different spellings of MicroPython present in comments, when there should be only one.
-
- Jul 03, 2017
-
-
Damien George authored
-
- Jul 02, 2017
-
-
Damien George authored
This matches the coding/layout style of all the other objects.
-
- Jun 07, 2017
-
-
Damien George authored
-
- Jun 02, 2017
-
-
Damien George authored
Negative values mean no limit on the number of splits so should delegate to the .split() method.
-
- May 29, 2017
-
-
Ville Skyttä authored
-
- Apr 02, 2017
-
-
Paul Sokolovsky authored
Split this setting from MICROPY_CPYTHON_COMPAT. The idea is to be able to keep MICROPY_CPYTHON_COMPAT disabled, but still pass more of regression testsuite. In particular, this fixes last failing test in basics/ for Zephyr port.
-
- Mar 29, 2017
-
-
Damien George authored
-
Damien George authored
This patch changes mp_uint_t to size_t for the len argument of the following public facing C functions: mp_obj_tuple_get mp_obj_list_get mp_obj_get_array These functions take a pointer to the len argument (to be filled in by the function) and callers of these functions should update their code so the type of len is changed to size_t. For ports that don't use nan-boxing there should be no change in generate code because the size of the type remains the same (word sized), and in a lot of cases there won't even be a compiler warning if the type remains as mp_uint_t. The reason for this change is to standardise on the use of size_t for variables that count memory (or memory related) sizes/lengths. It helps builds that use nan-boxing.
-
- Mar 23, 2017
-
-
Damien George authored
These values are used to compute memory addresses and so size_t is the more appropriate type to use.
-
- Mar 20, 2017
-
-
stijn authored
Instead of always reporting some object cannot be implicitly be converted to a 'str', even when it is a 'bytes' object, adjust the logic so that when trying to convert str to bytes it is shown like that. This will still report bad implicit conversion from e.g. 'int to bytes' as 'int to str' but it will not result in the confusing 'can't convert 'str' object to str implicitly' anymore for calls like b'somestring'.count('a').
-
- Mar 16, 2017
-
-
Damien George authored
The RHS can only be returned if it is the same type as the LHS.
-
- Mar 07, 2017
-
-
Krzysztof Blazewicz authored
-
- Feb 16, 2017
-
-
Damien George authored
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.
-
Damien George authored
-