1. 25 Mar, 2015 1 commit
    • Paul Sokolovsky's avatar
      py: Cast mp_obj_t to concrete types explicitly. · 3d598256
      Paul Sokolovsky authored
      mp_obj_t internal representation doesn't have to be a pointer to object,
      it can be anything.
      
      There's also a support for back-conversion in the form of MP_OBJ_UNCAST.
      This is kind of optimization/status quo preserver to minimize patching the
      existing code and avoid doing potentially expensive MP_OBJ_CAST over and
      over. But then one may imagine implementations where MP_OBJ_UNCAST is very
      expensive. But such implementations are unlikely interesting in practice.
      3d598256
  2. 20 Mar, 2015 3 commits
  3. 06 Mar, 2015 1 commit
  4. 27 Feb, 2015 1 commit
    • Paul Sokolovsky's avatar
      objarray: Implement array slice assignment. · cefcbb22
      Paul Sokolovsky authored
      This is rarely used feature which takes enough code to implement, so is
      controlled by MICROPY_PY_ARRAY_SLICE_ASSIGN config setting, default off.
      But otherwise it may be useful, as allows to update arbitrary-sized data
      buffers in-place.
      
      Slice is yet to implement, and actually, slice assignment implemented in
      such a way that RHS of assignment should be array of the exact same item
      typecode as LHS. CPython has it more relaxed, where RHS can be any sequence
      of compatible types (e.g. it's possible to assign list of int's to a
      bytearray slice).
      
      Overall, when all "slice write" features are implemented, it may cost ~1KB
      of code.
      cefcbb22
  5. 23 Feb, 2015 1 commit
  6. 21 Feb, 2015 1 commit
  7. 15 Feb, 2015 1 commit
  8. 08 Feb, 2015 1 commit
  9. 25 Jan, 2015 1 commit
  10. 21 Jan, 2015 2 commits
    • Damien George's avatar
      py: Remove mp_obj_str_builder and use vstr instead. · 05005f67
      Damien George authored
      With this patch str/bytes construction is streamlined.  Always use a
      vstr to build a str/bytes object.  If the size is known beforehand then
      use vstr_init_len to allocate only required memory.  Otherwise use
      vstr_init and the vstr will grow as needed.  Then use
      mp_obj_new_str_from_vstr to create a str/bytes object using the vstr
      memory.
      
      Saves code ROM: 68 bytes on stmhal, 108 bytes on bare-arm, and 336 bytes
      on unix x64.
      05005f67
    • Damien George's avatar
      py: Add mp_obj_new_str_from_vstr, and use it where relevant. · 0b9ee861
      Damien George authored
      This patch allows to reuse vstr memory when creating str/bytes object.
      This improves memory usage.
      
      Also saves code ROM: 128 bytes on stmhal, 92 bytes on bare-arm, and 88
      bytes on unix x64.
      0b9ee861
  11. 16 Jan, 2015 1 commit
  12. 11 Jan, 2015 1 commit
  13. 29 Dec, 2014 3 commits
  14. 10 Dec, 2014 1 commit
  15. 09 Dec, 2014 1 commit
    • Damien George's avatar
      py: Allow builtins to be overridden. · 78d702c3
      Damien George authored
      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.
      78d702c3
  16. 08 Dec, 2014 1 commit
    • Paul Sokolovsky's avatar
      modsys: Add sys.print_exception(exc, file=sys.stdout) function. · 46c3ab20
      Paul Sokolovsky authored
      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.
      46c3ab20
  17. 05 Dec, 2014 1 commit
  18. 29 Nov, 2014 1 commit
  19. 27 Nov, 2014 1 commit
  20. 16 Nov, 2014 2 commits
  21. 25 Oct, 2014 3 commits
    • Damien George's avatar
      py: Add mp_pending_exception global variable, for VM soft interrupt. · 124df6f8
      Damien George authored
      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).
      124df6f8
    • Paul Sokolovsky's avatar
      e5a3759f
    • Damien George's avatar
      py: Store bytecode arg names in bytecode (were in own array). · 1084b0f9
      Damien George authored
      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.
      1084b0f9
  22. 23 Oct, 2014 1 commit
  23. 22 Oct, 2014 1 commit
  24. 21 Oct, 2014 1 commit
  25. 03 Oct, 2014 1 commit
  26. 30 Sep, 2014 1 commit
  27. 25 Sep, 2014 1 commit
  28. 17 Sep, 2014 1 commit
  29. 13 Sep, 2014 1 commit
  30. 10 Sep, 2014 1 commit
  31. 07 Sep, 2014 2 commits