aboutsummaryrefslogtreecommitdiff
path: root/py/objtype.c
AgeCommit message (Collapse)Author
2015-02-08py: Fix instance lookup, since object is not a real type.Damien George
2015-01-31py: Add MICROPY_PY_ALL_SPECIAL_METHODS and __iadd__ special method under it.Paul Sokolovsky
2015-01-27py: Specify unary/binary op name in TypeError error message.Damien George
Eg, "() + 1" now tells you that __add__ is not supported for tuple and int types (before it just said the generic "binary operator"). We reuse the table of names for slot lookup because it would be a waste of code space to store the pretty name for each operator.
2015-01-20py: Use mp_arg_check_num in some _make_new functions.Damien George
Reduces stmhal code size by about 250 bytes.
2015-01-20py, unix: Allow to compile with -Wunused-parameter.Damien George
See issue #699.
2015-01-11py: Remove unnecessary BINARY_OP_EQUAL code that just checks pointers.Damien George
Previous patch c38dc3ccc76d1a9bf867704f43ea5d15da3fea7b allowed any object to be compared with any other, using pointer comparison for a fallback. As such, existing code which checked for this case is no longer needed.
2015-01-08tests: Add test for when instance member overrides class member.Damien George
2015-01-07py: Add option to cache map lookup results in bytecode.Damien George
This is a simple optimisation inspired by JITing technology: we cache in the bytecode (using 1 byte) the offset of the last successful lookup in a map. This allows us next time round to check in that location in the hash table (mp_map_t) for the desired entry, and if it's there use that entry straight away. Otherwise fallback to a normal map lookup. Works for LOAD_NAME, LOAD_GLOBAL, LOAD_ATTR and STORE_ATTR opcodes. On a few tests it gives >90% cache hit and greatly improves speed of code. Disabled by default. Enabled for unix and stmhal ports.
2015-01-01py: Move to guarded includes, everywhere in py/ core.Damien George
Addresses issue #1022.
2014-12-28showbc: Print operation mnemonic in BINARY_OP.Paul Sokolovsky
2014-11-06py: Use shorter, static error msgs when ERROR_REPORTING_TERSE enabled.Damien George
Going from MICROPY_ERROR_REPORTING_NORMAL to MICROPY_ERROR_REPORTING_TERSE now saves 2020 bytes ROM for ARM Thumb2, and 2200 bytes ROM for 32-bit x86. This is about a 2.5% code size reduction for bare-arm.
2014-11-05py: Fix some macros defines; cleanup some includes.Damien George
2014-11-03py: Explicitly set uninitialised struct member to false.Damien George
Uninitialised struct members get a default value of 0/false, so this is not strictly needed. But it actually decreases code size because when all members are initialised the compiler doesn't need to insert a call to memset to clear everything. In other words, setting 1 extra member to 0 uses less code than calling memset. ROM savings in bytes: 32-bit unix: 100; bare-arm: 44; stmhal: 52.
2014-11-03py: Fix builtin callable so it checks user-defined instances correctly.Damien George
Addresses issue #953.
2014-10-23py: Use MP_OBJ_NULL instead of NULL in a few places.Damien George
2014-08-30py: Make tuple and list use mp_int_t/mp_uint_t.Damien George
Part of code cleanup, to resolve issue #50.
2014-08-30Change some parts of the core API to use mp_uint_t instead of uint/int.Damien George
Addressing issue #50, still some way to go yet.
2014-08-26py: Add dispatch for user defined ==, >, <=, >=.Damien George
Addresses issue #827.
2014-08-24py: Fix bug where GC collected native/viper/asm function data.Damien George
Because (for Thumb) a function pointer has the LSB set, pointers to dynamic functions in RAM (eg native, viper or asm functions) were not being traced by the GC. This patch is a comprehensive fix for this. Addresses issue #820.
2014-07-05py: Automatically ake __new__ a staticmethod.Damien George
Addresses issue #622.
2014-07-03Rename machine_(u)int_t to mp_(u)int_t.Damien George
See discussion in issue #50.
2014-06-10py: Implement __contains__ special method.Damien George
2014-06-08objtype: Fix passing of class param to inherited classmethods.Paul Sokolovsky
This is getting more and more tangled, but that's old news.
2014-06-08objtype: Optimize stack usage mp_obj_class_lookup().Paul Sokolovsky
As before, instead of pushing constant values on stack again and again, just pass around pointer to a structure.
2014-06-08objtype: Enable __lt__ method support for instances.Paul Sokolovsky
2014-06-06Change comments (mainly URLs) to no longer specifically say Python 3.3Chris Angelico
2014-06-03py: Allow tail call optimisation in mp_call_function_n_kw.Damien George
This saves 4 words of stack space per Python call.
2014-06-01Rename bultins config variables to MICROPY_PY_BUILTINS_*.Damien George
This renames: MICROPY_PY_FROZENSET -> MICROPY_PY_BUILTINS_FROZENSET MICROPY_PY_PROPERTY -> MICROPY_PY_BUILTINS_PROPERTY MICROPY_PY_SLICE -> MICROPY_PY_BUILTINS_SLICE MICROPY_ENABLE_FLOAT -> MICROPY_PY_BUILTINS_FLOAT See issue #35 for discussion.
2014-05-24Rename configuration variables controling Python features.Damien George
Now of the form MICROPY_PY_*. See issue #35.
2014-05-22py: Initial attempts to actually allow implementing __new__ in Python.Paul Sokolovsky
Caveat is that __new__ should recurse to base class __new__, and ultimately, object.__new__ is what handles instance allocation.
2014-05-21objtype: super: Fall back to "object" lookup as last resort.Paul Sokolovsky
Also, define object.__init__() (semantically empty, purely CPython compat measure). Addresses #520.
2014-05-21objtype: super: Add stop condition for looking up in base types.Paul Sokolovsky
2014-05-21py: Rename MP_OBJ_NOT_SUPPORTED to MP_OBJ_NULL.Damien George
See issue #608 for justification.
2014-05-19objtype: Separate __new__ and __init__ methods.Paul Sokolovsky
Now schedule is: for native types, we call ->make_new() C-level method, which should perform actions of __new__ and __init__ (note that this is not compliant, but is efficient), but for user types, __new__ and __init__ are called as expected. Also, make sure we convert scalar attribute value to a bound-pair tight in mp_obj_class_lookup() method, which avoids converting it again and again in its callers.
2014-05-13py, unix: Add copyright for modules I worked closely on.Paul Sokolovsky
2014-05-11py: Use mp_arg_check_num in more places.Damien George
Updated functions now do proper checking that n_kw==0, and are simpler because they don't have to explicitly raise an exception. Down side is that the error messages no longer include the function name, but that's acceptable. Saves order 300 text bytes on x64 and ARM.
2014-05-11objtuple: Go out of the way to support comparison of subclasses.Paul Sokolovsky
Two things are handled here: allow to compare native subtypes of tuple, e.g. namedtuple (TODO: should compare type too, currently compared duck-typedly by content). Secondly, allow user sunclasses of tuples (and its subtypes) be compared either. "Magic" I did previously in objtype.c covers only one argument (lhs is many), so we're in trouble when lhs is native type - there's no other option besides handling rhs in special manner. Fortunately, this patch outlines approach with fast path for native types.
2014-05-11py: Don't try to "bind" types store as attributes of objects.Paul Sokolovsky
This was hit when trying to make urlparse.py from stdlib run. Took quite some time to debug. TODO: Reconsile bound method creation process better, maybe callable is to generic type to bind at all?
2014-05-10objtype: Comments for duplicating code in runtime.c.Paul Sokolovsky
2014-05-10objtype: Implement ->getiter() method for instances.Paul Sokolovsky
Includes support for native bases.
2014-05-10objtype: Don't treat inheritance from "object" as from native type.Paul Sokolovsky
"object" type in MicroPython currently doesn't implement any methods, and hopefully, we'll try to stay like that for as long as possible. Even if we have to add something eventually, look up from there might be handled in adhoc manner, as last resort (that's not compliant with Python3 MRO, but we're already non-compliant). Hence: 1) no need to spend type trying to lookup anything in object; 2) no need to allocate subobject when explicitly inheriting from object; 3) and having multiple bases inheriting from object is not a case of incompatible multiple inheritance.
2014-05-10py: Tidy up returning NULL which should be MP_OBJ_NOT_SUPPORTED.Damien George
2014-05-03Add license header to (almost) all files.Damien George
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/.
2014-05-03py, objtype.c: Rename class_ to instance_ following change of typedef.Damien George
This follows up 0a7e01ae3c529fddf79dc5c71bf7e43cff3f9fa0.
2014-05-02py, unix: Make "mpconfig.h" be first included, as other headers depend on it.Paul Sokolovsky
Specifically, nlr.h does.
2014-05-02objtype: Work around stupid strict aliasing check.Paul Sokolovsky
2014-05-02objtype: Rename mp_obj_class_t -> mp_obj_instance_t and move to local header.Paul Sokolovsky
TODO: Rename methods.
2014-05-02objtype: .print() Exception instances in adhoc way.Paul Sokolovsky
This is ugly, just as expected.
2014-04-30objtype: Support calling normal methods inherited from native base class.Paul Sokolovsky
Biggest part of this support is refactoring mp_obj_class_lookup() to return standard "bound member" pair (mp_obj_t[2]). Actual support of inherited native methods is 3 lines then. Some inherited features may be not supported yet (e.g. native class methods, native properties, etc., etc.). There may be opportunities for further optimization too.
2014-04-29objtype: Add support for looking up non-method attrs in native base class.Paul Sokolovsky