Damien George
1559a97810
py: Add builtin round function.
Addresses issue #934 .
10 years ago
Damien George
c9fc620723
py: Implement compile builtin, enabled only on unix port.
This should be pretty compliant with CPython, except perhaps for some
corner cases to do with globals/locals context.
Addresses issue #879 .
10 years ago
Paul Sokolovsky
8becca7c82
py: mp_builtin___import__(): Add const to arg type.
10 years ago
Damien George
f5d69794a8
extmod: Add uheapq module.
10 years ago
stijn
2fe4cf7761
Implement kwargs for builtin open() and _io.FileIO
This makes open() and _io.FileIO() more CPython compliant.
The mode kwarg is fully iplemented.
The encoding kwarg is allowed but not implemented; mainly to allow
the tests to specify encoding for CPython, see #874
10 years ago
Paul Sokolovsky
911c00bbc5
modzlibd: Remove, superceded by moduzlib.
10 years ago
Paul Sokolovsky
34162872b1
moduzlib: Integrate into the system.
10 years ago
Paul Sokolovsky
c71e045165
modure: Initial module, using re1.5 (which is based on re1 codebase).
https://github.com/pfalcon/re1.5
10 years ago
Damien George
612045f53f
py: Add native json printing using existing print framework.
Also add start of ujson module with dumps implemented. Enabled in unix
and stmhal ports. Test passes on both.
10 years ago
Damien George
013d53c0b4
Remove skeletal modselect from extmod and just put it in stmhal.
10 years ago
Damien George
6c9c7bc75a
stmhal: Implement generic select.select and select.poll.
10 years ago
Damien George
4abff7500f
py: Change uint to mp_uint_t in runtime.h, stackctrl.h, binary.h.
Part of code cleanup, working towards resolving issue #50 .
10 years ago
Paul Sokolovsky
510296f25a
modzlibd: Decompress part of "zlib" module, based on miniz tinfl.c .
10 years ago
Damien George
4c03b3a899
py: Implement builtin reversed() function.
reversed function now implemented, and works for tuple, list, str, bytes
and user objects with __len__ and __getitem__.
Renamed mp_builtin_len to mp_obj_len to make it publically available (eg
for reversed).
10 years ago
Paul Sokolovsky
cb66f41ebc
py: Make print() accept "file" argument, and actually print to stream.
And not system printf(), like it was before. For this, move pfenv_printf()
from stmhal port to py/.
10 years ago
Paul Sokolovsky
8215847b4d
moductypes: Foreign data interface module, roughly based on ctype ideas.
But much smaller and memory-efficient. Uses Python builtin data structures
(dict, tuple, int) to describe structure layout.
11 years ago
Paul Sokolovsky
561789d718
unix modsocket: Make .makefile() method more compliant.
.makefile() should allow to specify which stream time to create - byte
or text.
11 years ago
Paul Sokolovsky
ff30666c69
py: Add basic implementation of hasattr() function.
11 years ago
Paul Sokolovsky
f9e54e0ea5
modgc: Add new module for GC-related functionality.
11 years ago
Damien George
04b9147e15
Add license header to (almost) all files.
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/.
11 years ago
Damien George
71d3112f7e
py: Make built-in 'range' a class.
Addresses issue #487 .
11 years ago
Damien George
dbdfee15a1
py: Add cmath module, for complex math. Disabled by default.
Not all functions implemented. Not enabled on pyboard.
11 years ago
Damien George
897fe0c0d0
py: Add builtin functions bin and oct, and some tests for them.
11 years ago
Damien George
5805111732
py: Add hex builtin function.
A one-liner, added especially for @pfalcon :)
11 years ago
Paul Sokolovsky
14de114ba8
objdict: Add __delitem__.
11 years ago
Paul Sokolovsky
cd94b384a3
objdict: Add __setitem__.
11 years ago
Paul Sokolovsky
68e7c5146c
py: Factor out impl of special methods for builtin types into opmethods.c
11 years ago
Paul Sokolovsky
5500cdeec7
py, unix: Convert sys module to static representation.
11 years ago
Paul Sokolovsky
e9db840480
py: Start implementing "struct" module.
Only calcsize() and unpack() functions provided so far, for little-endian
byte order. Format strings don't support repition spec (like "2b3i").
Unfortunately, dealing with all the various binary type sizes and alignments
will lead to quite a bloated "binary" helper functions - if optimizing for
speed. Need to think if using dynamic parametrized algos makes more sense.
11 years ago
Paul Sokolovsky
cc0af3d727
py: Implement globals() and locals() builtins.
11 years ago
Paul Sokolovsky
c6813d92db
py: Put default namespace into module __main__.
That's how CPython has it, in particular, "import __main__" should work.
11 years ago
Paul Sokolovsky
98a627dc03
py: Add "io" module.
So far just includes "open" function, which should be supplied by a port.
TODO: Make the module #ifdef'ed.
11 years ago
Paul Sokolovsky
e9137b94f2
py: Implement getattr() builtin.
11 years ago
Damien George
caac542b23
Proper support for registering builtin modules in ROM.
Comes with some refactoring of code and renaming of files. All modules
are now named mod*.[ch].
11 years ago
Damien George
24ff063e80
py: Remove obsolete declarations; make mp_obj_get_array consistent.
11 years ago
Damien George
0c36da0b59
Implement ROMable modules. Add math module.
mp_module_obj_t can now be put in ROM.
Configuration of float type is now similar to longint: can now choose
none, float or double as the implementation.
math module has basic math functions. For STM port, these are not yet
implemented (they are just stub functions).
11 years ago
Paul Sokolovsky
d08fd68664
Add basic collections.namedtuple implementation.
11 years ago
Paul Sokolovsky
1d938c9503
Expose __import__() function.
11 years ago
Damien George
ca4767984b
py: Implement builtin exec.
11 years ago
Damien George
4acb2452b3
py: Add very basic implementation of dir() builtin.
Only works on modules and class instances.
11 years ago
xbe
0ebf8534ab
Implement and add tests for the id() builtin function.
11 years ago
Paul Sokolovsky
a80ff04fe7
Add dummy bytes() constructor.
Currently, MicroPython strings are mix between CPython byte and unicode
strings. So, conversion is null so far. This dummy implementation is
intended for compatibility with CPython (so, same code can run on both).
11 years ago
Damien George
91d457a277
py: Put micropython module init code in builtinmp.c.
11 years ago
Paul Sokolovsky
440cc3f028
Expose memory stats functions via "micropython" module.
These are micropython.mem_total(), .mem_current(), .mem_peak(). These are 3
individual functions with simple scalar return value to make sure that
calls to these functions themselves have minimal (hopefully zero) impact on
memory allocation.
11 years ago
Damien George
d02c6d8962
Implement eval.
11 years ago
Damien George
e2fb2baaa4
Implement repr.
11 years ago
Paul Sokolovsky
36c4499d36
Implement str() and repr() builtin functions.
11 years ago
Damien George
2300537c79
Cleanup built-ins, and fix some compiler warnings/errors.
11 years ago
John R. Lenton
5c76839559
sorted
11 years ago
Damien George
004cdcebfe
py: Implement base class lookup, issubclass, isinstance.
11 years ago