- Feb 25, 2019
-
-
Damien George authored
-
- Jan 10, 2019
-
-
Damien George authored
-
- Jun 12, 2018
-
-
Damien George authored
A user class derived from IOBase and implementing readinto/write/ioctl can now be used anywhere a native stream object is accepted. The mapping from C to Python is: stream_p->read --> readinto(buf) stream_p->write --> write(buf) stream_p->ioctl --> ioctl(request, arg) Among other things it allows the user to: - create an object which can be passed as the file argument to print: print(..., file=myobj), and then print will pass all the data to the object via the objects write method (same as CPython) - pass a user object to uio.BufferedWriter to buffer the writes (same as CPython) - use select.select on a user object - register user objects with select.poll, in particular so user objects can be used with uasyncio - create user files that can be returned from user filesystems, and import can import scripts from these user files For example: class MyOut(io.IOBase): def write(self, buf): print('write', repr(buf)) return len(buf) print('hello', file=MyOut()) The feature is enabled via MICROPY_PY_IO_IOBASE which is disabled by default.
-
- Dec 19, 2017
-
-
Damien George authored
-
- Nov 16, 2017
-
-
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).
-
- Jul 31, 2017
-
-
Alexander Steffen authored
There were several different spellings of MicroPython present in comments, when there should be only one.
-
- Jul 28, 2017
-
-
Paul Sokolovsky authored
-
- May 06, 2017
-
-
Paul Sokolovsky authored
-
- May 02, 2017
-
-
Paul Sokolovsky authored
The with semantics of this function is close to pkg_resources.resource_stream() function from setuptools, which is the canonical way to access non-source files belonging to a package (resources), regardless of what medium the package uses (e.g. individual source files vs zip archive). In the case of MicroPython, this function allows to access resources which are frozen into the executable, besides accessing resources in the file system. This is initial stage of the implementation, which actually doesn't implement "package" part of the semantics, just accesses frozen resources from "root", or filesystem resource - from current dir.
-
- Oct 07, 2016
-
-
Damien George authored
This is an often used code pattern, and its use reduces code size of the core by about 100 bytes.
-
- Sep 21, 2016
-
-
Damien George authored
One can instead lookup __name__ in the modules dict to get the value.
-
- Jun 18, 2016
-
-
Paul Sokolovsky authored
It's now used for more than just stream protocol (e.g. pin protocol), so don't use false names.
-
- May 17, 2016
-
-
Paul Sokolovsky authored
Both read and write operations support variants where either a) a single call is made to the undelying stream implementation and returned buffer length may be less than requested, or b) calls are repeated until requested amount of data is collected, shorter amount is returned only in case of EOF or error. These operations are available from the level of C support functions to be used by other C modules to implementations of Python methods to be used in user-facing objects. The rationale of these changes is to allow to write concise and robust code to work with *blocking* streams of types prone to short reads, like serial interfaces and sockets. Particular object types may select "exact" vs "once" types of methods depending on their needs. E.g., for sockets, revc() and send() methods continue to be "once", while read() and write() thus converted to "exactly" versions. These changes don't affect non-blocking handling, e.g. trying "exact" method on the non-blocking socket will return as much data as available without blocking. No data available is continued to be signaled as None return value to read() and write(). From the point of view of CPython compatibility, this model is a cross between its io.RawIOBase and io.BufferedIOBase abstract classes. For blocking streams, it works as io.BufferedIOBase model (guaranteeing lack of short reads/writes), while for non-blocking - as io.RawIOBase, returning None in case of lack of data (instead of raising expensive exception, as required by io.BufferedIOBase). Such a cross-behavior should be optimal for MicroPython needs.
-
- May 02, 2016
-
-
Paul Sokolovsky authored
-
- Mar 25, 2016
-
-
Paul Sokolovsky authored
-
Paul Sokolovsky authored
-
- Mar 24, 2016
-
-
Paul Sokolovsky authored
Just .write() method implemented currently.
-
- Nov 29, 2015
-
-
Damien George authored
-
- Feb 15, 2015
-
-
Damien George authored
-
- Jan 01, 2015
-
-
Damien George authored
Addresses issue #1022.
-
- Nov 29, 2014
-
-
Damien George authored
This is just a clean-up of the code. Generated code is exactly the same.
-
- Jun 21, 2014
-
-
Paul Sokolovsky authored
It defines types used by all other headers. Fixes #691.
-
- Jun 19, 2014
-
-
Emmanuel Blot authored
-
- Jun 11, 2014
-
-
Paul Sokolovsky authored
Functionality we provide in builtin io module is fairly minimal. Some code, including CPython stdlib, depends on more functionality. So, there's a choice to either implement it in C, or move it _io, and let implement other functionality in Python. 2nd choice is pursued. This setup matches CPython too (_io is builtin, io is Python-level).
-
- May 24, 2014
-
-
Damien George authored
Now of the form MICROPY_PY_*. See issue #35.
-
- May 19, 2014
-
-
Paul Sokolovsky authored
io.FileIO is binary I/O, ans actually optional. Default file type is io.TextIOWrapper, which provides str results. CPython3 explicitly describes io.TextIOWrapper as buffered I/O, but we don't have buffering support yet anyway.
-
- May 15, 2014
-
-
Paul Sokolovsky authored
Done in generalized manner, allowing any stream class to be specified as working with bytes.
-
- May 03, 2014
-
-
Damien George authored
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/.
-
- Apr 26, 2014
-
-
Paul Sokolovsky authored
-
Damien George authored
-
- Apr 05, 2014
-
-
Damien George authored
Towards addressing issue #424. Had a small increase to ROM usage (order 60 bytes).
-
- Apr 03, 2014
-
-
Paul Sokolovsky authored
So far just includes "open" function, which should be supplied by a port. TODO: Make the module #ifdef'ed.
-