1. 25 Jun, 2015 1 commit
    • Damien George's avatar
      py: Remove mp_load_const_bytes and instead load precreated bytes object. · 59fba2d6
      Damien George authored
      Previous to this patch each time a bytes object was referenced a new
      instance (with the same data) was created.  With this patch a single
      bytes object is created in the compiler and is loaded directly at execute
      time as a true constant (similar to loading bignum and float objects).
      This saves on allocating RAM and means that bytes objects can now be
      used when the memory manager is locked (eg in interrupts).
      
      The MP_BC_LOAD_CONST_BYTES bytecode was removed as part of this.
      
      Generated bytecode is slightly larger due to storing a pointer to the
      bytes object instead of the qstr identifier.
      
      Code size is reduced by about 60 bytes on Thumb2 architectures.
      59fba2d6
  2. 13 Jun, 2015 1 commit
  3. 12 May, 2015 1 commit
    • 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
  4. 05 May, 2015 1 commit
  5. 08 Feb, 2015 1 commit
    • Damien George's avatar
      py: Parse big-int/float/imag constants directly in parser. · 7d414a1b
      Damien George authored
      Previous to this patch, a big-int, float or imag constant was interned
      (made into a qstr) and then parsed at runtime to create an object each
      time it was needed.  This is wasteful in RAM and not efficient.  Now,
      these constants are parsed straight away in the parser and turned into
      objects.  This allows constants with large numbers of digits (so
      addresses issue #1103) and takes us a step closer to #722.
      7d414a1b
  6. 13 Jan, 2015 1 commit
  7. 01 Jan, 2015 1 commit
  8. 27 Dec, 2014 2 commits
    • Damien George's avatar
      py: Allow to properly disable builtin slice operation. · 83204f34
      Damien George authored
      This patch makes the MICROPY_PY_BUILTINS_SLICE compile-time option
      fully disable the builtin slice operation (when set to 0).  This
      includes removing the slice sytanx from the grammar.  Now, enabling
      slice costs 4228 bytes on unix x64, and 1816 bytes on stmhal.
      83204f34
    • Damien George's avatar
      py: Allow to properly disable builtin "set" object. · e37dcaaf
      Damien George authored
      This patch makes MICROPY_PY_BUILTINS_SET compile-time option fully
      disable the builtin set object (when set to 0).  This includes removing
      set constructor/comprehension from the grammar, the compiler and the
      emitters.  Now, enabling set costs 8168 bytes on unix x64, and 3576
      bytes on stmhal.
      e37dcaaf
  9. 25 Oct, 2014 1 commit
    • Damien George's avatar
      py: Compress load-int, load-fast, store-fast, unop, binop bytecodes. · 8456cc01
      Damien George authored
      There is a lot potential in compress bytecodes and make more use of the
      coding space.  This patch introduces "multi" bytecodes which have their
      argument included in the bytecode (by addition).
      
      UNARY_OP and BINARY_OP now no longer take a 1 byte argument for the
      opcode.  Rather, the opcode is included in the first byte itself.
      
      LOAD_FAST_[0,1,2] and STORE_FAST_[0,1,2] are removed in favour of their
      multi versions, which can take an argument between 0 and 15 inclusive.
      The majority of LOAD_FAST/STORE_FAST codes fit in this range and so this
      saves a byte for each of these.
      
      LOAD_CONST_SMALL_INT_MULTI is used to load small ints between -16 and 47
      inclusive.  Such ints are quite common and now only need 1 byte to
      store, and now have much faster decoding.
      
      In all this patch saves about 2% RAM for typically bytecode (1.8% on
      64-bit test, 2.5% on pyboard test).  It also reduces the binary size
      (because bytecodes are simplified) and doesn't harm performance.
      8456cc01
  10. 12 May, 2014 1 commit
  11. 03 May, 2014 1 commit
    • Damien George's avatar
      Add license header to (almost) all files. · 04b9147e
      Damien George authored
      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/.
      04b9147e
  12. 27 Apr, 2014 1 commit
  13. 20 Apr, 2014 1 commit
  14. 17 Apr, 2014 1 commit
  15. 15 Apr, 2014 2 commits