[Cython] Acquisition counted cdef classes
mark florisson
markflorisson88 at gmail.com
Mon Oct 24 23:51:22 CEST 2011
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.
Oh yes you're definitely right, that was silly of me. I suppose every
operation needs to lock. This can still be useful though, to allow
more fine-grained parallelism. Then it would be more efficient to use
arrays or memoryviews with acquisition counted objects, and the
dicts/lists/tuples etc for cases where you just need more fine-grained
locking and can deal with that overhead.
> --
> Greg
> _______________________________________________
> cython-devel mailing list
> cython-devel at python.org
> http://mail.python.org/mailman/listinfo/cython-devel
>
More information about the cython-devel
mailing list