[Cython] Acquisition counted cdef classes
robertwb at math.washington.edu
Tue Oct 25 06:47:05 CEST 2011
On Mon, Oct 24, 2011 at 2:52 PM, mark florisson
<markflorisson88 at gmail.com> wrote:
> On 24 October 2011 22:03, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
>> mark florisson wrote:
>>> These will by default not lock for operations to allow
>>> e.g. one thread to iterate over the list and another thread to index
>>> it without lock contention and other general overhead.
>> I don't think that's safe. You can't say "I'm not modifying
>> this, so I don't need to lock it" because there may be another
>> thread that *is* in the midst of modifying it.
> I was really thinking of the case where you instantiate it in Cython
> and then do some parallel work, in which case you're the only user.
> But you can't assume that in general.
It could be useful to assert for a chunk of code that a given object
is read-only and will not be mutated for the duration of the context
(programmer error and strange crash/data corruption if it is). E.g.
with nogil, assert_frozen(my_dict):
a = (<CdefClass>my_dict[key]).c_attribute
All references obtained could be borrowed. Perhaps we could even
enforce this for cdef classes (but perhaps not consistently enough,
and perhaps that would make things even more confusing). Just a
More information about the cython-devel