1. 19 Aug, 2015 1 commit
  2. 17 Aug, 2015 2 commits
    • Damien George's avatar
    • Damien George's avatar
      unix-cpy: Remove unix-cpy. It's no longer needed. · 65dc960e
      Damien George authored
      unix-cpy was originally written to get semantic equivalent with CPython
      without writing functional tests.  When writing the initial
      implementation of uPy it was a long way between lexer and functional
      tests, so the half-way test was to make sure that the bytecode was
      correct.  The idea was that if the uPy bytecode matched CPython 1-1 then
      uPy would be proper Python if the bytecodes acted correctly.  And having
      matching bytecode meant that it was less likely to miss some deep
      subtlety in the Python semantics that would require an architectural
      change later on.
      
      But that is all history and it no longer makes sense to retain the
      ability to output CPython bytecode, because:
      
      1. It outputs CPython 3.3 compatible bytecode.  CPython's bytecode
      changes from version to version, and seems to have changed quite a bit
      in 3.5.  There's no point in changing the bytecode output to match
      CPython anymore.
      
      2. uPy and CPy do different optimisations to the bytecode which makes it
      harder to match.
      
      3. The bytecode tests are not run.  They were never part of Travis and
      are not run locally anymore.
      
      4. The EMIT_CPYTHON option needs a lot of extra source code which adds
      heaps of noise, especially in compile.c.
      
      5. Now that there is an extensive test suite (which tests functionality)
      there is no need to match the bytecode.  Some very subtle behaviour is
      tested with the test suite and passing these tests is a much better
      way to stay Python-language compliant, rather than trying to match
      CPy bytecode.
      65dc960e
  3. 13 Aug, 2015 1 commit
  4. 12 Aug, 2015 2 commits
  5. 11 Aug, 2015 1 commit
  6. 02 Aug, 2015 1 commit
  7. 31 Jul, 2015 1 commit
  8. 29 Jul, 2015 2 commits
    • Damien George's avatar
      py/compile: Give more precise line number for compile errors. · cfc4c338
      Damien George authored
      Previous to this patch there were some cases where line numbers for
      errors were 0 (unknown).  Now the compiler attempts to give a better
      line number where possible, in some cases giving the line number of the
      closest statement, and other cases the line number of the inner-most
      scope of the error (eg the line number of the start of the function).
      This helps to give good (and sometimes exact) line numbers for
      ViperTypeError exceptions.
      
      This patch also makes sure that the first compile error (eg SyntaxError)
      that is encountered is reported (previously it was the last one that was
      reported).
      cfc4c338
    • Damien George's avatar
      py/repl: Don't look inside strings for unmatched brackets/quotes. · 28596edf
      Damien George authored
      When looking to see if the REPL input needs to be continued on the next
      line, don't look inside strings for unmatched ()[]{} ''' or """.
      
      Addresses issue #1387.
      28596edf
  9. 27 Jul, 2015 1 commit
  10. 26 Jul, 2015 2 commits
  11. 24 Jul, 2015 2 commits
  12. 23 Jul, 2015 3 commits
  13. 06 Jun, 2015 1 commit
  14. 20 Jul, 2015 3 commits
  15. 19 Jul, 2015 1 commit
  16. 14 Jul, 2015 1 commit
    • Damien George's avatar
      py: Improve allocation policy of qstr data. · ade9a052
      Damien George authored
      Previous to this patch all interned strings lived in their own malloc'd
      chunk.  On average this wastes N/2 bytes per interned string, where N is
      the number-of-bytes for a quanta of the memory allocator (16 bytes on 32
      bit archs).
      
      With this patch interned strings are concatenated into the same malloc'd
      chunk when possible.  Such chunks are enlarged inplace when possible,
      and shrunk to fit when a new chunk is needed.
      
      RAM savings with this patch are highly varied, but should always show an
      improvement (unless only 3 or 4 strings are interned).  New version
      typically uses about 70% of previous memory for the qstr data, and can
      lead to savings of around 10% of total memory footprint of a running
      script.
      
      Costs about 120 bytes code size on Thumb2 archs (depends on how many
      calls to gc_realloc are made).
      ade9a052
  17. 06 Jul, 2015 2 commits
    • Dave Hylands's avatar
      py: Prevent many extra vstr allocations. · 9f76dcd6
      Dave Hylands authored
      I checked the entire codebase, and every place that vstr_init_len
      was called, there was a call to mp_obj_new_str_from_vstr after it.
      
      mp_obj_new_str_from_vstr always tries to reallocate a new buffer
      1 byte larger than the original to store the terminating null
      character.
      
      In many cases, if we allocated the initial buffer to be 1 byte
      longer, we can prevent this extra allocation, and just reuse
      the originally allocated buffer.
      
      Asking to read 256 bytes and only getting 100 will still cause
      the extra allocation, but if you ask to read 256 and get 256
      then the extra allocation will be optimized away.
      
      Yes - the reallocation is optimized in the heap to try and reuse
      the buffer if it can, but it takes quite a few cycles to figure
      this out.
      
      Note by Damien: vstr_init_len should now be considered as a
      string-init convenience function and used only when creating
      null-terminated objects.
      9f76dcd6
    • Damien George's avatar
      py/repl: Fix case where shorter names are shadowed by longer names. · ef7dd8db
      Damien George authored
      Previous to this patch, if "abcd" and "ab" were possible completions
      to tab-completing "a", then tab would expand to "abcd" straight away
      if this identifier appeared first in the dict.
      ef7dd8db
  18. 05 Jul, 2015 1 commit
  19. 04 Jul, 2015 1 commit
  20. 02 Jul, 2015 2 commits
  21. 28 Jun, 2015 1 commit
    • Paul Sokolovsky's avatar
      builtinimport: Fix running package submodule with -m. · 9780e552
      Paul Sokolovsky authored
      When "micropython -m pkg.mod" command was used, relative imports in pkg.mod
      didn't work, because pkg.mod.__name__ was set to __main__, and the fact that
      it's a package submodule was missed. This is an original workaround to this
      issue. TODO: investigate and compare how CPython deals with this issue.
      9780e552
  22. 26 Jun, 2015 3 commits
  23. 25 Jun, 2015 2 commits
    • 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
    • Damien George's avatar
  24. 23 Jun, 2015 2 commits
  25. 22 Jun, 2015 1 commit