On Wed, 19 Apr 2000, Salz, Rich wrote: > >In my experience, allowing/requiring programmers to specify sharedness is > >a very rich source of hard-to-find bugs. > > My experience is the opposite, since most objects aren't shared. :) > You could probably do something like add an "owning thread" to each object > structure, and on refcount throw an exception if not shared and the current > thread isn't the owner. Not sure if space is a concern, but since the object > is either shared or needs its own mutex, you make them a union: > bool shared; > union { > python_thread_id_type id; > python_mutex_type m; > }; > > > (Not saying I have an answer to > the performance hit of locking on incref/decref, just saying that the > development cost of 'shared' is very high.) Regardless of complexity or lack thereof, any kind of "specified sharedness" cannot be implemented. Consider the case where a programmer forgets to note the sharedness. He passes the object to another thread. At certain points: BAM! The interpreter dumps core. Guido has specifically stated that *nothing* should ever allow that (in terms of pure Python code; bad C extension coding is all right). Sharedness has merit, but it cannot be used :-( Cheers, -g -- Greg Stein, http://www.lyra.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