aboutsummaryrefslogtreecommitdiff
path: root/py/obj.h
AgeCommit message (Collapse)Author
2015-01-16py, unix: Allow to compile with -Wsign-compare.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.
2014-12-30py: mp_obj_new_int_from_float() supported only for MICROPY_PY_BUILTINS_FLOAT.Paul Sokolovsky
2014-12-30py: Partially fix float to int conversion.Paul Sokolovsky
This fixes conversion when float type has more mantissa bits than small int, and float value has small exponent. This is for example the case of 32-bit platform using doubles, and converting value of time.time(). Conversion of floats with larg exponnet is still not handled correctly.
2014-12-29py: Add include guards to mpconfig,misc,qstr,obj,runtime,parsehelper.Damien George
2014-12-10py: Tidy up a few function declarations.Damien George
2014-12-09py: Allow builtins to be overridden.Damien George
This patch adds a configuration option (MICROPY_CAN_OVERRIDE_BUILTINS) which, when enabled, allows to override all names within the builtins module. A builtins override dict is created the first time the user assigns to a name in the builtins model, and then that dict is searched first on subsequent lookups. Note that this implementation doesn't allow deleting of names. This patch also does some refactoring of builtins code, creating the modbuiltins.c file. Addresses issue #959.
2014-12-08modsys: Add sys.print_exception(exc, file=sys.stdout) function.Paul Sokolovsky
The function is modeled after traceback.print_exception(), but unbloated, and put into existing module to save overhead on adding another module. Compliant traceback.print_exception() is intended to be implemented in micropython-lib in terms of sys.print_exception(). This change required refactoring mp_obj_print_exception() to take pfenv_t interface arguments. Addresses #751.
2014-12-05py: Rename mp_obj_int_get to mp_obj_int_get_truncated; fix struct.pack.Damien George
mp_obj_int_get_truncated is used as a "fast path" int accessor that doesn't check for overflow and returns the int truncated to the machine word size, ie mp_int_t. Use mp_obj_int_get_truncated to fix struct.pack when packing maximum word sized values. Addresses issues #779 and #998.
2014-11-29Use MP_DEFINE_CONST_DICT macro to define module dicts.Damien George
This is just a clean-up of the code. Generated code is exactly the same.
2014-11-27map: Add empty fixed map.Paul Sokolovsky
Useful when need to call kw-receiving functions without any keywords from C, etc.
2014-11-17stream: Implement seek operation support via ioctl, wrapped in generic method.Paul Sokolovsky
Also, implement for unix port.
2014-11-17stream: Convert .ioctl() to take fixed number of args.Paul Sokolovsky
This is more efficient, as allows to use register calling convention. If needed, a structure pointer can be passed as argument to pass more data.
2014-10-25py: Add mp_pending_exception global variable, for VM soft interrupt.Damien George
This allows to implement KeyboardInterrupt on unix, and a much safer ctrl-C in stmhal port. First ctrl-C is a soft one, with hope that VM will notice it; second ctrl-C is a hard one that kills anything (for both unix and stmhal). One needs to check for a pending exception in the VM only for jump opcodes. Others can't produce an infinite loop (infinite recursion is caught by stack check).
2014-10-25py: Factor out mp_obj_is_package() function.Paul Sokolovsky
2014-10-25py: Store bytecode arg names in bytecode (were in own array).Damien George
This saves a lot of RAM for 2 reasons: 1. For functions that don't have default values, var args or var kw args (which is a large number of functions in the general case), the mp_obj_fun_bc_t type now fits in 1 GC block (previously needed 2 because of the extra pointer to point to the arg_names array). So this saves 16 bytes per function (32 bytes on 64-bit machines). 2. Combining separate memory regions generally saves RAM because the unused bytes at the end of the GC block are saved for 1 of the blocks (since that block doesn't exist on its own anymore). So generally this saves 8 bytes per function. Tested by importing lots of modules: - 64-bit Linux gave about an 8% RAM saving for 86k of used RAM. - pyboard gave about a 6% RAM saving for 31k of used RAM.
2014-10-23py: Add builtin memoryview object (mostly using array code).Damien George
2014-10-22py: Remove unused and unneeded SystemError exception.Damien George
It's purpose is for internal errors that are not catastrophic (ie not as bad as RuntimeError). Since we don't use it, we don't need it.
2014-10-21py: Make mp_const_empty_bytes globally available.Damien George
2014-10-03py: Convert [u]int to mp_[u]int_t where appropriate.Damien George
Addressing issue #50.
2014-09-30py: Remove IOError since it's deprecated; use OSError instead.Damien George
In CPython IOError (and EnvironmentError) is deprecated and aliased to OSError. All modules that used to raise IOError now raise OSError (or a derived exception). In Micro Python we never used IOError (except 1 place, incorrectly) and so don't need to keep it. See http://legacy.python.org/dev/peps/pep-3151/ for background.
2014-09-25py: Tidy up exception matching; allow matching of tuple of exceptions.Damien George
Addresses issue #864.
2014-09-17py: Add native json printing using existing print framework.Damien George
Also add start of ujson module with dumps implemented. Enabled in unix and stmhal ports. Test passes on both.
2014-09-13py: Implement divmod, % and proper // for floating point.Damien George
Tested and working on unix and pyboard.
2014-09-10py: Enable struct/binary-helper to parse q and Q sized ints.Damien George
Addresses issue #848.
2014-09-07py: Rename mp_builtin_id to mp_obj_id and make it public.Damien George
2014-09-07stmhal: Implement generic select.select and select.poll.Damien George
2014-09-07py: Add ioctl method to stream protocol; add initial modselect.Damien George
2014-08-30py: Remove use of int type in obj.h.Damien George
Part of code cleanup, working towards resolving issue #50.
2014-08-30py: Change all uint to mp_uint_t in obj.h.Damien George
Part of code cleanup, working towards resolving issue #50.
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-30py: Make map, dict, set use mp_int_t/mp_uint_t exclusively.Damien George
Part of code cleanup, towards resolving 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-29py: Use memmove instead of memcpy when appropriate.Damien George
Found this bug by running unix/ tests with DEBUG=1 enabled when compiling.
2014-08-27py: Improve efficiency of MP_OBJ_IS_STR_OR_BYTES.Damien George
Saves ROM (16 on stmhal, 240 on 64-bit unix) and should be quicker since there is 1 less branch.
2014-08-26Make int(b'123') work properly.Dave Hylands
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-08-15py: Allow viper to have type annotations.Damien George
Viper functions can now be annotated with the type of their arguments and return value. Eg: @micropython.viper def f(x:int) -> int: return x + 1
2014-08-12py: Implement builtin reversed() function.Damien George
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).
2014-08-10py: mp_buffer_info_t::buf may be valid, but NULL for empty objects.Paul Sokolovsky
This happens for example for zero-size arrays. As .get_buffer() method now has explicit return value, it's enough to distinguish success vs failure of getting buffer.
2014-07-31py: Make MP_OBJ_NEW_SMALL_INT cast arg to mp_int_t itself.Damien George
Addresses issue #724.
2014-07-31py: Add mp_obj_str_builder_end_with_len.Damien George
This allows to create str's with a smaller length than initially asked for.
2014-07-29Merge pull request #738 from dhylands/except-argsDamien George
Add support for storing args during an exception raised by an irq.
2014-07-27py: Change stream protocol API: fns return uint; is_text for text.Damien George
2014-07-25Add support for storing args during an exception raised by an irq.Dave Hylands
The user code should call micropython.alloc_emergency_exception_buf(size) where size is the size of the buffer used to print the argument passed to the exception. With the test code from #732, and a call to micropython.alloc_emergenncy_exception_buf(100) the following error is now printed: ```python >>> import heartbeat_irq Uncaught exception in Timer(4) interrupt handler Traceback (most recent call last): File "0://heartbeat_irq.py", line 14, in heartbeat_cb NameError: name 'led' is not defined ```
2014-07-03Rename machine_(u)int_t to mp_(u)int_t.Damien George
See discussion in issue #50.
2014-06-14objstr: Be 8-bit clean even for repr().Paul Sokolovsky
This will allow roughly the same behavior as Python3 for non-ASCII strings, for example, print("<phrase in non-Latin script>".split()) will print list of words, not weird hex dump (like Python2 behaves). (Of course, that it will print list of words, if there're "words" in that phrase at all, separated by ASCII-compatible whitespace; that surely won't apply to every human language in existence).
2014-06-11objfun: Remove no longer used mp_obj_fun_prepare_simple_args().Paul Sokolovsky
2014-06-08py: Make sure getattr() works with non-interned strings (by interning them).Paul Sokolovsky
2014-06-07py: Implement default keyword only args.Damien George
Should finish addressing issue #524.