Skip to content
Snippets Groups Projects
  1. Feb 25, 2018
    • Damien George's avatar
      py/mpz: In mpz_clone, remove unused check for NULL dig. · f75c7ad1
      Damien George authored
      This path for src->deg==NULL is never used because mpz_clone() is always
      called with an argument that has a non-zero integer value, and hence has
      some digits allocated to it (mpz_clone() is a static function private to
      mpz.c all callers of this function first check if the integer value is zero
      and if so take a special-case path, bypassing the call to mpz_clone()).
      
      There is some unused and commented-out functions that may actually pass a
      zero-valued mpz to mpz_clone(), so some TODOs are added to these function
      in case they are needed in the future.
      f75c7ad1
  2. Feb 24, 2018
  3. Feb 23, 2018
  4. Feb 22, 2018
  5. Feb 21, 2018
  6. Feb 20, 2018
  7. Feb 19, 2018
    • Damien George's avatar
    • Damien George's avatar
      py/objstr: Protect against creating bytes(n) with n negative. · 4e469085
      Damien George authored
      Prior to this patch uPy (on a 32-bit arch) would have severe issues when
      calling bytes(-1): such a call would call vstr_init_len(vstr, -1) which
      would then +1 on the len and call vstr_init(vstr, 0), which would then
      round this up and allocate a small amount of memory for the vstr.  The
      bytes constructor would then attempt to zero out all this memory, thinking
      it had allocated 2^32-1 bytes.
      4e469085
    • Damien George's avatar
      py/repl: Generalise REPL autocomplete to use qstr probing. · 165aab12
      Damien George authored
      This patch changes the way REPL autocomplete finds matches.  It now probes
      the target object for all qstrs via mp_load_method_maybe to look for a
      match with the given input string.  Similar to how the builtin dir()
      function works, this new algorithm now find all methods and instances of
      user-defined classes including attributes of their parent classes.  This
      helps a lot at the REPL prompt for user-discovery and to autocomplete names
      even for classes that are derived.
      
      The downside is that this new algorithm is slower than the previous one,
      and in particular will be slower the more qstrs there are in the system.
      But because REPL autocomplete is primarily used in an interactive way it is
      not that important to make it fast, as long as it is "fast enough" compared
      to human reaction.
      
      On a slow microcontroller (CPU running at 16MHz) the autocomplete time for
      a list of 35 names in the outer namespace (pressing tab at a bare prompt)
      takes about 160ms with this algorithm, compared to about 40ms for the
      previous implementation (this time includes the actual printing of the
      names as well).  This time of 160ms is very reasonable especially given the
      new functionality of listing all the names.
      
      This patch also decreases code size by:
      
         bare-arm:    +0
      minimal x86:  -128
         unix x64:  -128
      unix nanbox:  -224
            stm32:   -88
           cc3200:   -80
          esp8266:   -92
            esp32:   -84
      165aab12
    • Damien George's avatar
      py/modbuiltins: Simplify and generalise dir() by probing qstrs. · 98647e83
      Damien George authored
      This patch improves the builtin dir() function by probing the target object
      with all possible qstrs via mp_load_method_maybe.  This is very simple (in
      terms of implementation), doesn't require recursion, and allows to list all
      methods of user-defined classes (without duplicates) even if they have
      multiple inheritance with a common parent.  The downside is that it can be
      slow because it has to iterate through all the qstrs in the system, but
      the "dir()" function is anyway mostly used for testing frameworks and user
      introspection of types, so speed is not considered a priority.
      
      In addition to providing a more complete implementation of dir(), this
      patch is simpler than the previous implementation and saves some code
      space:
      
         bare-arm:   -80
      minimal x86:   -80
         unix x64:   -56
      unix nanbox:   -48
            stm32:   -80
           cc3200:   -80
          esp8266:  -104
            esp32:   -64
      98647e83
    • Damien George's avatar
Loading