Vitja Makarov, 12.11.2010 08:52: > 2010/11/12 Stefan Behnel: >> Vitja Makarov, 12.11.2010 08:06: >>> 2010/11/8 Stefan Behnel: >>>> The problem is not the property behaviour, it's the mapping from a Python >>>> function/method to a C function, which must have a unique name. Currently, >>>> functions are unique within one namespace, be it the module namespace or a >>>> class body namespace. They are actually looked up statically, not >>>> dynamically in definition order, so the fix is not as easy as adding a >>>> counted ID to the C-level name. >>> >>> Is not it safe to add ID to C-function in pure python class scope? >>> I see problem in module scope when it turns functions into list of >>> methoddef that are passed to PyModule_Init. >> >> As I said, it's not *enough* to fix the name. > > Can please you explain the problem? What more should be done? > > I see problem in decorators here: > clsas Foo(object): > @property > def foo(self) > .... > @foo.setter > def foo(self, val): > .... > > Setter Cython first sets foo item, then get it back and decorate with > setter attribute: > > dict['foo'] = Foo_foo_method_000 > dict['foo'] = property(dict['foo']) > dict['foo'] = Foo_foo_method_001 > dict['foo'] = dict['foo'].setter(dict['foo']) > > Am I right here? I see problem in decorators, attribute assignment here.
This is not related to properties. What I meant by this: """ Currently, functions are unique within one namespace, be it the module namespace or a class body namespace. They are actually looked up statically, not dynamically in definition order """ is that you simply cannot currently define a function more than once within a namespace because it is looked up statically. So, when you redefine it, its Python name would get overwritten in the symbol table. So you couldn't refer to the previously defined function anymore from that point on, which means that you cannot even use it in the code that gets executed before the redefinition. The symbol table is not dynamically adaptive to the position in the code, it's just a plain table that is global to a namespace. This is a compiler, not an interpreter. Things don't simply happen in the order they are executed in the code. Does that explain it? Stefan _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
