micropython

TO_DO.txt

414:ea8cd6ca4083
2011-05-08 Paul Boddie Fixed the placeholder default for getattr which was a hybrid of the old and new mechanisms for defining such a placeholder.
     1 Dynamic Attribute Access
     2 ========================
     3 
     4 Ensure that getattr (or other dynamic attribute usage) causes propagation of coverage to
     5 the potential attributes.
     6 
     7 Consider explicit accessor initialisation.
     8 
     9 Attribute Usage
    10 ===============
    11 
    12 Consider attribute assignment observations, along with the possibility of class attribute
    13 assignment.
    14 
    15   Note direct assignments as usual, indirect assignments via the attribute usage
    16   mechanism. During attribute collection and inference, add assigned values to all
    17   inferred targets.
    18 
    19   Since class attributes can be assigned, StoreAttrIndex would no longer need to reject
    20   static attributes, although this might still be necessary where attribute usage analysis
    21   has not been performed.
    22 
    23   Potentially consider changing static attribute details to use object-relative offsets in
    24   order to simplify the instruction implementations. This might allow us to eliminate the
    25   static attribute flag for attributes in the object table, at least at run-time.
    26 
    27 Consider attribute usage observations being suspended inside blocks where AttributeError
    28 may be caught (although this doesn't anticipate such exceptions being caught outside a
    29 function altogether).
    30 
    31 Consider type deduction and its consequences where types belong to the same hierarchy
    32 and where a guard could be generated for the most general type.
    33 
    34 Consider permitting multiple class alternatives where the attributes are all identical.
    35 
    36 Support class attribute positioning similar to instance attribute positioning, potentially
    37 (for both) based on usage observations. For example, if __iter__ is used on two classes,
    38 the class attribute could be exposed at a similar relative position to the class (and
    39 potentially accessible using a LoadAttr-style instruction).
    40 
    41 **** Constant attribute users need not maintain usage since they are already resolved. ****
    42 
    43 Loop entry points should capture usage to update later assignments in the loop.
    44 The continue and break statements should affect usage propagation.
    45 
    46 Consider handling CallFunc in micropython.inspect in order to produce instances of specific classes.
    47 Then, consider adding support for guard removal/verification where known instances are involved.
    48 Consider handling branches of values within namespaces in order to support more precise value usage.
    49 
    50 Frame Optimisations
    51 ===================
    52 
    53 Stack frame replacement where a local frame is unused after a call, such as in a tail call
    54 situation.
    55 
    56 Local assignment detection plus frame re-use. Example: slice.__init__ calls
    57 xrange.__init__ with the same arguments which are unchanged in xrange.__init__. There is
    58 therefore no need to build a new frame for this call.
    59 
    60 Function Specialisation
    61 =======================
    62 
    63 Specialisation of certain functions, such as isinstance(x, cls) where cls is a known
    64 constant.
    65 
    66 Structure and Object Table Optimisations
    67 ========================================
    68 
    69 Fix object table entries for attributes not provided by any known object, or provide an
    70 error, potentially overridden by options. For example, the augmented assignment methods
    71 are not supported by the built-in objects and thus the operator module functions cause
    72 the compilation to fail. Alternatively, just supply the methods since something has to do
    73 so in the builtins.
    74 
    75 Consider attribute merging where many attributes are just aliases for the same underlying
    76 definition.
    77 
    78 Consider references to defaults as occurring only within the context of a particular
    79 function, thus eliminating default value classes if such functions are not themselves
    80 invoked.
    81 
    82 Scope Handling
    83 ==============
    84 
    85 Consider merging the InspectedModule.store tests with the scope conflict handling.
    86 
    87 Consider labelling _scope on assignments and dealing with the assignment of removed
    88 attributes, possibly removing the entire assignment, and distinguishing between such cases
    89 and unknown names.
    90 
    91 Check name origin where multiple branches could yield multiple scope interpretations:
    92 
    93 ----
    94 try:
    95     set # built-in name
    96 except NameError:
    97     from sets import Set as set # local definition of name
    98 
    99 set # could be confused by the local definition at run-time
   100 ----
   101 
   102 Object Coverage
   103 ===============
   104 
   105 Support __init__ traversal (and other implicit names) more effectively.
   106 
   107 Other
   108 =====
   109 
   110 Support tuple as a function returning any input tuple uncopied.
   111 
   112 Check context_value initialisation (avoiding or handling None effectively).
   113 
   114 __getitem__ could be written in Python, using a native method only to access fragments.
   115 
   116 Consider better "macro" support where new expressions need to be generated and processed.
   117 
   118 Detect TestIdentity results involving constants, potentially optimising status-affected
   119 instructions:
   120 
   121   TestIdentity(x, y) # where x is always y
   122   JumpIfFalse(...)   # would be removed (never false)
   123   JumpIfTrue(...)    # changed to Jump(...)
   124 
   125 Status-affected blocks could be optimised away for such constant-related results.