"Barry A. Warsaw" wrote: > > I've just uploaded PEP 231, which describes a new hook in the instance > access mechanism, called __findattr__() after a similar mechanism that > exists in Jython (but is not exposed at the Python layer). Ok, as I announced already, here some thoughts on __findattr__, system state, and how it could work. Looking at your patch, I realize that you are blocking __findattr__ for your whole instance, until this call ends. This is not what you want to do, I guess. This has an effect of affecting the whole system state when threads are involved. Also you cannot use __findattr__ on any other attribute during this call. You want most probably do this: __findattr__ should not be invoked again for this instance, with this attribute name, for this "thread", until you are done. The correct way to find out whether __findattr__ is active or not would be to look upwards the frame chain and inspect it. Moshe also asked about continuations: I think this would resolve quite fine. However we jump around, the current chain of frames dictates the semantics of __findattr__. It even applies to Guido's tamed coroutines, given that an explicit switch were allowed in the context of __findattr__. In a sense, we get some kind of dynamic context here, since we need to do a lookup for something in the dynamic call chain. I guess this would be quite messy to implement, and inefficient. Isn't there a way to accomplish the desired effect without modifying the instance? In the context of __findattr__, *we* know that we don't want to get a recursive call. Let's assume __getattr__ and __setattr__ had yet another optional parameter: infindattr, defaulting to 0. We would than have to pass a positive value in this context, which would object.c tell to not try to invoke __findattr__ again. With explicit passing of state, no problems with threads can occour. Readability might improve as well. cheers - chris -- Christian Tismer :^) <mailto:tismer@tismer.com> Mission Impossible 5oftware : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net 14163 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF where do you want to jump today? http://www.stackless.com
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4