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