Steven Bethard a écrit : > Bruno Desthuilliers wrote: > >> Steven Bethard a écrit : >> >>> Bruno Desthuilliers wrote: >>> >>>>> I guess as long as your documentation is clear about which >>>>> attributes require computation and which don't... >>>> >>>> >>>> Why should it ? > > [snip] > >> I believe we simply disagree on weither properties should be used when >> it makes sens (from a semantic POV, which doesn't prevent common sens, >> thanks) or if they should be restricted to refactoring-life-saver. Now >> since the second use implies that some attributes-looking properties >> of an object may not be what they looks like - and even worth, may >> suddenly become (a little bit) more costly without client code being >> warned - I don't see what's your problem with the first one. > > > I said those kind of expectation violations should be documented, and > you said "Why should it?" I gather you really only meant the "Why > should it?" in the situation that the computation is extremely minimal.
Did you failed to spot some kind of pattern in my previous posts ?-) More seriously: I do assume that what looks like an attribute will not require *heavy* computation - a bit more than 'extremely minimal' is ok for me, but we may not have the same definition of 'extremely minimal'. And FWIW, I do assume too that computation-heavy functions will be either obvious (either from the domain and/or wrt/ what I do pass as arguments - ie, I expect that sorting a 10K items list with a custom cmp callback will be heavier that naturally sorting a 10 words list) or documented as such. Else, I just write my code and, if and when I have a real problem, I profile the whole thing... strange enough, but so far it seems to work just fine. > I can understand that, but I'd still like it documented for any objects > I use. There are quite a lot of things I'd like to see documented - but hopefully I'm mostly working with OSS, so I usually use the source when I need a very exact and detailed documentation !-) Now how does your desire for documentation imply that "if you're creating a class for the first time, it should *never* use property()" ? I still wonder... >> Ho, and wrt/ training and expectations, I'm afraid you have to live >> with the fact that computed attributes (either properties and custom >> descriptors) are alreay widely used. FWIW, may I remind you that a >> method is actually a callable returned by a computed attribute ?-) > > > Yep. And it's documented. ;-) How many Python users ever bothered to read that part of the doc ? How many are not even aware of this ? -- http://mail.python.org/mailman/listinfo/python-list