summaryrefslogtreecommitdiff
path: root/py/builtin.c
AgeCommit message (Collapse)Author
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-29py: Rename old const type objects to mp_type_* for consistency.Damien George
2014-03-26Merge branch 'master' of github.com:micropython/micropythonDamien George
2014-03-26py: Improved builtin dir.Damien George
2014-03-27py: Implement getattr() builtin.Paul Sokolovsky
2014-03-26Remove mp_obj_type_t.methods entry and use .locals_dict instead.Damien George
Originally, .methods was used for methods in a ROM class, and locals_dict for methods in a user-created class. That distinction is unnecessary, and we can use locals_dict for ROM classes now that we have ROMable maps. This removes an entry in the bloated mp_obj_type_t struct, saving a word for each ROM object and each RAM object. ROM objects that have a methods table (now a locals_dict) need an extra word in total (removed the methods pointer (1 word), no longer need the sentinel (2 words), but now need an mp_obj_dict_t wrapper (4 words)). But RAM objects save a word because they never used the methods entry. Overall the ROM usage is down by a few hundred bytes, and RAM usage is down 1 word per user-defined type/class. There is less code (no need to check 2 tables), and now consistent with the way ROM modules have their tables initialised. Efficiency is very close to equivaluent.
2014-03-26Change mp_method_t.name from const char * to qstr.Damien George
Addresses issue #377.
2014-03-26py: Replace mp_const_stop_iteration object with MP_OBJ_NULL.Damien George
2014-03-23py: Improve dir(): extract names from type->methods table.Damien George
2014-03-22py: Make 'bytes' be a proper type, support standard constructor args.Paul Sokolovsky
2014-03-22py: Make 'str' be a proper type, support standard constructor args.Paul Sokolovsky
2014-03-17py: Clean up includes.xbe
Remove unnecessary includes. Add includes that improve portability.
2014-03-08Implement ROMable modules. Add math module.Damien George
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).
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-12Replace global "static" -> "STATIC", to allow "analysis builds". Part 2.Paul Sokolovsky
2014-02-08Make mp_obj_str_get_data return char* instead of byte*.Damien George
Can't decide which is better for string type, char or byte pointer. Changing to char removes a few casts. Really need to do proper unicode.
2014-02-02py: Add very basic implementation of dir() builtin.Damien George
Only works on modules and class instances.
2014-02-02Change id to return signed integer.Damien George
2014-02-01Implement and add tests for the id() builtin function.xbe
2014-01-22Second stage of qstr revamp: uPy str object can be qstr or not.Damien George
2014-01-21Merge branch 'master' of github.com:micropython/micropythonDamien George
Conflicts: py/objstr.c py/py.mk py/stream.c unix/main.c unix/socket.c
2014-01-21Revamp qstrs: they now include length and hash.Damien George
Can now have null bytes in strings. Can define ROM qstrs per port using qstrdefsport.h
2014-01-20Add dummy bytes() constructor.Paul Sokolovsky
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).
2014-01-19Change int to uint for n_args in function with variable arguments.Damien George
2014-01-18Make VM stack grow upwards, and so no reversed args arrays.Damien George
Change state layout in VM so the stack starts at state[0] and grows upwards. Locals are at the top end of the state and number downwards. This cleans up a lot of the interface connecting the VM to C: now all functions that take an array of Micro Python objects are in order (ie no longer in reverse). Also clean up C API with keyword arguments (call_n and call_n_kw replaced with single call method that takes keyword arguments). And now make_new takes keyword arguments. emitnative.c has not yet been changed to comply with the new order of stack layout.
2014-01-15Merge branch 'str-repr' of github.com:pfalcon/micropython into pfalcon-str-reprDamien George
Conflicts: tests/basics/tests/exception1.py
2014-01-15Implement repr.Damien George
2014-01-15Implement str() and repr() builtin functions.Paul Sokolovsky
2014-01-15type->print(): Distinguish str() and repr() variety by passing extra param.Paul Sokolovsky
2014-01-14Tidy up.Damien George
2014-01-13Merge remote-tracking branch 'upstream/master' into builtinsJohn R. Lenton
Conflicts: py/builtin.c py/builtin.h py/runtime.c
2014-01-13Made sorted() raise an exception instead of aborting when given no ↵John R. Lenton
arguments; moved around some things in objfun.c as a consequence
2014-01-13Cleaned up sorted() as per Damien's suggestions.John R. Lenton
2014-01-13Cleanup built-ins, and fix some compiler warnings/errors.Damien George
2014-01-13sortedJohn R. Lenton
2014-01-10Added dict.fromkeys. Are we done with dict and #99 yet? I do think we are.John R. Lenton
2014-01-09Improved type/class/instance code; mp_obj_type_t now has load_attr, store_attr.Damien George
Creating of classes (types) and instances is much more like CPython now. You can use "type('name', (), {...})" to create classes.
2014-01-08py: Proper framework for built-in 'type'.Damien George
2014-01-08py: add variable argument exception constructor function.Damien George
Addresses issue #104.
2014-01-08py: Stuff qstr in object pointer; keys for mp_map_t are now always mp_obj_t.Damien George
2014-01-08py: Improve __build_class__.Damien George
2014-01-04Convert Python types to proper Python type hierarchy.Damien George
Now much more inline with how CPython does types.
2014-01-04Split qstr into pools, and put initial pool in ROM.Damien George
Qstr's are now split into a linked-list of qstr pools. This has 2 benefits: the first pool can be in ROM (huge benefit, since we no longer use RAM for the core qstrs), and subsequent pools use m_new for the next pool instead of m_renew (thus avoiding a huge single table for all the qstrs). Still would be better to use a hash table, but this scheme takes us part of the way (eventually convert the pools to hash tables). Also fixed bug with import. Also improved the way the module code is referenced (not magic number 1 anymore).
2014-01-03Basic implementation of import.Damien George
import works for simple cases. Still work to do on finding the right script, and setting globals/locals correctly when running an imported function.
2014-01-02py: Add framework for built-in "type()" function.Damien George
2014-01-01py: add int() and float() built-ins, partially implemented.Damien George
2013-12-29py: add dict length function, and fix rt_store_set.Damien
2013-12-29Change memory allocation API to require size for free and realloc.Damien
2013-12-21py: simplify __next__ method for generators.Damien
2013-12-21Change object representation from 1 big union to individual structs.Damien
A big change. Micro Python objects are allocated as individual structs with the first element being a pointer to the type information (which is itself an object). This scheme follows CPython. Much more flexible, not necessarily slower, uses same heap memory, and can allocate objects statically. Also change name prefix, from py_ to mp_ (mp for Micro Python).