summaryrefslogtreecommitdiffstatshomepage
path: root/py/objstringio.c
Commit message (Collapse)AuthorAge
* 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/objstringio: If created from immutable object, follow copy on write policy.Paul Sokolovsky2017-06-09
| | | | | Don't create copy of immutable object's contents until .write() is called on BytesIO.
* py/objstringio: Catch mp_uint_t overflow of stream position in write().Tom Collins2017-05-26
|
* py/objstringio: Fix StringIO reads at or beyond EOF.Tom Collins2017-05-15
| | | | Existing code failed if seek() went past EOF (which is acceptable when writing).
* py: Use mp_raise_TypeError/mp_raise_ValueError helpers where possible.Damien George2017-03-28
| | | | Saves 168 bytes on bare-arm.
* 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/objstringio: Allow to specify initial capacity by passing numeric argument.Paul Sokolovsky2017-02-02
| | | | E.g. uio.BytesIO(100) will allocate buffer with 100 bytes of space.
* 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/vstr: Combine vstr_new_size with vstr_new since they are rarely used.Damien George2016-10-14
| | | | | | | Now there is just one function to allocate a new vstr, namely vstr_new (in addition to vstr_init etc). The caller of this function should know what initial size to allocate for the buffer, or at least have some policy or config option, instead of leaving it to a default (as it was before).
* extmod/modujson: Implement ujson.load() to load JSON from a stream.Damien George2016-10-13
| | | | | | | This refactors ujson.loads(s) to behave as ujson.load(StringIO(s)). Increase in code size is: 366 bytes for unix x86-64, 180 bytes for stmhal, 84 bytes for esp8266.
* py/objstringio: Add readinto() method.Paul Sokolovsky2016-10-09
| | | | Also, drop deprecated (as for MicroPython) readall() method.
* py/objstringio: Implement MP_STREAM_SEEK ioctl and add seek() method.Paul Sokolovsky2016-07-28
|
* py/objstringio: Add MP_STREAM_FLUSH ioctl and flush() method.Paul Sokolovsky2016-07-28
| | | | No-op for this object.
* all: Rename mp_obj_type_t::stream_p to protocol.Paul Sokolovsky2016-06-18
| | | | | It's now used for more than just stream protocol (e.g. pin protocol), so don't use false names.
* py/objstringio: Add TODO comment about avoiding copying on .getvalue().Paul Sokolovsky2016-05-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 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: 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: 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.
* py: Prevent segfault for operations on closed StringIO.stijn2015-01-20
| | | | Addresses issue #1067.
* py, unix: Allow to compile with -Wunused-parameter.Damien George2015-01-20
| | | | See issue #699.
* py: Move to guarded includes, everywhere in py/ core.Damien George2015-01-01
| | | | Addresses issue #1022.
* py: Make functions static where appropriate.Damien George2014-12-10
|
* 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: Change stream protocol API: fns return uint; is_text for text.Damien George2014-07-27
|
* Rename machine_(u)int_t to mp_(u)int_t.Damien George2014-07-03
| | | | See discussion in issue #50.
* py: Slightly improve efficiency of mp_obj_new_str; rename str_new.Damien George2014-05-25
| | | | | | Reorder interning logic in mp_obj_new_str, to be more efficient. str_new is globally accessible, so should be prefixed with mp_obj_.
* Rename configuration variables controling Python features.Damien George2014-05-24
| | | | Now of the form MICROPY_PY_*. See issue #35.
* objstringio: Implement io.BytesIO.Paul Sokolovsky2014-05-15
| | | | | Done in generalized manner, allowing any stream class to be specified as working with bytes.
* Add license header to (almost) all files.Damien George2014-05-03
| | | | | | | 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/.
* py, unix: Make "mpconfig.h" be first included, as other headers depend on it.Paul Sokolovsky2014-05-02
| | | | Specifically, nlr.h does.
* objstringio: Compile only if MICROPY_ENABLE_MOD_IO defined.Paul Sokolovsky2014-04-26
|
* modio: Implement io.StringIO class.Paul Sokolovsky2014-04-26