1. 20 Feb, 2018 1 commit
  2. 19 Feb, 2018 1 commit
    • 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
         bare-arm:   -80
      minimal x86:   -80
         unix x64:   -56
      unix nanbox:   -48
            stm32:   -80
           cc3200:   -80
          esp8266:  -104
            esp32:   -64
  3. 14 Feb, 2018 2 commits
  4. 07 Feb, 2018 1 commit
  5. 06 Feb, 2018 2 commits
  6. 05 Dec, 2017 1 commit
    • Damien George's avatar
      py/modbuiltins: Use standard arg-parsing helper func for builtin print. · 58f00d7c
      Damien George authored
      This allows the function to raise an exception when unknown keyword args
      are passed in.  This patch also reduces code size by (in bytes):
         bare-arm:   -24
      minimal x86:   -76
         unix x64:   -56
      unix nanbox:   -84
            stm32:   -40
          esp8266:   -68
           cc3200:   -48
      Furthermore, this patch adds space (" ") to the set of ROM qstrs which
      means it doesn't need to be put in RAM if it's ever used.
  7. 28 Nov, 2017 1 commit
  8. 27 Nov, 2017 2 commits
  9. 22 Nov, 2017 2 commits
  10. 16 Nov, 2017 1 commit
    • Damien George's avatar
      py/objstr: Remove "make_qstr_if_not_already" arg from mp_obj_new_str. · 4601759b
      Damien George authored
      This patch simplifies the str creation API to favour the common case of
      creating a str object that is not forced to be interned.  To force
      interning of a new str the new mp_obj_new_str_via_qstr function is added,
      and should only be used if warranted.
      Apart from simplifying the mp_obj_new_str function (and making it have the
      same signature as mp_obj_new_bytes), this patch also reduces code size by a
      bit (-16 bytes for bare-arm and roughly -40 bytes on the bare-metal archs).
  11. 11 Oct, 2017 1 commit
  12. 04 Oct, 2017 1 commit
    • Damien George's avatar
      all: Remove inclusion of internal py header files. · a3dc1b19
      Damien George authored
      Header files that are considered internal to the py core and should not
      normally be included directly are:
          py/nlr.h - internal nlr configuration and declarations
          py/bc0.h - contains bytecode macro definitions
          py/runtime0.h - contains basic runtime enums
      Instead, the top-level header files to include are one of:
          py/obj.h - includes runtime0.h and defines everything to use the
              mp_obj_t type
          py/runtime.h - includes mpstate.h and hence nlr.h, obj.h, runtime0.h,
              and defines everything to use the general runtime support functions
      Additional, specific headers (eg py/objlist.h) can be included if needed.
  13. 17 Sep, 2017 1 commit
    • Paul Sokolovsky's avatar
      py/modbuiltins: Implement abs() by dispatching to MP_UNARY_OP_ABS. · 9dce823c
      Paul Sokolovsky authored
      This allows user classes to implement __abs__ special method, and saves
      code size (104 bytes for x86_64), even though during refactor, an issue
      was fixed and few optimizations were made:
      * abs() of minimum (negative) small int value is calculated properly.
      * objint_longlong and objint_mpz avoid allocating new object is the
        argument is already non-negative.
  14. 02 Aug, 2017 1 commit
  15. 31 Jul, 2017 1 commit
  16. 07 Jul, 2017 1 commit
  17. 04 Jul, 2017 1 commit
  18. 15 Jun, 2017 1 commit
  19. 01 Jun, 2017 1 commit
    • Damien George's avatar
      py/modbuiltins: Add core-provided version of input() function. · bc76302e
      Damien George authored
      The implementation is taken from stmhal/input.c, with code added to handle
      ctrl-C.  This built-in is controlled by MICROPY_PY_BUILTINS_INPUT and is
      disabled by default.  It uses readline() to capture input but this can be
      overridden by defining the mp_hal_readline macro.
  20. 14 May, 2017 1 commit
  21. 29 Mar, 2017 1 commit
  22. 28 Mar, 2017 1 commit
  23. 24 Mar, 2017 2 commits
    • Damien George's avatar
      py/modbuiltins: Allow round() to return a big int if necessary. · c236ebfe
      Damien George authored
      Previous to this patch, if the result of the round function overflowed a
      small int, or was inf or nan, then a garbage value was returned.  With
      this patch the correct big-int is returned if necessary and exceptions are
      raised for inf or nan.
    • Damien George's avatar
      py/modbuiltins: For round() builtin use nearbyint instead of round. · 125eae1b
      Damien George authored
      The C nearbyint function has exactly the semantics that Python's round()
      requires, whereas C's round() requires extra steps to handle rounding of
      numbers half way between integers.  So using nearbyint reduces code size
      and potentially eliminates any source of errors in the handling of half-way
      Also, bare-metal implementations of nearbyint can be more efficient than
      round, so further code size is saved (and efficiency improved).
      nearbyint is provided in the C99 standard so it should be available on all
      supported platforms.
  24. 16 Feb, 2017 1 commit
    • Damien George's avatar
      py: Add iter_buf to getiter type method. · ae8d8675
      Damien George authored
      Allows to iterate over the following without allocating on the heap:
      - tuple
      - list
      - string, bytes
      - bytearray, array
      - dict (not dict.keys, dict.values, dict.items)
      - set, frozenset
      Allows to call the following without heap memory:
      - all, any, min, max, sum
      TODO: still need to allocate stack memory in bytecode for iter_buf.
  25. 02 Feb, 2017 1 commit
  26. 22 Jan, 2017 1 commit
  27. 20 Dec, 2016 1 commit
  28. 24 Oct, 2016 2 commits
  29. 21 Oct, 2016 1 commit
  30. 17 Oct, 2016 1 commit
  31. 21 Sep, 2016 1 commit
  32. 12 Aug, 2016 1 commit
  33. 13 Apr, 2016 1 commit
    • pohmelie's avatar
      py: add async/await/async for/async with syntax · 81ebba7e
      pohmelie authored
      They are sugar for marking function as generator, "yield from"
      and pep492 python "semantically equivalents" respectively.
      @dpgeorge was the original author of this patch, but @pohmelie made
      changes to implement `async for` and `async with`.
  34. 12 Apr, 2016 1 commit