RE: Re: vote on prop keyword
"Mark Hahn" <[email protected]>
| Newsgroups | gmane.comp.lang.prothon.user |
|---|---|
| Message-ID | <000201c46785$db66b870$0b01a8c0@mark> |
> From: Paul Prescod > > I wish I could give straighter answers rather than questions...sorry! Either will do. > > I never did understand the Python wrapper object mechanism > or I might > > have considered it. Does it have any advantages? > > Maybe subtle ones. Python's model is tied to its class system. ....<snip>.... Seems overly complex to me. > >... > > Detecting a specific type by the interpreter can be done in one > > comparisom. > > Even with multiple inheritance? The parents are in a simple list with length so it really takes two comparisoms. You have to check the list length and parent. But they are adjacent so if lucky the optimized machine language version might be able to do it in one big comparisom. Of course I only really care about the performance of the non-prop case because that is what my "hack" is adding in overhead. Luckily the case I care about is the failing case so any non-match of the length or link is the fast case. > > Also I think my method is pretty clear and intuitive. If tax "is a > > property" then shouldn't it be a "Property" through inheritance? > > Python does not use inheritance for much internally. It very > seldom says > things like: if you want to use X for purpose Y then X must be a > subclass of Z. > > When my object "inherits" from Prop, what does it get from > Prop? Just a > type flag? It gets nothing from Prop. Just the fact that it is a Prop. > I also notice that prothon does not treat properties > specially when they > are accessed through module objects. > > paul:/tmp pprescod$ cat ./myprop.pr > > object foo(Prop): > def get_(): print "Get foo" > def set_(): print "Set foo" > > > paul:/tmp pprescod$ cat ./test.pr > #!/usr/local/bin/prothon > > import myprop > > x = myprop.foo() > print x > > paul:/tmp pprescod$ ./test.pr > <Prop> Why are you using myprop.foo as a protoype? Myprop.foo works fine for me: O>> import myprop O>> print myprop.foo Get foo Set doesn't work in your myprop but that is because you forgot the value formal param. When I fixed that it worked also. O>> import myprop O>> myprop.foo = 1 Set foo I didn't look at your proposal because I assumed it was to fix my non-existant problem. Do you still want me to give it a look?