1.1 --- a/docs/assignment.txt Mon Mar 02 00:04:55 2009 +0100
1.2 +++ b/docs/assignment.txt Thu Mar 05 00:45:42 2009 +0100
1.3 @@ -47,11 +47,13 @@
1.4 local preserved LoadName
1.5 global (module) preserved LoadAddress LoadAttrIndex
1.6 class preserved LoadAddress LoadAttrIndex
1.7 - class via instance overridden LoadAddressContext LoadAttrIndex
1.8 + class via instance overridden LoadAddressContext (*) LoadAttrIndex (*)
1.9 instance preserved LoadAttr LoadAttrIndex
1.10
1.11 Access to a namespace may not preserve the stored context
1.12
1.13 + (*) Other modes of these instructions may exist for certain optimisations
1.14 +
1.15 Access to class attributes via instances:
1.16
1.17 Access to stored value with... Effect on context
1.18 @@ -64,6 +66,20 @@
1.19 LoadAddressContext and LoadAttrIndex must therefore check whether the
1.20 context must be overridden
1.21
1.22 +Optimisation possibilities:
1.23 +
1.24 + Class Class attribute Context of attribute Instruction
1.25 + ----- --------------- -------------------- -----------
1.26 + known constant preserved LoadAddress
1.27 + known constant overridden LoadAddressContext
1.28 + known not constant preserved LoadAddress (attribute may always be preserved)
1.29 + known not constant overridden LoadAddressContext (attribute may always be overridden)
1.30 + known not constant not known LoadAddressContextCond
1.31 + not known not known preserved LoadAttrIndex (attribute may have preserved context in all classes)
1.32 + not known not known overridden LoadAttrIndexContext (attribute may have overridden context in all classes)
1.33 + not known not known not known LoadAttrIndexContextCond
1.34 +
1.35 Since the object table encodes sufficient information (an instance must be
1.36 compatible to access the class attribute, and compatibility information is
1.37 - stored), an explicit compatibility test is not required at run-time
1.38 + stored), an explicit compatibility test may not always be required at
1.39 + run-time
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/tests/attributes_class_multiple.py Thu Mar 05 00:45:42 2009 +0100
2.3 @@ -0,0 +1,10 @@
2.4 +#!/usr/bin/env python
2.5 +
2.6 +class C:
2.7 + clsattr = 123
2.8 + clsattr = 456
2.9 +
2.10 +a = C
2.11 +b = C.clsattr
2.12 +
2.13 +# vim: tabstop=4 expandtab shiftwidth=4