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