# [IronPython] concurrent list access

Severin seob at gmx.ch
Mon Oct 6 06:09:23 CEST 2008

```Hello,
I have a problem with lists.

Taking a quick look to the IronPython list implementation they intend to be
thread safe (I guess). now I made a quicksort example that sorts a list in
place using threads. its a divide and conquer approach and at a certain
level the list ist just sorted using the sort function.

for some reason it doesn't work on ironpython (2.0B5 on Vista, quad-core)
sometimes.

so:
- can my concurrent list access corrupt the list? (especially the slice
operator)
- can anybody see another problem here?

any hint is appreciated

Severin

here is the code:
-----

def partition(array, begin, end):
while begin < end:
while begin < end:
if array[begin] > array[end]:
(array[begin], array[end]) = (array[end], array[begin])
break
end -= 1
while begin < end:
if array[begin] > array[end]:
(array[begin], array[end]) = (array[end], array[begin])
break
begin += 1
return begin

def quicksort(array, begin, end):
if begin < end:

if end - begin <= 2**12:
#print "%d %d" % (begin, end)
sorted = [x for x in array[begin:end]]
sorted.sort()
array[begin:end] = sorted
else:

split = partition(array, begin, end-1)

begin, split,))

split+1, end))

if __name__ == '__main__':

import random

# settings
n = 2**14

# setup
l = range(n)
random.shuffle(l)

# sort
quicksort(l, 0, len(l))

# join

# test
for i in range(n):
if i != l[i]:
print 'failure %d != %d' % (i, l[i])

print 'done'
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20081006/ddb3fb9d/attachment.html>
```