[New-bugs-announce] [issue14953] Reimplement subset of multiprocessing.sharedctypes using memoryview

Richard Oudkerk report at bugs.python.org
Tue May 29 16:59:43 CEST 2012


New submission from Richard Oudkerk <shibturn at gmail.com>:

The attached patch enables creation of shared objects allocated from shared memory using memoryview objects instead of ctypes.

This enables the use of shared memory on systems where ctypes is unavailable.

The new functions/classes RawArray, RawValue, Array and Array have been added to multiprocessing.heap.  They are almost equivalent to the functions/classes of the same name in multiprocessing and multiprocessing.sharedctypes when a letter typecode is used (rather than a ctypes type).

The differences in behaviour are due to the differences between memoryview objects and ctypes arrays.  The most noticeable is the fact that you can't set a slice using an arbitrary sequence, so

    arr = multiprocessing.RawArray('i', [0]*10)
    arr[:3] = [1,2,3]

has to be rewritten to something like

    arr = multiprocessing.heap.RawArray('i', [0]*10)
    arr[:3] = array.array('i', [1,2,3])

(No documetation yet.)

----------
files: memoryview-array-value.patch
keywords: patch
messages: 161892
nosy: sbt
priority: normal
severity: normal
stage: patch review
status: open
title: Reimplement subset of multiprocessing.sharedctypes using memoryview
type: enhancement
versions: Python 3.3
Added file: http://bugs.python.org/file25754/memoryview-array-value.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14953>
_______________________________________


More information about the New-bugs-announce mailing list