micropython

TO_DO.txt

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