aboutsummaryrefslogtreecommitdiff
path: root/py/sequence.c
AgeCommit message (Collapse)Author
2020-04-05all: Use MP_ERROR_TEXT for all error messages.Jim Mussared
2020-02-28all: Reformat C and Python source code with tools/codeformat.py.Damien George
This is run with uncrustify 0.70.1, and black 19.10b0.
2020-01-09py: Make mp_obj_get_type() return a const ptr to mp_obj_type_t.Damien George
Most types are in rodata/ROM, and mp_obj_base_t.type is a constant pointer, so enforce this const-ness throughout the code base. If a type ever needs to be modified (eg a user type) then a simple cast can be used.
2019-12-28py/objslice: Add support for indices() method on slice objects.Nicko van Someren
Instances of the slice class are passed to __getitem__() on objects when the user indexes them with a slice. In practice the majority of the time (other than passing it on untouched) is to work out what the slice means in the context of an array dimension of a particular length. Since Python 2.3 there has been a method on the slice class, indices(), that takes a dimension length and returns the real start, stop and step, accounting for missing or negative values in the slice spec. This commit implements such a indices() method on the slice class. It is configurable at compile-time via MICROPY_PY_BUILTINS_SLICE_INDICES, disabled by default, enabled on unix, stm32 and esp32 ports. This commit also adds new tests for slice indices and for slicing unicode strings.
2019-07-25py/sequence: Fix grammar in comment about equality.Yonatan Goldschmidt
2017-10-04all: Remove inclusion of internal py header files.Damien George
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.
2017-07-31all: Use the name MicroPython consistently in commentsAlexander Steffen
There were several different spellings of MicroPython present in comments, when there should be only one.
2017-05-18py/sequence: Fix boundary errors when slicing with a negative step.Damien George
2017-03-28py: Use mp_raise_TypeError/mp_raise_ValueError helpers where possible.Damien George
Saves 168 bytes on bare-arm.
2017-03-23py/sequence: Convert mp_uint_t to size_t where appropriate.Damien George
2017-03-23py: Use size_t as len argument and return type of mp_get_index.Damien George
These values are used to compute memory addresses and so size_t is the more appropriate type to use.
2016-10-30py/sequence: Fix reverse slicing of lists.Fabio Utzig
2016-10-17py: Use mp_raise_msg helper function where appropriate.Damien George
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.
2016-08-15py/sequence: Allow to use bignums as indices in slice objects.Damien George
See issue #2264.
2015-11-29py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR.Damien George
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.
2015-01-20py, unix: Allow to compile with -Wunused-parameter.Damien George
See issue #699.
2015-01-16py, unix: Allow to compile with -Wsign-compare.Damien George
See issue #699.
2015-01-01py: Move to guarded includes, everywhere in py/ core.Damien George
Addresses issue #1022.
2014-10-03py: Convert [u]int to mp_[u]int_t where appropriate.Damien George
Addressing issue #50.
2014-08-30py: Remove use of int type in obj.h.Damien George
Part of code cleanup, working towards resolving issue #50.
2014-08-30py: Change all uint to mp_uint_t in obj.h.Damien George
Part of code cleanup, working towards resolving issue #50.
2014-07-03Rename machine_(u)int_t to mp_(u)int_t.Damien George
See discussion in issue #50.
2014-06-10Remove unnecessary bounds check from mp_seq_get_fast_slice_indexes.Chris Angelico
At this point, start will be >= 0, so checking if stop < 0 is redundant with checking if start > stop a few lines later.
2014-06-01py: Fix configurability of builtin slice.Damien George
2014-05-25objlist: Implement support for arbitrary (3-arg) slices.Paul Sokolovsky
2014-05-25py: Refactor slice helpers, preparing to support arbitrary slicing.Paul Sokolovsky
2014-05-25sequence: Throw exception for not implemented slice steps.Paul Sokolovsky
2014-05-25py: Handle case of slice start > stop in common sequence function.Paul Sokolovsky
2014-05-25objslice: Support arbitrary objects start, stop, and step.Paul Sokolovsky
Older int-only encoding is not expressive enough to support arbitrary slice assignment operations.
2014-05-15sequence: Fix yet another case of improper sequence comparison.Paul Sokolovsky
This time, in mp_seq_cmp_bytes(). How many more cases are still lurking?
2014-05-13py, unix: Add copyright for modules I worked closely on.Paul Sokolovsky
2014-05-10py: Fix prefix on few sequence helpers, was incorrectly "mp_".Paul Sokolovsky
2014-05-10bytes: Implement comparison and other binary operations.Paul Sokolovsky
Should support everything supported by strings.
2014-05-03Add license header to (almost) all files.Damien George
Blanket wide to all .c and .h files. Some files originating from ST are difficult to deal with (license wise) so it was left out of those. Also merged modpyb.h, modos.h, modstm.h and modtime.h in stmhal/.
2014-05-02py, unix: Make "mpconfig.h" be first included, as other headers depend on it.Paul Sokolovsky
Specifically, nlr.h does.
2014-04-18sequence: Further simplify sequence comparison.Paul Sokolovsky
2014-04-18sequence: Fix glaring bug in sequence comparison.Paul Sokolovsky
2014-04-05py: Change nlr_jump to nlr_raise, to aid in debugging.Damien George
This does not affect code size or performance when debugging turned off. To address issue #420.
2014-03-30Merge map.h into obj.h.Damien George
Pretty much everyone needs to include map.h, since it's such an integral part of the Micro Python object implementation. Thus, the definitions are now in obj.h instead. map.h is removed.
2014-03-30Rename rt_* to mp_*.Damien George
Mostly just a global search and replace. Except rt_is_true which becomes mp_obj_is_true. Still would like to tidy up some of the names, but this will do for now.
2014-03-17py: Clean up includes.xbe
Remove unnecessary includes. Add includes that improve portability.
2014-03-12Implement str.count and add tests for it.xbe
Also modify mp_get_index to accept: 1. Indices that are or evaluate to a boolean. 2. Slice indices. Add tests for these two cases.
2014-02-15Implement proper exception type hierarchy.Damien George
Each built-in exception is now a type, with base type BaseException. C exceptions are created by passing a pointer to the exception type to make an instance of. When raising an exception from the VM, an instance is created automatically if an exception type is raised (as opposed to an exception instance). Exception matching (RT_BINARY_OP_EXCEPTION_MATCH) is now proper. Handling of parse error changed to match new exceptions. mp_const_type renamed to mp_type_type for consistency.
2014-02-10Fix some int casting that failed on 64 bit architecture.Damien George
2014-02-10Factor out mp_seq_count_obj() and implement tuple.count().Paul Sokolovsky
2014-02-10Implement tuple.index().Paul Sokolovsky
2014-02-10Factor out mp_seq_index_obj() function to implement .index() on sequences.Paul Sokolovsky
2014-02-08Refactor list comparison code to mp_seq_cmp_objs().Paul Sokolovsky
2014-02-02Implement str/bytes rich comparisons.Paul Sokolovsky
2014-02-02Factor out m_seq_get_fast_slice_indexes() fucntions as sequence helper.Paul Sokolovsky
Takes slice object and sequence length and computes subsequence indexes for case of slice step=1.