micropython

TO_DO.txt

401:4a8dd27c2994
2011-02-27 Paul Boddie Switched back to providing a common __class__ attribute for instances, intercepting __class__ accesses on classes during inspection, compilation and, through appropriate instruction sequences, execution. Exposed target details in the optimise_constant_accessor method's results. Exposed dynamic/static details in the possible_accessor_types ASTVisitor method's results. Improved frame stack visualisation in the RSVP machine.
     1 Permit __class__ as being differently defined for classes and instances. Since __class__
     2 is always defined, no shadowing may occur for the attribute exposing it at different
     3 levels.
     4 
     5   The instance definition of __class__ should be stored in the object table.
     6 
     7   Each common definition for instances of a class shall be stored as the first
     8   attribute of each class.
     9 
    10   Access to __class__ has to be detected and a special instruction (sequence)
    11   generated to handle the class/instance logic.
    12 
    13   The type class should be exposed as each class's __class__ attribute.
    14 
    15   Note that object table information will not be able to reflect the class-type
    16   relationship, but isinstance will need to check for instances and classes, anyway.
    17 
    18 Tuple references to stack locations in a merged stack/heap memory model.
    19 
    20 Attribute Usage
    21 ===============
    22 
    23 Consider attribute assignment observations, along with the possibility of class attribute
    24 assignment.
    25 
    26 Consider attribute usage observations being suspended inside blocks where AttributeError
    27 may be caught (although this doesn't anticipate such exceptions being caught outside a
    28 function altogether).
    29 
    30 Consider type deduction and its consequences where types belong to the same hierarchy
    31 and where a guard could be generated for the most general type.
    32 
    33 Consider permitting multiple class alternatives where the attributes are all identical.
    34 
    35 Support class attribute positioning similar to instance attribute positioning, potentially
    36 (for both) based on usage observations. For example, if __iter__ is used on two classes,
    37 the class attribute could be exposed at a similar relative position to the class (and
    38 potentially accessible using a LoadAttr-style instruction).
    39 
    40 **** Constant attribute users need not maintain usage since they are already resolved. ****
    41 
    42 Loop entry points should capture usage to update later assignments in the loop.
    43 The continue and break statements should affect usage propagation.
    44 
    45 Consider handling CallFunc in micropython.inspect in order to produce instances of specific classes.
    46 Then, consider adding support for guard removal/verification where known instances are involved.
    47 Consider handling branches of values within namespaces in order to support more precise value usage.
    48 
    49 Frame Optimisations
    50 ===================
    51 
    52 Stack frame replacement where a local frame is unused after a call, such as in a tail call
    53 situation.
    54 
    55 Local assignment detection plus frame re-use. Example: slice.__init__ calls
    56 xrange.__init__ with the same arguments which are unchanged in xrange.__init__. There is
    57 therefore no need to build a new frame for this call.
    58 
    59 Function Specialisation
    60 =======================
    61 
    62 Specialisation of certain functions, such as isinstance(x, cls) where cls is a known
    63 constant.
    64 
    65 Structure and Object Table Optimisations
    66 ========================================
    67 
    68 Fix object table entries for attributes not provided by any known object, or provide an
    69 error, potentially overridden by options. For example, the augmented assignment methods
    70 are not supported by the built-in objects and thus the operator module functions cause
    71 the compilation to fail. Alternatively, just supply the methods since something has to do
    72 so in the builtins.
    73 
    74 Consider attribute merging where many attributes are just aliases for the same underlying
    75 definition.
    76 
    77 Consider references to defaults as occurring only within the context of a particular
    78 function, thus eliminating default value classes if such functions are not themselves
    79 invoked.
    80 
    81 Scope Handling
    82 ==============
    83 
    84 Consider merging the InspectedModule.store tests with the scope conflict handling.
    85 
    86 Consider labelling _scope on assignments and dealing with the assignment of removed
    87 attributes, possibly removing the entire assignment, and distinguishing between such cases
    88 and unknown names.
    89 
    90 Check name origin where multiple branches could yield multiple scope interpretations:
    91 
    92 ----
    93 try:
    94     set # built-in name
    95 except NameError:
    96     from sets import Set as set # local definition of name
    97 
    98 set # could be confused by the local definition at run-time
    99 ----
   100 
   101 Object Coverage
   102 ===============
   103 
   104 Support __init__ traversal (and other implicit names) more effectively.
   105 
   106 Other
   107 =====
   108 
   109 Check context_value initialisation (avoiding or handling None effectively).
   110 
   111 __getitem__ could be written in Python, using a native method only to access fragments.
   112 
   113 Consider better "macro" support where new expressions need to be generated and processed.