1. 12 May, 2015 2 commits
    • Damien George's avatar
      py: Add mp_obj_get_int_truncated and use it where appropriate. · c50772d1
      Damien George authored
      mp_obj_get_int_truncated will raise a TypeError if the argument is not
      an integral type.  Use mp_obj_int_get_truncated only when you know the
      argument is a small or big int.
      c50772d1
    • Damien George's avatar
      py: Convert hash API to use MP_UNARY_OP_HASH instead of ad-hoc function. · c2a4e4ef
      Damien George authored
      Hashing is now done using mp_unary_op function with MP_UNARY_OP_HASH as
      the operator argument.  Hashing for int, str and bytes still go via
      fast-path in mp_unary_op since they are the most common objects which
      need to be hashed.
      
      This lead to quite a bit of code cleanup, and should be more efficient
      if anything.  It saves 176 bytes code space on Thumb2, and 360 bytes on
      x86.
      
      The only loss is that the error message "unhashable type" is now the
      more generic "unsupported type for __hash__".
      c2a4e4ef
  2. 04 May, 2015 1 commit
  3. 16 Apr, 2015 2 commits
    • Damien George's avatar
      044c473d
    • Damien George's avatar
      py: Overhaul and simplify printf/pfenv mechanism. · 7f9d1d6a
      Damien George authored
      Previous to this patch the printing mechanism was a bit of a tangled
      mess.  This patch attempts to consolidate printing into one interface.
      
      All (non-debug) printing now uses the mp_print* family of functions,
      mainly mp_printf.  All these functions take an mp_print_t structure as
      their first argument, and this structure defines the printing backend
      through the "print_strn" function of said structure.
      
      Printing from the uPy core can reach the platform-defined print code via
      two paths: either through mp_sys_stdout_obj (defined pert port) in
      conjunction with mp_stream_write; or through the mp_plat_print structure
      which uses the MP_PLAT_PRINT_STRN macro to define how string are printed
      on the platform.  The former is only used when MICROPY_PY_IO is defined.
      
      With this new scheme printing is generally more efficient (less layers
      to go through, less arguments to pass), and, given an mp_print_t*
      structure, one can call mp_print_str for efficiency instead of
      mp_printf("%s", ...).  Code size is also reduced by around 200 bytes on
      Thumb2 archs.
      7f9d1d6a
  4. 11 Apr, 2015 1 commit
  5. 04 Apr, 2015 2 commits
  6. 30 Mar, 2015 1 commit
  7. 26 Mar, 2015 1 commit
  8. 21 Mar, 2015 1 commit
    • Damien George's avatar
      py: Combine duplicated code that converts members from a lookup. · 55b74d1f
      Damien George authored
      Despite initial guess, this code factoring does not hamper performance.
      In fact it seems to improve speed by a little: running pystone(1.2) on
      pyboard (which gives a very stable result) this patch takes pystones
      from 1729.51 up to 1742.16.  Also, pystones on x64 increase by around
      the same proportion (but it's much noisier).
      
      Taking a look at the generated machine code, stack usage with this patch
      is unchanged, and call is tail-optimised with all arguments in
      registers.  Code size decreases by about 50 bytes on Thumb2 archs.
      55b74d1f
  9. 19 Mar, 2015 1 commit
  10. 17 Mar, 2015 1 commit
  11. 16 Mar, 2015 4 commits
  12. 21 Feb, 2015 1 commit
  13. 15 Feb, 2015 1 commit
  14. 14 Feb, 2015 1 commit
  15. 09 Feb, 2015 2 commits
  16. 08 Feb, 2015 1 commit
  17. 30 Jan, 2015 1 commit
  18. 27 Jan, 2015 1 commit
    • Damien George's avatar
      py: Specify unary/binary op name in TypeError error message. · a5efcd47
      Damien George authored
      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.
      a5efcd47
  19. 20 Jan, 2015 2 commits
  20. 11 Jan, 2015 1 commit
  21. 08 Jan, 2015 1 commit
  22. 07 Jan, 2015 1 commit
    • Damien George's avatar
      py: Add option to cache map lookup results in bytecode. · 7ee91cf8
      Damien George authored
      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.
      7ee91cf8
  23. 01 Jan, 2015 1 commit
  24. 28 Dec, 2014 1 commit
  25. 06 Nov, 2014 1 commit
  26. 05 Nov, 2014 1 commit
  27. 03 Nov, 2014 2 commits
  28. 23 Oct, 2014 1 commit
  29. 30 Aug, 2014 1 commit
  30. 29 Aug, 2014 1 commit
  31. 26 Aug, 2014 1 commit