summaryrefslogtreecommitdiffstatshomepage
path: root/py/objarray.c
Commit message (Collapse)AuthorAge
* all: Raise exceptions via mp_raise_XXXJavier Candeira2017-08-13
| | | | | | | | - 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.
* all: Use the name MicroPython consistently in commentsAlexander Steffen2017-07-31
| | | | | There were several different spellings of MicroPython present in comments, when there should be only one.
* py: Use mp_raise_TypeError/mp_raise_ValueError helpers where possible.Damien George2017-03-28
| | | | Saves 168 bytes on bare-arm.
* py/objarray: Use mp_obj_str_get_str instead of mp_obj_str_get_data.Damien George2017-03-25
|
* py: Use size_t as len argument and return type of mp_get_index.Damien George2017-03-23
| | | | | These values are used to compute memory addresses and so size_t is the more appropriate type to use.
* py/objarray: Disallow slice-assignment to read-only memoryview.Damien George2017-02-27
| | | | Also comes with a test for this. Fixes issue #2904.
* py: De-optimise some uses of mp_getiter, so they don't use the C stack.Damien George2017-02-16
| | | | | In these cases the heap is anyway used to create a new object so no real need to use the C stack for iterating. It saves a few bytes of code size.
* 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/objarray: Convert mp_uint_t to size_t where appropriate.Damien George2017-02-16
|
* py/binary: mp_binary_get_size: Raise error on unsupported typecodes.Paul Sokolovsky2017-01-17
| | | | | Previouly, we had errors checked in callers, which led to duplicate code or missing checks in some places.
* py: Use mp_raise_msg helper function where appropriate.Damien George2016-10-17
| | | | | Saves the following number of bytes of code space: 176 for bare-arm, 352 for minimal, 272 for unix x86-64, 140 for stmhal, 120 for esp8266.
* py/objarray: Split out header to allow direct access to object.Paul Sokolovsky2016-07-06
| | | | | | This follows source code/header file organization similar to few other objects, and intended to be used only is special cases, where efficiency/ simplicity matters.
* py/objarray: Fix array.append so it doesn't extend if append fails.Damien George2016-04-07
| | | | Addresses issue #1965.
* py/objarray: Fix array slice assignment when array is reallocated.Damien George2016-03-14
| | | | Addresses issue #1898.
* py/objarray: Implement "in" operator for bytearray.Paul Sokolovsky2016-02-14
|
* 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 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: 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: 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: Use mp_not_implemented consistently for not implemented features.Damien George2015-09-03
|
* py: reduce array slice assignment code sizeDelio Brignoli2015-06-06
|
* py: Small code space optimisations for memoryview slice assigment.Damien George2015-07-20
| | | | | Also adds #if guards to allow uPy core to compile without memoryview enabled, but with slice assignment enabled.
* py: Implement memoryview slice assignment.Delio Brignoli2015-07-20
| | | | | Adds ability to do "memcpy" with memoryview objects, such as: m1[0:3] = m2[2:5].
* py/objarray.c: Allow to build with debugging and bytearray but no array.Damien George2015-07-02
|
* py/binary: Make return type of mp_binary_get_size size_t instead of int.Kaspar Schleiser2015-05-17
| | | | Fixes sign-compare warning.
* py: Overhaul and simplify printf/pfenv mechanism.Damien George2015-04-16
| | | | | | | | | | | | | | | | | | | | | | Previous to this patch the printing mechanism was a bit of a tangled mess. This patch attempts to consolidate printing into one interface. All (non-debug) printing now uses the mp_print* family of functions, mainly mp_printf. All these functions take an mp_print_t structure as their first argument, and this structure defines the printing backend through the "print_strn" function of said structure. Printing from the uPy core can reach the platform-defined print code via two paths: either through mp_sys_stdout_obj (defined pert port) in conjunction with mp_stream_write; or through the mp_plat_print structure which uses the MP_PLAT_PRINT_STRN macro to define how string are printed on the platform. The former is only used when MICROPY_PY_IO is defined. With this new scheme printing is generally more efficient (less layers to go through, less arguments to pass), and, given an mp_print_t* structure, one can call mp_print_str for efficiency instead of mp_printf("%s", ...). Code size is also reduced by around 200 bytes on Thumb2 archs.
* objarray: Support assignment of bytes to bytearray slice.Paul Sokolovsky2015-04-16
|
* py: Allow to compile with extra warnings (sign-compare, unused-param).Damien George2015-03-19
|
* objmemoryview: Introduce mp_obj_new_memoryview().Paul Sokolovsky2015-03-06
| | | | | This follows existing pattern for object constructor API and allows to create memoryview objects e.g. in external modules.
* objarray: Fix typo in null TYPECODE_MASK.Paul Sokolovsky2015-03-04
|
* py: Add MICROPY_MALLOC_USES_ALLOCATED_SIZE to allow simpler malloc API.Damien George2015-03-03
|
* objarray: Implement array slice assignment.Paul Sokolovsky2015-02-27
| | | | | | | | | | | | | | | | 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.
* py: Use m_{new,renew,del} consistently.Damien George2015-02-27
| | | | This is so all memory requests go through the same interface.
* py, unix: Allow to compile with -Wunused-parameter.Damien George2015-01-20
| | | | See issue #699.
* objarray: Make sure that longint works as bytearray size.Paul Sokolovsky2015-01-04
|
* py: Move to guarded includes, everywhere in py/ core.Damien George2015-01-01
| | | | Addresses issue #1022.
* 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: Generalise and reduce code size of array +, += and .extend().Damien George2014-11-30
| | | | | | | | By using the buffer protocol for these array operations, we now allow addition of memoryview objects, and objects with "incompatible" typecodes (in this case it just adds bytes naively). This is an extension to CPython which seems sensible. It also reduces the code size.
* py: Implement +, += and .extend for bytearray and array objs.Damien George2014-11-30
| | | | Addresses issue #994.
* Fix errors after enabling -Wpointer-arithstijn2014-10-29
|
* py: Fix memoryview referencing so it retains ptr to original buffer.Damien George2014-10-26
| | | | | This way, if original parent object is GC'd, the memoryview still points to the underlying buffer data so that buffer is not GC'd.
* py: Add builtin memoryview object (mostly using array code).Damien George2014-10-23
|
* py: Convert [u]int to mp_[u]int_t where appropriate.Damien George2014-10-03
| | | | Addressing issue #50.
* 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.
* 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.
* objarray: Implement equality testing between arrays and other buffers.Paul Sokolovsky2014-08-10
|