Skip to content
Snippets Groups Projects
  1. May 17, 2019
  2. Feb 12, 2019
    • Damien George's avatar
      054dd33e
    • Damien George's avatar
      py: Downcase all MP_OBJ_IS_xxx macros to make a more consistent C API. · eee1e884
      Damien George authored
      These macros could in principle be (inline) functions so it makes sense to
      have them lower case, to match the other C API functions.
      
      The remaining macros that are upper case are:
      - MP_OBJ_TO_PTR, MP_OBJ_FROM_PTR
      - MP_OBJ_NEW_SMALL_INT, MP_OBJ_SMALL_INT_VALUE
      - MP_OBJ_NEW_QSTR, MP_OBJ_QSTR_VALUE
      - MP_OBJ_FUN_MAKE_SIG
      - MP_DECLARE_CONST_xxx
      - MP_DEFINE_CONST_xxx
      
      These must remain macros because they are used when defining const data (at
      least, MP_OBJ_NEW_SMALL_INT is so it makes sense to have
      MP_OBJ_SMALL_INT_VALUE also a macro).
      
      For those macros that have been made lower case, compatibility macros are
      provided for the old names so that users do not need to change their code
      immediately.
      eee1e884
  3. Dec 12, 2018
  4. Sep 27, 2018
  5. Jul 08, 2018
    • Damien George's avatar
      py/objdict: Make mp_obj_dict_get_map an inline function. · d9cdb880
      Damien George authored
      It's a very simple function and saves code, and improves efficiency, by
      being inline.  Note that this is an auxiliary helper function and so
      doesn't need mp_check_self -- that's used for functions that can be
      accessed directly from Python code (eg from a method table).
      d9cdb880
  6. Feb 19, 2018
  7. Nov 27, 2017
  8. Nov 24, 2017
    • Damien George's avatar
      py/runtime: Add MP_BINARY_OP_CONTAINS as reverse of MP_BINARY_OP_IN. · 5e34a113
      Damien George authored
      Before this patch MP_BINARY_OP_IN had two meanings: coming from bytecode it
      meant that the args needed to be swapped, but coming from within the
      runtime meant that the args were already in the correct order.  This lead
      to some confusion in the code and comments stating how args were reversed.
      It also lead to 2 bugs: 1) containment for a subclass of a native type
      didn't work; 2) the expression "{True} in True" would illegally succeed and
      return True.  In both of these cases it was because the args to
      MP_BINARY_OP_IN ended up being reversed twice.
      
      To fix these things this patch introduces MP_BINARY_OP_CONTAINS which
      corresponds exactly to the __contains__ special method, and this is the
      operator that built-in types should implement.  MP_BINARY_OP_IN is now only
      emitted by the compiler and is converted to MP_BINARY_OP_CONTAINS by
      swapping the arguments.
      5e34a113
  9. Oct 04, 2017
    • 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.
      a3dc1b19
  10. Aug 29, 2017
  11. Aug 11, 2017
  12. Jul 31, 2017
  13. Jul 04, 2017
  14. Apr 12, 2017
    • Damien George's avatar
      py: Optimise types for common case where type has a single parent type. · 816413e4
      Damien George authored
      The common cases for inheritance are 0 or 1 parent types, for both built-in
      types (eg built-in exceptions) as well as user defined types.  So it makes
      sense to optimise the case of 1 parent type by storing just the type and
      not a tuple of 1 value (that value being the single parent type).
      
      This patch makes such an optimisation.  Even though there is a bit more
      code to handle the two cases (either a single type or a tuple with 2 or
      more values) it helps reduce overall code size because it eliminates the
      need to create a static tuple to hold single parents (eg for the built-in
      exceptions).  It also helps reduce RAM usage for user defined types that
      only derive from a single parent.
      
      Changes in code size (in bytes) due to this patch:
      
          bare-arm:       -16
          minimal (x86): -176
          unix (x86-64): -320
          unix nanbox:   -384
          stmhal:         -64
          cc3200:         -32
          esp8266:       -108
      816413e4
  15. Mar 29, 2017
  16. Mar 28, 2017
  17. Feb 16, 2017
  18. Oct 17, 2016
  19. Aug 12, 2016
  20. Jun 12, 2016
  21. May 20, 2016
  22. Jan 11, 2016
  23. Jan 03, 2016
  24. Nov 29, 2015
  25. Nov 20, 2015
  26. Oct 11, 2015
  27. Apr 16, 2015
    • Damien George's avatar
    • 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
  28. Mar 26, 2015
  29. Mar 20, 2015
    • Paul Sokolovsky's avatar
      py: Implement core of OrderedDict type. · 0ef01d0a
      Paul Sokolovsky authored
      Given that there's already support for "fixed table" maps, which are
      essentially ordered maps, the implementation of OrderedDict just extends
      "fixed table" maps by adding an "is ordered" flag and add/remove
      operations, and reuses 95% of objdict code, just making methods tolerant
      to both dict and OrderedDict.
      
      Some things are missing so far, like CPython-compatible repr and comparison.
      
      OrderedDict is Disabled by default; enabled on unix and stmhal ports.
      0ef01d0a
  30. Jan 20, 2015
  31. Jan 14, 2015
Loading