Phillip J. Eby wrote: > At 10:50 AM 6/28/04 -0400, Jim Fulton wrote: > >> We often want to associate data with threads. Python >> manages a dictionary per-tread for this purpose, but there's >> currently no way to get to this dictionary from Python. >> >> 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. >> >> Any objections? > > > What's wrong with using (e.g. setting attributes on) > 'threading.currentThread()'? It's already implemented and available in > 2.3 (and numerous prior versions). But it's relatively expensive. You have to call threading.currentThread, Which then has to do a dict lookup. Plus, when you get the thread, you have to pick attribute names that won't conflict, which means that you either have ugly attribute names or introduce an intermediate object to provide a separate namespace, which ads more cost. OTOH, Python has this nice per-thread dict that wants to be used for thread data but is unexposed. As far as 2.3 support, we'll provide something like this in Zope, but I'd like to get it into Python so that we can stop providing it in Zope some time in the future. Jim -- Jim Fulton mailto:jim at zope.com Python Powered! CTO (540) 361-1714 http://www.python.org Zope Corporation http://www.zope.com http://www.zope.org
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