Commit Graph

15 Commits

Author SHA1 Message Date
Damien George 945a01c4e3 py: Fix bug in type_store_attr, trying to store to ROM. 2014-03-27 09:32:26 +00:00
Damien George 9b196cddab Remove mp_obj_type_t.methods entry and use .locals_dict instead.
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-26 21:47:19 +00:00
Damien George 510477557d py: Take out bitfield entries from their own structure.
Don't need to wrap bitfields in their own struct.  Compiler does the
correct thing without it.
2014-02-26 17:40:52 +00:00
Damien George 9a58d760c3 py: Allow mp_map_t to be initialised by a fixed-size, const table.
This allows keyword maps to be created directly from stack data.
2014-02-08 18:47:46 +00:00
Paul Sokolovsky 9a24a0465f Add mp_map_deinit() & mp_map_free() to finalize maps.
mp_map_deinit() finalizes static map, mp_map_free() - dynamic.
2014-01-25 02:04:01 +02:00
John R. Lenton ae00d334c6 Implemented set.remove 2014-01-12 19:16:59 +00:00
John R. Lenton 2a24172cdc Implemented set.discard 2014-01-12 16:39:39 +00:00
John R. Lenton 1d7fb2f21b Implemented set.clear 2014-01-12 15:44:26 +00:00
Damien George 062478e66d Improved type/class/instance code; mp_obj_type_t now has load_attr, store_attr.
Creating of classes (types) and instances is much more like CPython now.
You can use "type('name', (), {...})" to create classes.
2014-01-09 20:57:50 +00:00
Damien George 38a2da68c2 py: Stuff qstr in object pointer; keys for mp_map_t are now always mp_obj_t. 2014-01-08 17:33:12 +00:00
John R. Lenton 0fcbaa442f implemented dict.pop 2014-01-07 22:51:08 +00:00
John R. Lenton 4ce6ceadca Added dict.clear.
Added 0 to the list of primes. Funky primes, these.
2014-01-07 22:51:08 +00:00
Damien George 66028ab6dc Basic implementation of import.
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-03 14:03:48 +00:00
Damien d99b05282d Change object representation from 1 big union to individual structs.
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).
2013-12-21 18:17:45 +00:00
Damien 660365e14c py: split runtime into map, obj, builtin. 2013-12-17 18:27:24 +00:00