AFAIK, a module's dict is readonly, so I don't believe a dict subclass will
work there (I could be wrong) unless you hack up the module object from C.
You can do it with descriptors on a ModuleType however, which should be
plenty fast from Cython-land.
In [16]: class AGetter(object):
....: def __get__(self, obj, cls):
....: return obj.a
....: def __set__(self, obj, val):
....: obj.a = val
....:
In [17]: class MyMod(types.ModuleType):
....: b = AGetter()
....:
In [18]: mmod = MyMod('my_mod')
In [20]: mmod.__dict__['a'] = 42
In [21]: mmod.a
Out[21]: 42
In [22]: mmod.b
Out[22]: 42
In [23]: mmod.b = 87
In [24]: mmod.a
Out[24]: 87
_______________________________________________
cython-devel mailing list
[email protected]
http://mail.python.org/mailman/listinfo/cython-devel