Hello Jim, On Mon, Jun 28, 2004 at 10:50:08AM -0400, Jim Fulton wrote: > I propose, for 2.4, to add a get_dict method to the thread > module that will return this dictionary. This will be > implemented via a call to PyThreadState_GetDict. I am pretty sure that some extension modules would badly crash if arbitrary Python code would be allowed to temper with the data that they store there. Actually, to encourage encapsulation I'd push for another interface. For example there could be a constructor thread.Locals which you invoke once at a global level; it returns an object whose attributes are then local to the thread. An unrelated module's call to thread.Locals returns an unrelated object. To polish the idea more, thread.Locals would be a class that you can also inherit from to use the functionality in your own classes. Something along the lines of the C version of class Locals(object): def __getattribute__(self, attr): d = PyThreadState_GetDict() attrs = d.setdefault(self, {}) # use 'self' as the key try: return attrs[attr] except KeyError: ... def __setattr__(self, attr, value): ... def __delattr__(self, attr): ... Armin
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