# HG changeset patch # User Paul Boddie # Date 1338764582 -7200 # Node ID 814bd122d84d5bdcdb96fdba004e3ebd8879de7e # Parent e6f70a977e09a367bbbffa17f61c4a11d2022973 Updated the documentation to reflect class attribute assignment policies. Added tests to demonstrate class attribute rebinding. diff -r e6f70a977e09 -r 814bd122d84d docs/assignment.txt --- a/docs/assignment.txt Sun Jun 03 20:50:19 2012 +0200 +++ b/docs/assignment.txt Mon Jun 04 01:03:02 2012 +0200 @@ -37,10 +37,9 @@ local preserved StoreName global (module) preserved StoreAddress StoreAttrIndex instance preserved StoreAttr StoreAttrIndex - class -> class StoreAddressContext + class -> class StoreAddressContext StoreAttrIndex - Class assignments are not permitted except during initialisation and hence - employ no unoptimised instruction + Assignment of new class attributes is only permitted during initialisation Access types: diff -r e6f70a977e09 -r 814bd122d84d docs/concepts.txt --- a/docs/concepts.txt Sun Jun 03 20:50:19 2012 +0200 +++ b/docs/concepts.txt Mon Jun 04 01:03:02 2012 +0200 @@ -33,6 +33,14 @@ a class as a key to the object table, where the full name is a qualified path via the module hierarchy ending with the name of the class. +Rebinding of attributes outside classes and modules can be allowed if +attribute usage observations are being used to detect such external +modifications to such objects. Without such observations, such rebinding +should be forbidden since apparently constant attributes might be modified in +a running program, but code may have been generated that provides specific +objects for those attributes under the assumption that they will not be +changed. + See rejected.txt for complicating mechanisms which could be applied to mitigate the effects of these restrictions on optimisations. diff -r e6f70a977e09 -r 814bd122d84d tests/attributes_class_rebind.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/attributes_class_rebind.py Mon Jun 04 01:03:02 2012 +0200 @@ -0,0 +1,12 @@ +#!/usr/bin/env python + +class C: + e = 123 + +def f(obj): + obj.e = 456 # should rebind C.e + +f(C) +result_456 = C.e + +# vim: tabstop=4 expandtab shiftwidth=4 diff -r e6f70a977e09 -r 814bd122d84d tests/attributes_class_rebind_ambiguous.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/attributes_class_rebind_ambiguous.py Mon Jun 04 01:03:02 2012 +0200 @@ -0,0 +1,17 @@ +#!/usr/bin/env python + +class C: + e = 123 + +class F: + def __init__(self): + self.e = 789 + +def f(obj): + obj.e = 456 # should rebind C.e + +other = F() +f(C) +result_456 = C.e + +# vim: tabstop=4 expandtab shiftwidth=4